public VimObjectRefType GetResourcePoolVimRef() { try { if (this.Resource.VCloudExtension != null) { foreach (VCloudExtensionType vcloudExtensionType in this.Resource.VCloudExtension) { if (vcloudExtensionType.Any != null) { foreach (XmlNode xmlNode in vcloudExtensionType.Any) { VimObjectRefType resource = Response.GetResource <VimObjectRefType>(xmlNode.OuterXml); if (resource.VimObjectType.Equals(VimObjectTypeEnum.RESOURCE_POOL.Value())) { return(resource); } } } } } throw new VCloudException(SdkUtil.GetI18nString(SdkMessage.VIM_OBJECT_REF_NOT_FOUND_MSG)); } catch (Exception ex) { throw new VCloudException(ex.Message); } }
public Task MigrateVms( string sourceResourcePoolMoref, List <ReferenceType> vmRefs, VimObjectRefType resourcePoolVimRef) { string requestString = SerializationUtil.SerializeObject <MigrateParamsType>(new MigrateParamsType() { ResourcePoolRef = resourcePoolVimRef, VmRef = vmRefs.ToArray() }, "com.vmware.vcloud.api.rest.schema"); if (!this.GetResourcePoolsByMoref().ContainsKey(sourceResourcePoolMoref)) { throw new VCloudException(SdkUtil.GetI18nString(SdkMessage.VIM_OBJECT_REF_NOT_FOUND_MSG) + " " + sourceResourcePoolMoref); } return(new Task(this.VcloudClient, SdkUtil.Post <TaskType>(this.VcloudClient, this.GetResourcePoolsByMoref()[sourceResourcePoolMoref].ResourcePoolRef.href + "/action/migrateVms", requestString, "application/vnd.vmware.admin.migrateVmParams+xml", 202))); }
private void SortEntityAndNetworkRefs_v1_5() { this._vappTemplateRefs = new List <ReferenceType>(); this._mediaRefs = new List <ReferenceType>(); this._vappRefsByName = new Dictionary <string, ReferenceType>(); this._orgNetworkRefsByName = new Dictionary <string, ReferenceType>(); this._storageProfileRefs = new List <ReferenceType>(); this._diskRefs = new List <ReferenceType>(); if (this.Resource.ResourceEntities != null) { ResourceEntitiesType resourceEntities = this.Resource.ResourceEntities; List <ResourceReferenceType> resourceReferenceTypeList = new List <ResourceReferenceType>(); if (resourceEntities.ResourceEntity != null) { resourceReferenceTypeList = ((IEnumerable <ResourceReferenceType>)resourceEntities.ResourceEntity).ToList <ResourceReferenceType>(); } if (resourceReferenceTypeList != null) { foreach (ResourceReferenceType resourceReferenceType in resourceReferenceTypeList) { if (resourceReferenceType.type.Equals("application/vnd.vmware.vcloud.vAppTemplate+xml")) { this._vappTemplateRefs.Add((ReferenceType)resourceReferenceType); } else if (resourceReferenceType.type.Equals("application/vnd.vmware.vcloud.media+xml")) { this._mediaRefs.Add((ReferenceType)resourceReferenceType); } else if (resourceReferenceType.type.Equals("application/vnd.vmware.vcloud.vApp+xml")) { this._vappRefsByName.Add(resourceReferenceType.name, (ReferenceType)resourceReferenceType); } else if (resourceReferenceType.type.Equals("application/vnd.vmware.vcloud.disk+xml")) { this._diskRefs.Add((ReferenceType)resourceReferenceType); } else { Logger.Log(TraceLevel.Warning, SdkUtil.GetI18nString(SdkMessage.UNKNOWN_REF_TYPE_MSG), resourceReferenceType.type); } } } } if (this.Resource.AvailableNetworks != null) { AvailableNetworksType availableNetworks = this.Resource.AvailableNetworks; if (availableNetworks != null && availableNetworks.Network != null) { foreach (ReferenceType referenceType in availableNetworks.Network) { if (!this._orgNetworkRefsByName.ContainsKey(referenceType.name)) { this._orgNetworkRefsByName.Add(referenceType.name, referenceType); } } } } if (this.Resource.Link != null) { foreach (LinkType linkType in this.Resource.Link) { if (linkType.rel.Equals("up") && linkType.type.Equals("application/vnd.vmware.admin.organization+xml")) { this._adminOrgReference = (ReferenceType)linkType; } if (linkType.rel.Equals("alternate") && linkType.type.Equals("application/vnd.vmware.vcloud.vdc+xml")) { this._vdcReference = (ReferenceType)linkType; } if (linkType.rel.Equals("down") && linkType.type.Equals("application/vnd.vmware.admin.OrganizationVdcResourcePoolSet+xml")) { this._orgVdcResourcePoolsRef = (ReferenceType)linkType; } } } if (this.Resource.VCloudExtension != null) { foreach (VCloudExtensionType vcloudExtensionType in this.Resource.VCloudExtension) { foreach (XmlNode xmlNode in vcloudExtensionType.Any) { VimObjectRefType resource = Response.GetResource <VimObjectRefType>(xmlNode.OuterXml); if (resource.VimObjectType.Equals(VimObjectTypeEnum.RESOURCE_POOL.Value())) { this._primaryResourcePoolVimRef = resource; } } } } if (this.Resource.VdcStorageProfiles == null || this.Resource.VdcStorageProfiles.VdcStorageProfile == null) { return; } foreach (ReferenceType referenceType in this.Resource.VdcStorageProfiles.VdcStorageProfile) { this._storageProfileRefs.Add(referenceType); } }