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