Exemple #1
0
 public VimObjectRefType GetVMVimRef()
 {
     try
     {
         if (this.Resource != null && this.Resource.VCloudExtension != null)
         {
             foreach (VCloudExtensionType vcloudExtensionType in this.Resource.VCloudExtension)
             {
                 if (vcloudExtensionType.Any != null)
                 {
                     foreach (XmlNode xmlNode in vcloudExtensionType.Any)
                     {
                         VmVimInfoType resource = Response.GetResource <VmVimInfoType>(xmlNode.OuterXml);
                         if (resource.VmVimObjectRef.VimObjectType.Equals(VimObjectTypeEnum.VIRTUAL_MACHINE.Value()))
                         {
                             return(resource.VmVimObjectRef);
                         }
                     }
                 }
             }
         }
         throw new VCloudException(SdkUtil.GetI18nString(SdkMessage.VIM_OBJECT_REF_NOT_FOUND_MSG));
     }
     catch (Exception ex)
     {
         throw new VCloudException(ex.Message);
     }
 }
Exemple #2
0
 private void SortOvfSectionAndReferences_v1_5()
 {
     if (this.Resource.Items != null)
     {
         foreach (Section_Type sectionType in this.Resource.Items)
         {
             if (sectionType is NetworkConfigSectionType)
             {
                 this._networkConfigSection = (NetworkConfigSectionType)sectionType;
             }
             else if (sectionType is NetworkSection_Type)
             {
                 this._networkSection = (NetworkSection_Type)sectionType;
             }
             else if (sectionType is NetworkConnectionSectionType)
             {
                 this._networkConnectionSection = (NetworkConnectionSectionType)sectionType;
             }
             else if (sectionType is LeaseSettingsSectionType)
             {
                 this._leaseSettingsSection = (LeaseSettingsSectionType)sectionType;
             }
             else if (sectionType is CustomizationSectionType)
             {
                 this._customizationSection = (CustomizationSectionType)sectionType;
             }
             else if (sectionType is GuestCustomizationSectionType)
             {
                 this._guestCustomizationSection = (GuestCustomizationSectionType)sectionType;
             }
             else if (sectionType is ProductSection_Type)
             {
                 this._productSections.Add((ProductSection_Type)sectionType);
             }
             Logger.Log(TraceLevel.Information, sectionType.GetType().Name);
         }
     }
     if (this.Resource.Link != null)
     {
         foreach (LinkType linkType in this.Resource.Link)
         {
             if (this._parentVappTemplateReference == null || this._catalogItemReference == null || this._vdcReference == null)
             {
                 if (linkType.rel.Equals("up") && linkType.type.Equals("application/vnd.vmware.vcloud.vAppTemplate+xml"))
                 {
                     this._parentVappTemplateReference = (ReferenceType)linkType;
                 }
                 else if (linkType.rel.Equals("catalogItem") && linkType.type.Equals("application/vnd.vmware.vcloud.catalogItem+xml"))
                 {
                     this._catalogItemReference = (ReferenceType)linkType;
                 }
                 else if (linkType.rel.Equals("up") && linkType.type.Equals("application/vnd.vmware.vcloud.vdc+xml"))
                 {
                     this._vdcReference = (ReferenceType)linkType;
                 }
                 else if (linkType.rel.Equals("storageProfile") && linkType.type.Equals("application/vnd.vmware.vcloud.vdcStorageProfile+xml"))
                 {
                     this._storageProfileRef = (ReferenceType)linkType;
                 }
             }
             else
             {
                 break;
             }
         }
     }
     if (this.Resource == null || this.Resource.VCloudExtension == null)
     {
         return;
     }
     foreach (VCloudExtensionType vcloudExtensionType in this.Resource.VCloudExtension)
     {
         if (vcloudExtensionType.Any != null)
         {
             XmlElement[] any   = vcloudExtensionType.Any;
             int          index = 0;
             if (index < any.Length)
             {
                 this.vmVimInfoType = Response.GetResource <VmVimInfoType>(any[index].OuterXml);
             }
         }
     }
 }