Commit 76cabcdea24cba8b73d11950e9b31fbe3d9167f3

Authored by Antoine Duquenoy
1 parent 6536a229

Correction Ansible et programme C

Showing 3 changed files with 15 additions and 10 deletions   Show diff stats
Ansible/ansible.yml
... ... @@ -20,7 +20,7 @@
20 20  
21 21 - name: "Copie du binaire pour le(s) capteur(s)"
22 22 copy:
23   - src: ~/pfe/files/{{ binary_dir }}/out.bin
  23 + src: ~/PFE_DEMO/files/{{ binary_dir }}/out.bin
24 24 dest: /home/pi/{{ servernames }}/out.bin
25 25  
26 26 - name: "Copie du ficher de correspondance"
... ... @@ -55,7 +55,7 @@
55 55 - name: "Copie des résultats sur le serveur"
56 56 fetch:
57 57 src: /home/pi/{{ servernames }}/res/{{ item }}
58   - dest: /home/antoine/pfe_results/{{ servernames }}/{{ ansible_host }}/
  58 + dest: ~/PFE_DEMO/results/{{ servernames }}/{{ ansible_host }}/
59 59 flat: yes
60 60 with_items: "{{ files_to_copy.stdout_lines }}"
61 61  
... ... @@ -64,6 +64,6 @@
64 64  
65 65 - name: "Suppression du fichier d'experimentation"
66 66 file:
67   - path: "~/pfe/toflash/{{ servernames }}.yml.started"
  67 + path: "~/PFE_DEMO/toflash/{{ exp_name }}.started"
68 68 state: absent
69 69 delegate_to: 127.0.0.1
... ...
Serveur/main
No preview for this file type
Serveur/main.c
... ... @@ -10,8 +10,9 @@
10 10 #define MAX_SENSORS 8
11 11 #define MAX_BUFFER 1024
12 12 #define USERNAME "antoine"
13   -#define FILES_PATH "/home/antoine/pfe/files/"
14   -#define TOFLASH_PATH "./toflash/"
  13 +#define FILES_PATH "/home/antoine/PFE_DEMO/files/"
  14 +#define TOFLASH_PATH "/home/antoine/PFE_DEMO/toflash/"
  15 +#define PLAYBOOK_PATH "/home/antoine/PFE_DEMO/ansible.yml"
15 16  
16 17 typedef struct node {
17 18 char *ip;
... ... @@ -28,6 +29,7 @@ typedef struct experiment {
28 29 char *name;
29 30 char *arch;
30 31 char *dir;
  32 + char *exp_name;
31 33 Node nodes[MAX_NODES];
32 34 } Experiment;
33 35  
... ... @@ -139,9 +141,8 @@ Experiment *read_file(char *file_name) {
139 141 int check_date(Experiment *experiment) {
140 142 time_t now;
141 143 time(&now);
142   -
143 144 struct tm tm = { 0 };
144   - strptime(experiment->date, "%Y-%m-%dT%H:M", &tm);
  145 + strptime(experiment->date, "%Y-%m-%dT%H:%M", &tm);
145 146 time_t t = mktime(&tm);
146 147  
147 148 if(t <= now) {
... ... @@ -224,12 +225,14 @@ int process_exp(Experiment *experiment) {
224 225 fclose(hosts_fp);
225 226  
226 227 char ansible_command[512];
227   - sprintf(ansible_command, "runuser -l %s -c \'ansible-playbook /home/antoine/pfe/ansible.yml -i %s -e \"servernames=exp_%d exp_duration=%d binary_dir=%s\"",
  228 + sprintf(ansible_command, "runuser -l %s -c \'ansible-playbook %s -i %s -e \"servernames=exp_%d exp_duration=%d binary_dir=%s exp_name=%s\"",
228 229 USERNAME,
  230 + PLAYBOOK_PATH,
229 231 hosts_filename,
230 232 experiment->exp_id,
231 233 time_sec,
232   - experiment->dir);
  234 + experiment->dir,
  235 + experiment->exp_name);
233 236 exec_prog_background(ansible_command);
234 237  
235 238 return 0;
... ... @@ -238,7 +241,7 @@ int process_exp(Experiment *experiment) {
238 241 void print_exp(Experiment *experiment) {
239 242 printf("== EXP[%d] : %s ==\n%s during %s with the file %s (%s) on the %d nodes :\n",
240 243 experiment->exp_id,
241   - experiment->name,
  244 + experiment->exp_name,
242 245 experiment->date,
243 246 experiment->duration,
244 247 experiment->file,
... ... @@ -259,6 +262,7 @@ void free_exp(Experiment *experiment) {
259 262 free(experiment->arch);
260 263 free(experiment->dir);
261 264 free(experiment->name);
  265 + free(experiment->exp_name);
262 266 for(int i = 0; i < experiment->n_nodes; i++) {
263 267 for(int j = 0; j < experiment->nodes[i].n_sensors; j++) {
264 268 free(experiment->nodes[i].sensors[j]);
... ... @@ -281,6 +285,7 @@ void check_files() {
281 285 strcpy(file_name, TOFLASH_PATH);
282 286 strcat(file_name, dirent->d_name);
283 287 Experiment *experiment = read_file(file_name);
  288 + experiment->exp_name = strdup(dirent->d_name);
284 289 #ifdef DEBUG
285 290 print_exp(experiment);
286 291 #endif
... ...