56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/azure/cloud_service_management/serialization.rb', line 56
def self.cloud_services_from_xml(cloud_xml)
clouds = []
cloud_services_xml = cloud_xml.css('HostedServices HostedService')
cloud_services_xml = cloud_xml.css('HostedService') if \
cloud_services_xml.length == 0
cloud_services_xml.each do |cloud_service_xml|
cloud = CloudService.new
cloud.url = xml_content(cloud_service_xml, 'Url')
cloud.name = xml_content(cloud_service_xml, 'ServiceName')
props_xml = cloud_service_xml.css('HostedServiceProperties')
cloud.label = Base64.decode64(xml_content(props_xml, 'Label'))
cloud.description = xml_content(props_xml, 'Description')
location = xml_content(props_xml, 'Location')
cloud.location = location unless location.empty?
affinity_group = xml_content(props_xml, 'AffinityGroup')
cloud.affinity_group = affinity_group unless affinity_group
cloud.status = xml_content(props_xml, 'Status')
cloud.date_created = xml_content(props_xml, 'DateCreated')
cloud.date_modified = xml_content(props_xml, 'DateLastModified')
cloud.extended_properties = {}
props_xml.css('ExtendedProperties ExtendedProperty').map do |prop|
p_name = xml_content(prop, 'Name')
p_value = xml_content(prop, 'Value')
cloud.extended_properties[p_name] = p_value
end
cloud.default_winrm_certificate_thumbprint = xml_content(
cloud_service_xml, 'DefaultWinRMCertificateThumbprint'
)
deployment_xml = cloud_services_xml.css('Deployments Deployment')
cloud.deployment_name = xml_content(deployment_xml, 'Name')
vms_in_deployment = {}
cloud_service_xml.css('Deployments').each do |deployxml|
deployment_name = xml_content(deployxml, 'Deployment Name')
vms = Azure::VirtualMachineManagement::Serialization.virtual_machines_from_xml(
deployxml, cloud.name
)
vms_in_deployment[deployment_name.to_sym] = vms if vms
end
cloud.virtual_machines = vms_in_deployment
clouds << cloud
end
clouds.compact
end
|