lib/azure/cloud_service_management/serialization.rb in azure-0.6.2 vs lib/azure/cloud_service_management/serialization.rb in azure-0.6.3

- old
+ new

@@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. #-------------------------------------------------------------------------- require 'base64' require 'azure/cloud_service_management/cloud_service' +require 'azure/virtual_machine_management/serialization' module Azure module CloudServiceManagement module Serialization def self.cloud_services_to_xml(name, options = {}) @@ -52,10 +53,12 @@ end 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') @@ -78,9 +81,21 @@ cloud.default_winrm_certificate_thumbprint = xml_content( cloud_service_xml, 'DefaultWinRMCertificateThumbprint' ) + 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 + end + + cloud.virtual_machines = vms_in_deployment clouds << cloud end clouds.compact end