Package com.cloud.hypervisor.vmware.mo

Examples of com.cloud.hypervisor.vmware.mo.HostMO


        morHyperHost.setType(hostTokens[0]);
        morHyperHost.set_value(hostTokens[1]);

        if(morHyperHost.getType().equalsIgnoreCase("HostSystem")) {
            HostMO hostMo =  new HostMO(context, morHyperHost);

            try {
               
                ManagedObjectReference mor = hostMo.getHyperHostCluster();
                ClusterMO clusterMo = new ClusterMO(hostMo.getContext(), mor);
                List<Pair<ManagedObjectReference, String>> hostsInCluster = clusterMo.getClusterHosts();
                for(Pair<ManagedObjectReference, String> hostPair : hostsInCluster) {
                    HostMO hostIteratorMo = new HostMO(hostMo.getContext(), hostPair.first());
                   
                    VmwareHypervisorHostNetworkSummary netSummary = hostIteratorMo.getHyperHostNetworkSummary(
                            hostIteratorMo.getHostType() == VmwareHostType.ESXi ? cmd.getContextParam("manageportgroup") : cmd.getContextParam("serviceconsole"));
                    _resource.ensureOutgoingRuleForAddress(netSummary.getHostIp());
                   
                    s_logger.info("Setup firewall rule for host: " + netSummary.getHostIp());
                }
            } catch(Throwable e) {
View Full Code Here


        morHyperHost.setType(hostTokens[0]);
        morHyperHost.set_value(hostTokens[1]);

        if(morHyperHost.getType().equalsIgnoreCase("HostSystem")) {
            HostMO hostMo =  new HostMO(context, morHyperHost);
            try {
                VmwareHypervisorHostNetworkSummary netSummary = hostMo.getHyperHostNetworkSummary(
                  hostMo.getHostType() == VmwareHostType.ESXi ? cmd.getContextParam("manageportgroup") : cmd.getContextParam("serviceconsole"));
                assert(netSummary != null);
                if(netSummary.getHostIp() != null && !netSummary.getHostIp().isEmpty()) {
                    if(s_logger.isDebugEnabled()) {
                        s_logger.debug("Context validation succeeded. Validated via host: " + netSummary.getHostIp() + ", guid: " + guid);
                    }
View Full Code Here

            if(mor.getType().equals("ComputeResource")) {
                ManagedObjectReference[] hosts = (ManagedObjectReference[])serviceContext.getServiceUtil().getDynamicProperty(mor, "host");
                assert(hosts != null);

                // For ESX host, we need to enable host firewall to allow VNC access
                HostMO hostMo = new HostMO(serviceContext, hosts[0]);
                HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
                if(firewallMo != null) {
                if(hostMo.getHostType() == VmwareHostType.ESX) {
                   
                      firewallMo.enableRuleset("vncServer");
                      firewallMo.refreshFirewall();
                }
                }

                // prepare at least one network on the vswitch to enable OVF importing
                String vlanId = null;
                if(privateTrafficLabel != null) {
                  String[] tokens = privateTrafficLabel.split(",");
                  if(tokens.length == 2)
                    vlanId = tokens[1];
                }

                if(!_nexusVSwitchActive) {
                  HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
                }
                else {
                    s_logger.info("Preparing Network on " + privateTrafficLabel);
                    HypervisorHostHelper.prepareNetwork(privateTrafficLabel, "cloud.private", hostMo, vlanId, null, null, 180000);
                }
                returnedHostList.add(hosts[0]);
                return returnedHostList;
            } else if(mor.getType().equals("ClusterComputeResource")) {
                ManagedObjectReference[] hosts = (ManagedObjectReference[])serviceContext.getServiceUtil().getDynamicProperty(mor, "host");
                assert(hosts != null);
               
                if(hosts.length > _maxHostsPerCluster) {
                  String msg = "vCenter cluster size is too big (current configured cluster size: " + _maxHostsPerCluster + ")";
                  s_logger.error(msg);
                  throw new DiscoveredWithErrorException(msg);
                }
               
                for(ManagedObjectReference morHost: hosts) {
                    // For ESX host, we need to enable host firewall to allow VNC access
                    HostMO hostMo = new HostMO(serviceContext, morHost);
                    HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
                    if(firewallMo != null) {
                    if(hostMo.getHostType() == VmwareHostType.ESX) {
                          firewallMo.enableRuleset("vncServer");
                          firewallMo.refreshFirewall();
                    }
                    }

                    String vlanId = null;
                    if(privateTrafficLabel != null) {
                        String[] tokens = privateTrafficLabel.split(",");
                        if(tokens.length == 2)
                            vlanId = tokens[1];
                    }
                   
                   
                    s_logger.info("Calling prepareNetwork : " + hostMo.getContext().toString());
                    // prepare at least one network on the vswitch to enable OVF importing
                    if(!_nexusVSwitchActive) {
                      HypervisorHostHelper.prepareNetwork(_privateNetworkVSwitchName, "cloud.private", hostMo, vlanId, null, null, 180000, false);
                    }
                    else {
                        s_logger.info("Preparing Network on " + privateTrafficLabel);
                        HypervisorHostHelper.prepareNetwork(privateTrafficLabel, "cloud.private", hostMo, vlanId, null, null, 180000);
                    }
                    returnedHostList.add(morHost);
                }
                return returnedHostList;
            } else if(mor.getType().equals("HostSystem")) {
                // For ESX host, we need to enable host firewall to allow VNC access
                HostMO hostMo = new HostMO(serviceContext, mor);
                HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
                if(firewallMo != null) {
                if(hostMo.getHostType() == VmwareHostType.ESX) {
                      firewallMo.enableRuleset("vncServer");
                      firewallMo.refreshFirewall();
                }
                }
View Full Code Here

                throw new CloudRuntimeException("Successfully added host into vSphere but unable to find it later on?!. Please make sure you are either using IP address or full qualified domain name for host");
            }
        }

        // For ESX host, we need to enable host firewall to allow VNC access
        HostMO hostMo = new HostMO(serviceContext, morHost);
        HostFirewallSystemMO firewallMo = hostMo.getHostFirewallSystemMO();
        if(firewallMo != null) {
            firewallMo.enableRuleset("vncServer");
            firewallMo.refreshFirewall();
        }
        return morHost;
View Full Code Here

 
  public static VirtualMachineMO pickOneVmOnRunningHost(List<VirtualMachineMO> vmList, boolean bFirstFit) throws Exception {
    List<VirtualMachineMO> candidates = new ArrayList<VirtualMachineMO>();
   
      for(VirtualMachineMO vmMo : vmList) {
        HostMO hostMo = vmMo.getRunningHost();
        if(hostMo.isHyperHostConnected())
          candidates.add(vmMo);
      }
     
      if(candidates.size() == 0)
        return null;
View Full Code Here

                        VirtualMachineDiskInfo diskInfo = null;
                        if (vol.getChainInfo() != null)
                            diskInfo = _gson.fromJson(vol.getChainInfo(), VirtualMachineDiskInfo.class);

                        HostMO hostMo = vmMo.getRunningHost();
                        List<NetworkDetails> networks = vmMo.getNetworksWithDetails();

                        // tear down all devices first before we destroy the VM to avoid accidently delete disk backing files
                        if (VmwareResource.getVmState(vmMo) != State.Stopped) {
                            vmMo.safePowerOff(_shutdownWaitMs);
View Full Code Here

        addRemoveInternetScsiTargetsToAllHosts(context, true, lstTargets, lstHosts);

        rescanAllHosts(context, lstHosts);

        HostMO host = new HostMO(context, lstHosts.get(0).first());
        HostDatastoreSystemMO hostDatastoreSystem = host.getHostDatastoreSystemMO();

        ManagedObjectReference morDs = hostDatastoreSystem.findDatastoreByName(datastoreName);

        if (morDs != null) {
            return morDs;
        }

        rescanAllHosts(context, lstHosts);

        HostStorageSystemMO hostStorageSystem = host.getHostStorageSystemMO();
        List<HostScsiDisk> lstHostScsiDisks = hostDatastoreSystem.queryAvailableDisksForVmfs();

        HostScsiDisk hostScsiDisk = getHostScsiDisk(hostStorageSystem.getStorageDeviceInfo().getScsiTopology(), lstHostScsiDisks, iqn);

        if (hostScsiDisk == null) {
View Full Code Here

        ExecutorService executorService = Executors.newFixedThreadPool(lstHosts.size());

        final List<Exception> exceptions = new ArrayList<Exception>();

        for (Pair<ManagedObjectReference, String> hostPair : lstHosts) {
            HostMO host = new HostMO(context, hostPair.first());
            HostStorageSystemMO hostStorageSystem = host.getHostStorageSystemMO();

            boolean iScsiHbaConfigured = false;

            for (HostHostBusAdapter hba : hostStorageSystem.getStorageDeviceInfo().getHostBusAdapter()) {
                if (hba instanceof HostInternetScsiHba) {
View Full Code Here

        ExecutorService executorService = Executors.newFixedThreadPool(lstHosts.size());

        final List<Exception> exceptions = new ArrayList<Exception>();

        for (Pair<ManagedObjectReference, String> hostPair : lstHosts) {
            HostMO host = new HostMO(context, hostPair.first());
            HostStorageSystemMO hostStorageSystem = host.getHostStorageSystemMO();

            boolean iScsiHbaConfigured = false;

            for (HostHostBusAdapter hba : hostStorageSystem.getStorageDeviceInfo().getHostBusAdapter()) {
                if (hba instanceof HostInternetScsiHba) {
View Full Code Here

        VmwareContext context = hostService.getServiceContext(null);
        VmwareHypervisorHost hyperHost = hostService.getHyperHost(context, null);
        ManagedObjectReference morCluster = hyperHost.getHyperHostCluster();
        ClusterMO cluster = new ClusterMO(context, morCluster);
        List<Pair<ManagedObjectReference, String>> lstHosts = cluster.getClusterHosts();
        HostMO host = new HostMO(context, lstHosts.get(0).first());
        HostStorageSystemMO hostStorageSystem = host.getHostStorageSystemMO();

        for (HostHostBusAdapter hba : hostStorageSystem.getStorageDeviceInfo().getHostBusAdapter()) {
            if (hba instanceof HostInternetScsiHba) {
                List<HostInternetScsiHbaStaticTarget> lstTargets = ((HostInternetScsiHba)hba).getConfiguredStaticTarget();
View Full Code Here

TOP

Related Classes of com.cloud.hypervisor.vmware.mo.HostMO

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.