<s> """<STR_LIT>""" <EOL> import re <EOL> import time <EOL> import collections <EOL> import random <EOL> import sys <EOL> import copy <EOL> import base64 <EOL> from datetime import datetime <EOL> from xml . dom import minidom <EOL> from xml . sax . saxutils import escape as xml_escape <EOL> try : <EOL> from lxml import etree as ET <EOL> except ImportError : <EOL> from xml . etree import ElementTree as ET <EOL> from libcloud . common . azure import AzureServiceManagementConnection <EOL> from libcloud . common . azure import AzureRedirectException <EOL> from libcloud . compute . providers import Provider <EOL> from libcloud . compute . base import Node , NodeDriver , NodeLocation , NodeSize <EOL> from libcloud . compute . base import NodeImage , StorageVolume <EOL> from libcloud . compute . types import NodeState <EOL> from libcloud . common . types import LibcloudError <EOL> from libcloud . utils . py3 import _real_unicode <EOL> from libcloud . utils . py3 import httplib <EOL> from libcloud . utils . py3 import urlparse <EOL> from libcloud . utils . py3 import ensure_string <EOL> from libcloud . utils . py3 import urlquote as url_quote <EOL> from libcloud . utils . misc import ReprMixin <EOL> HTTPSConnection = httplib . HTTPSConnection <EOL> if sys . version_info < ( <NUM_LIT:3> , ) : <EOL> _unicode_type = unicode <EOL> def _str ( value ) : <EOL> if isinstance ( value , unicode ) : <EOL> return value . encode ( '<STR_LIT:utf-8>' ) <EOL> return str ( value ) <EOL> else : <EOL> _str = str <EOL> _unicode_type = str <EOL> AZURE_SERVICE_MANAGEMENT_HOST = '<STR_LIT>' <EOL> X_MS_VERSION = '<STR_LIT>' <EOL> WINDOWS_SERVER_REGEX = re . compile ( <EOL> r'<STR_LIT>' <EOL> ) <EOL> """<STR_LIT>""" <EOL> AZURE_COMPUTE_INSTANCE_TYPES = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : <NUM_LIT:1> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:4> , <EOL> '<STR_LIT>' : <NUM_LIT:2> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:8> , <EOL> '<STR_LIT>' : <NUM_LIT:4> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:16> , <EOL> '<STR_LIT>' : <NUM_LIT:8> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:4> , <EOL> '<STR_LIT>' : <NUM_LIT:2> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:8> , <EOL> '<STR_LIT>' : <NUM_LIT:4> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:16> , <EOL> '<STR_LIT>' : <NUM_LIT:8> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:16> , <EOL> '<STR_LIT>' : <NUM_LIT:8> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:16> , <EOL> '<STR_LIT>' : <NUM_LIT:16> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:16> , <EOL> '<STR_LIT>' : <NUM_LIT:8> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:16> , <EOL> '<STR_LIT>' : <NUM_LIT:16> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : <NUM_LIT:1> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:4> , <EOL> '<STR_LIT>' : <NUM_LIT:2> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:8> , <EOL> '<STR_LIT>' : <NUM_LIT:4> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:16> , <EOL> '<STR_LIT>' : <NUM_LIT:8> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:4> , <EOL> '<STR_LIT>' : <NUM_LIT:2> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:8> , <EOL> '<STR_LIT>' : <NUM_LIT:4> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:16> , <EOL> '<STR_LIT>' : <NUM_LIT:8> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:32> , <EOL> '<STR_LIT>' : <NUM_LIT:16> <EOL> } <EOL> } <EOL> _KNOWN_SERIALIZATION_XFORMS = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> class AzureNodeDriver ( NodeDriver ) : <EOL> connectionCls = AzureServiceManagementConnection <EOL> name = '<STR_LIT>' <EOL> website = '<STR_LIT>' <EOL> type = Provider . AZURE <EOL> _instance_types = AZURE_COMPUTE_INSTANCE_TYPES <EOL> _blob_url = "<STR_LIT>" <EOL> features = { '<STR_LIT>' : [ '<STR_LIT:password>' ] } <EOL> service_location = collections . namedtuple ( <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> ) <EOL> NODE_STATE_MAP = { <EOL> '<STR_LIT>' : NodeState . UNKNOWN , <EOL> '<STR_LIT>' : NodeState . PENDING , <EOL> '<STR_LIT>' : NodeState . PENDING , <EOL> '<STR_LIT>' : NodeState . PENDING , <EOL> '<STR_LIT>' : NodeState . PENDING , <EOL> '<STR_LIT>' : NodeState . PENDING , <EOL> '<STR_LIT>' : NodeState . RUNNING , <EOL> '<STR_LIT>' : NodeState . PENDING , <EOL> '<STR_LIT>' : NodeState . PENDING , <EOL> '<STR_LIT>' : NodeState . PENDING , <EOL> '<STR_LIT>' : NodeState . PENDING , <EOL> '<STR_LIT>' : NodeState . STOPPED , <EOL> '<STR_LIT>' : NodeState . REBOOTING , <EOL> '<STR_LIT>' : NodeState . TERMINATED , <EOL> '<STR_LIT>' : NodeState . TERMINATED , <EOL> '<STR_LIT>' : NodeState . TERMINATED , <EOL> '<STR_LIT>' : NodeState . TERMINATED , <EOL> '<STR_LIT>' : NodeState . TERMINATED , <EOL> } <EOL> def __init__ ( self , subscription_id = None , key_file = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> self . subscription_id = subscription_id <EOL> self . key_file = key_file <EOL> self . follow_redirects = kwargs . get ( '<STR_LIT>' , True ) <EOL> super ( AzureNodeDriver , self ) . __init__ ( <EOL> self . subscription_id , <EOL> self . key_file , <EOL> secure = True , <EOL> ** kwargs <EOL> ) <EOL> def list_sizes ( self ) : <EOL> """<STR_LIT>""" <EOL> sizes = [ ] <EOL> for _ , values in self . _instance_types . items ( ) : <EOL> node_size = self . _to_node_size ( copy . deepcopy ( values ) ) <EOL> sizes . append ( node_size ) <EOL> return sizes <EOL> def list_images ( self , location = None ) : <EOL> """<STR_LIT>""" <EOL> data = self . _perform_get ( self . _get_image_path ( ) , Images ) <EOL> custom_image_data = self . _perform_get ( <EOL> self . _get_vmimage_path ( ) , <EOL> VMImages <EOL> ) <EOL> images = [ self . _to_image ( i ) for i in data ] <EOL> images . extend ( self . _vm_to_image ( j ) for j in custom_image_data ) <EOL> if location is not None : <EOL> images = [ <EOL> image <EOL> for image in images <EOL> if location in image . extra [ "<STR_LIT:location>" ] <EOL> ] <EOL> return images <EOL> def list_locations ( self ) : <EOL> """<STR_LIT>""" <EOL> data = self . _perform_get ( <EOL> '<STR_LIT:/>' + self . subscription_id + '<STR_LIT>' , <EOL> Locations <EOL> ) <EOL> return [ self . _to_location ( l ) for l in data ] <EOL> def list_nodes ( self , ex_cloud_service_name ) : <EOL> """<STR_LIT>""" <EOL> response = self . _perform_get ( <EOL> self . _get_hosted_service_path ( ex_cloud_service_name ) + <EOL> '<STR_LIT>' , <EOL> None <EOL> ) <EOL> self . raise_for_response ( response , <NUM_LIT:200> ) <EOL> data = self . _parse_response ( response , HostedService ) <EOL> vips = None <EOL> if ( len ( data . deployments ) > <NUM_LIT:0> and <EOL> data . deployments [ <NUM_LIT:0> ] . virtual_ips is not None ) : <EOL> vips = [ vip . address for vip in data . deployments [ <NUM_LIT:0> ] . virtual_ips ] <EOL> try : <EOL> return [ <EOL> self . _to_node ( n , ex_cloud_service_name , vips ) <EOL> for n in data . deployments [ <NUM_LIT:0> ] . role_instance_list <EOL> ] <EOL> except IndexError : <EOL> return [ ] <EOL> def reboot_node ( self , node , ex_cloud_service_name = None , <EOL> ex_deployment_slot = None ) : <EOL> """<STR_LIT>""" <EOL> if ex_cloud_service_name is None : <EOL> if node . extra is not None : <EOL> ex_cloud_service_name = node . extra . get ( <EOL> '<STR_LIT>' <EOL> ) <EOL> if not ex_cloud_service_name : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if not ex_deployment_slot : <EOL> ex_deployment_slot = "<STR_LIT>" <EOL> _deployment_name = self . _get_deployment ( <EOL> service_name = ex_cloud_service_name , <EOL> deployment_slot = ex_deployment_slot <EOL> ) . name <EOL> try : <EOL> response = self . _perform_post ( <EOL> self . _get_deployment_path_using_name ( <EOL> ex_cloud_service_name , <EOL> _deployment_name <EOL> ) + '<STR_LIT>' + _str ( node . id ) + '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . raise_for_response ( response , <NUM_LIT> ) <EOL> if self . _parse_response_for_async_op ( response ) : <EOL> return True <EOL> else : <EOL> return False <EOL> except Exception : <EOL> return False <EOL> def list_volumes ( self , node = None ) : <EOL> """<STR_LIT>""" <EOL> data = self . _perform_get ( self . _get_disk_path ( ) , Disks ) <EOL> volumes = [ self . _to_volume ( volume = v , node = node ) for v in data ] <EOL> return volumes <EOL> def create_node ( self , name , size , image , ex_cloud_service_name , <EOL> ex_storage_service_name = None , ex_new_deployment = False , <EOL> ex_deployment_slot = "<STR_LIT>" , ex_deployment_name = None , <EOL> ex_admin_user_id = "<STR_LIT>" , ex_custom_data = None , <EOL> ex_virtual_network_name = None , ex_network_config = None , <EOL> auth = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> auth = self . _get_and_check_auth ( auth ) <EOL> password = auth . password <EOL> if not isinstance ( size , NodeSize ) : <EOL> raise ValueError ( '<STR_LIT>' ) <EOL> if not isinstance ( image , NodeImage ) : <EOL> raise ValueError ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) <EOL> node_list = self . list_nodes ( <EOL> ex_cloud_service_name = ex_cloud_service_name <EOL> ) <EOL> if ex_network_config is None : <EOL> network_config = ConfigurationSet ( ) <EOL> else : <EOL> network_config = ex_network_config <EOL> network_config . configuration_set_type = '<STR_LIT>' <EOL> if ex_custom_data : <EOL> ex_custom_data = self . _encode_base64 ( data = ex_custom_data ) <EOL> if WINDOWS_SERVER_REGEX . search ( image . id , re . I ) : <EOL> machine_config = WindowsConfigurationSet ( <EOL> computer_name = name , <EOL> admin_password = password , <EOL> admin_user_name = ex_admin_user_id <EOL> ) <EOL> machine_config . domain_join = None <EOL> if not node_list or ex_new_deployment : <EOL> port = "<STR_LIT>" <EOL> else : <EOL> port = random . randint ( <NUM_LIT> , <NUM_LIT> ) <EOL> endpoints = self . _get_deployment ( <EOL> service_name = ex_cloud_service_name , <EOL> deployment_slot = ex_deployment_slot <EOL> ) <EOL> for instances in endpoints . role_instance_list : <EOL> ports = [ ep . public_port for ep in <EOL> instances . instance_endpoints ] <EOL> while port in ports : <EOL> port = random . randint ( <NUM_LIT> , <NUM_LIT> ) <EOL> endpoint = ConfigurationSetInputEndpoint ( <EOL> name = '<STR_LIT>' , <EOL> protocol = '<STR_LIT>' , <EOL> port = port , <EOL> local_port = '<STR_LIT>' , <EOL> load_balanced_endpoint_set_name = None , <EOL> enable_direct_server_return = False <EOL> ) <EOL> else : <EOL> if not node_list or ex_new_deployment : <EOL> port = "<STR_LIT>" <EOL> else : <EOL> port = random . randint ( <NUM_LIT> , <NUM_LIT> ) <EOL> endpoints = self . _get_deployment ( <EOL> service_name = ex_cloud_service_name , <EOL> deployment_slot = ex_deployment_slot <EOL> ) <EOL> for instances in endpoints . role_instance_list : <EOL> ports = [ ] <EOL> if instances . instance_endpoints is not None : <EOL> for ep in instances . instance_endpoints : <EOL> ports += [ ep . public_port ] <EOL> while port in ports : <EOL> port = random . randint ( <NUM_LIT> , <NUM_LIT> ) <EOL> endpoint = ConfigurationSetInputEndpoint ( <EOL> name = '<STR_LIT>' , <EOL> protocol = '<STR_LIT>' , <EOL> port = port , <EOL> local_port = '<STR_LIT>' , <EOL> load_balanced_endpoint_set_name = None , <EOL> enable_direct_server_return = False <EOL> ) <EOL> machine_config = LinuxConfigurationSet ( <EOL> name , <EOL> ex_admin_user_id , <EOL> password , <EOL> False , <EOL> ex_custom_data <EOL> ) <EOL> network_config . input_endpoints . items . append ( endpoint ) <EOL> _storage_location = self . _get_cloud_service_location ( <EOL> service_name = ex_cloud_service_name <EOL> ) <EOL> if ex_storage_service_name is None : <EOL> ex_storage_service_name = ex_cloud_service_name <EOL> ex_storage_service_name = re . sub ( <EOL> r'<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ex_storage_service_name . lower ( ) , <EOL> flags = re . UNICODE <EOL> ) <EOL> if self . _is_storage_service_unique ( <EOL> service_name = ex_storage_service_name ) : <EOL> self . _create_storage_account ( <EOL> service_name = ex_storage_service_name , <EOL> location = _storage_location . service_location , <EOL> is_affinity_group = _storage_location . is_affinity_group <EOL> ) <EOL> if not node_list or ex_new_deployment : <EOL> if not ex_deployment_name : <EOL> ex_deployment_name = ex_cloud_service_name <EOL> vm_image_id = None <EOL> disk_config = None <EOL> if image . extra . get ( '<STR_LIT>' , False ) : <EOL> vm_image_id = image . id <EOL> else : <EOL> blob_url = "<STR_LIT>" % ( <EOL> ex_storage_service_name ) <EOL> disk_name = "<STR_LIT>" % ( <EOL> ex_cloud_service_name , <EOL> name , <EOL> time . strftime ( "<STR_LIT>" ) <EOL> ) <EOL> media_link = "<STR_LIT>" % ( blob_url , disk_name ) <EOL> disk_config = OSVirtualHardDisk ( image . id , media_link ) <EOL> response = self . _perform_post ( <EOL> self . _get_deployment_path_using_name ( ex_cloud_service_name ) , <EOL> AzureXmlSerializer . virtual_machine_deployment_to_xml ( <EOL> ex_deployment_name , <EOL> ex_deployment_slot , <EOL> name , <EOL> name , <EOL> machine_config , <EOL> disk_config , <EOL> '<STR_LIT>' , <EOL> network_config , <EOL> None , <EOL> None , <EOL> size . id , <EOL> ex_virtual_network_name , <EOL> vm_image_id <EOL> ) <EOL> ) <EOL> self . raise_for_response ( response , <NUM_LIT> ) <EOL> self . _ex_complete_async_azure_operation ( response ) <EOL> else : <EOL> _deployment_name = self . _get_deployment ( <EOL> service_name = ex_cloud_service_name , <EOL> deployment_slot = ex_deployment_slot <EOL> ) . name <EOL> vm_image_id = None <EOL> disk_config = None <EOL> if image . extra . get ( '<STR_LIT>' , False ) : <EOL> vm_image_id = image . id <EOL> else : <EOL> blob_url = "<STR_LIT>" % ( <EOL> ex_storage_service_name <EOL> ) <EOL> disk_name = "<STR_LIT>" % ( <EOL> ex_cloud_service_name , <EOL> name , <EOL> time . strftime ( "<STR_LIT>" ) <EOL> ) <EOL> media_link = "<STR_LIT>" % ( blob_url , disk_name ) <EOL> disk_config = OSVirtualHardDisk ( image . id , media_link ) <EOL> path = self . _get_role_path ( ex_cloud_service_name , _deployment_name ) <EOL> body = AzureXmlSerializer . add_role_to_xml ( <EOL> name , <EOL> machine_config , <EOL> disk_config , <EOL> '<STR_LIT>' , <EOL> network_config , <EOL> None , <EOL> None , <EOL> vm_image_id , <EOL> size . id <EOL> ) <EOL> response = self . _perform_post ( path , body ) <EOL> self . raise_for_response ( response , <NUM_LIT> ) <EOL> self . _ex_complete_async_azure_operation ( response ) <EOL> return Node ( <EOL> id = name , <EOL> name = name , <EOL> state = NodeState . PENDING , <EOL> public_ips = [ ] , <EOL> private_ips = [ ] , <EOL> driver = self . connection . driver , <EOL> extra = { <EOL> '<STR_LIT>' : ex_cloud_service_name <EOL> } <EOL> ) <EOL> def destroy_node ( self , node , ex_cloud_service_name = None , <EOL> ex_deployment_slot = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> if not isinstance ( node , Node ) : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if ex_cloud_service_name is None and node . extra is not None : <EOL> ex_cloud_service_name = node . extra . get ( '<STR_LIT>' ) <EOL> if not ex_cloud_service_name : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> _deployment = self . _get_deployment ( <EOL> service_name = ex_cloud_service_name , <EOL> deployment_slot = ex_deployment_slot <EOL> ) <EOL> _deployment_name = _deployment . name <EOL> _server_deployment_count = len ( _deployment . role_instance_list ) <EOL> if _server_deployment_count > <NUM_LIT:1> : <EOL> path = self . _get_role_path ( <EOL> ex_cloud_service_name , <EOL> _deployment_name , <EOL> node . id <EOL> ) <EOL> else : <EOL> path = self . _get_deployment_path_using_name ( <EOL> ex_cloud_service_name , <EOL> _deployment_name <EOL> ) <EOL> path += '<STR_LIT>' <EOL> self . _perform_delete ( path ) <EOL> return True <EOL> def ex_list_cloud_services ( self ) : <EOL> return self . _perform_get ( <EOL> self . _get_hosted_service_path ( ) , <EOL> HostedServices <EOL> ) <EOL> def ex_create_cloud_service ( self , name , location , description = None , <EOL> extended_properties = None ) : <EOL> """<STR_LIT>""" <EOL> response = self . _perform_cloud_service_create ( <EOL> self . _get_hosted_service_path ( ) , <EOL> AzureXmlSerializer . create_hosted_service_to_xml ( <EOL> name , <EOL> self . _encode_base64 ( name ) , <EOL> description , <EOL> location , <EOL> None , <EOL> extended_properties <EOL> ) <EOL> ) <EOL> self . raise_for_response ( response , <NUM_LIT> ) <EOL> return True <EOL> def ex_destroy_cloud_service ( self , name ) : <EOL> """<STR_LIT>""" <EOL> response = self . _perform_cloud_service_delete ( <EOL> self . _get_hosted_service_path ( name ) <EOL> ) <EOL> self . raise_for_response ( response , <NUM_LIT:200> ) <EOL> return True <EOL> def ex_add_instance_endpoints ( self , node , endpoints , <EOL> ex_deployment_slot = "<STR_LIT>" ) : <EOL> all_endpoints = [ <EOL> { <EOL> "<STR_LIT:name>" : endpoint . name , <EOL> "<STR_LIT>" : endpoint . protocol , <EOL> "<STR_LIT:port>" : endpoint . public_port , <EOL> "<STR_LIT>" : endpoint . local_port , <EOL> } <EOL> for endpoint in node . extra [ '<STR_LIT>' ] <EOL> ] <EOL> all_endpoints . extend ( endpoints ) <EOL> result = self . ex_set_instance_endpoints ( node , all_endpoints , <EOL> ex_deployment_slot ) <EOL> return result <EOL> def ex_set_instance_endpoints ( self , node , endpoints , <EOL> ex_deployment_slot = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> ex_cloud_service_name = node . extra [ '<STR_LIT>' ] <EOL> vm_role_name = node . name <EOL> network_config = ConfigurationSet ( ) <EOL> network_config . configuration_set_type = '<STR_LIT>' <EOL> for endpoint in endpoints : <EOL> new_endpoint = ConfigurationSetInputEndpoint ( ** endpoint ) <EOL> network_config . input_endpoints . items . append ( new_endpoint ) <EOL> _deployment_name = self . _get_deployment ( <EOL> service_name = ex_cloud_service_name , <EOL> deployment_slot = ex_deployment_slot <EOL> ) . name <EOL> response = self . _perform_put ( <EOL> self . _get_role_path ( <EOL> ex_cloud_service_name , <EOL> _deployment_name , <EOL> vm_role_name <EOL> ) , <EOL> AzureXmlSerializer . add_role_to_xml ( <EOL> None , <EOL> None , <EOL> None , <EOL> '<STR_LIT>' , <EOL> network_config , <EOL> None , <EOL> None , <EOL> None , <EOL> None <EOL> ) <EOL> ) <EOL> self . raise_for_response ( response , <NUM_LIT> ) <EOL> def ex_create_storage_service ( self , name , location , <EOL> description = None , affinity_group = None , <EOL> extended_properties = None ) : <EOL> """<STR_LIT>""" <EOL> response = self . _perform_storage_service_create ( <EOL> self . _get_storage_service_path ( ) , <EOL> AzureXmlSerializer . create_storage_service_to_xml ( <EOL> service_name = name , <EOL> label = self . _encode_base64 ( name ) , <EOL> description = description , <EOL> location = location , <EOL> affinity_group = affinity_group , <EOL> extended_properties = extended_properties <EOL> ) <EOL> ) <EOL> self . raise_for_response ( response , <NUM_LIT> ) <EOL> return True <EOL> def ex_destroy_storage_service ( self , name ) : <EOL> """<STR_LIT>""" <EOL> response = self . _perform_storage_service_delete ( <EOL> self . _get_storage_service_path ( name ) <EOL> ) <EOL> self . raise_for_response ( response , <NUM_LIT:200> ) <EOL> return True <EOL> """<STR_LIT>""" <EOL> def create_volume_snapshot ( self ) : <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> def attach_volume ( self ) : <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> def create_volume ( self ) : <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> def detach_volume ( self ) : <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> def destroy_volume ( self ) : <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) <EOL> """<STR_LIT>""" <EOL> def _perform_cloud_service_create ( self , path , data ) : <EOL> request = AzureHTTPRequest ( ) <EOL> request . method = '<STR_LIT:POST>' <EOL> request . host = AZURE_SERVICE_MANAGEMENT_HOST <EOL> request . path = path <EOL> request . body = data <EOL> request . path , request . query = self . _update_request_uri_query ( request ) <EOL> request . headers = self . _update_management_header ( request ) <EOL> response = self . _perform_request ( request ) <EOL> return response <EOL> def _perform_cloud_service_delete ( self , path ) : <EOL> request = AzureHTTPRequest ( ) <EOL> request . method = '<STR_LIT>' <EOL> request . host = AZURE_SERVICE_MANAGEMENT_HOST <EOL> request . path = path <EOL> request . path , request . query = self . _update_request_uri_query ( request ) <EOL> request . headers = self . _update_management_header ( request ) <EOL> response = self . _perform_request ( request ) <EOL> return response <EOL> def _perform_storage_service_create ( self , path , data ) : <EOL> request = AzureHTTPRequest ( ) <EOL> request . method = '<STR_LIT:POST>' <EOL> request . host = AZURE_SERVICE_MANAGEMENT_HOST <EOL> request . path = path <EOL> request . body = data <EOL> request . path , request . query = self . _update_request_uri_query ( request ) <EOL> request . headers = self . _update_management_header ( request ) <EOL> response = self . _perform_request ( request ) <EOL> return response <EOL> def _perform_storage_service_delete ( self , path ) : <EOL> request = AzureHTTPRequest ( ) <EOL> request . method = '<STR_LIT>' <EOL> request . host = AZURE_SERVICE_MANAGEMENT_HOST <EOL> request . path = path <EOL> request . path , request . query = self . _update_request_uri_query ( request ) <EOL> request . headers = self . _update_management_header ( request ) <EOL> response = self . _perform_request ( request ) <EOL> return response <EOL> def _to_node ( self , data , ex_cloud_service_name = None , virtual_ips = None ) : <EOL> """<STR_LIT>""" <EOL> remote_desktop_port = '<STR_LIT>' <EOL> ssh_port = '<STR_LIT>' <EOL> public_ips = virtual_ips or [ ] <EOL> if data . instance_endpoints is not None : <EOL> if len ( data . instance_endpoints ) >= <NUM_LIT:1> : <EOL> public_ips = [ data . instance_endpoints [ <NUM_LIT:0> ] . vip ] <EOL> for port in data . instance_endpoints : <EOL> if port . name == '<STR_LIT>' : <EOL> remote_desktop_port = port . public_port <EOL> if port . name == "<STR_LIT>" : <EOL> ssh_port = port . public_port <EOL> return Node ( <EOL> id = data . role_name , <EOL> name = data . role_name , <EOL> state = self . NODE_STATE_MAP . get ( <EOL> data . instance_status , <EOL> NodeState . UNKNOWN <EOL> ) , <EOL> public_ips = public_ips , <EOL> private_ips = [ data . ip_address ] , <EOL> driver = self . connection . driver , <EOL> extra = { <EOL> '<STR_LIT>' : data . instance_endpoints , <EOL> '<STR_LIT>' : remote_desktop_port , <EOL> '<STR_LIT>' : ssh_port , <EOL> '<STR_LIT>' : data . power_state , <EOL> '<STR_LIT>' : data . instance_size , <EOL> '<STR_LIT>' : ex_cloud_service_name <EOL> } <EOL> ) <EOL> def _to_location ( self , data ) : <EOL> """<STR_LIT>""" <EOL> country = data . display_name <EOL> if "<STR_LIT>" in data . display_name : <EOL> country = "<STR_LIT>" <EOL> if "<STR_LIT>" in data . display_name : <EOL> country = "<STR_LIT>" <EOL> if "<STR_LIT>" in data . display_name : <EOL> country = "<STR_LIT>" <EOL> if "<STR_LIT>" in data . display_name : <EOL> country = "<STR_LIT>" <EOL> if "<STR_LIT>" in data . display_name : <EOL> country = "<STR_LIT>" <EOL> vm_role_sizes = data . compute_capabilities . virtual_machines_role_sizes <EOL> return AzureNodeLocation ( <EOL> id = data . name , <EOL> name = data . display_name , <EOL> country = country , <EOL> driver = self . connection . driver , <EOL> available_services = data . available_services , <EOL> virtual_machine_role_sizes = vm_role_sizes <EOL> ) <EOL> def _to_node_size ( self , data ) : <EOL> """<STR_LIT>""" <EOL> return NodeSize ( <EOL> id = data [ "<STR_LIT:id>" ] , <EOL> name = data [ "<STR_LIT:name>" ] , <EOL> ram = data [ "<STR_LIT>" ] , <EOL> disk = data [ "<STR_LIT>" ] , <EOL> bandwidth = data [ "<STR_LIT>" ] , <EOL> price = data [ "<STR_LIT>" ] , <EOL> driver = self . connection . driver , <EOL> extra = { <EOL> '<STR_LIT>' : data [ "<STR_LIT>" ] , <EOL> '<STR_LIT>' : data [ "<STR_LIT>" ] <EOL> } <EOL> ) <EOL> def _to_image ( self , data ) : <EOL> return NodeImage ( <EOL> id = data . name , <EOL> name = data . label , <EOL> driver = self . connection . driver , <EOL> extra = { <EOL> '<STR_LIT>' : data . os , <EOL> '<STR_LIT>' : data . category , <EOL> '<STR_LIT:description>' : data . description , <EOL> '<STR_LIT:location>' : data . location , <EOL> '<STR_LIT>' : data . affinity_group , <EOL> '<STR_LIT>' : data . media_link , <EOL> '<STR_LIT>' : False <EOL> } <EOL> ) <EOL> def _vm_to_image ( self , data ) : <EOL> return NodeImage ( <EOL> id = data . name , <EOL> name = data . label , <EOL> driver = self . connection . driver , <EOL> extra = { <EOL> '<STR_LIT>' : data . os_disk_configuration . os , <EOL> '<STR_LIT>' : data . category , <EOL> '<STR_LIT:location>' : data . location , <EOL> '<STR_LIT>' : data . os_disk_configuration . media_link , <EOL> '<STR_LIT>' : data . affinity_group , <EOL> '<STR_LIT>' : data . deployment_name , <EOL> '<STR_LIT>' : True <EOL> } <EOL> ) <EOL> def _to_volume ( self , volume , node ) : <EOL> extra = { <EOL> '<STR_LIT>' : volume . affinity_group , <EOL> '<STR_LIT>' : volume . os , <EOL> '<STR_LIT:location>' : volume . location , <EOL> '<STR_LIT>' : volume . media_link , <EOL> '<STR_LIT>' : volume . source_image_name <EOL> } <EOL> role_name = getattr ( volume . attached_to , '<STR_LIT>' , None ) <EOL> hosted_service_name = getattr ( <EOL> volume . attached_to , <EOL> '<STR_LIT>' , <EOL> None <EOL> ) <EOL> deployment_name = getattr ( <EOL> volume . attached_to , <EOL> '<STR_LIT>' , <EOL> None <EOL> ) <EOL> if role_name is not None : <EOL> extra [ '<STR_LIT>' ] = role_name <EOL> if hosted_service_name is not None : <EOL> extra [ '<STR_LIT>' ] = hosted_service_name <EOL> if deployment_name is not None : <EOL> extra [ '<STR_LIT>' ] = deployment_name <EOL> if node : <EOL> if role_name is not None and role_name == node . id : <EOL> return StorageVolume ( <EOL> id = volume . name , <EOL> name = volume . name , <EOL> size = int ( volume . logical_disk_size_in_gb ) , <EOL> driver = self . connection . driver , <EOL> extra = extra <EOL> ) <EOL> else : <EOL> return StorageVolume ( <EOL> id = volume . name , <EOL> name = volume . name , <EOL> size = int ( volume . logical_disk_size_in_gb ) , <EOL> driver = self . connection . driver , <EOL> extra = extra <EOL> ) <EOL> def _get_deployment ( self , ** kwargs ) : <EOL> _service_name = kwargs [ '<STR_LIT>' ] <EOL> _deployment_slot = kwargs [ '<STR_LIT>' ] <EOL> response = self . _perform_get ( <EOL> self . _get_deployment_path_using_slot ( <EOL> _service_name , <EOL> _deployment_slot <EOL> ) , <EOL> None <EOL> ) <EOL> self . raise_for_response ( response , <NUM_LIT:200> ) <EOL> return self . _parse_response ( response , Deployment ) <EOL> def _get_cloud_service_location ( self , service_name = None ) : <EOL> if not service_name : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> res = self . _perform_get ( <EOL> '<STR_LIT>' % ( <EOL> self . _get_hosted_service_path ( service_name ) <EOL> ) , <EOL> HostedService <EOL> ) <EOL> _affinity_group = res . hosted_service_properties . affinity_group <EOL> _cloud_service_location = res . hosted_service_properties . location <EOL> if _affinity_group is not None and _affinity_group is not '<STR_LIT>' : <EOL> return self . service_location ( True , _affinity_group ) <EOL> elif _cloud_service_location is not None : <EOL> return self . service_location ( False , _cloud_service_location ) <EOL> else : <EOL> return None <EOL> def _is_storage_service_unique ( self , service_name = None ) : <EOL> if not service_name : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> _check_availability = self . _perform_get ( <EOL> '<STR_LIT>' % ( <EOL> self . _get_storage_service_path ( ) , <EOL> _str ( service_name ) , <EOL> '<STR_LIT>' <EOL> ) , <EOL> AvailabilityResponse <EOL> ) <EOL> self . raise_for_response ( _check_availability , <NUM_LIT:200> ) <EOL> return _check_availability . result <EOL> def _create_storage_account ( self , ** kwargs ) : <EOL> if kwargs [ '<STR_LIT>' ] is True : <EOL> response = self . _perform_post ( <EOL> self . _get_storage_service_path ( ) , <EOL> AzureXmlSerializer . create_storage_service_input_to_xml ( <EOL> kwargs [ '<STR_LIT>' ] , <EOL> kwargs [ '<STR_LIT>' ] , <EOL> self . _encode_base64 ( kwargs [ '<STR_LIT>' ] ) , <EOL> kwargs [ '<STR_LIT:location>' ] , <EOL> None , <EOL> True , <EOL> None <EOL> ) <EOL> ) <EOL> self . raise_for_response ( response , <NUM_LIT> ) <EOL> else : <EOL> response = self . _perform_post ( <EOL> self . _get_storage_service_path ( ) , <EOL> AzureXmlSerializer . create_storage_service_input_to_xml ( <EOL> kwargs [ '<STR_LIT>' ] , <EOL> kwargs [ '<STR_LIT>' ] , <EOL> self . _encode_base64 ( kwargs [ '<STR_LIT>' ] ) , <EOL> None , <EOL> kwargs [ '<STR_LIT:location>' ] , <EOL> True , <EOL> None <EOL> ) <EOL> ) <EOL> self . raise_for_response ( response , <NUM_LIT> ) <EOL> self . _ex_complete_async_azure_operation ( <EOL> response , <EOL> "<STR_LIT>" <EOL> ) <EOL> def _get_operation_status ( self , request_id ) : <EOL> return self . _perform_get ( <EOL> '<STR_LIT:/>' + self . subscription_id + '<STR_LIT>' + _str ( request_id ) , <EOL> Operation <EOL> ) <EOL> def _perform_get ( self , path , response_type ) : <EOL> request = AzureHTTPRequest ( ) <EOL> request . method = '<STR_LIT:GET>' <EOL> request . host = AZURE_SERVICE_MANAGEMENT_HOST <EOL> request . path = path <EOL> request . path , request . query = self . _update_request_uri_query ( request ) <EOL> request . headers = self . _update_management_header ( request ) <EOL> response = self . _perform_request ( request ) <EOL> if response_type is not None : <EOL> return self . _parse_response ( response , response_type ) <EOL> return response <EOL> def _perform_post ( self , path , body , response_type = None , async = False ) : <EOL> request = AzureHTTPRequest ( ) <EOL> request . method = '<STR_LIT:POST>' <EOL> request . host = AZURE_SERVICE_MANAGEMENT_HOST <EOL> request . path = path <EOL> request . body = ensure_string ( self . _get_request_body ( body ) ) <EOL> request . path , request . query = self . _update_request_uri_query ( request ) <EOL> request . headers = self . _update_management_header ( request ) <EOL> response = self . _perform_request ( request ) <EOL> return response <EOL> def _perform_put ( self , path , body , response_type = None , async = False ) : <EOL> request = AzureHTTPRequest ( ) <EOL> request . method = '<STR_LIT>' <EOL> request . host = AZURE_SERVICE_MANAGEMENT_HOST <EOL> request . path = path <EOL> request . body = ensure_string ( self . _get_request_body ( body ) ) <EOL> request . path , request . query = self . _update_request_uri_query ( request ) <EOL> request . headers = self . _update_management_header ( request ) <EOL> response = self . _perform_request ( request ) <EOL> return response <EOL> def _perform_delete ( self , path , async = False ) : <EOL> request = AzureHTTPRequest ( ) <EOL> request . method = '<STR_LIT>' <EOL> request . host = AZURE_SERVICE_MANAGEMENT_HOST <EOL> request . path = path <EOL> request . path , request . query = self . _update_request_uri_query ( request ) <EOL> request . headers = self . _update_management_header ( request ) <EOL> response = self . _perform_request ( request ) <EOL> self . raise_for_response ( response , <NUM_LIT> ) <EOL> if async : <EOL> return self . _parse_response_for_async_op ( response ) <EOL> def _perform_request ( self , request ) : <EOL> try : <EOL> return self . connection . request ( <EOL> action = request . path , <EOL> data = request . body , <EOL> headers = request . headers , <EOL> method = request . method <EOL> ) <EOL> except AzureRedirectException : <EOL> e = sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> parsed_url = urlparse . urlparse ( e . location ) <EOL> request . host = parsed_url . netloc <EOL> return self . _perform_request ( request ) <EOL> except Exception as e : <EOL> raise e <EOL> def _update_request_uri_query ( self , request ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT:?>' in request . path : <EOL> request . path , _ , query_string = request . path . partition ( '<STR_LIT:?>' ) <EOL> if query_string : <EOL> query_params = query_string . split ( '<STR_LIT:&>' ) <EOL> for query in query_params : <EOL> if '<STR_LIT:=>' in query : <EOL> name , _ , value = query . partition ( '<STR_LIT:=>' ) <EOL> request . query . append ( ( name , value ) ) <EOL> request . path = url_quote ( request . path , '<STR_LIT>' ) <EOL> if request . query : <EOL> request . path += '<STR_LIT:?>' <EOL> for name , value in request . query : <EOL> if value is not None : <EOL> request . path += '<STR_LIT>' % ( <EOL> name , <EOL> url_quote ( value , '<STR_LIT>' ) , <EOL> '<STR_LIT:&>' <EOL> ) <EOL> request . path = request . path [ : - <NUM_LIT:1> ] <EOL> return request . path , request . query <EOL> def _update_management_header ( self , request ) : <EOL> """<STR_LIT>""" <EOL> if request . method in [ '<STR_LIT>' , '<STR_LIT:POST>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> request . headers [ '<STR_LIT>' ] = str ( len ( request . body ) ) <EOL> if request . method not in [ '<STR_LIT:GET>' , '<STR_LIT>' ] : <EOL> for key in request . headers : <EOL> if '<STR_LIT>' == key . lower ( ) : <EOL> break <EOL> else : <EOL> request . headers [ '<STR_LIT:Content-Type>' ] = '<STR_LIT>' <EOL> return request . headers <EOL> def _parse_response ( self , response , return_type ) : <EOL> """<STR_LIT>""" <EOL> return self . _parse_response_body_from_xml_text ( <EOL> response = response , <EOL> return_type = return_type <EOL> ) <EOL> def _parse_response_body_from_xml_text ( self , response , return_type ) : <EOL> """<STR_LIT>""" <EOL> respbody = response . body <EOL> doc = minidom . parseString ( respbody ) <EOL> return_obj = return_type ( ) <EOL> for node in self . _get_child_nodes ( doc , return_type . __name__ ) : <EOL> self . _fill_data_to_return_object ( node , return_obj ) <EOL> return_obj . status = response . status <EOL> return return_obj <EOL> def _get_child_nodes ( self , node , tag_name ) : <EOL> return [ childNode for childNode in node . getElementsByTagName ( tag_name ) <EOL> if childNode . parentNode == node ] <EOL> def _fill_data_to_return_object ( self , node , return_obj ) : <EOL> members = dict ( vars ( return_obj ) ) <EOL> for name , value in members . items ( ) : <EOL> if isinstance ( value , _ListOf ) : <EOL> setattr ( <EOL> return_obj , <EOL> name , <EOL> self . _fill_list_of ( <EOL> node , <EOL> value . list_type , <EOL> value . xml_element_name <EOL> ) <EOL> ) <EOL> elif isinstance ( value , ScalarListOf ) : <EOL> setattr ( <EOL> return_obj , <EOL> name , <EOL> self . _fill_scalar_list_of ( <EOL> node , <EOL> value . list_type , <EOL> self . _get_serialization_name ( name ) , <EOL> value . xml_element_name <EOL> ) <EOL> ) <EOL> elif isinstance ( value , _DictOf ) : <EOL> setattr ( <EOL> return_obj , <EOL> name , <EOL> self . _fill_dict_of ( <EOL> node , <EOL> self . _get_serialization_name ( name ) , <EOL> value . pair_xml_element_name , <EOL> value . key_xml_element_name , <EOL> value . value_xml_element_name <EOL> ) <EOL> ) <EOL> elif isinstance ( value , WindowsAzureData ) : <EOL> setattr ( <EOL> return_obj , <EOL> name , <EOL> self . _fill_instance_child ( node , name , value . __class__ ) <EOL> ) <EOL> elif isinstance ( value , dict ) : <EOL> setattr ( <EOL> return_obj , <EOL> name , <EOL> self . _fill_dict ( <EOL> node , <EOL> self . _get_serialization_name ( name ) <EOL> ) <EOL> ) <EOL> elif isinstance ( value , _Base64String ) : <EOL> value = self . _fill_data_minidom ( node , name , '<STR_LIT>' ) <EOL> if value is not None : <EOL> value = self . _decode_base64_to_text ( value ) <EOL> setattr ( return_obj , name , value ) <EOL> else : <EOL> value = self . _fill_data_minidom ( node , name , value ) <EOL> if value is not None : <EOL> setattr ( return_obj , name , value ) <EOL> def _fill_list_of ( self , xmldoc , element_type , xml_element_name ) : <EOL> xmlelements = self . _get_child_nodes ( xmldoc , xml_element_name ) <EOL> return [ <EOL> self . _parse_response_body_from_xml_node ( xmlelement , element_type ) <EOL> for xmlelement in xmlelements <EOL> ] <EOL> def _parse_response_body_from_xml_node ( self , node , return_type ) : <EOL> """<STR_LIT>""" <EOL> return_obj = return_type ( ) <EOL> self . _fill_data_to_return_object ( node , return_obj ) <EOL> return return_obj <EOL> def _fill_scalar_list_of ( self , <EOL> xmldoc , <EOL> element_type , <EOL> parent_xml_element_name , <EOL> xml_element_name ) : <EOL> xmlelements = self . _get_child_nodes ( xmldoc , parent_xml_element_name ) <EOL> if xmlelements : <EOL> xmlelements = self . _get_child_nodes ( <EOL> xmlelements [ <NUM_LIT:0> ] , <EOL> xml_element_name <EOL> ) <EOL> return [ <EOL> self . _get_node_value ( xmlelement , element_type ) <EOL> for xmlelement in xmlelements <EOL> ] <EOL> def _get_node_value ( self , xmlelement , data_type ) : <EOL> value = xmlelement . firstChild . nodeValue <EOL> if data_type is datetime : <EOL> return self . _to_datetime ( value ) <EOL> elif data_type is bool : <EOL> return value . lower ( ) != '<STR_LIT:false>' <EOL> else : <EOL> return data_type ( value ) <EOL> def _get_serialization_name ( self , element_name ) : <EOL> """<STR_LIT>""" <EOL> known = _KNOWN_SERIALIZATION_XFORMS . get ( element_name ) <EOL> if known is not None : <EOL> return known <EOL> if element_name . startswith ( '<STR_LIT>' ) : <EOL> return element_name . replace ( '<STR_LIT:_>' , '<STR_LIT:->' ) <EOL> if element_name . endswith ( '<STR_LIT>' ) : <EOL> element_name = element_name . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> for name in [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] : <EOL> if element_name . startswith ( name ) : <EOL> element_name = element_name . replace ( '<STR_LIT:_>' , '<STR_LIT>' ) <EOL> return '<STR_LIT>' . join ( name . capitalize ( ) for name in element_name . split ( '<STR_LIT:_>' ) ) <EOL> def _fill_dict_of ( self , xmldoc , parent_xml_element_name , <EOL> pair_xml_element_name , key_xml_element_name , <EOL> value_xml_element_name ) : <EOL> return_obj = { } <EOL> xmlelements = self . _get_child_nodes ( xmldoc , parent_xml_element_name ) <EOL> if xmlelements : <EOL> xmlelements = self . _get_child_nodes ( <EOL> xmlelements [ <NUM_LIT:0> ] , <EOL> pair_xml_element_name <EOL> ) <EOL> for pair in xmlelements : <EOL> keys = self . _get_child_nodes ( pair , key_xml_element_name ) <EOL> values = self . _get_child_nodes ( pair , value_xml_element_name ) <EOL> if keys and values : <EOL> key = keys [ <NUM_LIT:0> ] . firstChild . nodeValue <EOL> value = values [ <NUM_LIT:0> ] . firstChild . nodeValue <EOL> return_obj [ key ] = value <EOL> return return_obj <EOL> def _fill_instance_child ( self , xmldoc , element_name , return_type ) : <EOL> """<STR_LIT>""" <EOL> xmlelements = self . _get_child_nodes ( <EOL> xmldoc , <EOL> self . _get_serialization_name ( element_name ) <EOL> ) <EOL> if not xmlelements : <EOL> return None <EOL> return_obj = return_type ( ) <EOL> self . _fill_data_to_return_object ( xmlelements [ <NUM_LIT:0> ] , return_obj ) <EOL> return return_obj <EOL> def _fill_dict ( self , xmldoc , element_name ) : <EOL> xmlelements = self . _get_child_nodes ( xmldoc , element_name ) <EOL> if xmlelements : <EOL> return_obj = { } <EOL> for child in xmlelements [ <NUM_LIT:0> ] . childNodes : <EOL> if child . firstChild : <EOL> return_obj [ child . nodeName ] = child . firstChild . nodeValue <EOL> return return_obj <EOL> def _encode_base64 ( self , data ) : <EOL> if isinstance ( data , _unicode_type ) : <EOL> data = data . encode ( '<STR_LIT:utf-8>' ) <EOL> encoded = base64 . b64encode ( data ) <EOL> return encoded . decode ( '<STR_LIT:utf-8>' ) <EOL> def _decode_base64_to_bytes ( self , data ) : <EOL> if isinstance ( data , _unicode_type ) : <EOL> data = data . encode ( '<STR_LIT:utf-8>' ) <EOL> return base64 . b64decode ( data ) <EOL> def _decode_base64_to_text ( self , data ) : <EOL> decoded_bytes = self . _decode_base64_to_bytes ( data ) <EOL> return decoded_bytes . decode ( '<STR_LIT:utf-8>' ) <EOL> def _fill_data_minidom ( self , xmldoc , element_name , data_member ) : <EOL> xmlelements = self . _get_child_nodes ( <EOL> xmldoc , <EOL> self . _get_serialization_name ( element_name ) <EOL> ) <EOL> if not xmlelements or not xmlelements [ <NUM_LIT:0> ] . childNodes : <EOL> return None <EOL> value = xmlelements [ <NUM_LIT:0> ] . firstChild . nodeValue <EOL> if data_member is None : <EOL> return value <EOL> elif isinstance ( data_member , datetime ) : <EOL> return self . _to_datetime ( value ) <EOL> elif type ( data_member ) is bool : <EOL> return value . lower ( ) != '<STR_LIT:false>' <EOL> elif type ( data_member ) is str : <EOL> return _real_unicode ( value ) <EOL> else : <EOL> return type ( data_member ) ( value ) <EOL> def _to_datetime ( self , strtime ) : <EOL> return datetime . strptime ( strtime , "<STR_LIT>" ) <EOL> def _get_request_body ( self , request_body ) : <EOL> if request_body is None : <EOL> return b'<STR_LIT>' <EOL> if isinstance ( request_body , WindowsAzureData ) : <EOL> request_body = self . _convert_class_to_xml ( request_body ) <EOL> if isinstance ( request_body , bytes ) : <EOL> return request_body <EOL> if isinstance ( request_body , _unicode_type ) : <EOL> return request_body . encode ( '<STR_LIT:utf-8>' ) <EOL> request_body = str ( request_body ) <EOL> if isinstance ( request_body , _unicode_type ) : <EOL> return request_body . encode ( '<STR_LIT:utf-8>' ) <EOL> return request_body <EOL> def _convert_class_to_xml ( self , source , xml_prefix = True ) : <EOL> root = ET . Element ( ) <EOL> doc = self . _construct_element_tree ( source , root ) <EOL> result = ensure_string ( ET . tostring ( doc , encoding = '<STR_LIT:utf-8>' , <EOL> method = '<STR_LIT>' ) ) <EOL> return result <EOL> def _construct_element_tree ( self , source , etree ) : <EOL> if source is None : <EOL> return ET . Element ( ) <EOL> if isinstance ( source , list ) : <EOL> for value in source : <EOL> etree . append ( self . _construct_element_tree ( value , etree ) ) <EOL> elif isinstance ( source , WindowsAzureData ) : <EOL> class_name = source . __class__ . __name__ <EOL> etree . append ( ET . Element ( class_name ) ) <EOL> for name , value in vars ( source ) . items ( ) : <EOL> if value is not None : <EOL> if ( isinstance ( value , list ) or <EOL> isinstance ( value , WindowsAzureData ) ) : <EOL> etree . append ( <EOL> self . _construct_element_tree ( value , etree ) <EOL> ) <EOL> else : <EOL> ele = ET . Element ( self . _get_serialization_name ( name ) ) <EOL> ele . text = xml_escape ( str ( value ) ) <EOL> etree . append ( ele ) <EOL> etree . append ( ET . Element ( class_name ) ) <EOL> return etree <EOL> def _parse_response_for_async_op ( self , response ) : <EOL> if response is None : <EOL> return None <EOL> result = AsynchronousOperationResult ( ) <EOL> if response . headers : <EOL> for name , value in response . headers . items ( ) : <EOL> if name . lower ( ) == '<STR_LIT>' : <EOL> result . request_id = value <EOL> return result <EOL> def _get_deployment_path_using_name ( self , service_name , <EOL> deployment_name = None ) : <EOL> components = [ <EOL> '<STR_LIT>' , <EOL> _str ( service_name ) , <EOL> '<STR_LIT>' <EOL> ] <EOL> resource = '<STR_LIT>' . join ( components ) <EOL> return self . _get_path ( resource , deployment_name ) <EOL> def _get_path ( self , resource , name ) : <EOL> path = '<STR_LIT:/>' + self . subscription_id + '<STR_LIT:/>' + resource <EOL> if name is not None : <EOL> path += '<STR_LIT:/>' + _str ( name ) <EOL> return path <EOL> def _get_image_path ( self , image_name = None ) : <EOL> return self . _get_path ( '<STR_LIT>' , image_name ) <EOL> def _get_vmimage_path ( self , image_name = None ) : <EOL> return self . _get_path ( '<STR_LIT>' , image_name ) <EOL> def _get_hosted_service_path ( self , service_name = None ) : <EOL> return self . _get_path ( '<STR_LIT>' , service_name ) <EOL> def _get_deployment_path_using_slot ( self , service_name , slot = None ) : <EOL> return self . _get_path ( <EOL> '<STR_LIT>' % ( <EOL> _str ( service_name ) <EOL> ) , <EOL> slot <EOL> ) <EOL> def _get_disk_path ( self , disk_name = None ) : <EOL> return self . _get_path ( '<STR_LIT>' , disk_name ) <EOL> def _get_role_path ( self , service_name , deployment_name , role_name = None ) : <EOL> components = [ <EOL> '<STR_LIT>' , <EOL> _str ( service_name ) , <EOL> '<STR_LIT>' , <EOL> deployment_name , <EOL> '<STR_LIT>' <EOL> ] <EOL> resource = '<STR_LIT>' . join ( components ) <EOL> return self . _get_path ( resource , role_name ) <EOL> def _get_storage_service_path ( self , service_name = None ) : <EOL> return self . _get_path ( '<STR_LIT>' , service_name ) <EOL> def _ex_complete_async_azure_operation ( self , response = None , <EOL> operation_type = '<STR_LIT>' ) : <EOL> request_id = self . _parse_response_for_async_op ( response ) <EOL> operation_status = self . _get_operation_status ( request_id . request_id ) <EOL> timeout = <NUM_LIT> * <NUM_LIT:5> <EOL> waittime = <NUM_LIT:0> <EOL> interval = <NUM_LIT:5> <EOL> while operation_status . status == "<STR_LIT>" and waittime < timeout : <EOL> operation_status = self . _get_operation_status ( request_id ) <EOL> if operation_status . status == "<STR_LIT>" : <EOL> break <EOL> waittime += interval <EOL> time . sleep ( interval ) <EOL> if operation_status . status == '<STR_LIT>' : <EOL> raise LibcloudError ( <EOL> '<STR_LIT>' % <EOL> operation_type , <EOL> driver = self . connection . driver <EOL> ) <EOL> def raise_for_response ( self , response , valid_response ) : <EOL> if response . status != valid_response : <EOL> values = ( response . error , response . body , response . status ) <EOL> message = '<STR_LIT>' % ( values ) <EOL> raise LibcloudError ( message , driver = self ) <EOL> """<STR_LIT>""" <EOL> def _lower ( text ) : <EOL> return text . lower ( ) <EOL> class AzureXmlSerializer ( object ) : <EOL> @ staticmethod <EOL> def create_storage_service_input_to_xml ( service_name , <EOL> description , <EOL> label , <EOL> affinity_group , <EOL> location , <EOL> geo_replication_enabled , <EOL> extended_properties ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , service_name ) , <EOL> ( '<STR_LIT>' , description ) , <EOL> ( '<STR_LIT>' , label ) , <EOL> ( '<STR_LIT>' , affinity_group ) , <EOL> ( '<STR_LIT>' , location ) , <EOL> ( '<STR_LIT>' , geo_replication_enabled , _lower ) <EOL> ] , <EOL> extended_properties <EOL> ) <EOL> @ staticmethod <EOL> def update_storage_service_input_to_xml ( description , <EOL> label , <EOL> geo_replication_enabled , <EOL> extended_properties ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , description ) , <EOL> ( '<STR_LIT>' , label , AzureNodeDriver . _encode_base64 ) , <EOL> ( '<STR_LIT>' , geo_replication_enabled , _lower ) <EOL> ] , <EOL> extended_properties <EOL> ) <EOL> @ staticmethod <EOL> def regenerate_keys_to_xml ( key_type ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , key_type ) ] <EOL> ) <EOL> @ staticmethod <EOL> def update_hosted_service_to_xml ( label , description , extended_properties ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , label , AzureNodeDriver . _encode_base64 ) , <EOL> ( '<STR_LIT>' , description ) <EOL> ] , <EOL> extended_properties <EOL> ) <EOL> @ staticmethod <EOL> def create_hosted_service_to_xml ( service_name , <EOL> label , <EOL> description , <EOL> location , <EOL> affinity_group = None , <EOL> extended_properties = None ) : <EOL> if affinity_group : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , service_name ) , <EOL> ( '<STR_LIT>' , label ) , <EOL> ( '<STR_LIT>' , description ) , <EOL> ( '<STR_LIT>' , affinity_group ) , <EOL> ] , <EOL> extended_properties <EOL> ) <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , service_name ) , <EOL> ( '<STR_LIT>' , label ) , <EOL> ( '<STR_LIT>' , description ) , <EOL> ( '<STR_LIT>' , location ) , <EOL> ] , <EOL> extended_properties <EOL> ) <EOL> @ staticmethod <EOL> def create_storage_service_to_xml ( service_name , <EOL> label , <EOL> description , <EOL> location , <EOL> affinity_group , <EOL> extended_properties = None ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , service_name ) , <EOL> ( '<STR_LIT>' , label ) , <EOL> ( '<STR_LIT>' , description ) , <EOL> ( '<STR_LIT>' , location ) , <EOL> ( '<STR_LIT>' , affinity_group ) <EOL> ] , <EOL> extended_properties <EOL> ) <EOL> @ staticmethod <EOL> def create_deployment_to_xml ( name , <EOL> package_url , <EOL> label , <EOL> configuration , <EOL> start_deployment , <EOL> treat_warnings_as_error , <EOL> extended_properties ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT:Name>' , name ) , <EOL> ( '<STR_LIT>' , package_url ) , <EOL> ( '<STR_LIT>' , label , AzureNodeDriver . _encode_base64 ) , <EOL> ( '<STR_LIT>' , configuration ) , <EOL> ( '<STR_LIT>' , start_deployment , _lower ) , <EOL> ( '<STR_LIT>' , treat_warnings_as_error , _lower ) <EOL> ] , <EOL> extended_properties <EOL> ) <EOL> @ staticmethod <EOL> def swap_deployment_to_xml ( production , source_deployment ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , production ) , <EOL> ( '<STR_LIT>' , source_deployment ) <EOL> ] <EOL> ) <EOL> @ staticmethod <EOL> def update_deployment_status_to_xml ( status ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , status ) ] <EOL> ) <EOL> @ staticmethod <EOL> def change_deployment_to_xml ( configuration , <EOL> treat_warnings_as_error , <EOL> mode , <EOL> extended_properties ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , configuration ) , <EOL> ( '<STR_LIT>' , treat_warnings_as_error , _lower ) , <EOL> ( '<STR_LIT>' , mode ) <EOL> ] , <EOL> extended_properties <EOL> ) <EOL> @ staticmethod <EOL> def upgrade_deployment_to_xml ( mode , <EOL> package_url , <EOL> configuration , <EOL> label , <EOL> role_to_upgrade , <EOL> force , <EOL> extended_properties ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , mode ) , <EOL> ( '<STR_LIT>' , package_url ) , <EOL> ( '<STR_LIT>' , configuration ) , <EOL> ( '<STR_LIT>' , label , AzureNodeDriver . _encode_base64 ) , <EOL> ( '<STR_LIT>' , role_to_upgrade ) , <EOL> ( '<STR_LIT>' , force , _lower ) <EOL> ] , <EOL> extended_properties <EOL> ) <EOL> @ staticmethod <EOL> def rollback_upgrade_to_xml ( mode , force ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , mode ) , <EOL> ( '<STR_LIT>' , force , _lower ) <EOL> ] <EOL> ) <EOL> @ staticmethod <EOL> def walk_upgrade_domain_to_xml ( upgrade_domain ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ ( '<STR_LIT>' , upgrade_domain ) ] <EOL> ) <EOL> @ staticmethod <EOL> def certificate_file_to_xml ( data , certificate_format , password ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , data ) , <EOL> ( '<STR_LIT>' , certificate_format ) , <EOL> ( '<STR_LIT>' , password ) <EOL> ] <EOL> ) <EOL> @ staticmethod <EOL> def create_affinity_group_to_xml ( name , label , description , location ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT:Name>' , name ) , <EOL> ( '<STR_LIT>' , label , AzureNodeDriver . _encode_base64 ) , <EOL> ( '<STR_LIT>' , description ) , <EOL> ( '<STR_LIT>' , location ) <EOL> ] <EOL> ) <EOL> @ staticmethod <EOL> def update_affinity_group_to_xml ( label , description ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , label , AzureNodeDriver . _encode_base64 ) , <EOL> ( '<STR_LIT>' , description ) <EOL> ] <EOL> ) <EOL> @ staticmethod <EOL> def subscription_certificate_to_xml ( public_key , thumbprint , data ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , public_key ) , <EOL> ( '<STR_LIT>' , thumbprint ) , <EOL> ( '<STR_LIT>' , data ) <EOL> ] <EOL> ) <EOL> @ staticmethod <EOL> def os_image_to_xml ( label , media_link , name , os ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , label ) , <EOL> ( '<STR_LIT>' , media_link ) , <EOL> ( '<STR_LIT:Name>' , name ) , <EOL> ( '<STR_LIT>' , os ) <EOL> ] <EOL> ) <EOL> @ staticmethod <EOL> def data_virtual_hard_disk_to_xml ( host_caching , <EOL> disk_label , <EOL> disk_name , <EOL> lun , <EOL> logical_disk_size_in_gb , <EOL> media_link , <EOL> source_media_link ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , host_caching ) , <EOL> ( '<STR_LIT>' , disk_label ) , <EOL> ( '<STR_LIT>' , disk_name ) , <EOL> ( '<STR_LIT>' , lun ) , <EOL> ( '<STR_LIT>' , logical_disk_size_in_gb ) , <EOL> ( '<STR_LIT>' , media_link ) , <EOL> ( '<STR_LIT>' , source_media_link ) <EOL> ] <EOL> ) <EOL> @ staticmethod <EOL> def disk_to_xml ( has_operating_system , label , media_link , name , os ) : <EOL> return AzureXmlSerializer . doc_from_data ( <EOL> '<STR_LIT>' , <EOL> [ <EOL> ( '<STR_LIT>' , has_operating_system , _lower ) , <EOL> ( '<STR_LIT>' , label ) , <EOL> ( '<STR_LIT>' , media_link ) , <EOL> ( '<STR_LIT:Name>' , name ) , <EOL> ( '<STR_LIT>' , os ) <EOL> ] <EOL> ) <EOL> @ staticmethod <EOL> def restart_role_operation_to_xml ( ) : <EOL> xml = ET . Element ( "<STR_LIT>" ) <EOL> xml . text = "<STR_LIT>" <EOL> doc = AzureXmlSerializer . doc_from_xml ( <EOL> '<STR_LIT>' , <EOL> xml <EOL> ) <EOL> result = ensure_string ( ET . tostring ( doc , encoding = '<STR_LIT:utf-8>' ) ) <EOL> return result <EOL> @ staticmethod <EOL> def shutdown_role_operation_to_xml ( ) : <EOL> xml = ET . Element ( "<STR_LIT>" ) <EOL> xml . text = "<STR_LIT>" <EOL> doc = AzureXmlSerializer . doc_from_xml ( <EOL> '<STR_LIT>' , <EOL> xml <EOL> ) <EOL> result = ensure_string ( ET . tostring ( doc , encoding = '<STR_LIT:utf-8>' ) ) <EOL> return result <EOL> @ staticmethod <EOL> def start_role_operation_to_xml ( ) : <EOL> xml = ET . Element ( "<STR_LIT>" ) <EOL> xml . text = "<STR_LIT>" <EOL> doc = AzureXmlSerializer . doc_from_xml ( <EOL> '<STR_LIT>' , <EOL> xml <EOL> ) <EOL> result = ensure_string ( ET . tostring ( doc , encoding = '<STR_LIT:utf-8>' ) ) <EOL> return result <EOL> @ staticmethod <EOL> def windows_configuration_to_xml ( configuration , xml ) : <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , configuration . configuration_set_type ) ] , <EOL> xml <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , configuration . computer_name ) ] , <EOL> xml <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , configuration . admin_password ) ] , <EOL> xml <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ <EOL> ( <EOL> '<STR_LIT>' , <EOL> configuration . reset_password_on_first_logon , <EOL> _lower <EOL> ) <EOL> ] , <EOL> xml <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ <EOL> ( <EOL> '<STR_LIT>' , <EOL> configuration . enable_automatic_updates , <EOL> _lower <EOL> ) <EOL> ] , <EOL> xml <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , configuration . time_zone ) ] , <EOL> xml <EOL> ) <EOL> if configuration . domain_join is not None : <EOL> domain = ET . xml ( "<STR_LIT>" ) <EOL> creds = ET . xml ( "<STR_LIT>" ) <EOL> domain . appemnd ( creds ) <EOL> xml . append ( domain ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , configuration . domain_join . credentials . domain ) ] , <EOL> creds <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ <EOL> ( <EOL> '<STR_LIT>' , <EOL> configuration . domain_join . credentials . username <EOL> ) <EOL> ] , <EOL> creds <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ <EOL> ( <EOL> '<STR_LIT>' , <EOL> configuration . domain_join . credentials . password <EOL> ) <EOL> ] , <EOL> creds <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , configuration . domain_join . join_domain ) ] , <EOL> domain <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ <EOL> ( <EOL> '<STR_LIT>' , <EOL> configuration . domain_join . machine_object_ou <EOL> ) <EOL> ] , <EOL> domain <EOL> ) <EOL> if configuration . stored_certificate_settings is not None : <EOL> cert_settings = ET . Element ( "<STR_LIT>" ) <EOL> xml . append ( cert_settings ) <EOL> for cert in configuration . stored_certificate_settings : <EOL> cert_setting = ET . Element ( "<STR_LIT>" ) <EOL> cert_settings . append ( cert_setting ) <EOL> cert_setting . append ( AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , cert . store_location ) ] ) <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , cert . store_name ) ] , <EOL> cert_setting <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , cert . thumbprint ) ] , <EOL> cert_setting <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , configuration . admin_user_name ) ] , <EOL> xml <EOL> ) <EOL> return xml <EOL> @ staticmethod <EOL> def linux_configuration_to_xml ( configuration , xml ) : <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , configuration . configuration_set_type ) ] , <EOL> xml <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , configuration . host_name ) ] , <EOL> xml <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , configuration . user_name ) ] , <EOL> xml <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , configuration . user_password ) ] , <EOL> xml <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ <EOL> ( <EOL> '<STR_LIT>' , <EOL> configuration . disable_ssh_password_authentication , <EOL> _lower <EOL> ) <EOL> ] , <EOL> xml <EOL> ) <EOL> if configuration . ssh is not None : <EOL> ssh = ET . Element ( "<STR_LIT>" ) <EOL> pkeys = ET . Element ( "<STR_LIT>" ) <EOL> kpairs = ET . Element ( "<STR_LIT>" ) <EOL> ssh . append ( pkeys ) <EOL> ssh . append ( kpairs ) <EOL> xml . append ( ssh ) <EOL> for key in configuration . ssh . public_keys : <EOL> pkey = ET . Element ( "<STR_LIT>" ) <EOL> pkeys . append ( pkey ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , key . fingerprint ) ] , <EOL> pkey <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( [ ( '<STR_LIT>' , key . path ) ] , pkey ) <EOL> for key in configuration . ssh . key_pairs : <EOL> kpair = ET . Element ( "<STR_LIT>" ) <EOL> kpairs . append ( kpair ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , key . fingerprint ) ] , <EOL> kpair <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( [ ( '<STR_LIT>' , key . path ) ] , kpair ) <EOL> if configuration . custom_data is not None : <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , configuration . custom_data ) ] , <EOL> xml <EOL> ) <EOL> return xml <EOL> @ staticmethod <EOL> def network_configuration_to_xml ( configuration , xml ) : <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , configuration . configuration_set_type ) ] , <EOL> xml <EOL> ) <EOL> input_endpoints = ET . Element ( "<STR_LIT>" ) <EOL> xml . append ( input_endpoints ) <EOL> for endpoint in configuration . input_endpoints : <EOL> input_endpoint = ET . Element ( "<STR_LIT>" ) <EOL> input_endpoints . append ( input_endpoint ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ <EOL> ( <EOL> '<STR_LIT>' , <EOL> endpoint . load_balanced_endpoint_set_name <EOL> ) <EOL> ] , <EOL> input_endpoint <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , endpoint . local_port ) ] , <EOL> input_endpoint <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT:Name>' , endpoint . name ) ] , <EOL> input_endpoint <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , endpoint . port ) ] , <EOL> input_endpoint <EOL> ) <EOL> if ( endpoint . load_balancer_probe . path or <EOL> endpoint . load_balancer_probe . port or <EOL> endpoint . load_balancer_probe . protocol ) : <EOL> load_balancer_probe = ET . Element ( "<STR_LIT>" ) <EOL> input_endpoint . append ( load_balancer_probe ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , endpoint . load_balancer_probe . path ) ] , <EOL> load_balancer_probe <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , endpoint . load_balancer_probe . port ) ] , <EOL> load_balancer_probe <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , endpoint . load_balancer_probe . protocol ) ] , <EOL> load_balancer_probe <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , endpoint . protocol ) ] , <EOL> input_endpoint <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ <EOL> ( <EOL> '<STR_LIT>' , <EOL> endpoint . enable_direct_server_return , <EOL> _lower <EOL> ) <EOL> ] , <EOL> input_endpoint <EOL> ) <EOL> subnet_names = ET . Element ( "<STR_LIT>" ) <EOL> xml . append ( subnet_names ) <EOL> for name in configuration . subnet_names : <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , name ) ] , <EOL> subnet_names <EOL> ) <EOL> return xml <EOL> @ staticmethod <EOL> def role_to_xml ( availability_set_name , <EOL> data_virtual_hard_disks , <EOL> network_configuration_set , <EOL> os_virtual_hard_disk , <EOL> vm_image_name , <EOL> role_name , <EOL> role_size , <EOL> role_type , <EOL> system_configuration_set , <EOL> xml ) : <EOL> AzureXmlSerializer . data_to_xml ( [ ( '<STR_LIT>' , role_name ) ] , xml ) <EOL> AzureXmlSerializer . data_to_xml ( [ ( '<STR_LIT>' , role_type ) ] , xml ) <EOL> config_sets = ET . Element ( "<STR_LIT>" ) <EOL> xml . append ( config_sets ) <EOL> if system_configuration_set is not None : <EOL> config_set = ET . Element ( "<STR_LIT>" ) <EOL> config_sets . append ( config_set ) <EOL> if isinstance ( system_configuration_set , WindowsConfigurationSet ) : <EOL> AzureXmlSerializer . windows_configuration_to_xml ( <EOL> system_configuration_set , <EOL> config_set <EOL> ) <EOL> elif isinstance ( system_configuration_set , LinuxConfigurationSet ) : <EOL> AzureXmlSerializer . linux_configuration_to_xml ( <EOL> system_configuration_set , <EOL> config_set <EOL> ) <EOL> if network_configuration_set is not None : <EOL> config_set = ET . Element ( "<STR_LIT>" ) <EOL> config_sets . append ( config_set ) <EOL> AzureXmlSerializer . network_configuration_to_xml ( <EOL> network_configuration_set , <EOL> config_set <EOL> ) <EOL> if availability_set_name is not None : <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , availability_set_name ) ] , <EOL> xml <EOL> ) <EOL> if data_virtual_hard_disks is not None : <EOL> vhds = ET . Element ( "<STR_LIT>" ) <EOL> xml . append ( vhds ) <EOL> for hd in data_virtual_hard_disks : <EOL> vhd = ET . Element ( "<STR_LIT>" ) <EOL> vhds . append ( vhd ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , hd . host_caching ) ] , <EOL> vhd <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , hd . disk_label ) ] , <EOL> vhd <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , hd . disk_name ) ] , <EOL> vhd <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , hd . lun ) ] , <EOL> vhd <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , hd . logical_disk_size_in_gb ) ] , <EOL> vhd <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , hd . media_link ) ] , <EOL> vhd <EOL> ) <EOL> if os_virtual_hard_disk is not None : <EOL> hd = ET . Element ( "<STR_LIT>" ) <EOL> xml . append ( hd ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , os_virtual_hard_disk . host_caching ) ] , <EOL> hd <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , os_virtual_hard_disk . disk_label ) ] , <EOL> hd <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , os_virtual_hard_disk . disk_name ) ] , <EOL> hd <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , os_virtual_hard_disk . media_link ) ] , <EOL> hd <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , os_virtual_hard_disk . source_image_name ) ] , <EOL> hd <EOL> ) <EOL> if vm_image_name is not None : <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , vm_image_name ) ] , <EOL> xml <EOL> ) <EOL> if role_size is not None : <EOL> AzureXmlSerializer . data_to_xml ( [ ( '<STR_LIT>' , role_size ) ] , xml ) <EOL> return xml <EOL> @ staticmethod <EOL> def add_role_to_xml ( role_name , <EOL> system_configuration_set , <EOL> os_virtual_hard_disk , <EOL> role_type , <EOL> network_configuration_set , <EOL> availability_set_name , <EOL> data_virtual_hard_disks , <EOL> vm_image_name , <EOL> role_size ) : <EOL> doc = AzureXmlSerializer . doc_from_xml ( '<STR_LIT>' ) <EOL> xml = AzureXmlSerializer . role_to_xml ( <EOL> availability_set_name , <EOL> data_virtual_hard_disks , <EOL> network_configuration_set , <EOL> os_virtual_hard_disk , <EOL> vm_image_name , <EOL> role_name , <EOL> role_size , <EOL> role_type , <EOL> system_configuration_set , <EOL> doc <EOL> ) <EOL> result = ensure_string ( ET . tostring ( xml , encoding = '<STR_LIT:utf-8>' ) ) <EOL> return result <EOL> @ staticmethod <EOL> def update_role_to_xml ( role_name , <EOL> os_virtual_hard_disk , <EOL> role_type , <EOL> network_configuration_set , <EOL> availability_set_name , <EOL> data_virtual_hard_disks , <EOL> vm_image_name , <EOL> role_size ) : <EOL> doc = AzureXmlSerializer . doc_from_xml ( '<STR_LIT>' ) <EOL> AzureXmlSerializer . role_to_xml ( <EOL> availability_set_name , <EOL> data_virtual_hard_disks , <EOL> network_configuration_set , <EOL> os_virtual_hard_disk , <EOL> vm_image_name , <EOL> role_name , <EOL> role_size , <EOL> role_type , <EOL> None , <EOL> doc <EOL> ) <EOL> result = ensure_string ( ET . tostring ( doc , encoding = '<STR_LIT:utf-8>' ) ) <EOL> return result <EOL> @ staticmethod <EOL> def capture_role_to_xml ( post_capture_action , <EOL> target_image_name , <EOL> target_image_label , <EOL> provisioning_configuration ) : <EOL> xml = AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , post_capture_action ) ] , <EOL> xml <EOL> ) <EOL> if provisioning_configuration is not None : <EOL> provisioning_config = ET . Element ( "<STR_LIT>" ) <EOL> xml . append ( provisioning_config ) <EOL> if isinstance ( provisioning_configuration , WindowsConfigurationSet ) : <EOL> AzureXmlSerializer . windows_configuration_to_xml ( <EOL> provisioning_configuration , <EOL> provisioning_config <EOL> ) <EOL> elif isinstance ( provisioning_configuration , LinuxConfigurationSet ) : <EOL> AzureXmlSerializer . linux_configuration_to_xml ( <EOL> provisioning_configuration , <EOL> provisioning_config <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , target_image_label ) ] , <EOL> xml <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , target_image_name ) ] , <EOL> xml <EOL> ) <EOL> doc = AzureXmlSerializer . doc_from_xml ( '<STR_LIT>' , xml ) <EOL> result = ensure_string ( ET . tostring ( doc , encoding = '<STR_LIT:utf-8>' ) ) <EOL> return result <EOL> @ staticmethod <EOL> def virtual_machine_deployment_to_xml ( deployment_name , <EOL> deployment_slot , <EOL> label , <EOL> role_name , <EOL> system_configuration_set , <EOL> os_virtual_hard_disk , <EOL> role_type , <EOL> network_configuration_set , <EOL> availability_set_name , <EOL> data_virtual_hard_disks , <EOL> role_size , <EOL> virtual_network_name , <EOL> vm_image_name ) : <EOL> doc = AzureXmlSerializer . doc_from_xml ( '<STR_LIT>' ) <EOL> AzureXmlSerializer . data_to_xml ( [ ( '<STR_LIT:Name>' , deployment_name ) ] , doc ) <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , deployment_slot ) ] , <EOL> doc <EOL> ) <EOL> AzureXmlSerializer . data_to_xml ( [ ( '<STR_LIT>' , label ) ] , doc ) <EOL> role_list = ET . Element ( "<STR_LIT>" ) <EOL> role = ET . Element ( "<STR_LIT>" ) <EOL> role_list . append ( role ) <EOL> doc . append ( role_list ) <EOL> AzureXmlSerializer . role_to_xml ( <EOL> availability_set_name , <EOL> data_virtual_hard_disks , <EOL> network_configuration_set , <EOL> os_virtual_hard_disk , <EOL> vm_image_name , <EOL> role_name , <EOL> role_size , <EOL> role_type , <EOL> system_configuration_set , <EOL> role <EOL> ) <EOL> if virtual_network_name is not None : <EOL> doc . append ( <EOL> AzureXmlSerializer . data_to_xml ( <EOL> [ ( '<STR_LIT>' , virtual_network_name ) ] <EOL> ) <EOL> ) <EOL> result = ensure_string ( ET . tostring ( doc , encoding = '<STR_LIT:utf-8>' ) ) <EOL> return result <EOL> @ staticmethod <EOL> def data_to_xml ( data , xml = None ) : <EOL> """<STR_LIT>""" <EOL> for element in data : <EOL> name = element [ <NUM_LIT:0> ] <EOL> val = element [ <NUM_LIT:1> ] <EOL> if len ( element ) > <NUM_LIT:2> : <EOL> converter = element [ <NUM_LIT:2> ] <EOL> else : <EOL> converter = None <EOL> if val is not None : <EOL> if converter is not None : <EOL> text = _str ( converter ( _str ( val ) ) ) <EOL> else : <EOL> text = _str ( val ) <EOL> entry = ET . Element ( name ) <EOL> entry . text = text <EOL> if xml is not None : <EOL> xml . append ( entry ) <EOL> else : <EOL> return entry <EOL> return xml <EOL> @ staticmethod <EOL> def doc_from_xml ( document_element_name , inner_xml = None ) : <EOL> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> xml = ET . Element ( document_element_name ) <EOL> xml . set ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> if inner_xml is not None : <EOL> xml . append ( inner_xml ) <EOL> return xml <EOL> @ staticmethod <EOL> def doc_from_data ( document_element_name , data , extended_properties = None ) : <EOL> doc = AzureXmlSerializer . doc_from_xml ( document_element_name ) <EOL> AzureXmlSerializer . data_to_xml ( data , doc ) <EOL> if extended_properties is not None : <EOL> doc . append ( <EOL> AzureXmlSerializer . extended_properties_dict_to_xml_fragment ( <EOL> extended_properties <EOL> ) <EOL> ) <EOL> result = ensure_string ( ET . tostring ( doc , encoding = '<STR_LIT:utf-8>' ) ) <EOL> return result <EOL> @ staticmethod <EOL> def extended_properties_dict_to_xml_fragment ( extended_properties ) : <EOL> if extended_properties is not None and len ( extended_properties ) > <NUM_LIT:0> : <EOL> xml = ET . Element ( "<STR_LIT>" ) <EOL> for key , val in extended_properties . items ( ) : <EOL> extended_property = ET . Element ( "<STR_LIT>" ) <EOL> name = ET . Element ( "<STR_LIT:Name>" ) <EOL> name . text = _str ( key ) <EOL> value = ET . Element ( "<STR_LIT>" ) <EOL> value . text = _str ( val ) <EOL> extended_property . append ( name ) <EOL> extended_property . append ( value ) <EOL> xml . append ( extended_property ) <EOL> return xml <EOL> """<STR_LIT>""" <EOL> class WindowsAzureData ( object ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class WindowsAzureDataTypedList ( WindowsAzureData ) : <EOL> list_type = None <EOL> xml_element_name = None <EOL> def __init__ ( self ) : <EOL> self . items = _ListOf ( self . list_type , self . xml_element_name ) <EOL> def __iter__ ( self ) : <EOL> return iter ( self . items ) <EOL> def __len__ ( self ) : <EOL> return len ( self . items ) <EOL> def __getitem__ ( self , index ) : <EOL> return self . items [ index ] <EOL> class OSVirtualHardDisk ( WindowsAzureData ) : <EOL> def __init__ ( self , source_image_name = None , media_link = None , <EOL> host_caching = None , disk_label = None , disk_name = None ) : <EOL> self . source_image_name = source_image_name <EOL> self . media_link = media_link <EOL> self . host_caching = host_caching <EOL> self . disk_label = disk_label <EOL> self . disk_name = disk_name <EOL> self . os = '<STR_LIT>' <EOL> class LinuxConfigurationSet ( WindowsAzureData ) : <EOL> def __init__ ( self , <EOL> host_name = None , <EOL> user_name = None , <EOL> user_password = None , <EOL> disable_ssh_password_authentication = None , <EOL> custom_data = None ) : <EOL> self . configuration_set_type = '<STR_LIT>' <EOL> self . host_name = host_name <EOL> self . user_name = user_name <EOL> self . user_password = user_password <EOL> self . disable_ssh_password_authentication = disable_ssh_password_authentication <EOL> self . ssh = SSH ( ) <EOL> self . custom_data = custom_data <EOL> class WindowsConfigurationSet ( WindowsAzureData ) : <EOL> def __init__ ( self , <EOL> computer_name = None , <EOL> admin_password = None , <EOL> reset_password_on_first_logon = None , <EOL> enable_automatic_updates = None , <EOL> time_zone = None , <EOL> admin_user_name = None ) : <EOL> self . configuration_set_type = '<STR_LIT>' <EOL> self . computer_name = computer_name <EOL> self . admin_password = admin_password <EOL> self . reset_password_on_first_logon = reset_password_on_first_logon <EOL> self . enable_automatic_updates = enable_automatic_updates <EOL> self . time_zone = time_zone <EOL> self . admin_user_name = admin_user_name <EOL> self . domain_join = DomainJoin ( ) <EOL> self . stored_certificate_settings = StoredCertificateSettings ( ) <EOL> class DomainJoin ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . credentials = Credentials ( ) <EOL> self . join_domain = '<STR_LIT>' <EOL> self . machine_object_ou = '<STR_LIT>' <EOL> class Credentials ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . domain = '<STR_LIT>' <EOL> self . username = '<STR_LIT>' <EOL> self . password = '<STR_LIT>' <EOL> class CertificateSetting ( WindowsAzureData ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , thumbprint = '<STR_LIT>' , store_name = '<STR_LIT>' , store_location = '<STR_LIT>' ) : <EOL> self . thumbprint = thumbprint <EOL> self . store_name = store_name <EOL> self . store_location = store_location <EOL> class StoredCertificateSettings ( WindowsAzureDataTypedList ) : <EOL> list_type = CertificateSetting <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class SSH ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . public_keys = PublicKeys ( ) <EOL> self . key_pairs = KeyPairs ( ) <EOL> class PublicKey ( WindowsAzureData ) : <EOL> def __init__ ( self , fingerprint = '<STR_LIT>' , path = '<STR_LIT>' ) : <EOL> self . fingerprint = fingerprint <EOL> self . path = path <EOL> class PublicKeys ( WindowsAzureDataTypedList ) : <EOL> list_type = PublicKey <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class AzureKeyPair ( WindowsAzureData ) : <EOL> def __init__ ( self , fingerprint = '<STR_LIT>' , path = '<STR_LIT>' ) : <EOL> self . fingerprint = fingerprint <EOL> self . path = path <EOL> class KeyPairs ( WindowsAzureDataTypedList ) : <EOL> list_type = AzureKeyPair <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class LoadBalancerProbe ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . path = '<STR_LIT>' <EOL> self . port = '<STR_LIT>' <EOL> self . protocol = '<STR_LIT>' <EOL> class ConfigurationSet ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . configuration_set_type = '<STR_LIT>' <EOL> self . role_type = '<STR_LIT>' <EOL> self . input_endpoints = ConfigurationSetInputEndpoints ( ) <EOL> self . subnet_names = ScalarListOf ( str , '<STR_LIT>' ) <EOL> class ConfigurationSets ( WindowsAzureDataTypedList ) : <EOL> list_type = ConfigurationSet <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class ConfigurationSetInputEndpoint ( WindowsAzureData ) : <EOL> def __init__ ( self , <EOL> name = '<STR_LIT>' , <EOL> protocol = '<STR_LIT>' , <EOL> port = '<STR_LIT>' , <EOL> local_port = '<STR_LIT>' , <EOL> load_balanced_endpoint_set_name = '<STR_LIT>' , <EOL> enable_direct_server_return = False ) : <EOL> self . enable_direct_server_return = enable_direct_server_return <EOL> self . load_balanced_endpoint_set_name = load_balanced_endpoint_set_name <EOL> self . local_port = local_port <EOL> self . name = name <EOL> self . port = port <EOL> self . load_balancer_probe = LoadBalancerProbe ( ) <EOL> self . protocol = protocol <EOL> class ConfigurationSetInputEndpoints ( WindowsAzureDataTypedList ) : <EOL> list_type = ConfigurationSetInputEndpoint <EOL> xml_element_name = '<STR_LIT>' <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class Location ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . name = '<STR_LIT>' <EOL> self . display_name = '<STR_LIT>' <EOL> self . available_services = ScalarListOf ( str , '<STR_LIT>' ) <EOL> self . compute_capabilities = ComputeCapability ( ) <EOL> class Locations ( WindowsAzureDataTypedList ) : <EOL> list_type = Location <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class ComputeCapability ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . virtual_machines_role_sizes = ScalarListOf ( str , '<STR_LIT>' ) <EOL> class VirtualMachinesRoleSizes ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . role_size = ScalarListOf ( str , '<STR_LIT>' ) <EOL> class OSImage ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . affinity_group = '<STR_LIT>' <EOL> self . category = '<STR_LIT>' <EOL> self . location = '<STR_LIT>' <EOL> self . logical_size_in_gb = <NUM_LIT:0> <EOL> self . label = '<STR_LIT>' <EOL> self . media_link = '<STR_LIT>' <EOL> self . name = '<STR_LIT>' <EOL> self . os = '<STR_LIT>' <EOL> self . eula = '<STR_LIT>' <EOL> self . description = '<STR_LIT>' <EOL> class Images ( WindowsAzureDataTypedList ) : <EOL> list_type = OSImage <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class VMImage ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . name = '<STR_LIT>' <EOL> self . label = '<STR_LIT>' <EOL> self . category = '<STR_LIT>' <EOL> self . os_disk_configuration = OSDiskConfiguration ( ) <EOL> self . service_name = '<STR_LIT>' <EOL> self . deployment_name = '<STR_LIT>' <EOL> self . role_name = '<STR_LIT>' <EOL> self . location = '<STR_LIT>' <EOL> self . affinity_group = '<STR_LIT>' <EOL> class VMImages ( WindowsAzureDataTypedList ) : <EOL> list_type = VMImage <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class VirtualIP ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . address = '<STR_LIT>' <EOL> self . is_dns_programmed = '<STR_LIT>' <EOL> self . name = '<STR_LIT>' <EOL> class VirtualIPs ( WindowsAzureDataTypedList ) : <EOL> list_type = VirtualIP <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class HostedService ( WindowsAzureData , ReprMixin ) : <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:url>' <EOL> ] <EOL> def __init__ ( self ) : <EOL> self . url = '<STR_LIT>' <EOL> self . service_name = '<STR_LIT>' <EOL> self . hosted_service_properties = HostedServiceProperties ( ) <EOL> self . deployments = Deployments ( ) <EOL> class HostedServices ( WindowsAzureDataTypedList , ReprMixin ) : <EOL> list_type = HostedService <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class HostedServiceProperties ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . description = '<STR_LIT>' <EOL> self . location = '<STR_LIT>' <EOL> self . affinity_group = '<STR_LIT>' <EOL> self . label = _Base64String ( ) <EOL> self . status = '<STR_LIT>' <EOL> self . date_created = '<STR_LIT>' <EOL> self . date_last_modified = '<STR_LIT>' <EOL> self . extended_properties = _DictOf ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:Name>' , <EOL> '<STR_LIT>' <EOL> ) <EOL> class Deployment ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . name = '<STR_LIT>' <EOL> self . deployment_slot = '<STR_LIT>' <EOL> self . private_id = '<STR_LIT>' <EOL> self . status = '<STR_LIT>' <EOL> self . label = _Base64String ( ) <EOL> self . url = '<STR_LIT>' <EOL> self . configuration = _Base64String ( ) <EOL> self . role_instance_list = RoleInstanceList ( ) <EOL> self . upgrade_status = UpgradeStatus ( ) <EOL> self . upgrade_domain_count = '<STR_LIT>' <EOL> self . role_list = RoleList ( ) <EOL> self . sdk_version = '<STR_LIT>' <EOL> self . input_endpoint_list = InputEndpoints ( ) <EOL> self . locked = False <EOL> self . rollback_allowed = False <EOL> self . persistent_vm_downtime_info = PersistentVMDowntimeInfo ( ) <EOL> self . created_time = '<STR_LIT>' <EOL> self . last_modified_time = '<STR_LIT>' <EOL> self . extended_properties = _DictOf ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:Name>' , <EOL> '<STR_LIT>' <EOL> ) <EOL> self . virtual_ips = VirtualIPs ( ) <EOL> class Deployments ( WindowsAzureDataTypedList ) : <EOL> list_type = Deployment <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class UpgradeStatus ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . upgrade_type = '<STR_LIT>' <EOL> self . current_upgrade_domain_state = '<STR_LIT>' <EOL> self . current_upgrade_domain = '<STR_LIT>' <EOL> class RoleInstance ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . role_name = '<STR_LIT>' <EOL> self . instance_name = '<STR_LIT>' <EOL> self . instance_status = '<STR_LIT>' <EOL> self . instance_upgrade_domain = <NUM_LIT:0> <EOL> self . instance_fault_domain = <NUM_LIT:0> <EOL> self . instance_size = '<STR_LIT>' <EOL> self . instance_state_details = '<STR_LIT>' <EOL> self . instance_error_code = '<STR_LIT>' <EOL> self . ip_address = '<STR_LIT>' <EOL> self . instance_endpoints = InstanceEndpoints ( ) <EOL> self . power_state = '<STR_LIT>' <EOL> self . fqdn = '<STR_LIT>' <EOL> self . host_name = '<STR_LIT>' <EOL> class RoleInstanceList ( WindowsAzureDataTypedList ) : <EOL> list_type = RoleInstance <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class InstanceEndpoint ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . name = '<STR_LIT>' <EOL> self . vip = '<STR_LIT>' <EOL> self . public_port = '<STR_LIT>' <EOL> self . local_port = '<STR_LIT>' <EOL> self . protocol = '<STR_LIT>' <EOL> class InstanceEndpoints ( WindowsAzureDataTypedList ) : <EOL> list_type = InstanceEndpoint <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class InputEndpoint ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . role_name = '<STR_LIT>' <EOL> self . vip = '<STR_LIT>' <EOL> self . port = '<STR_LIT>' <EOL> class InputEndpoints ( WindowsAzureDataTypedList ) : <EOL> list_type = InputEndpoint <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class Role ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . role_name = '<STR_LIT>' <EOL> self . os_version = '<STR_LIT>' <EOL> class RoleList ( WindowsAzureDataTypedList ) : <EOL> list_type = Role <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class PersistentVMDowntimeInfo ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . start_time = '<STR_LIT>' <EOL> self . end_time = '<STR_LIT>' <EOL> self . status = '<STR_LIT>' <EOL> class AsynchronousOperationResult ( WindowsAzureData ) : <EOL> def __init__ ( self , request_id = None ) : <EOL> self . request_id = request_id <EOL> class Disk ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . affinity_group = '<STR_LIT>' <EOL> self . attached_to = AttachedTo ( ) <EOL> self . has_operating_system = '<STR_LIT>' <EOL> self . is_corrupted = '<STR_LIT>' <EOL> self . location = '<STR_LIT>' <EOL> self . logical_disk_size_in_gb = <NUM_LIT:0> <EOL> self . label = '<STR_LIT>' <EOL> self . media_link = '<STR_LIT>' <EOL> self . name = '<STR_LIT>' <EOL> self . os = '<STR_LIT>' <EOL> self . source_image_name = '<STR_LIT>' <EOL> class Disks ( WindowsAzureDataTypedList ) : <EOL> list_type = Disk <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class AttachedTo ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . hosted_service_name = '<STR_LIT>' <EOL> self . deployment_name = '<STR_LIT>' <EOL> self . role_name = '<STR_LIT>' <EOL> class OperationError ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . code = '<STR_LIT>' <EOL> self . message = '<STR_LIT>' <EOL> class Operation ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . id = '<STR_LIT>' <EOL> self . status = '<STR_LIT>' <EOL> self . http_status_code = '<STR_LIT>' <EOL> self . error = OperationError ( ) <EOL> class OperatingSystem ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . version = '<STR_LIT>' <EOL> self . label = _Base64String ( ) <EOL> self . is_default = True <EOL> self . is_active = True <EOL> self . family = <NUM_LIT:0> <EOL> self . family_label = _Base64String ( ) <EOL> class OSDiskConfiguration ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . name = '<STR_LIT>' <EOL> self . host_caching = '<STR_LIT>' <EOL> self . os_state = '<STR_LIT>' <EOL> self . os = '<STR_LIT>' <EOL> self . media_link = '<STR_LIT>' <EOL> self . logical_disk_size_in_gb = <NUM_LIT:0> <EOL> class OperatingSystems ( WindowsAzureDataTypedList ) : <EOL> list_type = OperatingSystem <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class OperatingSystemFamily ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . name = '<STR_LIT>' <EOL> self . label = _Base64String ( ) <EOL> self . operating_systems = OperatingSystems ( ) <EOL> class OperatingSystemFamilies ( WindowsAzureDataTypedList ) : <EOL> list_type = OperatingSystemFamily <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class Subscription ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . subscription_id = '<STR_LIT>' <EOL> self . subscription_name = '<STR_LIT>' <EOL> self . subscription_status = '<STR_LIT>' <EOL> self . account_admin_live_email_id = '<STR_LIT>' <EOL> self . service_admin_live_email_id = '<STR_LIT>' <EOL> self . max_core_count = <NUM_LIT:0> <EOL> self . max_storage_accounts = <NUM_LIT:0> <EOL> self . max_hosted_services = <NUM_LIT:0> <EOL> self . current_core_count = <NUM_LIT:0> <EOL> self . current_hosted_services = <NUM_LIT:0> <EOL> self . current_storage_accounts = <NUM_LIT:0> <EOL> self . max_virtual_network_sites = <NUM_LIT:0> <EOL> self . max_local_network_sites = <NUM_LIT:0> <EOL> self . max_dns_servers = <NUM_LIT:0> <EOL> class AvailabilityResponse ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . result = False <EOL> class SubscriptionCertificate ( WindowsAzureData ) : <EOL> def __init__ ( self ) : <EOL> self . subscription_certificate_public_key = '<STR_LIT>' <EOL> self . subscription_certificate_thumbprint = '<STR_LIT>' <EOL> self . subscription_certificate_data = '<STR_LIT>' <EOL> self . created = '<STR_LIT>' <EOL> class SubscriptionCertificates ( WindowsAzureDataTypedList ) : <EOL> list_type = SubscriptionCertificate <EOL> _repr_attributes = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class AzureHTTPRequest ( object ) : <EOL> def __init__ ( self ) : <EOL> self . host = '<STR_LIT>' <EOL> self . method = '<STR_LIT>' <EOL> self . path = '<STR_LIT>' <EOL> self . query = [ ] <EOL> self . headers = { } <EOL> self . body = '<STR_LIT>' <EOL> self . protocol_override = None <EOL> class AzureHTTPResponse ( object ) : <EOL> def __init__ ( self , status , message , headers , body ) : <EOL> self . status = status <EOL> self . message = message <EOL> self . headers = headers <EOL> self . body = body <EOL> """<STR_LIT>""" <EOL> class _Base64String ( str ) : <EOL> pass <EOL> class _ListOf ( list ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , list_type , xml_element_name = None ) : <EOL> self . list_type = list_type <EOL> if xml_element_name is None : <EOL> self . xml_element_name = list_type . __name__ <EOL> else : <EOL> self . xml_element_name = xml_element_name <EOL> super ( _ListOf , self ) . __init__ ( ) <EOL> class ScalarListOf ( list ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , list_type , xml_element_name ) : <EOL> self . list_type = list_type <EOL> self . xml_element_name = xml_element_name <EOL> super ( ScalarListOf , self ) . __init__ ( ) <EOL> class _DictOf ( dict ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , <EOL> pair_xml_element_name , <EOL> key_xml_element_name , <EOL> value_xml_element_name ) : <EOL> self . pair_xml_element_name = pair_xml_element_name <EOL> self . key_xml_element_name = key_xml_element_name <EOL> self . value_xml_element_name = value_xml_element_name <EOL> super ( _DictOf , self ) . __init__ ( ) <EOL> class AzureNodeLocation ( NodeLocation ) : <EOL> def __init__ ( self , id , name , country , driver , available_services , <EOL> virtual_machine_role_sizes ) : <EOL> super ( AzureNodeLocation , self ) . __init__ ( id , name , country , driver ) <EOL> self . available_services = available_services <EOL> self . virtual_machine_role_sizes = virtual_machine_role_sizes <EOL> def __repr__ ( self ) : <EOL> return ( <EOL> ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) % ( <EOL> self . id , <EOL> self . name , <EOL> self . country , <EOL> self . driver . name , <EOL> '<STR_LIT:U+002C>' . join ( self . available_services ) , <EOL> '<STR_LIT:U+002C>' . join ( self . virtual_machine_role_sizes ) <EOL> ) <EOL> ) </s>
