/[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 298 Revision 299
7 7
8use IPC::Open2; 8use IPC::Open2;
9use Getopt::Long; 9use Getopt::Long;
10use Data::Dumper; 10use Data::Dumper;
11use File::Path; 11use File::Path;
12use Sys::Hostname;
12 13
13my $SCIRE_CONFIG_FILE = '../etc/scire.conf'; #will be /etc/scire.conf when released. 14my $SCIRE_CONFIG_FILE = '../etc/scire.conf'; #will be /etc/scire.conf when released.
14my %conf; 15my %conf;
15my ($SERVER_STDOUT, $SERVER_STDIN); 16my ($SERVER_STDOUT, $SERVER_STDIN);
16my $connection_pid; 17my $connection_pid;
158 159
159sub register_client { 160sub register_client {
160# my $mac = "00:11:22:33:44:55"; 161# my $mac = "00:11:22:33:44:55";
161# my $ip = "192.168.2.3"; 162# my $ip = "192.168.2.3";
162 my ($mac, $ip) = get_interface_info(defined $conf{interface} && $conf{interface} ? $conf{interface} : "eth0"); 163 my ($mac, $ip) = get_interface_info(defined $conf{interface} && $conf{interface} ? $conf{interface} : "eth0");
164 my $hostname = hostname();
163 my ($status, $message) = parse_response(send_command("REGISTER", $mac, $ip)); 165 my ($status, $message) = parse_response(send_command("REGISTER", $mac, $ip, $hostname));
164 die "Could not register client $mac w/ ip $ip. Got: $message" if (! defined $status or $status ne "OK"); 166 die "Could not register client $mac w/ ip $ip and hostname $hostname. Got: $message" if (! defined $status or $status ne "OK");
165 debug("Client registered. Status is pending."); 167 debug("Client registered. Status is pending. digest is $message");
168 open(FILE, ">$conf{key_file}") or die("Couldn't open key file $conf{key_file} for writing: $!");
169 print FILE "$message\n";
170 close(FILE);
166} 171}
167 172
168sub identify_client { 173sub identify_client {
169 open(FILE, $conf{key_file}) or die "Couldn't open client_key $conf{key_file}: $!"; 174 open(FILE, $conf{key_file}) or die("Couldn't open client_key $conf{key_file}: $!");
170 my $client_key = join("", <FILE>); 175 my $digest = join("", <FILE>);
171 close(FILE); 176 close(FILE);
172 $conf{key_type} ||= "DSA";
173# my $key_obj = Net::SSH::Perl::Key->new($conf{key_type}, $client_key);
174# my $fingerprint = $key_obj->fingerprint();
175 177
176 my $fingerprint = "124567890"; 178 #my $digest = "124567890";
177 my ($status, $message) = parse_response(send_command("IDENTIFY", $fingerprint)); 179 my ($status, $message) = parse_response(send_command("IDENTIFY", $digest));
178 unless (defined $status && $status eq "OK") { 180 unless (defined $status && $status eq "OK") {
179 print "Could not identify to server: $message\n"; 181 print "Could not identify to server: $message\n";
180 return 0; 182 return 0;
181 } 183 }
182 debug("Client identified"); 184 debug("Client identified");
184} 186}
185 187
186sub get_jobs { 188sub get_jobs {
187 my ($status, $jobs) = parse_response(send_command("GET_JOBS")); 189 my ($status, $jobs) = parse_response(send_command("GET_JOBS"));
188 unless (defined $status && $status eq "OK") { 190 unless (defined $status && $status eq "OK") {
189 print "Could not get jobs list from server: $message\n"; 191 print "Could not get jobs list from server: $jobs\n";
190 return 0; 192 return 0;
191 } 193 }
192 $jobs =~ s/\s//g; #Remove all whitespace 194 $jobs =~ s/\s//g; #Remove all whitespace
193 my @jobs_list = split(/,/, $jobs); 195 my @jobs_list = split(/,/, $jobs);
194 foreach my $job (@jobs_list) { 196 foreach my $job (@jobs_list) {

Legend:
Removed from v.298  
changed lines
  Added in v.299

  ViewVC Help
Powered by ViewVC 1.1.20