You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by fa...@apache.org on 2012/10/04 18:00:21 UTC

svn commit: r1394122 - in /vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module: OS.pm OS/Linux/Ubuntu.pm

Author: fapeeler
Date: Thu Oct  4 16:00:21 2012
New Revision: 1394122

URL: http://svn.apache.org/viewvc?rev=1394122&view=rev
Log:
VCL-639
OS.pm fixed readding users on reinstall

VCL-584
fixed IP address support for Ubuntu servers


Modified:
    vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/OS.pm
    vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/OS/Linux/Ubuntu.pm

Modified: vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/OS.pm
URL: http://svn.apache.org/viewvc/vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/OS.pm?rev=1394122&r1=1394121&r2=1394122&view=diff
==============================================================================
--- vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/OS.pm (original)
+++ vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/OS.pm Thu Oct  4 16:00:21 2012
@@ -2346,6 +2346,7 @@ sub manage_server_access {
 	my $user_login_id_owner         = $self->data->get_user_login_id();
 	my $user_id_owner		           = $self->data->get_user_id();
 	my $image_os_type 		= $self->data->get_image_os_type();
+	my $request_laststate_name      = $self->data->get_request_laststate_name();
 
 	# Build list of users.
 	# If in admin group set admin flag
@@ -2365,6 +2366,7 @@ sub manage_server_access {
 		@userlist_login = getusergroupmembers($server_request_logingroupid);
 	}	
 	
+	notify($ERRORS{'OK'}, 0, "request_laststate_name=$request_laststate_name");	
 	notify($ERRORS{'OK'}, 0, " admin login list= @userlist_admin");
 	notify($ERRORS{'OK'}, 0, " nonadmin login list= @userlist_login");
 	
@@ -2407,7 +2409,6 @@ sub manage_server_access {
 	foreach my $userid (sort keys %user_hash) {
 		next if (!($userid));
 		#Skip reservation owner, this account is processed in the new and reserved states
-		notify($ERRORS{'DEBUG'}, 0, "userid= $userid  user_id_owner= $user_id_owner login_id_owner= $user_login_id_owner ");
 		if ($userid eq $user_id_owner) {
 			#Add owner's login id if does not already exist
          $allow_list .= " $user_login_id_owner" if ($allow_list !~ /$user_login_id_owner/) ;
@@ -2417,7 +2418,8 @@ sub manage_server_access {
 		if(!$self->user_exists($user_hash{$userid}{username})){
 			delete($res_accounts{$userid});
 		}
-		if(!exists($res_accounts{$userid})){
+		
+		if(!exists($res_accounts{$userid}) || $request_laststate_name eq "reinstall" ){
 			# check affiliation
 			notify($ERRORS{'DEBUG'}, 0, "checking affiliation for $userid");
 			my $affiliation_name = get_user_affiliation($user_hash{$userid}{vcl_user_id}); 
@@ -2428,16 +2430,31 @@ sub manage_server_access {
 				}
 			}
 			
-			$user_hash{$userid}{"passwd"} = 0;
-			# Generate password if linux and standalone affiliation
-			unless ($image_os_type =~ /linux/ && !$standalone) {
-				$user_hash{$userid}{"passwd"} = getpw();
-			}
+			if($request_laststate_name ne "reinstall" ){	
+				$user_hash{$userid}{"passwd"} = 0;
+				# Generate password if linux and standalone affiliation
+				unless ($image_os_type =~ /linux/ && !$standalone) {
+					$user_hash{$userid}{"passwd"} = getpw();
+				}
 			
-			if (update_reservation_accounts($reservation_id,$userid,$user_hash{$userid}{passwd},"add")) {
-				notify($ERRORS{'OK'}, 0, "Inserted $reservation_id,$userid,$user_hash{$userid}{passwd} into reservationsaccounts table");
+				if (update_reservation_accounts($reservation_id,$userid,$user_hash{$userid}{passwd},"add")) {
+					notify($ERRORS{'OK'}, 0, "Inserted $reservation_id,$userid into reservationsaccounts table");
+				}
 			}
-			
+			# if reinstall and standalone check for existing password
+			if($request_laststate_name eq "reinstall" && $standalone) {
+				if ( $res_accounts{$userid}{password} ) {
+					$user_hash{$userid}{passwd} = $res_accounts{$userid}{password}
+				}
+				else {
+					#should have password for standalone accounts
+					$user_hash{$userid}{"passwd"} = getpw();
+					if (update_reservation_accounts($reservation_id,$userid,$user_hash{$userid}{passwd},"add")) {
+						notify($ERRORS{'OK'}, 0, "Inserted $reservation_id,$userid into reservationsaccounts table");
+					}
+				}
+			}
+	
 			# Create user on the OS
 			if($self->create_user($user_hash{$userid}{username},$user_hash{$userid}{passwd},$user_hash{$userid}{uid},$user_hash{$userid}{rootaccess},$standalone)) {
 				notify($ERRORS{'OK'}, 0, "Successfully created user $user_hash{$userid}{username} on $computer_node_name");

Modified: vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/OS/Linux/Ubuntu.pm
URL: http://svn.apache.org/viewvc/vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/OS/Linux/Ubuntu.pm?rev=1394122&r1=1394121&r2=1394122&view=diff
==============================================================================
--- vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/OS/Linux/Ubuntu.pm (original)
+++ vcl/branches/vcl-2.3-bugfixes/managementnode/lib/VCL/Module/OS/Linux/Ubuntu.pm Thu Oct  4 16:00:21 2012
@@ -957,13 +957,18 @@ sub set_static_public_address {
 	my $request_id            = $self->data->get_request_id();
 	my $server_request_id     = $self->data->get_server_request_id();
 	my $management_node_keys     = $self->data->get_management_node_keys();
+
+   my $server_request_fixedIP       = $self->data->get_server_request_fixedIP();
+
 	
   	# Make sure public IP configuration is static or this is a server request
    my $ip_configuration = $self->data->get_management_node_public_ip_configuration();
    
-	if ($ip_configuration !~ /static/i || $server_request_id ) {
-      notify($ERRORS{'WARNING'}, 0, "static public address can only be set if IP configuration is static or through a server reservation, current value: $ip_configuration");
-      return;
+   if ($ip_configuration !~ /static/i) {
+      if( !$server_request_fixedIP ) {
+         notify($ERRORS{'WARNING'}, 0, "static public address can only be set if IP configuration is static or is a server request, current value: $ip_configuration \nserver_request_fixedIP=$server_request_fixedIP");
+         return;
+      }    
    }
 
    # Get the IP configuration
@@ -973,6 +978,13 @@ sub set_static_public_address {
    my $default_gateway = $self->data->get_management_node_public_default_gateway() || '<undefined>';
    my @dns_servers = $self->data->get_management_node_public_dns_servers();
 
+   if ($server_request_fixedIP) {
+      $ip_address = $server_request_fixedIP;
+      $subnet_mask = $self->data->get_server_request_netmask();
+      $default_gateway = $self->data->get_server_request_router();
+      @dns_servers = $self->data->get_server_request_DNSservers();
+   }
+
    # Make sure required info was retrieved
    if ("$interface_name $ip_address $subnet_mask $default_gateway" =~ /undefined/) {
       notify($ERRORS{'WARNING'}, 0, "failed to retrieve required network configuration for $computer_name");
@@ -981,6 +993,13 @@ sub set_static_public_address {
    else {
       notify($ERRORS{'OK'}, 0, "attempting to set static public IP address on $computer_name");
    }
+	
+	#Try to ping address to make sure it's available
+   #FIXME  -- need to add other tests for checking ip_address is or is not available.
+   if(_pingnode($ip_address)) {
+      notify($ERRORS{'WARNING'}, 0, "ip_address $ip_address is pingable, can not assign to $computer_name ");
+      return;
+   }
 
    # Assemble the ifcfg file path
    my $network_interfaces_file = "/etc/network/interfaces";