Search in sources :

Example 61 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.

the class EditHostModel method setSelectedCluster.

public void setSelectedCluster(VDS host) {
    ArrayList<Cluster> clusters;
    if (getCluster().getItems() == null) {
        Cluster tempVar = new Cluster();
        tempVar.setName(host.getClusterName());
        tempVar.setId(host.getClusterId());
        tempVar.setCompatibilityVersion(host.getClusterCompatibilityVersion());
        getCluster().setItems(new ArrayList<>(Arrays.asList(new Cluster[] { tempVar })));
    }
    clusters = (ArrayList<Cluster>) getCluster().getItems();
    updateModelClusterFromVds(clusters, host);
    if (getCluster().getSelectedItem() == null) {
        getCluster().setSelectedItem(Linq.firstOrNull(clusters));
    }
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster)

Example 62 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.

the class FenceAgentModel method test.

/**
 * Execute the fence agent test.
 */
public void test() {
    validatePmModels();
    if (!isValid()) {
        return;
    }
    setMessage(ConstantsManager.getInstance().getConstants().testingInProgressItWillTakeFewSecondsPleaseWaitMsg());
    getTestCommand().setIsExecutionAllowed(false);
    Cluster cluster = getHost().getCluster().getSelectedItem();
    GetFenceAgentStatusParameters param = new GetFenceAgentStatusParameters();
    FenceAgent agent = new FenceAgent();
    if (getHost().getHostId() != null) {
        param.setVdsId(getHost().getHostId());
    }
    agent.setOrder(getOrder().getEntity());
    agent.setIp(getManagementIp().getEntity());
    agent.setType(getPmType().getSelectedItem());
    agent.setUser(getPmUserName().getEntity());
    agent.setPassword(getPmPassword().getEntity());
    agent.setPort(getPmPort().getEntity());
    agent.setOptionsMap(getPmOptionsMap());
    param.setAgent(agent);
    param.setStoragePoolId(cluster.getStoragePoolId() != null ? cluster.getStoragePoolId() : Guid.Empty);
    param.setFenceProxySources(FenceProxySourceTypeHelper.parseFromString(getHost().getPmProxyPreferences()));
    param.setVdsName(getHost().getName().getEntity());
    param.setHostName(getHost().getHost().getEntity());
    param.setClusterId(cluster.getId());
    Frontend.getInstance().runQuery(QueryType.GetFenceAgentStatus, param, new AsyncQuery<QueryReturnValue>(returnValue -> {
        String msg;
        if (returnValue == null) {
            msg = ConstantsManager.getInstance().getConstants().testFailedUnknownErrorMsg();
        } else {
            FenceOperationResult result = returnValue.getReturnValue();
            if (result.getStatus() == FenceOperationResult.Status.SUCCESS) {
                msg = ConstantsManager.getInstance().getMessages().testSuccessfulWithPowerStatus(result.getPowerStatus() == PowerStatus.ON ? ConstantsManager.getInstance().getConstants().powerOn() : ConstantsManager.getInstance().getConstants().powerOff());
            } else {
                msg = ConstantsManager.getInstance().getMessages().testFailedWithErrorMsg(result.getMessage());
            }
        }
        setMessage(msg);
        getTestCommand().setIsExecutionAllowed(true);
    }, true));
}
Also used : NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) QueryType(org.ovirt.engine.core.common.queries.QueryType) PowerStatus(org.ovirt.engine.core.common.businessentities.pm.PowerStatus) Guid(org.ovirt.engine.core.compat.Guid) HashMap(java.util.HashMap) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) GetFenceAgentStatusParameters(org.ovirt.engine.core.common.queries.GetFenceAgentStatusParameters) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Frontend(org.ovirt.engine.ui.frontend.Frontend) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) ICommandTarget(org.ovirt.engine.ui.uicommonweb.ICommandTarget) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) StringHelper(org.ovirt.engine.core.compat.StringHelper) Objects(java.util.Objects) List(java.util.List) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) FenceProxySourceTypeHelper(org.ovirt.engine.core.common.utils.pm.FenceProxySourceTypeHelper) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) Comparator(java.util.Comparator) HostAddressValidation(org.ovirt.engine.ui.uicommonweb.validation.HostAddressValidation) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) FenceOperationResult(org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult) FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) GetFenceAgentStatusParameters(org.ovirt.engine.core.common.queries.GetFenceAgentStatusParameters)

Example 63 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.

the class RegisterVmModel method prepareParameters.

private List<ActionParametersBase> prepareParameters() {
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    for (RegisterVmData registerVmData : getEntities().getItems()) {
        VM vm = registerVmData.getEntity();
        Cluster cluster = registerVmData.getCluster().getSelectedItem();
        ImportVmFromConfParameters params = new ImportVmFromConfParameters(cloneExternalVnicProfiles(cluster), registerVmData.getReassignMacs().getEntity());
        params.setContainerId(vm.getId());
        params.setStorageDomainId(getStorageDomainId());
        params.setImagesExistOnTargetStorageDomain(true);
        params.setClusterId(cluster != null ? cluster.getId() : null);
        params.setAllowPartialImport(registerVmData.getAllowPartialImport().getEntity());
        if (isQuotaEnabled()) {
            Quota quota = registerVmData.getClusterQuota().getSelectedItem();
            params.setQuotaId(quota != null ? quota.getId() : null);
            params.setDiskMap(vm.getDiskMap());
            updateDiskQuotas(new ArrayList<>(params.getDiskMap().values()));
        }
        parameters.add(params);
    }
    return parameters;
}
Also used : Quota(org.ovirt.engine.core.common.businessentities.Quota) RegisterVmData(org.ovirt.engine.ui.uicommonweb.models.vms.register.RegisterVmData) VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ImportVmFromConfParameters(org.ovirt.engine.core.common.action.ImportVmFromConfParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 64 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.

the class BalloonEnabled method balloonEnabled.

public static boolean balloonEnabled(UnitVmModel model) {
    Cluster cluster = model.getSelectedCluster();
    Integer osType = model.getOSType().getSelectedItem();
    Boolean deviceEnabled = Boolean.TRUE.equals(model.getMemoryBalloonDeviceEnabled().getEntity());
    if (cluster == null || osType == null) {
        if (model.getBehavior() instanceof ExistingBlankTemplateModelBehavior || model.getBehavior() instanceof ExistingInstanceTypeModelBehavior || model.getBehavior() instanceof NewInstanceTypeModelBehavior) {
            return deviceEnabled;
        }
        return false;
    }
    return deviceEnabled && AsyncDataProvider.getInstance().isBalloonEnabled(osType, model.getCompatibilityVersion());
}
Also used : ExistingBlankTemplateModelBehavior(org.ovirt.engine.ui.uicommonweb.models.templates.ExistingBlankTemplateModelBehavior) NewInstanceTypeModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.NewInstanceTypeModelBehavior) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ExistingInstanceTypeModelBehavior(org.ovirt.engine.ui.uicommonweb.models.vms.instancetypes.ExistingInstanceTypeModelBehavior)

Example 65 with Cluster

use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.

the class DataCenterGuideModel method onSelectHost.

public void onSelectHost() {
    MoveHost model = (MoveHost) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (!model.validate()) {
        return;
    }
    model.setSelectedHosts(new ArrayList<MoveHostData>());
    for (MoveHostData a : model.getItems()) {
        if (a.getIsSelected()) {
            model.getSelectedHosts().add(a);
        }
    }
    Cluster cluster = model.getCluster().getSelectedItem();
    final List<ActionParametersBase> parameterList = new ArrayList<>();
    for (MoveHostData hostData : model.getSelectedHosts()) {
        VDS host = hostData.getEntity();
        // Try to change host's cluster as neccessary.
        if (host.getClusterId() != null && !host.getClusterId().equals(cluster.getId())) {
            parameterList.add(new ChangeVDSClusterParameters(cluster.getId(), host.getId()));
        }
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.ChangeVDSCluster, parameterList, new IFrontendMultipleActionAsyncCallback() {

        @Override
        public void executed(FrontendMultipleActionAsyncResult result) {
            final DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
            List<MoveHostData> hosts = ((MoveHost) dataCenterGuideModel.getWindow()).getSelectedHosts();
            List<ActionReturnValue> retVals = result.getReturnValue();
            final List<ActionParametersBase> activateVdsParameterList = new ArrayList<>();
            if (retVals != null && hosts.size() == retVals.size()) {
                int i = 0;
                for (MoveHostData selectedHostData : hosts) {
                    VDS selectedHost = selectedHostData.getEntity();
                    if (selectedHost.getStatus() == VDSStatus.PendingApproval && retVals.get(i) != null && retVals.get(i).getSucceeded()) {
                        Frontend.getInstance().runAction(ActionType.ApproveVds, new ApproveVdsParameters(selectedHost.getId()), null, this);
                    } else if (selectedHostData.getActivateHost()) {
                        activateVdsParameterList.add(new VdsActionParameters(selectedHostData.getEntity().getId()));
                    }
                    i++;
                }
            }
            if (activateVdsParameterList.isEmpty()) {
                dataCenterGuideModel.getWindow().stopProgress();
                dataCenterGuideModel.cancel();
                dataCenterGuideModel.postAction();
            } else {
                final String searchString = getVdsSearchString((MoveHost) dataCenterGuideModel.getWindow());
                Timer timer = new Timer() {

                    public void run() {
                        checkVdsClusterChangeSucceeded(searchString, parameterList, activateVdsParameterList);
                    }
                };
                timer.schedule(2000);
            }
        }
    }, this);
}
Also used : IFrontendMultipleActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback) MoveHost(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHost) VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) FrontendMultipleActionAsyncResult(org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult) Timer(com.google.gwt.user.client.Timer) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) MoveHostData(org.ovirt.engine.ui.uicommonweb.models.hosts.MoveHostData) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

Cluster (org.ovirt.engine.core.common.businessentities.Cluster)346 Test (org.junit.Test)83 ArrayList (java.util.ArrayList)80 Guid (org.ovirt.engine.core.compat.Guid)77 VDS (org.ovirt.engine.core.common.businessentities.VDS)54 List (java.util.List)50 VM (org.ovirt.engine.core.common.businessentities.VM)36 HashMap (java.util.HashMap)35 Map (java.util.Map)33 HashSet (java.util.HashSet)30 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)30 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)28 Version (org.ovirt.engine.core.compat.Version)27 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)26 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)26 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)25 Set (java.util.Set)24 QueryType (org.ovirt.engine.core.common.queries.QueryType)23 Collections (java.util.Collections)22 Frontend (org.ovirt.engine.ui.frontend.Frontend)22