MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory();
CloudConfigFactory cloudConfigFactory=new CloudConfigFactory();
+
+ protected MsoNeutronUtils neutron;
+
+ protected MsoHeatUtils heat;
+
+ protected MsoHeatUtilsWithUpdate heatWithUpdate;
private static final String AIC3_NW_PROPERTY= "org.openecomp.mso.adapters.network.aic3nw";
private static final String AIC3_NW="OS::ContrailV2::VirtualNetwork";
private static final String NEUTRON_MODE = "NEUTRON";
private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
- protected CloudConfig cloudConfig;
/**
* Health Check web method. Does nothing but return to show the adapter is deployed.
public MsoNetworkAdapterImpl(MsoPropertiesFactory msoPropFactory,CloudConfigFactory cloudConfigFact) {
this.msoPropertiesFactory = msoPropFactory;
this.cloudConfigFactory=cloudConfigFact;
- cloudConfig = cloudConfigFactory.getCloudConfig ();
+ neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
+ heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory, cloudConfigFactory);
+ heatWithUpdate = new MsoHeatUtilsWithUpdate(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
+ cloudConfigFactory);
}
@Override
* the orchestration fails on a subsequent operation.
*/
- private void createNetwork (String cloudSiteId,
+ protected void createNetwork (String cloudSiteId,
String tenantId,
String networkType,
String modelCustomizationUuid,
// If the tenant doesn’t exist, the Heat calls will fail anyway (when the HeatUtils try to obtain a token).
// So this is just catching that error in a bit more obvious way up front.
- cloudConfig = cloudConfigFactory.getCloudConfig ();
+ CloudConfig cloudConfig = getCloudConfigFactory().getCloudConfig ();
Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite(cloudSiteId);
if (!cloudSiteOpt.isPresent())
{
if (NEUTRON_MODE.equals(mode)) {
- // Use an MsoNeutronUtils for all neutron commands
- MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
-
// See if the Network already exists (by name)
NetworkInfo netInfo = null;
long queryNetworkStarttime = System.currentTimeMillis();
LOGGER.debug("Network " + networkName + " created, id = " + netInfo.getId());
} else if ("HEAT".equals(mode)) {
- // Use an MsoHeatUtils for all Heat commands
- MsoHeatUtils heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
- cloudConfigFactory);
-
//HeatTemplate heatTemplate = db.getHeatTemplate (networkResource.getTemplateId ());
HeatTemplate heatTemplate = db
.getHeatTemplateByArtifactUuidRegularQuery(networkResource.getHeatTemplateArtifactUUID());
networkRollback.setTenantId (tenantId);
networkRollback.setMsoRequest (msoRequest);
- cloudConfig = cloudConfigFactory.getCloudConfig ();
+ CloudConfig cloudConfig = getCloudConfigFactory().getCloudConfig ();
Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite (cloudSiteId);
if (!cloudSiteOpt.isPresent()) {
String error = "UpdateNetwork: Configuration Error. Stack " + networkName + " in "
String mode = networkResource.getOrchestrationMode();
NetworkType neutronNetworkType = NetworkType.valueOf(networkResource.getNeutronNetworkType());
- // Use an MsoNeutronUtils for all Neutron commands
- MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
-
if (NEUTRON_MODE.equals(mode)) {
// Verify that the Network exists
LOGGER.debug("Network " + networkId + " updated, id = " + netInfo.getId());
} else if ("HEAT".equals(mode)) {
- // Use an MsoHeatUtils for all Heat commands
- MsoHeatUtilsWithUpdate heat = new MsoHeatUtilsWithUpdate(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
- cloudConfigFactory);
-
// First, look up to see that the Network already exists.
// For Heat-based orchestration, the networkId is the network Stack ID.
StackInfo heatStack = null;
long queryStackStarttime = System.currentTimeMillis();
try {
- heatStack = heat.queryStack(cloudSiteId, tenantId, networkName);
+ heatStack = heatWithUpdate.queryStack(cloudSiteId, tenantId, networkName);
LOGGER.recordMetricEvent(queryStackStarttime, MsoLogger.StatusCode.COMPLETE,
MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", "OpenStack",
"QueryStack", null);
// Validate (and update) the input parameters against the DB definition
// Shouldn't happen unless DB config is wrong, since all networks use same inputs
try {
- stackParams = heat.validateStackParams(stackParams, heatTemplate);
+ stackParams = heatWithUpdate.validateStackParams(stackParams, heatTemplate);
} catch (IllegalArgumentException e) {
String error = "UpdateNetwork: Configuration Error: Network Type=" + networkType;
LOGGER.error(MessageEnum.RA_CONFIG_EXC, "Network Type=" + networkType, "OpenStack", "",
// Ignore MsoStackNotFound exception because we already checked.
long updateStackStarttime = System.currentTimeMillis();
try {
- heatStack = heat.updateStack(cloudSiteId,
+ heatStack = heatWithUpdate.updateStack(cloudSiteId,
tenantId,
networkId,
template,
return;
}
- private NetworkResource networkCheck (CatalogDatabase db,
+ protected NetworkResource networkCheck (CatalogDatabase db,
long startTime,
String networkType,
String modelCustomizationUuid,
throw new NetworkException (error, MsoExceptionCategory.USERDATA);
}
- cloudConfig = cloudConfigFactory.getCloudConfig();
+ CloudConfig cloudConfig = getCloudConfigFactory().getCloudConfig();
Optional<CloudSite> cloudSiteOpt = cloudConfig.getCloudSite(cloudSiteId);
if (!cloudSiteOpt.isPresent())
{
throw new NetworkException (error, MsoExceptionCategory.USERDATA);
}
- // Use MsoNeutronUtils for all NEUTRON commands
- MsoHeatUtils heat = new MsoHeatUtils (MSO_PROP_NETWORK_ADAPTER,msoPropertiesFactory,cloudConfigFactory);
- MsoNeutronUtils neutron = new MsoNeutronUtils (MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
-
String mode;
String neutronId;
// Try Heat first, since networks may be named the same as the Heat stack
}
if (NEUTRON_MODE.equals(mode)) {
-
- // Use MsoNeutronUtils for all NEUTRON commands
- MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
long deleteNetworkStarttime = System.currentTimeMillis();
try {
// The deleteNetwork function in MsoNeutronUtils returns success if the network
}
} else { // DEFAULT to ("HEAT".equals (mode))
long deleteStackStarttime = System.currentTimeMillis();
- // Use MsoHeatUtils for all HEAT commands
- MsoHeatUtils heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
- cloudConfigFactory);
try {
// The deleteStack function in MsoHeatUtils returns NOTFOUND if the stack was not found or if the stack was deleted.
return CatalogDatabase.getInstance();
}
+ public CloudConfigFactory getCloudConfigFactory() {
+ return cloudConfigFactory;
+ }
+
/**
* This web service endpoint will rollback a previous Create VNF operation.
* A rollback object is returned to the client in a successful creation
// Rolling back a newly created network, so delete it.
if (NEUTRON_MODE.equals(mode)) {
// Use MsoNeutronUtils for all NEUTRON commands
- MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, cloudConfigFactory);
+ MsoNeutronUtils neutron = new MsoNeutronUtils(MSO_PROP_NETWORK_ADAPTER, getCloudConfigFactory());
long deleteNetworkStarttime = System.currentTimeMillis();
try {
// The deleteNetwork function in MsoNeutronUtils returns success if the network
} else { // DEFAULT to if ("HEAT".equals (mode))
// Use MsoHeatUtils for all HEAT commands
MsoHeatUtils heat = new MsoHeatUtils(MSO_PROP_NETWORK_ADAPTER, msoPropertiesFactory,
- cloudConfigFactory);
+ getCloudConfigFactory());
long deleteStackStarttime = System.currentTimeMillis();
try {
// The deleteStack function in MsoHeatUtils returns success if the stack
return missing.toString ();
}
- private Map <String, Object> populateNetworkParams (NetworkType neutronNetworkType,
+ protected Map <String, Object> populateNetworkParams (NetworkType neutronNetworkType,
String networkName,
String physicalNetwork,
List <Integer> vlans,