/[scire]/branches/new-fu/client/scireclient.pl
Gentoo

Diff of /branches/new-fu/client/scireclient.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 291 Revision 292
44 } 44 }
45 45
46 #3. Scan the jobs directory. If there are done/failed jobs, report them. Note jobs in running or queue. 46 #3. Scan the jobs directory. If there are done/failed jobs, report them. Note jobs in running or queue.
47 my @existing_jobs = scan_jobs_dir(); 47 my @existing_jobs = scan_jobs_dir();
48 #4. Fetch the jobs list 48 #4. Fetch the jobs list
49 get_jobs(@existing_jobs); 49 get_jobs();
50 #5. ??? 50 #5. ???
51 #6. Profit! 51 #6. Profit!
52} 52}
53 53
54sub parse_command_line { 54sub parse_command_line {
87 } else { 87 } else {
88 $arg =~ s/"/\\"/g; 88 $arg =~ s/"/\\"/g;
89 $tosend .= " \"${arg}\""; 89 $tosend .= " \"${arg}\"";
90 } 90 }
91 } 91 }
92 debug("Sending: ${tosend}\n"); 92 debug("Sending: ${tosend}");
93 print SERVER_STDIN "${tosend}\n"; 93 print SERVER_STDIN "${tosend}\n";
94 #FIXME WE NEED A TIMEOUT HERE OF SOME SORT!! 94 #FIXME WE NEED A TIMEOUT HERE OF SOME SORT!!
95 #if the server doesn't give you a newline this just hangs! 95 #if the server doesn't give you a newline this just hangs!
96 my $response = <SERVER_STDOUT>; 96 my $response = <SERVER_STDOUT>;
97 return $response; 97 return $response;
164# my $mac = "00:11:22:33:44:55"; 164# my $mac = "00:11:22:33:44:55";
165# my $ip = "192.168.2.3"; 165# my $ip = "192.168.2.3";
166 my ($mac, $ip) = get_interface_info(defined $conf{interface} && $conf{interface} ? $conf{interface} : "eth0"); 166 my ($mac, $ip) = get_interface_info(defined $conf{interface} && $conf{interface} ? $conf{interface} : "eth0");
167 my ($status, $message) = parse_response(send_command("REGISTER", $mac, $ip)); 167 my ($status, $message) = parse_response(send_command("REGISTER", $mac, $ip));
168 die "Could not register client $mac w/ ip $ip. Got: $message" if (! defined $status or $status ne "OK"); 168 die "Could not register client $mac w/ ip $ip. Got: $message" if (! defined $status or $status ne "OK");
169 debug("Client registered. Status is pending.\n"); 169 debug("Client registered. Status is pending.");
170} 170}
171 171
172sub identify_client { 172sub identify_client {
173 open(FILE, $conf{key_file}) or die "Couldn't open client_key $conf{key_file}: $!"; 173 open(FILE, $conf{key_file}) or die "Couldn't open client_key $conf{key_file}: $!";
174 my $client_key = join("", <FILE>); 174 my $client_key = join("", <FILE>);
181 my ($status, $message) = parse_response(send_command("IDENTIFY", $fingerprint)); 181 my ($status, $message) = parse_response(send_command("IDENTIFY", $fingerprint));
182 unless (defined $status && $status eq "OK") { 182 unless (defined $status && $status eq "OK") {
183 print "Could not identify to server: $message\n"; 183 print "Could not identify to server: $message\n";
184 return 0; 184 return 0;
185 } 185 }
186 debug("Client identified\n"); 186 debug("Client identified");
187 return 1; 187 return 1;
188} 188}
189 189
190sub get_jobs { 190sub get_jobs {
191 my @existing_jobs = @_;
192 my ($status, $message) = parse_response(send_command("GET_JOBS", @existing_jobs)); 191 my ($status, $jobs) = parse_response(send_command("GET_JOBS"));
193 unless (defined $status && $status eq "OK") { 192 unless (defined $status && $status eq "OK") {
194 print "Could not get jobs list from server: $message\n"; 193 print "Could not get jobs list from server: $message\n";
195 return 0; 194 return 0;
196 } 195 }
197 my $jobs = $2;
198 $jobs =~ s/\s//g; #Remove all whitespace 196 $jobs =~ s/\s//g; #Remove all whitespace
199 my @jobs_list = split(/,/, $jobs); 197 my @jobs_list = split(/,/, $jobs);
200 foreach my $job (@jobs_list) { 198 foreach my $job (@jobs_list) {
201 my ($status, $message) = parse_response(send_command("GET_JOB", $job)); 199 my ($status, $message) = parse_response(send_command("GET_JOB", $job));
202 open(JOBFILE, ">$conf{job_dir}/queue/${job}.job") or do { 200 open(JOBFILE, ">$conf{job_dir}/queue/${job}.job") or do {
204 next; 202 next;
205 }; 203 };
206 # XXX: Modify this to fetch a file instead 204 # XXX: Modify this to fetch a file instead
207# print JOBFILE parse_response($resp); 205# print JOBFILE parse_response($resp);
208 close(JOBFILE); 206 close(JOBFILE);
209 debug("Fetched job $job \n"); 207 debug("Fetched job $job ");
210 } 208 }
211 #This function doesn't actually need to do anything with the list of jobs, the executor handles that part. 209 #This function doesn't actually need to do anything with the list of jobs, the executor handles that part.
212} 210}
213 211
214sub scan_jobs_dir { 212sub scan_jobs_dir {
238} 236}
239 237
240sub debug { 238sub debug {
241 my $msg = shift; 239 my $msg = shift;
242 if($conf{debug}) { 240 if($conf{debug}) {
243 print STDERR $msg; 241 print STDERR $msg."\n";
244 } 242 }
245} 243}
246 244
247sub get_interface_info { 245sub get_interface_info {
248 my $interface = shift; 246 my $interface = shift;

Legend:
Removed from v.291  
changed lines
  Added in v.292

  ViewVC Help
Powered by ViewVC 1.1.20