Package com.vmware.vim25

Examples of com.vmware.vim25.ManagedObjectReference


        }
        }
      }
     
      if(detachedDiskFiles.size() > 0) {
        ManagedObjectReference morTask = _context.getService().reconfigVMTask(_mor, reConfigSpec);
      boolean result = _context.getVimClient().waitForTask(morTask);
      if(result) {
        _context.waitForTaskProgressDone(morTask);
      } else {
        s_logger.warn("Unable to reconfigure the VM to detach disks");
View Full Code Here


    public String getDvPortGroupName(VirtualEthernetCard nic) throws Exception {
        VirtualEthernetCardDistributedVirtualPortBackingInfo dvpBackingInfo =
                (VirtualEthernetCardDistributedVirtualPortBackingInfo) nic.getBacking();
        DistributedVirtualSwitchPortConnection dvsPort = dvpBackingInfo.getPort();
        String dvPortGroupKey = dvsPort.getPortgroupKey();
        ManagedObjectReference dvPortGroupMor = new ManagedObjectReference();
        dvPortGroupMor.setValue(dvPortGroupKey);
        dvPortGroupMor.setType("DistributedVirtualPortgroup");
        return (String) _context.getVimClient().getDynamicProperty(dvPortGroupMor, "name");
    }
View Full Code Here

    if(morHost != null)
      hostMo = new HostMO(getContext(), morHost);
    else
      hostMo = getRunningHost();

    ManagedObjectReference morFolder = getParentMor();
    ManagedObjectReference morPool = hostMo.getHyperHostOwnerResourcePool();

    _context.getService().unregisterVM(_mor);

    ManagedObjectReference morTask = _context.getService().registerVMTask(
         morFolder,
         vmFileInfo.getVmPathName(),
         vmName, false,
         morPool, hostMo.getMor());
View Full Code Here

    return _context.getService().createVmfsDatastore(_mor, vmfsDatastoreCreateSpec);
  }

  public boolean deleteDatastore(String name) throws Exception {
    ManagedObjectReference morDatastore = findDatastore(name);
    if(morDatastore != null) {
      _context.getService().removeDatastore(_mor, morDatastore);
      return true;
    }
    return false;
View Full Code Here

            if (templateMo == null) {
                if(s_logger.isInfoEnabled()) {
                    s_logger.info("Template " + templateName + " is not setup yet, setup template from secondary storage with uuid name: " + templateUuidName);
                }
                ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPoolUuid());
                assert (morDs != null);
                DatastoreMO primaryStorageDatastoreMo = new DatastoreMO(context, morDs);

                copyTemplateFromSecondaryToPrimary(hyperHost,
                        primaryStorageDatastoreMo, secondaryStorageUrl,
View Full Code Here

        String prevSnapshotUuid = cmd.getPrevSnapshotUuid();
        String prevBackupUuid = cmd.getPrevBackupUuid();
        VirtualMachineMO workerVm=null;
        String workerVMName = null;
        String volumePath = cmd.getVolumePath();
        ManagedObjectReference morDs = null;
        DatastoreMO dsMo=null;

        // By default assume failure
        String details = null;
        boolean success = false;
        String snapshotBackupUuid = null;

        VmwareContext context = hostService.getServiceContext(cmd);
        VirtualMachineMO vmMo = null;
        try {
            VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
            morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, cmd.getPool().getUuid());

            try {
                vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
                if (vmMo == null) {
                    if(s_logger.isDebugEnabled()) {
                        s_logger.debug("Unable to find owner VM for BackupSnapshotCommand on host " + hyperHost.getHyperHostName() + ", will try within datacenter");
                    }

                    vmMo = hyperHost.findVmOnPeerHyperHost(cmd.getVmName());
                    if(vmMo == null) {
                        dsMo = new DatastoreMO(hyperHost.getContext(), morDs);

                        workerVMName = hostService.getWorkerName(context, cmd, 0);

                        // attach a volume to dummay wrapper VM for taking snapshot and exporting the VM for backup
                        if (!hyperHost.createBlankVm(workerVMName, null, 1, 512, 0, false, 4, 0, VirtualMachineGuestOsIdentifier.OTHER_GUEST.value(), morDs, false)) {
                            String msg = "Unable to create worker VM to execute BackupSnapshotCommand";
                            s_logger.error(msg);
                            throw new Exception(msg);
                        }
                        vmMo = hyperHost.findVmOnHyperHost(workerVMName);
                        if (vmMo == null) {
                            throw new Exception("Failed to find the newly create or relocated VM. vmName: " + workerVMName);
                        }
                        workerVm = vmMo;

                        // attach volume to worker VM
                        String datastoreVolumePath = getVolumePathInDatastore(dsMo, volumePath + ".vmdk");
                        vmMo.attachDisk(new String[] { datastoreVolumePath }, morDs);
                    }
                }

                if (!vmMo.createSnapshot(snapshotUuid, "Snapshot taken for " + cmd.getSnapshotName(), false, false)) {
                    throw new Exception("Failed to take snapshot " + cmd.getSnapshotName() + " on vm: " + cmd.getVmName());
                }

                snapshotBackupUuid = backupSnapshotToSecondaryStorage(vmMo, accountId, volumeId, cmd.getVolumePath(), snapshotUuid, secondaryStorageUrl, prevSnapshotUuid, prevBackupUuid,
                        hostService.getWorkerName(context, cmd, 1));

                success = (snapshotBackupUuid != null);
                if (success) {
                    details = "Successfully backedUp the snapshotUuid: " + snapshotUuid + " to secondary storage.";
                }

            } finally {
                if(vmMo != null){
                    ManagedObjectReference snapshotMor = vmMo.getSnapshotMor(snapshotUuid);
                    if (snapshotMor != null) {
                        vmMo.removeSnapshot(snapshotUuid, false);
                    }
                }
View Full Code Here

                        secondaryStorageURL,
                        hostService.getWorkerName(context, cmd, 0));
            } else {
                StorageFilerTO poolTO = cmd.getPool();

                ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolTO.getUuid());
                if (morDatastore == null) {
                    morDatastore = hyperHost.mountDatastore(
                            false,
                            poolTO.getHost(), 0, poolTO.getPath(),
                            poolTO.getUuid().replace("-", ""));
View Full Code Here

        String newVolumeName = UUID.randomUUID().toString().replaceAll("-", "");

        VmwareContext context = hostService.getServiceContext(cmd);
        try {
            VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, cmd);
            ManagedObjectReference morPrimaryDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost,
                    primaryStorageNameLabel);
            if (morPrimaryDs == null) {
                String msg = "Unable to find datastore: " + primaryStorageNameLabel;
                s_logger.error(msg);
                throw new Exception(msg);
View Full Code Here

        VirtualMachineMO workerVm=null;
        VirtualMachineMO vmMo=null;
        String exportName = UUID.randomUUID().toString();

        try {
            ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolId);

            if (morDs == null) {
                String msg = "Unable to find volumes's storage pool for copy volume operation";
                s_logger.error(msg);
                throw new Exception(msg);
View Full Code Here

    private long getVMSnapshotChainSize(VmwareContext context, VmwareHypervisorHost hyperHost,
            String fileName, String poolUuid, String exceptFileName)
                    throws Exception{
        long size = 0;
        ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, poolUuid);
        DatastoreMO dsMo = new DatastoreMO(context, morDs);
        HostDatastoreBrowserMO browserMo = dsMo.getHostDatastoreBrowserMO();
        String datastorePath = "[" + dsMo.getName() + "]";
        HostDatastoreBrowserSearchSpec searchSpec = new HostDatastoreBrowserSearchSpec();
        FileQueryFlags fqf = new FileQueryFlags();
View Full Code Here

TOP

Related Classes of com.vmware.vim25.ManagedObjectReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.