Search in sources :

Example 1 with OpenstackNetworkProviderProperties

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

the class NeutronAgentModel method flush.

public void flush(Provider<OpenstackNetworkProviderProperties> provider) {
    OpenstackNetworkProviderProperties properties = provider.getAdditionalProperties();
    if (properties == null) {
        properties = new OpenstackNetworkProviderProperties();
        provider.setAdditionalProperties(properties);
    }
    properties.setPluginType(NetworkProviderPluginTranslator.getPluginNameForDisplayString(getPluginType().getSelectedItem()));
    if (!isPluginConfigurationAvailable().getEntity()) {
        properties.setAgentConfiguration(null);
    } else {
        AgentConfiguration agentConfiguration = properties.getAgentConfiguration();
        if (agentConfiguration == null) {
            agentConfiguration = new AgentConfiguration();
            properties.setAgentConfiguration(agentConfiguration);
        }
        agentConfiguration.setNetworkMappings(getInterfaceMappings().getEntity());
        MessagingConfiguration messagingConfiguration = agentConfiguration.getMessagingConfiguration();
        if (messagingConfiguration == null) {
            messagingConfiguration = new MessagingConfiguration();
            agentConfiguration.setMessagingConfiguration(messagingConfiguration);
        }
        messagingConfiguration.setAddress(getMessagingServer().getEntity());
        String port = getMessagingServerPort().getEntity();
        messagingConfiguration.setPort(port == null ? null : Integer.valueOf(port));
        messagingConfiguration.setUsername(getMessagingServerUsername().getEntity());
        messagingConfiguration.setPassword(getMessagingServerPassword().getEntity());
        messagingConfiguration.setBrokerType(getBrokerType().getSelectedItem());
    }
}
Also used : AgentConfiguration(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties.AgentConfiguration) MessagingConfiguration(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties.MessagingConfiguration) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties)

Example 2 with OpenstackNetworkProviderProperties

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

the class NeutronAgentModel method init.

public void init(Provider<OpenstackNetworkProviderProperties> provider, ProviderType type) {
    OpenstackNetworkProviderProperties properties = provider.getAdditionalProperties();
    NetworkProviderPluginTranslator translator = NetworkProviderPluginTranslator.getTranslatorByProviderType(type);
    String pluginName = translator.getDisplayStringForPluginName(properties == null ? translator.getDefault() : properties.getPluginType());
    List<String> displayItems = translator.getPresetDisplayStrings();
    getPluginType().setItems(displayItems);
    getPluginType().setSelectedItem(pluginName);
    pluginValidator = translator.getPluginValidator();
    if (properties != null) {
        AgentConfiguration agentConfiguration = properties.getAgentConfiguration();
        if (agentConfiguration != null) {
            getInterfaceMappings().setEntity(agentConfiguration.getNetworkMappings());
            MessagingConfiguration messagingConfiguration = agentConfiguration.getMessagingConfiguration();
            if (messagingConfiguration != null) {
                getBrokerType().setSelectedItem(messagingConfiguration.getBrokerType());
                getMessagingServer().setEntity(messagingConfiguration.getAddress());
                Integer port = messagingConfiguration.getPort();
                getMessagingServerPort().setEntity(port == null ? null : Integer.toString(port));
                getMessagingServerUsername().setEntity(messagingConfiguration.getUsername());
                getMessagingServerPassword().setEntity(messagingConfiguration.getPassword());
            }
        }
    }
}
Also used : AgentConfiguration(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties.AgentConfiguration) MessagingConfiguration(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties.MessagingConfiguration) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties)

Example 3 with OpenstackNetworkProviderProperties

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

the class NetworkProviderValidator method validatePluginType.

public ValidationResult validatePluginType() {
    OpenstackNetworkProviderProperties properties = (OpenstackNetworkProviderProperties) provider.getAdditionalProperties();
    String pluginType = properties.getPluginType();
    return ValidationResult.failWith(EngineMessage.ACTION_TYPE_FAILED_PROVIDER_NO_PLUGIN_TYPE).when(StringUtils.isEmpty(pluginType));
}
Also used : OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties)

Example 4 with OpenstackNetworkProviderProperties

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

the class OpenStackNetworkProviderMapper method map.

@Mapping(from = Provider.class, to = OpenStackNetworkProvider.class)
public static OpenStackNetworkProvider map(Provider<OpenstackNetworkProviderProperties> entity, OpenStackNetworkProvider template) {
    OpenStackNetworkProvider model = template != null ? template : new OpenStackNetworkProvider();
    model.setType(mapProviderType(entity.getType()));
    if (entity.getId() != null) {
        model.setId(entity.getId().toString());
    }
    if (entity.getName() != null) {
        model.setName(entity.getName());
    }
    if (entity.getDescription() != null) {
        model.setDescription(entity.getDescription());
    }
    if (entity.getUrl() != null) {
        model.setUrl(entity.getUrl());
    }
    if (entity.getAuthUrl() != null) {
        model.setAuthenticationUrl(entity.getAuthUrl());
    }
    model.setUnmanaged(entity.getIsUnmanaged());
    model.setRequiresAuthentication(entity.isRequiringAuthentication());
    if (entity.getUsername() != null) {
        model.setUsername(entity.getUsername());
    }
    // The password isn't mapped for security reasons.
    // if (entity.getPassword() != null) {
    // model.setPassword(entity.getPassword());
    // }
    Map<String, String> customProperties = entity.getCustomProperties();
    if (customProperties != null) {
        Properties properties = new Properties();
        for (Map.Entry<String, String> entry : customProperties.entrySet()) {
            Property property = new Property();
            property.setName(entry.getKey());
            property.setValue(entry.getValue());
            properties.getProperties().add(property);
        }
        model.setProperties(properties);
    }
    OpenstackNetworkProviderProperties additionalProperties = entity.getAdditionalProperties();
    if (additionalProperties != null) {
        if (additionalProperties.getTenantName() != null) {
            model.setTenantName(additionalProperties.getTenantName());
        }
        String pluginType = additionalProperties.getPluginType();
        if (pluginType != null) {
            // for backwards compatibility, and should be removed in version 5 of the API.
            if (entity.getType() == ProviderType.OPENSTACK_NETWORK && OpenstackNetworkPluginType.OPEN_VSWITCH.name().equalsIgnoreCase(pluginType)) {
                model.setPluginType(NetworkPluginType.OPEN_VSWITCH);
            }
            model.setExternalPluginType(additionalProperties.getPluginType());
        }
        if (additionalProperties.getAgentConfiguration() != null) {
            model.setAgentConfiguration(map(additionalProperties.getAgentConfiguration(), null));
        }
        model.setReadOnly(additionalProperties.getReadOnly());
        model.setAutoSync(additionalProperties.getAutoSync());
    }
    return model;
}
Also used : OpenStackNetworkProvider(org.ovirt.engine.api.model.OpenStackNetworkProvider) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) Properties(org.ovirt.engine.api.model.Properties) HashMap(java.util.HashMap) Map(java.util.Map) Property(org.ovirt.engine.api.model.Property) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) Mapping(org.ovirt.engine.api.restapi.types.Mapping)

Example 5 with OpenstackNetworkProviderProperties

use of org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties 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)

Aggregations

OpenstackNetworkProviderProperties (org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties)14 AgentConfiguration (org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties.AgentConfiguration)4 Provider (org.ovirt.engine.core.common.businessentities.Provider)3 AdditionalProperties (org.ovirt.engine.core.common.businessentities.Provider.AdditionalProperties)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2 OpenStackImageProviderProperties (org.ovirt.engine.core.common.businessentities.OpenStackImageProviderProperties)2 MessagingConfiguration (org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties.MessagingConfiguration)2 OpenStackVolumeProviderProperties (org.ovirt.engine.core.common.businessentities.storage.OpenStackVolumeProviderProperties)2 GroupedListModelListBox (org.ovirt.engine.ui.common.widget.editor.GroupedListModelListBox)2 EntityModelCheckBoxEditor (org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor)2 EntityModelRadioButtonEditor (org.ovirt.engine.ui.common.widget.editor.generic.EntityModelRadioButtonEditor)2 EnumRenderer (org.ovirt.engine.ui.common.widget.renderer.EnumRenderer)2 NameRenderer (org.ovirt.engine.ui.common.widget.renderer.NameRenderer)2 AbstractRenderer (com.google.gwt.text.shared.AbstractRenderer)1 RadioButton (com.google.gwt.user.client.ui.RadioButton)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 TimeUnit (java.util.concurrent.TimeUnit)1