Search in sources :

Example 11 with ClusterMO

use of com.cloud.hypervisor.vmware.mo.ClusterMO in project cloudstack by apache.

the class VmwareStorageProcessor method prepareManagedDatastore.

private ManagedObjectReference prepareManagedDatastore(VmwareContext context, VmwareHypervisorHost hyperHost, String diskUuid, String iScsiName, String storageHost, int storagePort, String chapInitiatorUsername, String chapInitiatorSecret, String chapTargetUsername, String chapTargetSecret) throws Exception {
    if (storagePort == DEFAULT_NFS_PORT) {
        s_logger.info("creating the NFS datastore with the following configuration - storageHost: " + storageHost + ", storagePort: " + storagePort + ", exportpath: " + iScsiName + "and diskUuid : " + diskUuid);
        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());
        HostDatastoreSystemMO hostDatastoreSystem = host.getHostDatastoreSystemMO();
        return hostDatastoreSystem.createNfsDatastore(storageHost, storagePort, iScsiName, diskUuid);
    } else {
        return getVmfsDatastore(context, hyperHost, VmwareResource.getDatastoreName(iScsiName), storageHost, storagePort, trimIqn(iScsiName), chapInitiatorUsername, chapInitiatorSecret, chapTargetUsername, chapTargetSecret);
    }
}
Also used : HostMO(com.cloud.hypervisor.vmware.mo.HostMO) HostDatastoreSystemMO(com.cloud.hypervisor.vmware.mo.HostDatastoreSystemMO) ClusterMO(com.cloud.hypervisor.vmware.mo.ClusterMO) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) Pair(com.cloud.utils.Pair)

Example 12 with ClusterMO

use of com.cloud.hypervisor.vmware.mo.ClusterMO in project cloudstack by apache.

the class VmwareStorageProcessor method removeManagedTargetsFromCluster.

private void removeManagedTargetsFromCluster(List<String> iqns) throws Exception {
    List<HostInternetScsiHbaStaticTarget> lstManagedTargets = new ArrayList<HostInternetScsiHbaStaticTarget>();
    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();
            if (lstTargets != null) {
                for (HostInternetScsiHbaStaticTarget target : lstTargets) {
                    if (iqns.contains(target.getIScsiName())) {
                        lstManagedTargets.add(target);
                    }
                }
            }
        }
    }
    addRemoveInternetScsiTargetsToAllHosts(context, false, lstManagedTargets, lstHosts);
    rescanAllHosts(context, lstHosts);
}
Also used : HostMO(com.cloud.hypervisor.vmware.mo.HostMO) HostInternetScsiHbaStaticTarget(com.vmware.vim25.HostInternetScsiHbaStaticTarget) ArrayList(java.util.ArrayList) VmwareHypervisorHost(com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost) ClusterMO(com.cloud.hypervisor.vmware.mo.ClusterMO) VmwareContext(com.cloud.hypervisor.vmware.util.VmwareContext) HostInternetScsiHba(com.vmware.vim25.HostInternetScsiHba) HostStorageSystemMO(com.cloud.hypervisor.vmware.mo.HostStorageSystemMO) HostHostBusAdapter(com.vmware.vim25.HostHostBusAdapter) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) Pair(com.cloud.utils.Pair)

Example 13 with ClusterMO

use of com.cloud.hypervisor.vmware.mo.ClusterMO in project cloudstack by apache.

the class VmwareStorageProcessor method removeVmfsDatastore.

private void removeVmfsDatastore(VmwareHypervisorHost hyperHost, String datastoreName, String storageIpAddress, int storagePortNumber, String iqn) throws Exception {
    // hyperHost.unmountDatastore(datastoreName);
    VmwareContext context = hostService.getServiceContext(null);
    ManagedObjectReference morCluster = hyperHost.getHyperHostCluster();
    ClusterMO cluster = new ClusterMO(context, morCluster);
    List<Pair<ManagedObjectReference, String>> lstHosts = cluster.getClusterHosts();
    HostInternetScsiHbaStaticTarget target = new HostInternetScsiHbaStaticTarget();
    target.setAddress(storageIpAddress);
    target.setPort(storagePortNumber);
    target.setIScsiName(iqn);
    final List<HostInternetScsiHbaStaticTarget> lstTargets = new ArrayList<HostInternetScsiHbaStaticTarget>();
    lstTargets.add(target);
    addRemoveInternetScsiTargetsToAllHosts(context, false, lstTargets, lstHosts);
    rescanAllHosts(context, lstHosts);
}
Also used : VmwareContext(com.cloud.hypervisor.vmware.util.VmwareContext) HostInternetScsiHbaStaticTarget(com.vmware.vim25.HostInternetScsiHbaStaticTarget) ArrayList(java.util.ArrayList) ClusterMO(com.cloud.hypervisor.vmware.mo.ClusterMO) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) Pair(com.cloud.utils.Pair)

Example 14 with ClusterMO

use of com.cloud.hypervisor.vmware.mo.ClusterMO in project cloudstack by apache.

the class VmwareSecondaryStorageResourceHandler method getHyperHost.

@Override
public VmwareHypervisorHost getHyperHost(VmwareContext context, Command cmd) {
    String guid = cmd.getContextParam("guid");
    assert (guid != null);
    String[] tokens = guid.split("@");
    assert (tokens != null && tokens.length == 2);
    ManagedObjectReference morHyperHost = new ManagedObjectReference();
    String[] hostTokens = tokens[0].split(":");
    if (hostTokens == null || hostTokens.length != 2) {
        s_logger.error("Invalid content in command context parameter guid");
        return null;
    }
    morHyperHost.setType(hostTokens[0]);
    morHyperHost.setValue(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) {
            s_logger.warn("Unable to retrive host network information due to exception " + e.toString() + ", host: " + hostTokens[0] + "-" + hostTokens[1]);
        }
        return hostMo;
    }
    assert (false);
    return new ClusterMO(context, morHyperHost);
}
Also used : HostMO(com.cloud.hypervisor.vmware.mo.HostMO) VmwareHypervisorHostNetworkSummary(com.cloud.hypervisor.vmware.mo.VmwareHypervisorHostNetworkSummary) ClusterMO(com.cloud.hypervisor.vmware.mo.ClusterMO) ManagedObjectReference(com.vmware.vim25.ManagedObjectReference) Pair(com.cloud.utils.Pair)

Aggregations

ClusterMO (com.cloud.hypervisor.vmware.mo.ClusterMO)14 HostMO (com.cloud.hypervisor.vmware.mo.HostMO)12 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)11 VmwareContext (com.cloud.hypervisor.vmware.util.VmwareContext)9 UnsupportedEncodingException (java.io.UnsupportedEncodingException)9 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)8 RemoteException (java.rmi.RemoteException)8 VirtualMachineMO (com.cloud.hypervisor.vmware.mo.VirtualMachineMO)7 VmwareHypervisorHost (com.cloud.hypervisor.vmware.mo.VmwareHypervisorHost)7 Pair (com.cloud.utils.Pair)7 ConfigurationException (javax.naming.ConfigurationException)6 CloudException (com.cloud.exception.CloudException)5 InternalErrorException (com.cloud.exception.InternalErrorException)5 IOException (java.io.IOException)5 ConnectException (java.net.ConnectException)5 DatacenterMO (com.cloud.hypervisor.vmware.mo.DatacenterMO)4 UnPlugNicAnswer (com.cloud.agent.api.UnPlugNicAnswer)3 VmwareManager (com.cloud.hypervisor.vmware.manager.VmwareManager)3 HostInternetScsiHbaStaticTarget (com.vmware.vim25.HostInternetScsiHbaStaticTarget)3 ArrayList (java.util.ArrayList)3