Search in sources :

Example 26 with MorObjectHandler

use of io.cloudslang.content.vmware.services.helpers.MorObjectHandler in project cs-actions by CloudSlang.

the class ClusterComputeResourceService method getVmOverride.

public String getVmOverride(final HttpInputs httpInputs, final VmInputs vmInputs) throws Exception {
    ConnectionResources connectionResources = new ConnectionResources(httpInputs, vmInputs);
    try {
        final ManagedObjectReference clusterMor = new MorObjectHandler().getSpecificMor(connectionResources, connectionResources.getMorRootFolder(), ClusterParameter.CLUSTER_COMPUTE_RESOURCE.getValue(), vmInputs.getClusterName());
        final ClusterConfigInfoEx clusterConfigInfoEx = getClusterConfiguration(connectionResources, clusterMor, vmInputs.getClusterName());
        final String restartPriority;
        if (StringUtilities.isNotBlank(vmInputs.getVirtualMachineId()) || StringUtilities.isNotBlank(vmInputs.getVirtualMachineName())) {
            final ManagedObjectReference vmMor = getVirtualMachineReference(vmInputs, connectionResources);
            restartPriority = getVmRestartPriority(clusterConfigInfoEx, vmMor);
        } else {
            restartPriority = getVmRestartPriority(clusterConfigInfoEx);
        }
        return restartPriority;
    } finally {
        if (httpInputs.isCloseSession()) {
            connectionResources.getConnection().disconnect();
            clearConnectionFromContext(httpInputs.getGlobalSessionObject());
        }
    }
}
Also used : ConnectionResources(io.cloudslang.content.vmware.connection.ConnectionResources) MorObjectHandler(io.cloudslang.content.vmware.services.helpers.MorObjectHandler)

Example 27 with MorObjectHandler

use of io.cloudslang.content.vmware.services.helpers.MorObjectHandler in project cs-actions by CloudSlang.

the class ClusterComputeResourceService method deleteHostGroup.

public Map<String, String> deleteHostGroup(HttpInputs httpInputs, VmInputs vmInputs) throws Exception {
    ConnectionResources connectionResources = new ConnectionResources(httpInputs);
    try {
        ManagedObjectReference clusterMor = new MorObjectHandler().getSpecificMor(connectionResources, connectionResources.getMorRootFolder(), ClusterParameter.CLUSTER_COMPUTE_RESOURCE.getValue(), vmInputs.getClusterName());
        ClusterHostGroup clusterHostGroup = new ClusterHostGroup();
        clusterHostGroup.setName(vmInputs.getHostGroupName());
        ClusterGroupSpec clusterGroupSpec = new ClusterGroupSpec();
        clusterGroupSpec.setInfo(clusterHostGroup);
        clusterGroupSpec.setOperation(ArrayUpdateOperation.REMOVE);
        clusterGroupSpec.setRemoveKey(vmInputs.getHostGroupName());
        return reconfigureClusterGroup(vmInputs, connectionResources, clusterMor, clusterGroupSpec);
    } finally {
        if (httpInputs.isCloseSession()) {
            connectionResources.getConnection().disconnect();
            clearConnectionFromContext(httpInputs.getGlobalSessionObject());
        }
    }
}
Also used : ConnectionResources(io.cloudslang.content.vmware.connection.ConnectionResources) MorObjectHandler(io.cloudslang.content.vmware.services.helpers.MorObjectHandler)

Aggregations

MorObjectHandler (io.cloudslang.content.vmware.services.helpers.MorObjectHandler)27 ManagedObjectReference (com.vmware.vim25.ManagedObjectReference)17 ConnectionResources (io.cloudslang.content.vmware.connection.ConnectionResources)17 ResponseHelper (io.cloudslang.content.vmware.services.helpers.ResponseHelper)7 ArrayOfManagedObjectReference (com.vmware.vim25.ArrayOfManagedObjectReference)6 VmUtils (io.cloudslang.content.vmware.services.utils.VmUtils)3 OvfNetworkMapping (com.vmware.vim25.OvfNetworkMapping)2 ArrayList (java.util.ArrayList)2 ConfigTarget (com.vmware.vim25.ConfigTarget)1 CustomizationSpec (com.vmware.vim25.CustomizationSpec)1 DatastoreSummary (com.vmware.vim25.DatastoreSummary)1 DynamicProperty (com.vmware.vim25.DynamicProperty)1 GuestOsDescriptor (com.vmware.vim25.GuestOsDescriptor)1 KeyValue (com.vmware.vim25.KeyValue)1 ObjectContent (com.vmware.vim25.ObjectContent)1 OvfCreateImportSpecResult (com.vmware.vim25.OvfCreateImportSpecResult)1 VirtualMachineCloneSpec (com.vmware.vim25.VirtualMachineCloneSpec)1 VirtualMachineConfigOption (com.vmware.vim25.VirtualMachineConfigOption)1 VirtualMachineConfigSpec (com.vmware.vim25.VirtualMachineConfigSpec)1 VirtualMachineConfigSummary (com.vmware.vim25.VirtualMachineConfigSummary)1