Author: arkurth
Date: Thu Feb  2 22:41:33 2017
New Revision: 1781479

URL: http://svn.apache.org/viewvc?rev=1781479&view=rev
Log:
VCL-867
Initial commit for Active Directory code.

DataStructure.pm:
* Added image_domain* getters/setters
* Added get_image_domain_dns_servers sub (mainly added to return simple array 
for consistency)

utils.pm:
* Added get_image_active_directory_domain_info sub. Added call to 
get_request_info.
* Added update_reservation_addomain sub.

Windows.pm:
* Added code in pre_capture to call ad_unjoin.
* Added code to post_load to call ad_join. Reworked the code which may have 
rebooted the computer at the end of post_load to eliminate unnecessary reboots.
* Updated create_user to determine if a random password needs to be set.
* Added code to delete_user to remove the user from local groups if not a local 
account.
* Added subroutines:
** ad_get_current_domain
** ad_delete_computer
** ad_join
** ad_join_prepare
** ad_search
** ad_search_computer
** ad_search_ou
** ad_unjoin
** ad_user_exists
** create_update_cygwin_startup_scheduled_task
** enable_dynamic_dns
** enable_windows_feature
** get_ad_computer_ou_dn
** get_current_computer_hostname
** get_group_members
** get_windows_features
** get_windows_feature_info
** is_windows_feature_enabled
** powershell_command_exists
** remove_user_from_group
** run_powershell_as_script
** run_powershell_command
** set_static_dns_servers
** should_set_user_password


VCL-1010
Removed get_kms_client_product_key. It was previously moved to Windows.pm.
Added to Windows.pm:
* get_kms_client_product_keys
* get_kms_client_product_key

Other
Added insert_natport to export list in utils.pm so it can be called from 
elsewhere.

Modified utils.pm::notify to not strip leading spaces from every line. It was 
removing formatting which is useful.

Removed legacy calls to code in Windows.pm::pre_capture which disable/stop a 
ntsyslog service and disable dynamic DHCP. 

Modified:
    vcl/trunk/managementnode/lib/VCL/DataStructure.pm
    vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
    vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm
    vcl/trunk/managementnode/lib/VCL/utils.pm

Modified: vcl/trunk/managementnode/lib/VCL/DataStructure.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/DataStructure.pm?rev=1781479&r1=1781478&r2=1781479&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/DataStructure.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/DataStructure.pm Thu Feb  2 22:41:33 2017
@@ -393,6 +393,15 @@ $SUBROUTINE_MAPPINGS{imagemeta_sysprep}
 $SUBROUTINE_MAPPINGS{imagemeta_rootaccess} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagemeta}{rootaccess}';
 $SUBROUTINE_MAPPINGS{imagemeta_sethostname} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagemeta}{sethostname}';
 
+$SUBROUTINE_MAPPINGS{image_domain_dns_servers} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{dnsServers}';
+$SUBROUTINE_MAPPINGS{image_domain_dns_name} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{domainDNSName}';
+$SUBROUTINE_MAPPINGS{image_domain_id} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{id}';
+$SUBROUTINE_MAPPINGS{image_domain_login_description} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{logindescription}';
+$SUBROUTINE_MAPPINGS{image_domain_password} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{password}';
+$SUBROUTINE_MAPPINGS{image_domain_prettyname} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{prettyname}';
+$SUBROUTINE_MAPPINGS{image_domain_username} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{username}';
+$SUBROUTINE_MAPPINGS{image_domain_base_ou} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{imagedomain}{imageaddomain}{baseOU}';
+
 $SUBROUTINE_MAPPINGS{image_os_name} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{OS}{name}';
 $SUBROUTINE_MAPPINGS{image_os_prettyname} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{OS}{prettyname}';
 $SUBROUTINE_MAPPINGS{image_os_type} = 
'$self->request_data->{reservation}{RESERVATION_ID}{image}{OS}{type}';
@@ -891,7 +900,9 @@ sub _automethod : Automethod {
                        $return_value = eval $hash_path;
                }
                elsif (!$key_defined) {
-                       notify($ERRORS{'WARNING'}, 0, "corresponding data has 
not been initialized for $method_name: $hash_path", $self->request_data) if 
$show_warnings;
+                       if ($show_warnings && $hash_path !~ /(serverrequest)/) {
+                               notify($ERRORS{'WARNING'}, 0, "corresponding 
data has not been initialized for $method_name: $hash_path", 
$self->request_data);
+                       }
                        return sub { };
                }
                else {
@@ -1914,6 +1925,34 @@ sub get_management_node_public_default_g
 
 #/////////////////////////////////////////////////////////////////////////////
 
+=head2 get_image_domain_dns_servers
+
+ Parameters  : none
+ Returns     : array
+ Description : Returns an array containing the addresses of the Active 
Directory
+               domain DNS servers configured for the image.
+
+=cut
+
+sub get_image_domain_dns_servers {
+       my $self = shift;
+       unless (ref($self) && $self->isa('VCL::DataStructure')) {
+               notify($ERRORS{'CRITICAL'}, 0, "subroutine can only be called 
as a VCL::DataStructure module object method");
+               return;
+       }
+       
+       my $reservation_id = $self->reservation_id;
+       my $dns_servers_array_ref = 
$self->request_data->{reservation}{$reservation_id}{image}{imagedomain}{dnsServers};
+       if (!$dns_servers_array_ref) {
+               notify($ERRORS{'DEBUG'}, 0, "no Active Directory domain DNS 
server addresses are configured for the image");
+               return ();
+       }
+       return @$dns_servers_array_ref
+}
+
+
+#/////////////////////////////////////////////////////////////////////////////
+
 =head2 get_management_node_public_dns_servers
 
  Parameters  : None
@@ -2289,7 +2328,7 @@ sub get_reservation_info_json_string {
                return;
        }
        
-       notify($ERRORS{'DEBUG'}, 0, "constructed JSON string based on 
reservation infor:\n$json");
+       notify($ERRORS{'DEBUG'}, 0, "constructed JSON string based on 
reservation information:\n$json");
        return $json;
 }
 


Reply via email to