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());
}
}
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());
}
}
}
}
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));
}
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;
}
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);
}
}
Aggregations