Search in sources :

Example 1 with DISK_FULL_PATH

use of com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.DISK_FULL_PATH in project photon-model by vmware.

the class ClientUtils method attachDiskToVM.

public static String attachDiskToVM(ArrayOfVirtualDevice devices, ManagedObjectReference vm, DiskService.DiskStateExpanded diskState, ManagedObjectReference diskDatastore, Connection connection, VimPortType vimPort) throws Exception {
    String diskPath = VimUtils.uriToDatastorePath(diskState.sourceImageReference);
    String diskFullPath = CustomProperties.of(diskState).getString(DISK_FULL_PATH, null);
    Boolean insertCdRom = CustomProperties.of(diskState).getBoolean(INSERT_CDROM, false);
    VirtualDeviceConfigSpec deviceConfigSpec = null;
    if (diskState.type == DiskService.DiskType.HDD) {
        VirtualSCSIController scsiController = getFirstScsiController(devices);
        // Get available free unit numbers for the given scsi controller.
        Integer[] scsiUnits = findFreeScsiUnit(scsiController, devices.getVirtualDevice());
        List<VirtualMachineDefinedProfileSpec> pbmSpec = getPbmProfileSpec(diskState);
        deviceConfigSpec = createHdd(scsiController.getKey(), scsiUnits[0], diskState, diskFullPath, diskDatastore, pbmSpec, false);
    } else if (diskState.type == DiskService.DiskType.CDROM) {
        if (insertCdRom) {
            if (diskPath == null) {
                throw new IllegalStateException(String.format("Cannot insert empty iso file into CD-ROM"));
            }
            // Find first available CD ROM to insert the iso file
            VirtualCdrom cdrom = devices.getVirtualDevice().stream().filter(d -> d instanceof VirtualCdrom).map(d -> (VirtualCdrom) d).findFirst().orElse(null);
            if (cdrom == null) {
                throw new IllegalStateException(String.format("Could not find Virtual CD ROM to insert %s.", diskPath));
            }
            insertCdrom(cdrom, diskPath);
            deviceConfigSpec = new VirtualDeviceConfigSpec();
            deviceConfigSpec.setDevice(cdrom);
            deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT);
        } else {
            VirtualDevice ideController = getFirstIdeController(devices);
            int ideUnit = findFreeUnit(ideController, devices.getVirtualDevice());
            int availableUnitNumber = nextUnitNumber(ideUnit);
            deviceConfigSpec = createCdrom(ideController, availableUnitNumber);
            fillInControllerUnitNumber(diskState, availableUnitNumber);
            if (diskPath != null) {
                // mount iso image
                insertCdrom((VirtualCdrom) deviceConfigSpec.getDevice(), diskPath);
            }
            // Live add of cd-rom is not possible. Hence it needs to be powered off
            // Power off is needed to ADD cd-rom
            powerOffVm(connection, vimPort, vm);
        }
    } else if (diskState.type == DiskService.DiskType.FLOPPY) {
        VirtualDevice sioController = getFirstSioController(devices);
        int sioUnit = findFreeUnit(sioController, devices.getVirtualDevice());
        int availableUnitNumber = nextUnitNumber(sioUnit);
        deviceConfigSpec = createFloppy(sioController, availableUnitNumber);
        fillInControllerUnitNumber(diskState, availableUnitNumber);
        if (diskPath != null) {
            insertFloppy((VirtualFloppy) deviceConfigSpec.getDevice(), diskPath);
        }
        // Power off is needed to ADD floppy
        powerOffVm(connection, vimPort, vm);
    }
    VirtualMachineConfigSpec spec = new VirtualMachineConfigSpec();
    spec.getDeviceChange().add(deviceConfigSpec);
    ManagedObjectReference reconfigureTask = vimPort.reconfigVMTask(vm, spec);
    TaskInfo info = VimUtils.waitTaskEnd(connection, reconfigureTask);
    if (info.getState() == TaskInfoState.ERROR) {
        VimUtils.rethrow(info.getError());
    }
    if (!insertCdRom && diskState.type != DiskService.DiskType.HDD) {
        // This means it is CDROM or Floppy. Hence power on the VM as it is powered off to
        // perform the operation
        powerOnVM(connection, vimPort, vm);
    }
    return diskFullPath;
}
Also used : PbmPlacementHub(com.vmware.pbm.PbmPlacementHub) SSLContext(javax.net.ssl.SSLContext) VirtualMachineConfigSpec(com.vmware.vim25.VirtualMachineConfigSpec) InvalidDatastoreFaultMsg(com.vmware.vim25.InvalidDatastoreFaultMsg) ArrayOfVirtualDevice(com.vmware.vim25.ArrayOfVirtualDevice) StringUtils(org.apache.commons.lang3.StringUtils) FileNotFoundFaultMsg(com.vmware.vim25.FileNotFoundFaultMsg) VirtualDeviceConnectInfo(com.vmware.vim25.VirtualDeviceConnectInfo) Utils(com.vmware.xenon.common.Utils) Map(java.util.Map) PbmProfileId(com.vmware.pbm.PbmProfileId) VirtualDeviceConfigSpecFileOperation(com.vmware.vim25.VirtualDeviceConfigSpecFileOperation) VimPortType(com.vmware.vim25.VimPortType) ServiceDocumentQueryResult(com.vmware.xenon.common.ServiceDocumentQueryResult) VirtualDevice(com.vmware.vim25.VirtualDevice) EnumSet(java.util.EnumSet) FinderException(com.vmware.photon.controller.model.adapters.vsphere.util.finders.FinderException) VirtualDiskFlatVer1BackingInfo(com.vmware.vim25.VirtualDiskFlatVer1BackingInfo) LIMIT_IOPS(com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.LIMIT_IOPS) GregorianCalendar(java.util.GregorianCalendar) KeyManagementException(java.security.KeyManagementException) ServiceClient(com.vmware.xenon.common.ServiceClient) Executors(java.util.concurrent.Executors) NettyHttpServiceClient(com.vmware.xenon.common.http.netty.NettyHttpServiceClient) PERSISTENT(com.vmware.vim25.VirtualDiskMode.PERSISTENT) StorageDescriptionService(com.vmware.photon.controller.model.resources.StorageDescriptionService) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UriUtils(com.vmware.xenon.common.UriUtils) VirtualFloppy(com.vmware.vim25.VirtualFloppy) Finder(com.vmware.photon.controller.model.adapters.vsphere.util.finders.Finder) INSERT_CDROM(com.vmware.photon.controller.model.constants.PhotonModelConstants.INSERT_CDROM) RuntimeFaultFaultMsg(com.vmware.vim25.RuntimeFaultFaultMsg) VirtualCdromAtapiBackingInfo(com.vmware.vim25.VirtualCdromAtapiBackingInfo) ArrayList(java.util.ArrayList) VirtualCdrom(com.vmware.vim25.VirtualCdrom) DISK_FULL_PATH(com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.DISK_FULL_PATH) Calendar(java.util.Calendar) DEVICE_STATUS(com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.DEVICE_STATUS) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) FileFaultFaultMsg(com.vmware.vim25.FileFaultFaultMsg) AdapterUtils(com.vmware.photon.controller.model.adapters.util.AdapterUtils) VirtualDeviceConfigSpec(com.vmware.vim25.VirtualDeviceConfigSpec) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) VirtualDeviceBackingInfo(com.vmware.vim25.VirtualDeviceBackingInfo) PROVIDER_DISK_UNIQUE_ID(com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.PROVIDER_DISK_UNIQUE_ID) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) VirtualDisk(com.vmware.vim25.VirtualDisk) Paths(java.nio.file.Paths) SHARES_LEVEL(com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.SHARES_LEVEL) X509TrustManager(javax.net.ssl.X509TrustManager) StorageIOAllocationInfo(com.vmware.vim25.StorageIOAllocationInfo) VirtualDiskType(com.vmware.vim25.VirtualDiskType) Service(com.vmware.xenon.common.Service) SHARES(com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.SHARES) URISyntaxException(java.net.URISyntaxException) QueryTask(com.vmware.xenon.services.common.QueryTask) LoggerFactory(org.slf4j.LoggerFactory) TrustManager(javax.net.ssl.TrustManager) DiskType(com.vmware.photon.controller.model.resources.DiskService.DiskType) VirtualDeviceFileBackingInfo(com.vmware.vim25.VirtualDeviceFileBackingInfo) Connection(com.vmware.photon.controller.model.adapters.vsphere.util.connection.Connection) URI(java.net.URI) TaskInfo(com.vmware.vim25.TaskInfo) VirtualDiskFlatVer2BackingInfo(com.vmware.vim25.VirtualDiskFlatVer2BackingInfo) SharesInfo(com.vmware.vim25.SharesInfo) VirtualCdromIsoBackingInfo(com.vmware.vim25.VirtualCdromIsoBackingInfo) DiskStateExpanded(com.vmware.photon.controller.model.resources.DiskService.DiskStateExpanded) Collectors(java.util.stream.Collectors) ServiceHost(com.vmware.xenon.common.ServiceHost) Objects(java.util.Objects) List(java.util.List) InvalidPropertyFaultMsg(com.vmware.vim25.InvalidPropertyFaultMsg) PROVISION_TYPE(com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.PROVISION_TYPE) DiskService(com.vmware.photon.controller.model.resources.DiskService) DISK_MODE_INDEPENDENT(com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.DISK_MODE_INDEPENDENT) PhotonModelUriUtils(com.vmware.photon.controller.model.util.PhotonModelUriUtils) HashMap(java.util.HashMap) DISK_MODE_PERSISTENT(com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.DISK_MODE_PERSISTENT) Level(java.util.logging.Level) DEVICE_CONNECTED(com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.DEVICE_CONNECTED) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) InvalidDatastorePathFaultMsg(com.vmware.vim25.InvalidDatastorePathFaultMsg) SharesLevel(com.vmware.vim25.SharesLevel) Logger(org.slf4j.Logger) Element(com.vmware.photon.controller.model.adapters.vsphere.util.finders.Element) VirtualIDEController(com.vmware.vim25.VirtualIDEController) VirtualFloppyDeviceBackingInfo(com.vmware.vim25.VirtualFloppyDeviceBackingInfo) Operation(com.vmware.xenon.common.Operation) PbmFaultFaultMsg(com.vmware.pbm.PbmFaultFaultMsg) DISK_CONTROLLER_NUMBER(com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.DISK_CONTROLLER_NUMBER) VirtualSCSIController(com.vmware.vim25.VirtualSCSIController) VirtualDiskMode(com.vmware.vim25.VirtualDiskMode) VimNames(com.vmware.photon.controller.model.adapters.vsphere.util.VimNames) Consumer(java.util.function.Consumer) VirtualDeviceConfigSpecOperation(com.vmware.vim25.VirtualDeviceConfigSpecOperation) VirtualFloppyImageBackingInfo(com.vmware.vim25.VirtualFloppyImageBackingInfo) VirtualMachineDefinedProfileSpec(com.vmware.vim25.VirtualMachineDefinedProfileSpec) VirtualSIOController(com.vmware.vim25.VirtualSIOController) VIRTUAL_MACHINE_LINK(com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.VIRTUAL_MACHINE_LINK) TaskInfoState(com.vmware.vim25.TaskInfoState) VirtualDeviceConfigSpec(com.vmware.vim25.VirtualDeviceConfigSpec) VirtualSCSIController(com.vmware.vim25.VirtualSCSIController) VirtualCdrom(com.vmware.vim25.VirtualCdrom) ArrayOfVirtualDevice(com.vmware.vim25.ArrayOfVirtualDevice) VirtualDevice(com.vmware.vim25.VirtualDevice) VirtualMachineDefinedProfileSpec(com.vmware.vim25.VirtualMachineDefinedProfileSpec) TaskInfo(com.vmware.vim25.TaskInfo) VirtualMachineConfigSpec(com.vmware.vim25.VirtualMachineConfigSpec) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference)

Example 2 with DISK_FULL_PATH

use of com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.DISK_FULL_PATH in project photon-model by vmware.

the class VSphereVMDiskContext method populateVMDiskContextThen.

/**
 * Populates the given initial context and invoke the onSuccess handler when built. At every
 * step, if failure occurs the VSphereVMDiskContext's errorHandler is invoked to cleanup.
 */
protected static void populateVMDiskContextThen(Service service, VSphereVMDiskContext ctx, Consumer<VSphereVMDiskContext> onSuccess) {
    if (ctx.computeDesc == null) {
        URI computeUri = createInventoryUri(service.getHost(), UriUtils.extendUriWithQuery(ctx.request.resourceReference, UriUtils.URI_PARAM_ODATA_EXPAND, Boolean.TRUE.toString()));
        AdapterUtils.getServiceState(service, computeUri, op -> {
            ctx.computeDesc = op.getBody(ComputeStateWithDescription.class);
            if (CustomProperties.of(ctx.computeDesc).getString(CustomProperties.MOREF, null) == null) {
                ctx.fail(new IllegalStateException(String.format("VM Moref is not defined in resource %s", ctx.computeDesc.documentSelfLink)));
                return;
            }
            populateVMDiskContextThen(service, ctx, onSuccess);
        }, ctx.errorHandler);
        return;
    }
    if (ctx.diskState == null) {
        URI diskUri = createInventoryUri(service.getHost(), DiskService.DiskStateExpanded.buildUri(UriUtils.buildUri(service.getHost(), ctx.request.payload.get(DISK_LINK))));
        AdapterUtils.getServiceState(service, diskUri, op -> {
            ctx.diskState = op.getBody(DiskService.DiskStateExpanded.class);
            // the VM. So CD_ROM can be in any status.
            if (!ctx.request.isMockRequest) {
                if (ctx.request.operation.equals(ResourceOperation.ATTACH_DISK.operation)) {
                    EnumSet<DiskService.DiskType> notSupportedTypes = EnumSet.of(DiskService.DiskType.SSD, DiskService.DiskType.NETWORK);
                    if (notSupportedTypes.contains(ctx.diskState.type)) {
                        ctx.fail(new IllegalStateException(String.format("Not supported disk type %s.", ctx.diskState.type)));
                        return;
                    }
                    if (ctx.diskState.type == DiskService.DiskType.HDD) {
                        if (ctx.diskState.status != DiskService.DiskStatus.AVAILABLE) {
                            ctx.fail(new IllegalStateException(String.format("Disk %s is not in AVAILABLE status to attach to VM.", ctx.diskState.documentSelfLink)));
                            return;
                        } else if (CustomProperties.of(ctx.diskState).getString(DISK_FULL_PATH, null) == null || CustomProperties.of(ctx.diskState).getString(DISK_DATASTORE_NAME, null) == null) {
                            ctx.fail(new IllegalStateException(String.format("Disk %s is missing path details to attach to VM.", ctx.diskState.documentSelfLink)));
                            return;
                        }
                    }
                } else {
                    // Allowing only HDD based disk to be detached
                    if (ctx.diskState.type != DiskService.DiskType.HDD) {
                        ctx.fail(new IllegalStateException(String.format("Not supported disk type %s for detach.", ctx.diskState.type)));
                        return;
                    }
                    if (ctx.diskState.status != DiskService.DiskStatus.ATTACHED) {
                        ctx.fail(new IllegalStateException(String.format("Disk %s is not in ATTACHED status to detach from VM.", ctx.diskState.documentSelfLink)));
                        return;
                    }
                }
            }
            // fetch the content from the content service
            if (ctx.diskState.type == DiskService.DiskType.CDROM) {
                String contentUriStr = CustomProperties.of(ctx.diskState).getString(DISK_CONTENT_LINK, null);
                if (contentUriStr != null) {
                    ctx.contentLink = contentUriStr;
                    URI contentUri = PhotonModelUriUtils.createInventoryUri(service.getHost(), UriUtils.buildUri(service.getHost(), contentUriStr));
                    AdapterUtils.getServiceState(service, contentUri, MEDIA_TYPE_APPLICATION_OCTET_STREAM, op2 -> {
                        ctx.contentToUpload = op2.getBody(byte[].class);
                        populateVMDiskContextThen(service, ctx, onSuccess);
                    }, ctx.errorHandler);
                } else {
                    populateVMDiskContextThen(service, ctx, onSuccess);
                }
            } else {
                populateVMDiskContextThen(service, ctx, onSuccess);
            }
        }, ctx.errorHandler);
        return;
    }
    // If it is CD-ROM attach then collect all the disk links objects if insertCDRom is true
    if (ctx.computeDiskStates == null) {
        Boolean insertCdRom = CustomProperties.of(ctx.diskState).getBoolean(INSERT_CDROM, false);
        if (ctx.diskState.type == DiskService.DiskType.CDROM && insertCdRom && ctx.computeDesc.diskLinks != null && !ctx.computeDesc.diskLinks.isEmpty()) {
            ctx.computeDiskStates = new ArrayList<>(ctx.computeDesc.diskLinks.size());
            // collect disks in parallel
            Stream<Operation> opsGetDisk = ctx.computeDesc.diskLinks.stream().map(link -> {
                URI diskStateUri = createInventoryUri(service.getHost(), link);
                return Operation.createGet(createInventoryUri(service.getHost(), DiskService.DiskStateExpanded.buildUri(diskStateUri)));
            });
            OperationJoin join = OperationJoin.create(opsGetDisk).setCompletion((os, errors) -> {
                if (errors != null && !errors.isEmpty()) {
                    // fail on first error
                    ctx.errorHandler.accept(new IllegalStateException("Cannot get disk state", errors.values().iterator().next()));
                    return;
                }
                os.values().forEach(op -> ctx.computeDiskStates.add(op.getBody(DiskService.DiskStateExpanded.class)));
                populateVMDiskContextThen(service, ctx, onSuccess);
            });
            join.sendWith(service);
        } else {
            ctx.computeDiskStates = Collections.emptyList();
            populateVMDiskContextThen(service, ctx, onSuccess);
        }
        return;
    }
    if (ctx.parentComputeDesc == null && ctx.computeDesc.parentLink != null) {
        URI computeUri = createInventoryUri(service.getHost(), UriUtils.extendUriWithQuery(UriUtils.buildUri(service.getHost(), ctx.computeDesc.parentLink), UriUtils.URI_PARAM_ODATA_EXPAND, Boolean.TRUE.toString()));
        AdapterUtils.getServiceState(service, computeUri, op -> {
            ctx.parentComputeDesc = op.getBody(ComputeStateWithDescription.class);
            populateVMDiskContextThen(service, ctx, onSuccess);
        }, ctx.errorHandler);
        return;
    }
    if (ctx.vSphereCredentials == null) {
        if (IAAS_API_ENABLED) {
            if (ctx.operation == null) {
                ctx.fail(new IllegalArgumentException("Caller operation cannot be empty"));
                return;
            }
            SessionUtil.retrieveExternalToken(service, ctx.operation.getAuthorizationContext()).whenComplete((authCredentialsServiceState, throwable) -> {
                if (throwable != null) {
                    ctx.errorHandler.accept(throwable);
                    return;
                }
                ctx.vSphereCredentials = authCredentialsServiceState;
                populateVMDiskContextThen(service, ctx, onSuccess);
            });
        } else {
            if (ctx.parentComputeDesc.description.authCredentialsLink == null) {
                ctx.fail(new IllegalStateException(String.format("authCredentialsLink is not defined in resource %s", ctx.parentComputeDesc.description.documentSelfLink)));
                return;
            }
            URI credUri = createInventoryUri(service.getHost(), ctx.parentComputeDesc.description.authCredentialsLink);
            AdapterUtils.getServiceState(service, credUri, op -> {
                ctx.vSphereCredentials = op.getBody(AuthCredentialsServiceState.class);
                populateVMDiskContextThen(service, ctx, onSuccess);
            }, ctx.errorHandler);
        }
        return;
    }
    if (ctx.datacenterMoRef == null) {
        try {
            String regionId = ctx.diskState.regionId;
            if (regionId == null || regionId.isEmpty()) {
                if (ctx.computeDesc.regionId != null) {
                    regionId = ctx.computeDesc.regionId;
                } else if (ctx.parentComputeDesc.regionId != null) {
                    regionId = ctx.parentComputeDesc.regionId;
                }
            }
            ctx.datacenterMoRef = VimUtils.convertStringToMoRef(regionId);
        } catch (IllegalArgumentException ex) {
            ctx.fail(ex);
            return;
        }
        populateVMDiskContextThen(service, ctx, onSuccess);
        return;
    }
    if (ctx.computePlacementHost == null) {
        String placementLink = CustomProperties.of(ctx.computeDesc).getString(ComputeProperties.COMPUTE_HOST_LINK_PROP_NAME);
        // compute host link will be not null here.
        URI expandedPlacementUri = UriUtils.extendUriWithQuery(PhotonModelUriUtils.createInventoryUri(service.getHost(), placementLink), UriUtils.URI_PARAM_ODATA_EXPAND, Boolean.TRUE.toString());
        expandedPlacementUri = PhotonModelUriUtils.createInventoryUri(service.getHost(), expandedPlacementUri);
        AdapterUtils.getServiceState(service, expandedPlacementUri, op -> {
            ctx.computePlacementHost = op.getBody(ComputeStateWithDescription.class);
            if (ctx.computePlacementHost.groupLinks != null) {
                ctx.computeGroupLinks = ctx.computePlacementHost.groupLinks.stream().filter(link -> link.contains(PREFIX_DATASTORE)).collect(Collectors.toSet());
            }
            populateVMDiskContextThen(service, ctx, onSuccess);
        }, ctx.errorHandler);
        return;
    }
    // populate datastore name
    if (ctx.datastoreName == null) {
        if (ctx.diskState.customProperties != null && ctx.diskState.customProperties.get(DISK_DATASTORE_NAME) != null) {
            ctx.datastoreName = ctx.diskState.customProperties.get(DISK_DATASTORE_NAME);
            populateVMDiskContextThen(service, ctx, onSuccess);
        } else if (ctx.diskState.storageDescription != null) {
            ctx.datastoreName = ctx.diskState.storageDescription.id;
            populateVMDiskContextThen(service, ctx, onSuccess);
        } else if (ctx.diskState.resourceGroupStates != null && !ctx.diskState.resourceGroupStates.isEmpty()) {
            // There will always be only one resource group state existing for a disk
            ResourceGroupService.ResourceGroupState resource = ctx.diskState.resourceGroupStates.iterator().next();
            ClientUtils.getDatastoresForProfile(service, resource.documentSelfLink, ctx.diskState.endpointLink, ctx.diskState.tenantLinks, ctx.errorHandler, (result) -> {
                if (result.documents != null && result.documents.size() > 0) {
                    // pick the first datastore and proceed.
                    ctx.datastoreName = Utils.fromJson(result.documents.values().iterator().next(), StorageDescriptionService.StorageDescription.class).id;
                } else {
                    // Since no result found default to the available datastore.
                    ctx.datastoreName = "";
                }
                populateVMDiskContextThen(service, ctx, onSuccess);
            });
        } else if (ctx.computeGroupLinks != null) {
            // try to get the datastore form the placement link of compute
            String datastoreLink = ctx.computeGroupLinks.iterator().next();
            URI dsUri = PhotonModelUriUtils.createInventoryUri(service.getHost(), UriUtils.buildUri(service.getHost(), datastoreLink));
            AdapterUtils.getServiceState(service, dsUri, op -> {
                ResourceGroupService.ResourceGroupState rgState = op.getBody(ResourceGroupService.ResourceGroupState.class);
                ctx.datastoreName = rgState.id;
                populateVMDiskContextThen(service, ctx, onSuccess);
            }, ctx.errorHandler);
        } else {
            ctx.datastoreName = "";
            populateVMDiskContextThen(service, ctx, onSuccess);
        }
        return;
    }
    // context populated, invoke handler
    onSuccess.accept(ctx);
}
Also used : Service(com.vmware.xenon.common.Service) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) ComputeProperties(com.vmware.photon.controller.model.ComputeProperties) SessionUtil(com.vmware.photon.controller.model.resources.SessionUtil) PhotonModelUriUtils(com.vmware.photon.controller.model.util.PhotonModelUriUtils) INSERT_CDROM(com.vmware.photon.controller.model.constants.PhotonModelConstants.INSERT_CDROM) ResourceOperationRequest(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationRequest) ArrayList(java.util.ArrayList) DISK_FULL_PATH(com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.DISK_FULL_PATH) Utils(com.vmware.xenon.common.Utils) DISK_DATASTORE_NAME(com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.DISK_DATASTORE_NAME) URI(java.net.URI) EnumSet(java.util.EnumSet) AdapterUtils(com.vmware.photon.controller.model.adapters.util.AdapterUtils) Operation(com.vmware.xenon.common.Operation) TaskManager(com.vmware.photon.controller.model.adapters.util.TaskManager) DISK_LINK(com.vmware.photon.controller.model.constants.PhotonModelConstants.DISK_LINK) MEDIA_TYPE_APPLICATION_OCTET_STREAM(com.vmware.xenon.common.Operation.MEDIA_TYPE_APPLICATION_OCTET_STREAM) Set(java.util.Set) Collectors(java.util.stream.Collectors) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) Consumer(java.util.function.Consumer) ResourceGroupService(com.vmware.photon.controller.model.resources.ResourceGroupService) List(java.util.List) Stream(java.util.stream.Stream) ResourceOperation(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperation) DISK_CONTENT_LINK(com.vmware.photon.controller.model.constants.PhotonModelConstants.DISK_CONTENT_LINK) ComputeStateWithDescription(com.vmware.photon.controller.model.resources.ComputeService.ComputeStateWithDescription) StorageDescriptionService(com.vmware.photon.controller.model.resources.StorageDescriptionService) UriUtils(com.vmware.xenon.common.UriUtils) IAAS_API_ENABLED(com.vmware.photon.controller.model.UriPaths.IAAS_API_ENABLED) DiskService(com.vmware.photon.controller.model.resources.DiskService) PREFIX_DATASTORE(com.vmware.photon.controller.model.adapters.vsphere.VSphereIncrementalEnumerationService.PREFIX_DATASTORE) Collections(java.util.Collections) OperationJoin(com.vmware.xenon.common.OperationJoin) PhotonModelUriUtils.createInventoryUri(com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri) ComputeStateWithDescription(com.vmware.photon.controller.model.resources.ComputeService.ComputeStateWithDescription) OperationJoin(com.vmware.xenon.common.OperationJoin) Operation(com.vmware.xenon.common.Operation) ResourceOperation(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperation) URI(java.net.URI) DiskService(com.vmware.photon.controller.model.resources.DiskService) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) ResourceGroupService(com.vmware.photon.controller.model.resources.ResourceGroupService) StorageDescriptionService(com.vmware.photon.controller.model.resources.StorageDescriptionService)

Aggregations

AdapterUtils (com.vmware.photon.controller.model.adapters.util.AdapterUtils)2 DISK_FULL_PATH (com.vmware.photon.controller.model.adapters.vsphere.CustomProperties.DISK_FULL_PATH)2 INSERT_CDROM (com.vmware.photon.controller.model.constants.PhotonModelConstants.INSERT_CDROM)2 DiskService (com.vmware.photon.controller.model.resources.DiskService)2 StorageDescriptionService (com.vmware.photon.controller.model.resources.StorageDescriptionService)2 PhotonModelUriUtils (com.vmware.photon.controller.model.util.PhotonModelUriUtils)2 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)2 Operation (com.vmware.xenon.common.Operation)2 Service (com.vmware.xenon.common.Service)2 UriUtils (com.vmware.xenon.common.UriUtils)2 Utils (com.vmware.xenon.common.Utils)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 EnumSet (java.util.EnumSet)2 List (java.util.List)2 Consumer (java.util.function.Consumer)2 Collectors (java.util.stream.Collectors)2 PbmFaultFaultMsg (com.vmware.pbm.PbmFaultFaultMsg)1 PbmPlacementHub (com.vmware.pbm.PbmPlacementHub)1 PbmProfileId (com.vmware.pbm.PbmProfileId)1