#NEWLINE# def execute( self , service , shared_data ) : #NEWLINE# #INDENT# osutils = osutils_factory . get_os_utils ( ) #NEWLINE# security_utils = security . WindowsSecurityUtils ( ) #NEWLINE# if ( not self . _check_winrm_service ( osutils ) ) : #NEWLINE# #INDENT# return ( base . PLUGIN_EXECUTE_ON_NEXT_BOOT , False ) #NEWLINE# #UNINDENT# disable_uac_remote_restrictions = ( osutils . check_os_version ( 6 , 0 ) and ( not osutils . check_os_version ( 6 , 2 ) ) and security_utils . get_uac_remote_restrictions ( ) ) #NEWLINE# try : #NEWLINE# #INDENT# if disable_uac_remote_restrictions : #NEWLINE# #INDENT# LOG . debug ( 'Disabling UAC remote restrictions' ) #NEWLINE# security_utils . set_uac_remote_restrictions ( enable = False ) #NEWLINE# #UNINDENT# winrm_config = winrmconfig . WinRMConfig ( ) #NEWLINE# winrm_config . set_auth_config ( basic = CONF . winrm_enable_basic_auth ) #NEWLINE# cert_manager = x509 . CryptoAPICertManager ( ) #NEWLINE# cert_thumbprint = cert_manager . create_self_signed_cert ( self . _cert_subject ) #NEWLINE# protocol = winrmconfig . LISTENER_PROTOCOL_HTTPS #NEWLINE# if winrm_config . get_listener ( protocol = protocol ) : #NEWLINE# #INDENT# winrm_config . delete_listener ( protocol = protocol ) #NEWLINE# #UNINDENT# winrm_config . create_listener ( cert_thumbprint = cert_thumbprint , protocol = protocol ) #NEWLINE# listener_config = winrm_config . get_listener ( protocol = protocol ) #NEWLINE# listener_port = listener_config . get ( 'Port' ) #NEWLINE# rule_name = ( 'WinRM %s' % protocol ) #NEWLINE# osutils . firewall_create_rule ( rule_name , listener_port , osutils . PROTOCOL_TCP ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# if osutils : #NEWLINE# #INDENT# LOG . debug ( 'Enabling UAC remote restrictions' ) #NEWLINE# security_utils . set_uac_remote_restrictions ( enable = True ) #NEWLINE# #UNINDENT# #UNINDENT# return ( base . PLUGIN_EXECUTION_DONE , False )