Examples of VmwareContext


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

        return answerCmds;
    }

    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

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

        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

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

        _morHyperHost = new ManagedObjectReference();
        String[] hostTokens = tokens[0].split(":");
        _morHyperHost.setType(hostTokens[0]);
        _morHyperHost.set_value(hostTokens[1]);
       
        VmwareContext context = getServiceContext();
        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 (mgr.getNexusVSwitchGlobalParameter()) {
              cfmMo.ensureCustomFieldDef("DistributedVirtualPortgroup", CustomFieldConstants.CLOUD_GC_DVP);
            } else {
              cfmMo.ensureCustomFieldDef("Network", CustomFieldConstants.CLOUD_GC);
            }

            cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_UUID);
            cfmMo.ensureCustomFieldDef("VirtualMachine", CustomFieldConstants.CLOUD_NIC_MASK);

            VmwareHypervisorHost hostMo = this.getHyperHost(context);
            _hostName = hostMo.getHyperHostName();

            Map<String, String> vsmCredentials;
            if (mgr.getNexusVSwitchGlobalParameter()) {
                vsmCredentials = mgr.getNexusVSMCredentialsByClusterId(Long.parseLong(_cluster));
                if (vsmCredentials != null) {
                    s_logger.info("Stocking credentials while configuring resource.");
                    context.registerStockObject("vsmcredentials", vsmCredentials);
                }
                _privateNetworkVSwitchName = mgr.getPrivateVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
                _publicNetworkVSwitchName = mgr.getPublicVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
                _guestNetworkVSwitchName = mgr.getGuestVSwitchName(Long.parseLong(_dcId), HypervisorType.VMware);
            }
View Full Code Here

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

      s_logger.debug("initialize VmwareContext. url: " + serviceUrl + ", username: " + vCenterUserName + ", password: " + StringUtils.getMaskedPasswordForDisplay(vCenterPassword));

    VmwareClient vimClient = new VmwareClient(vCenterAddress + "-" + s_seq++);
    vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword);

    VmwareContext context = new VmwareContext(vimClient, vCenterAddress);
    context.registerStockObject(VmwareManager.CONTEXT_STOCK_NAME, s_vmwareMgr);

    context.registerStockObject("serviceconsole", s_vmwareMgr.getServiceConsolePortGroupName());
    context.registerStockObject("manageportgroup", s_vmwareMgr.getManagementPortGroupName());

    context.setPoolInfo(s_pool, VmwareContextPool.composePoolKey(vCenterAddress, vCenterUserName));
    s_pool.registerOutstandingContext(context);
   
    return context;
  }
View Full Code Here

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

   
    return context;
  }
 
  public static VmwareContext getContext(String vCenterAddress, String vCenterUserName, String vCenterPassword) throws Exception {
    VmwareContext context = s_pool.getContext(vCenterAddress, vCenterUserName);
    if(context == null)
      context = create(vCenterAddress, vCenterUserName, vCenterPassword);
   
    if(context != null) {
      context.registerStockObject(VmwareManager.CONTEXT_STOCK_NAME, s_vmwareMgr);

      context.registerStockObject("serviceconsole", s_vmwareMgr.getServiceConsolePortGroupName());
      context.registerStockObject("manageportgroup", s_vmwareMgr.getManagementPortGroupName());
    }
   
    return context;
  }
View Full Code Here

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

      s_logger.debug("initialize VmwareContext. url: " + serviceUrl + ", username: " + vCenterUserName + ", password: " + StringUtils.getMaskedPasswordForDisplay(vCenterPassword));

    VmwareClient vimClient = new VmwareClient(vCenterAddress + "-" + s_seq++);
    vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword);

    VmwareContext context = new VmwareContext(vimClient, vCenterAddress);
    return context;
  }
View Full Code Here

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

    VmwareContext context = new VmwareContext(vimClient, vCenterAddress);
    return context;
  }
 
  public static VmwareContext getContext(String vCenterAddress, String vCenterUserName, String vCenterPassword) throws Exception {
    VmwareContext context = s_pool.getContext(vCenterAddress, vCenterUserName);
    if(context == null)
      context = create(vCenterAddress, vCenterUserName, vCenterPassword);
   
    if(context != null) {
      context.setPoolInfo(s_pool, VmwareContextPool.composePoolKey(vCenterAddress, vCenterUserName));
    }
   
    return context;
  }
View Full Code Here

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

                throw discEx;
            }
            vsmCredentials = _vmwareMgr.getNexusVSMCredentialsByClusterId(clusterId);
    }

    VmwareContext context = null;
    try {
      context = VmwareContextFactory.create(url.getHost(), username,
          password);
      if (privateTrafficLabel != null)
        context.registerStockObject("privateTrafficLabel",
            privateTrafficLabel);

            if (nexusDVS) {
        if (vsmCredentials != null) {
          s_logger.info("Stocking credentials of Nexus VSM");
          context.registerStockObject("vsmcredentials",
              vsmCredentials);
        }
      }
      List<ManagedObjectReference> morHosts = _vmwareMgr
          .addHostToPodCluster(context, dcId, podId, clusterId,
              URLDecoder.decode(url.getPath()));
      if (morHosts == null)
        s_logger.info("Found 0 hosts.");
      if (privateTrafficLabel != null)
        context.uregisterStockObject("privateTrafficLabel");

      if (morHosts == null) {
        s_logger.error("Unable to find host or cluster based on url: "
            + URLDecoder.decode(url.getPath()));
        return null;
      }

      ManagedObjectReference morCluster = null;
            clusterDetails = _clusterDetailsDao.findDetails(clusterId);
      if (clusterDetails.get("url") != null) {
        URI uriFromCluster = new URI(
            UriUtils.encodeURIComponent(clusterDetails.get("url")));
        morCluster = context.getHostMorByPath(URLDecoder
            .decode(uriFromCluster.getPath()));

        if (morCluster == null
            || !morCluster.getType().equalsIgnoreCase(
                "ClusterComputeResource")) {
          s_logger.warn("Cluster url does not point to a valid vSphere cluster, url: "
              + clusterDetails.get("url"));
          return null;
        } else {
          ClusterMO clusterMo = new ClusterMO(context, morCluster);
          ClusterDasConfigInfo dasConfig = clusterMo.getDasConfig();
          if (dasConfig != null && dasConfig.isEnabled() != null
              && dasConfig.isEnabled().booleanValue()) {
            clusterDetails.put("NativeHA", "true");
            _clusterDetailsDao.persist(clusterId, clusterDetails);
          }
        }
      }

      if (!validateDiscoveredHosts(context, morCluster, morHosts)) {
        if (morCluster == null)
          s_logger.warn("The discovered host is not standalone host, can not be added to a standalone cluster");
        else
          s_logger.warn("The discovered host does not belong to the cluster");
        return null;
      }

      Map<VmwareResource, Map<String, String>> resources = new HashMap<VmwareResource, Map<String, String>>();
      for (ManagedObjectReference morHost : morHosts) {
        Map<String, String> details = new HashMap<String, String>();
        Map<String, Object> params = new HashMap<String, Object>();

        HostMO hostMo = new HostMO(context, morHost);
        details.put("url", hostMo.getHostName());
        details.put("username", username);
        details.put("password", password);
        String guid = morHost.getType() + ":" + morHost.getValue()
            + "@" + url.getHost();
        details.put("guid", guid);

        params.put("url", hostMo.getHostName());
        params.put("username", username);
        params.put("password", password);
        params.put("zone", Long.toString(dcId));
        params.put("pod", Long.toString(podId));
        params.put("cluster", Long.toString(clusterId));
        params.put("guid", guid);
        if (privateTrafficLabel != null) {
          params.put("private.network.vswitch.name",
              privateTrafficLabel);
        }
                params.put("guestTrafficInfo", guestTrafficLabelObj);
                params.put("publicTrafficInfo", publicTrafficLabelObj);

        VmwareResource resource = new VmwareResource();
        try {
          resource.configure("VMware", params);
        } catch (ConfigurationException e) {
          _alertMgr.sendAlert(AlertManager.ALERT_TYPE_HOST, dcId,
              podId, "Unable to add " + url.getHost(),
              "Error is " + e.getMessage());
          s_logger.warn("Unable to instantiate " + url.getHost(), e);
        }
        resource.start();

        resources.put(resource, details);
      }

      // place a place holder guid derived from cluster ID
      cluster.setGuid(UUID.nameUUIDFromBytes(
          String.valueOf(clusterId).getBytes()).toString());
      _clusterDao.update(clusterId, cluster);
            // Flag cluster discovery success
            failureInClusterDiscovery = false;
      return resources;
    } catch (DiscoveredWithErrorException e) {
      throw e;
    } catch (Exception e) {
      s_logger.warn("Unable to connect to Vmware vSphere server. service address: "
          + url.getHost());
      return null;
    } finally {
      if (context != null)
        context.close();
            if (failureInClusterDiscovery && vsmInfo.first()) {
                try {
                    s_logger.debug("Deleting Nexus 1000v VSM " + vsmIp + " because cluster discovery and addition to zone has failed.");
                    _nexusElement.deleteCiscoNexusVSM(vsmInfo.second().longValue());
                } catch(Exception e) {
View Full Code Here

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

    @Override
    public VmwareContext getServiceContext(Command cmd) {
      if(s_serviceContext.get() != null)
        return s_serviceContext.get();
     
      VmwareContext context = null;
        try {
            context = VmwareContextFactory.getContext(_vCenterAddress, _username, _password);
            s_serviceContext.set(context);
        } catch (Exception e) {
            s_logger.error("Unable to connect to vSphere server: " + _vCenterAddress, e);
View Full Code Here

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

      if(context != null)
        context.close();
    }

  private static void recycleServiceContext() {
    VmwareContext context = s_serviceContext.get();
    s_serviceContext.set(null);
   
    if(context != null) {
      assert(context.getPool() != null);
      context.getPool().returnContext(context);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.