Package com.cloud.hypervisor.vmware.util

Examples of com.cloud.hypervisor.vmware.util.VmwareContext


         * "path":"i-2-1-KY-ROOT","size":0,"type":"ROOT", "resourceType":"STORAGE_POOL", "storagePoolType":"NetworkFilesystem",
         * "poolId":0,"deviceId":0 } }
         */

        try {
            VmwareContext context = getServiceContext();
            VmwareHypervisorHost hyperHost = getHyperHost(context);
            VolumeObjectTO vol = (VolumeObjectTO)cmd.getData();
            PrimaryDataStoreTO store = (PrimaryDataStoreTO)vol.getDataStore();

            ManagedObjectReference morDs = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, store.getUuid());
View Full Code Here


        if (s_logger.isInfoEnabled()) {
            s_logger.info("Executing resource CopyVolumeCommand: " + _gson.toJson(cmd));
        }

        try {
            VmwareContext context = getServiceContext();
            VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
            return (CopyVolumeAnswer) mgr.getStorageManager().execute(this, cmd);
        } catch (Throwable e) {
            if (e instanceof RemoteException) {
                s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
                invalidateServiceContext();
View Full Code Here

        StorageFilerTO pool = cmd.getPool();
        DiskProfile dskch = cmd.getDiskCharacteristics();

        try {
            VmwareContext context = getServiceContext();
            VmwareHypervisorHost hyperHost = getHyperHost(context);
            DatacenterMO dcMo = new DatacenterMO(context, hyperHost.getHyperHostDatacenter());

            ManagedObjectReference morDatastore = HypervisorHostHelper.findDatastoreWithBackwardsCompatibility(hyperHost, pool.getUuid());
            if (morDatastore == null)
View Full Code Here

              return null;
          }
 
          try {
              // take the chance to do left-over dummy VM cleanup from previous run
              VmwareContext context = getServiceContext();
              VmwareHypervisorHost hyperHost = getHyperHost(context);
              VmwareManager mgr = hyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
 
              if(hyperHost.isHyperHostConnected()) {
                  mgr.gcLeftOverVMs(context);
View Full Code Here

    @Override
    public StartupCommand[] initialize() {
      try {
          String hostApiVersion = "4.1";
          VmwareContext context = getServiceContext();
          try {
              VmwareHypervisorHost hyperHost = getHyperHost(context);
              assert(hyperHost instanceof HostMO);
              if(!((HostMO)hyperHost).isHyperHostConnected()) {
                  s_logger.info("Host " + hyperHost.getHyperHostName() + " is not in connected state");
View Full Code Here

      }
    }

    private List<StartupStorageCommand> initializeLocalStorage() {
        List<StartupStorageCommand> storageCmds = new ArrayList<StartupStorageCommand>();
        VmwareContext context = getServiceContext();

        try {
            VmwareHypervisorHost hyperHost = getHyperHost(context);
            if (hyperHost instanceof HostMO) {
                HostMO hostMo = (HostMO) hyperHost;
View Full Code Here

        return storageCmds;
    }

    protected void fillHostInfo(StartupRoutingCommand cmd) {
        VmwareContext serviceContext = getServiceContext();
        Map<String, String> details = cmd.getHostDetails();
        if (details == null) {
            details = new HashMap<String, String>();
        }
View Full Code Here

          _morHyperHost.setType(hostTokens[0]);
          _morHyperHost.setValue(hostTokens[1]);
 
          _guestTrafficInfo = (VmwareTrafficLabel) params.get("guestTrafficInfo");
          _publicTrafficInfo = (VmwareTrafficLabel) params.get("publicTrafficInfo");
          VmwareContext context = getServiceContext();
          volMgr = ComponentContext.inject(VolumeManagerImpl.class);
          try {
              VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
              mgr.setupResourceStartupParams(params);
 
              CustomFieldsManagerMO cfmMo = new CustomFieldsManagerMO(context, context.getServiceContent().getCustomFieldsManager());
              cfmMo.ensureCustomFieldDef("Datastore", CustomFieldConstants.CLOUD_UUID);
              if (_publicTrafficInfo != null && _publicTrafficInfo.getVirtualSwitchType() != VirtualSwitchType.StandardVirtualSwitch ||
                      _guestTrafficInfo != null && _guestTrafficInfo.getVirtualSwitchType() != VirtualSwitchType.StandardVirtualSwitch) {
                  cfmMo.ensureCustomFieldDef("DistributedVirtualPortgroup", CustomFieldConstants.CLOUD_GC_DVP);
              }
              cfmMo.ensureCustomFieldDef("Network", CustomFieldConstants.CLOUD_GC);
              cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_UUID);
              cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_NIC_MASK);
              cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_VM_INTERNAL_NAME);
 
              VmwareHypervisorHost hostMo = this.getHyperHost(context);
              _hostName = hostMo.getHyperHostName();
 
              if (_guestTrafficInfo.getVirtualSwitchType() == VirtualSwitchType.NexusDistributedVirtualSwitch ||
                      _publicTrafficInfo.getVirtualSwitchType() == VirtualSwitchType.NexusDistributedVirtualSwitch) {
                  _vsmCredentials = mgr.getNexusVSMCredentialsByClusterId(Long.parseLong(_cluster));
                  _privateNetworkVSwitchName = mgr.getPrivateVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
              }
 
          } catch (Exception e) {
              s_logger.error("Unexpected Exception ", e);
          }
 
          if(_privateNetworkVSwitchName == null) {
              _privateNetworkVSwitchName = (String) params.get("private.network.vswitch.name");
          }
 
          String value = (String) params.get("vmware.recycle.hung.wokervm");
          if(value != null && value.equalsIgnoreCase("true"))
              _recycleHungWorker = true;

          value = (String)params.get("vmware.root.disk.controller");
          if(value != null && value.equalsIgnoreCase("scsi"))
              _rootDiskController = DiskControllerType.scsi;
          else
              _rootDiskController = DiskControllerType.ide;
 
          Integer intObj = (Integer) params.get("ports.per.dvportgroup");
          if (intObj != null)
              _portsPerDvPortGroup = intObj.intValue();
 
          s_logger.info("VmwareResource network configuration info." +
                  " private traffic over vSwitch: " + _privateNetworkVSwitchName + ", public traffic over " +
                  _publicTrafficInfo.getVirtualSwitchType() + " : " + _publicTrafficInfo.getVirtualSwitchName() +
                  ", guest traffic over " + _guestTrafficInfo.getVirtualSwitchType() + " : " +
                  _guestTrafficInfo.getVirtualSwitchName());
 
          value = params.get("vmware.create.full.clone").toString();
          if (value != null && value.equalsIgnoreCase("true")) {
              _fullCloneFlag = true;
          } else {
              _fullCloneFlag = false;
          }
 
          value = params.get("vm.instancename.flag").toString();
          if (value != null && value.equalsIgnoreCase("true")) {
              _instanceNameFlag = true;
          } else {
              _instanceNameFlag = false;
          }
 
          value = (String)params.get("scripts.timeout");
          int timeout = NumbersUtil.parseInt(value, 1440) * 1000;
          VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
          VmwareStorageProcessor storageProcessor = new VmwareStorageProcessor((VmwareHostService)this, _fullCloneFlag, (VmwareStorageMount)mgr,
                  timeout, this, _shutdown_waitMs, null
                  );
          storageHandler = new VmwareStorageSubsystemCommandHandler(storageProcessor);
 
View Full Code Here

        }

        try {
            _resource.ensureOutgoingRuleForAddress(vCenterAddress);
           
        VmwareContext context = currentContext.get();
        if(context == null) {
          s_logger.info("Open new VmwareContext. vCenter: " + vCenterAddress + ", user: " + username
            + ", password: " + StringUtils.getMaskedPasswordForDisplay(password));
                context = VmwareSecondaryStorageContextFactory.getContext(vCenterAddress, username, password);
        }
       
            if (context != null) {
                context.registerStockObject("serviceconsole", cmd.getContextParam("serviceconsole"));
                context.registerStockObject("manageportgroup", cmd.getContextParam("manageportgroup"));
            }
            currentContext.set(context);
            return context;
        } catch (Exception e) {
            s_logger.error("Unexpected exception " + e.toString(), e);
View Full Code Here

        }
    }
   
    public void recycleServiceContext() {
      if(currentContext.get() != null) {
        VmwareContext context = currentContext.get();
        currentContext.set(null);
        assert(context.getPool() != null);
        context.getPool().returnContext(context);
      }
    }
View Full Code Here

TOP

Related Classes of com.cloud.hypervisor.vmware.util.VmwareContext

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.