Search in sources :

Example 6 with AddVdsActionParameters

use of org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters in project ovirt-engine by oVirt.

the class AddVdsCommandTest method createParameters.

public AddVdsActionParameters createParameters() {
    AddVdsActionParameters parameters = new AddVdsActionParameters();
    parameters.setPassword("secret");
    VDS newVds = makeTestVds(vdsId);
    parameters.setvds(newVds);
    return parameters;
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)

Example 7 with AddVdsActionParameters

use of org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters in project ovirt-engine by oVirt.

the class HostListModel method onSaveInternal.

public void onSaveInternal(boolean approveInitiated) {
    HostModel model = (HostModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    VDS host = model.getIsNew() ? new VDS() : (VDS) Cloner.clone(getSelectedItem());
    // Save changes.
    host.setVdsName(model.getName().getEntity());
    host.setComment(model.getComment().getEntity());
    host.setHostName(model.getHost().getEntity().trim());
    host.setPort(Integer.parseInt(model.getPort().getEntity().toString()));
    host.setSshPort(Integer.parseInt(model.getAuthSshPort().getEntity().toString()));
    boolean sshUsernameSet = model.getUserName().getEntity() != null;
    host.setSshUsername(sshUsernameSet ? model.getUserName().getEntity() : null);
    boolean sshFpSet = model.getFetchSshFingerprint().getEntity() != null;
    host.setSshKeyFingerprint(!sshFpSet ? null : model.getFetchSshFingerprint().getEntity());
    host.setVdsSpmPriority(model.getSpmPriorityValue());
    boolean consoleAddressSet = model.getConsoleAddressEnabled().getEntity();
    host.setConsoleAddress(!consoleAddressSet ? null : model.getConsoleAddress().getEntity());
    Guid oldClusterId = host.getClusterId();
    Guid newClusterId = model.getCluster().getSelectedItem().getId();
    host.setClusterId(newClusterId);
    host.setVdsSpmPriority(model.getSpmPriorityValue());
    host.setFenceProxySources(FenceProxySourceTypeHelper.parseFromString(model.getPmProxyPreferences()));
    // Save other PM parameters.
    host.setPmEnabled(model.getIsPm().getEntity());
    host.setDisablePowerManagementPolicy(model.getDisableAutomaticPowerManagement().getEntity());
    host.setPmKdumpDetection(model.getPmKdumpDetection().getEntity());
    host.setCurrentKernelCmdline(model.getKernelCmdline().getEntity());
    host.setKernelCmdlineBlacklistNouveau(model.getKernelCmdlineBlacklistNouveau().getEntity());
    host.setKernelCmdlineParsable(model.isKernelCmdlineParsable());
    host.setKernelCmdlineIommu(model.getKernelCmdlineIommu().getEntity());
    host.setKernelCmdlineKvmNested(model.getKernelCmdlineKvmNested().getEntity());
    host.setKernelCmdlineUnsafeInterrupts(model.getKernelCmdlineUnsafeInterrupts().getEntity());
    host.setKernelCmdlinePciRealloc(model.getKernelCmdlinePciRealloc().getEntity());
    cancelConfirm();
    model.startProgress();
    if (model.getIsNew()) {
        AddVdsActionParameters parameters = new AddVdsActionParameters();
        parameters.setVdsId(host.getId());
        parameters.setvds(host);
        parameters.setFenceAgents(model.getFenceAgentListModel().getFenceAgents());
        if (model.getUserPassword().getEntity() != null) {
            parameters.setPassword(model.getUserPassword().getEntity());
        }
        parameters.setOverrideFirewall(model.getOverrideIpTables().getEntity());
        parameters.setAuthMethod(model.getAuthenticationMethod());
        Provider<?> networkProvider = model.getNetworkProviders().getSelectedItem();
        if (networkProvider != null) {
            parameters.getVdsStaticData().setOpenstackNetworkProviderId(networkProvider.getId());
            parameters.setNetworkMappings(model.getInterfaceMappings().getEntity());
        }
        if (model.getProviders().getSelectedItem() != null) {
            parameters.getVdsStaticData().setHostProviderId(model.getProviders().getSelectedItem().getId());
        }
        if (Boolean.TRUE.equals(model.getIsDiscoveredHosts().getEntity())) {
            Provider<?> provider = model.getProviders().getSelectedItem();
            ExternalHostGroup hostGroup = (ExternalHostGroup) model.getExternalHostGroups().getSelectedItem();
            ExternalComputeResource computeResource = (ExternalComputeResource) model.getExternalComputeResource().getSelectedItem();
            ExternalDiscoveredHost discoveredHost = (ExternalDiscoveredHost) model.getExternalDiscoveredHosts().getSelectedItem();
            parameters.initVdsActionParametersForProvision(provider.getId(), hostGroup, computeResource, discoveredHost.getMac(), discoveredHost.getName(), discoveredHost.getIp());
        }
        parameters.setHostedEngineDeployConfiguration(new HostedEngineDeployConfiguration(model.getHostedEngineHostModel().getSelectedItem()));
        parameters.setAffinityLabels(model.getLabelList().getSelectedItems());
        Frontend.getInstance().runAction(ActionType.AddVds, parameters, result -> {
            Object[] array = (Object[]) result.getState();
            HostListModel<Void> localModel = (HostListModel<Void>) array[0];
            boolean localApproveInitiated = (Boolean) array[1];
            localModel.postOnSaveInternal(result.getReturnValue(), localApproveInitiated);
        }, new Object[] { this, approveInitiated });
    } else {
        // Update VDS -> consists of changing VDS cluster first and then updating rest of VDS properties:
        UpdateVdsActionParameters parameters = new UpdateVdsActionParameters();
        parameters.setvds(host);
        parameters.setVdsId(host.getId());
        // $NON-NLS-1$
        parameters.setPassword("");
        parameters.setInstallHost(false);
        parameters.setAuthMethod(model.getAuthenticationMethod());
        parameters.setFenceAgents(model.getFenceAgentListModel().getFenceAgents());
        parameters.setAffinityLabels(model.getLabelList().getSelectedItems());
        if (model.getExternalHostProviderEnabled().getEntity() && model.getProviders().getSelectedItem() != null) {
            host.setHostProviderId(model.getProviders().getSelectedItem().getId());
        }
        if (!oldClusterId.equals(newClusterId)) {
            Frontend.getInstance().runAction(ActionType.ChangeVDSCluster, new ChangeVDSClusterParameters(newClusterId, host.getId()), result -> {
                Object[] array = (Object[]) result.getState();
                HostListModel<Void> localModel = (HostListModel<Void>) array[0];
                UpdateVdsActionParameters localParameters = (UpdateVdsActionParameters) array[1];
                boolean localApproveInitiated = (Boolean) array[2];
                ActionReturnValue localReturnValue = result.getReturnValue();
                if (localReturnValue != null && localReturnValue.getSucceeded()) {
                    localModel.postOnSaveInternalChangeCluster(localParameters, localApproveInitiated);
                } else {
                    localModel.getWindow().stopProgress();
                }
            }, new Object[] { this, parameters, approveInitiated });
        } else {
            postOnSaveInternalChangeCluster(parameters, approveInitiated);
        }
    }
}
Also used : ExternalComputeResource(org.ovirt.engine.core.common.businessentities.ExternalComputeResource) ExternalDiscoveredHost(org.ovirt.engine.core.common.businessentities.ExternalDiscoveredHost) VDS(org.ovirt.engine.core.common.businessentities.VDS) ExternalHostGroup(org.ovirt.engine.core.common.businessentities.ExternalHostGroup) Guid(org.ovirt.engine.core.compat.Guid) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) UpdateVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) JsSingleValueStringObject(org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject) HostedEngineDeployConfiguration(org.ovirt.engine.core.common.businessentities.HostedEngineDeployConfiguration)

Example 8 with AddVdsActionParameters

use of org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters in project ovirt-engine by oVirt.

the class RegisterVdsQuery method registerNewHost.

private boolean registerNewHost(Guid clusterId, boolean pending) {
    boolean returnValue = true;
    VdsStatic vds = new VdsStatic(getParameters().getVdsHostName(), getStrippedVdsUniqueId(), getParameters().getVdsPort(), getParameters().getSSHPort(), getParameters().getSSHUser(), clusterId, Guid.Empty, getParameters().getVdsName(), Config.<Boolean>getValue(ConfigValues.SSLEnabled), VDSType.VDS, null);
    vds.setSshKeyFingerprint(getParameters().getSSHFingerprint());
    log.debug("RegisterVdsQuery::register - Will try now to add VDS from scratch; Name: '{}', Hostname: '{}', Unique: '{}', VdsPort: '{}',Subnet mask: '{}', isPending: '{}' with force synchronize", getParameters().getVdsName(), getParameters().getVdsHostName(), getStrippedVdsUniqueId(), getParameters().getVdsPort(), pending);
    AddVdsActionParameters p = new AddVdsActionParameters(vds, "");
    p.setPending(pending);
    ActionReturnValue ret = Backend.getInstance().runInternalAction(ActionType.AddVds, p);
    if (!ret.getSucceeded()) {
        log.error("RegisterVdsQuery::register - Registration failed for VDS - Name: '{}', Hostname: '{}', UniqueID: '{}', Subnet mask: '{}'", getParameters().getVdsName(), getParameters().getVdsHostName(), getStrippedVdsUniqueId());
        captureCommandErrorsToLogger(ret, "RegisterVdsQuery::register");
        error = AuditLogType.VDS_REGISTER_FAILED;
        returnValue = false;
    } else {
        log.info("RegisterVdsQuery::register - Registered a new VDS '{}' - Name: '{}', Hostname: '{}', UniqueID: '{}'", pending ? "pending approval" : "automatically approved", getParameters().getVdsName(), getParameters().getVdsHostName(), getStrippedVdsUniqueId());
    }
    return returnValue;
}
Also used : VdsStatic(org.ovirt.engine.core.common.businessentities.VdsStatic) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)

Aggregations

AddVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters)8 VDS (org.ovirt.engine.core.common.businessentities.VDS)6 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)4 ArrayList (java.util.ArrayList)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 VdsStatic (org.ovirt.engine.core.common.businessentities.VdsStatic)2 Guid (org.ovirt.engine.core.compat.Guid)2 HostDetailModel (org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel)2 HostModel (org.ovirt.engine.ui.uicommonweb.models.hosts.HostModel)2 NewHostModel (org.ovirt.engine.ui.uicommonweb.models.hosts.NewHostModel)2 Host (org.ovirt.engine.api.model.Host)1 ChangeVDSClusterParameters (org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)1 VdsOperationActionParameters (org.ovirt.engine.core.common.action.VdsOperationActionParameters)1 UpdateVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters)1 ExternalComputeResource (org.ovirt.engine.core.common.businessentities.ExternalComputeResource)1 ExternalDiscoveredHost (org.ovirt.engine.core.common.businessentities.ExternalDiscoveredHost)1 ExternalHostGroup (org.ovirt.engine.core.common.businessentities.ExternalHostGroup)1 HostedEngineDeployConfiguration (org.ovirt.engine.core.common.businessentities.HostedEngineDeployConfiguration)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1 JsSingleValueStringObject (org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject)1