Search in sources :

Example 1 with FirewallType

use of org.ovirt.engine.core.common.network.FirewallType in project ovirt-engine by oVirt.

the class InstallVdsInternalCommand method installHost.

private void installHost() {
    try (final VdsDeploy deploy = new VdsDeploy("ovirt-host-deploy", getVds(), true)) {
        log.info("Before Installation host {}, {}", getVds().getId(), getVds().getName());
        T parameters = getParameters();
        deploy.setCorrelationId(getCorrelationId());
        deploy.addUnit(new VdsDeployMiscUnit(), new VdsDeployVdsmUnit(), new VdsDeployPKIUnit(), new VdsDeployKdumpUnit(), new VdsDeployKernelUnit());
        if (parameters.getNetworkProviderId() != null) {
            Provider<?> provider = providerDao.get(parameters.getNetworkProviderId());
            if (provider.getType() == ProviderType.OPENSTACK_NETWORK) {
                OpenstackNetworkProviderProperties agentProperties = (OpenstackNetworkProviderProperties) provider.getAdditionalProperties();
                if (StringUtils.isNotBlank(parameters.getNetworkMappings())) {
                    agentProperties.getAgentConfiguration().setNetworkMappings(parameters.getNetworkMappings());
                }
                deploy.addUnit(new VdsDeployOpenStackUnit(agentProperties));
            }
        }
        Cluster hostCluster = clusterDao.get(getClusterId());
        FirewallType hostFirewallType = hostCluster.getFirewallType();
        if (parameters.getOverrideFirewall()) {
            switch(getVds().getVdsType()) {
                case VDS:
                case oVirtNode:
                    deploy.addUnit(new VdsDeployIptablesUnit(hostFirewallType.equals(FirewallType.IPTABLES)));
                    break;
                case oVirtVintageNode:
                    log.warn("Installation of Host {} will ignore Firewall Override option, since it is not supported for Host type {}", getVds().getName(), getVds().getVdsType().name());
                    break;
                default:
                    throw new IllegalArgumentException(String.format("Not handled VDS type: %1$s", getVds().getVdsType()));
            }
        }
        if (parameters.getEnableSerialConsole()) {
            deploy.addUnit(new VdsDeployVmconsoleUnit());
        }
        if (MapUtils.isNotEmpty(parameters.getHostedEngineConfiguration())) {
            deploy.addUnit(new VdsDeployHostedEngineUnit(parameters.getHostedEngineConfiguration()));
        }
        switch(getParameters().getAuthMethod()) {
            case Password:
                deploy.setPassword(parameters.getPassword());
                break;
            case PublicKey:
                deploy.useDefaultKeyPair();
                break;
            default:
                throw new Exception("Invalid authentication method value was sent to InstallVdsInternalCommand");
        }
        setVdsStatus(VDSStatus.Installing);
        deploy.execute();
        switch(deploy.getDeployStatus()) {
            case Failed:
                throw new VdsInstallException(VDSStatus.InstallFailed, StringUtils.EMPTY);
            case Incomplete:
                markCurrentCmdlineAsStored();
                throw new VdsInstallException(VDSStatus.InstallFailed, "Partial installation");
            case Reboot:
                markCurrentCmdlineAsStored();
                markVdsReinstalled();
                setVdsStatus(VDSStatus.Reboot);
                runSleepOnReboot(getStatusOnReboot());
                break;
            case Complete:
                markCurrentCmdlineAsStored();
                markVdsReinstalled();
                // TODO: When more logic goes to ovirt-host-deploy role,
                // this code should be moved to appropriate place, currently
                // we run this playbook only after successful run of otopi host-deploy
                runAnsibleHostDeployPlaybook(hostCluster);
                configureManagementNetwork();
                if (!getParameters().getActivateHost() && VDSStatus.Maintenance.equals(vdsInitialStatus)) {
                    setVdsStatus(VDSStatus.Maintenance);
                } else {
                    setVdsStatus(VDSStatus.Initializing);
                }
                break;
        }
        log.info("After Installation host {}, {}", getVds().getName(), getVds().getVdsType().name());
        setSucceeded(true);
    } catch (VdsInstallException e) {
        handleError(e, e.getStatus());
    } catch (Exception e) {
        handleError(e, VDSStatus.InstallFailed);
    }
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) IOException(java.io.IOException) VDSNetworkException(org.ovirt.engine.core.vdsbroker.vdsbroker.VDSNetworkException) FirewallType(org.ovirt.engine.core.common.network.FirewallType) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties)

Example 2 with FirewallType

use of org.ovirt.engine.core.common.network.FirewallType in project ovirt-engine by oVirt.

the class ClusterOperationCommandBase method setDefaultFirewallTypeIfNeeded.

protected void setDefaultFirewallTypeIfNeeded() {
    Cluster cluster = getCluster();
    if (cluster.getFirewallType() == null) {
        FirewallType defaultFirewallType = DefaultFirewallType.getDefaultFirewallType(cluster.getCompatibilityVersion());
        cluster.setFirewallType(defaultFirewallType);
    }
}
Also used : FirewallType(org.ovirt.engine.core.common.network.FirewallType) DefaultFirewallType(org.ovirt.engine.core.common.network.DefaultFirewallType) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster)

Aggregations

Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 FirewallType (org.ovirt.engine.core.common.network.FirewallType)2 IOException (java.io.IOException)1 OpenstackNetworkProviderProperties (org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties)1 NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)1 DefaultFirewallType (org.ovirt.engine.core.common.network.DefaultFirewallType)1 VDSNetworkException (org.ovirt.engine.core.vdsbroker.vdsbroker.VDSNetworkException)1