move creation of segments to design phase

This commit is contained in:
Pearl Dsilva 2023-09-27 11:32:17 -04:00
parent cec7bebce6
commit 272704c4a7
27 changed files with 91 additions and 57 deletions

View File

@ -79,20 +79,22 @@ public interface NetworkGuru extends Adapter {
* be used to make determination can be isolation methods, services
* provided on the guest network and the service provider that's on the
* guest network.
*
* <p>
* If a network is already fully substantiated with the necessary resources
* during this design phase, then the state should be set to Setup. If
* the resources are not allocated at this point, the state should be set
* to Allocated.
*
* @param offering network offering that contains the package of services
* the end user intends to use on that network.
* @param plan where is this network being deployed.
* @param offering network offering that contains the package of services
* the end user intends to use on that network.
* @param plan where is this network being deployed.
* @param userSpecified user specified parameters for this network.
* @param owner owner of this network.
* @param name
* @param vpcId
* @param owner owner of this network.
* @return Network
*/
Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner);
Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner);
/**
* For guest networks that are in Allocated state after the design stage,

View File

@ -764,7 +764,7 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
long related = -1;
for (final NetworkGuru guru : networkGurus) {
final Network network = guru.design(offering, plan, predefined, owner);
final Network network = guru.design(offering, plan, predefined, name, vpcId, owner);
if (network == null) {
continue;
}

View File

@ -145,7 +145,7 @@ public class BigSwitchBcfGuestNetworkGuru extends GuestNetworkGuru implements Ne
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner) {
// Check if the isolation type of the physical network is BCF_SEGMENT, then delegate GuestNetworkGuru to design
PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
if (physnet == null || physnet.getIsolationMethods() == null || !physnet.getIsolationMethods().contains("BCF_SEGMENT")) {
@ -164,7 +164,7 @@ public class BigSwitchBcfGuestNetworkGuru extends GuestNetworkGuru implements Ne
}
s_logger.debug("Physical isolation type is BCF_SEGMENT, asking GuestNetworkGuru to design this network");
NetworkVO networkObject = (NetworkVO)super.design(offering, plan, userSpecified, owner);
NetworkVO networkObject = (NetworkVO)super.design(offering, plan, userSpecified, name, vpcId, owner);
if (networkObject == null) {
return null;
}

View File

@ -97,7 +97,7 @@ public class BrocadeVcsGuestNetworkGuru extends GuestNetworkGuru {
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner) {
// Check of the isolation type of the related physical network is VLAN
PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
@ -106,7 +106,7 @@ public class BrocadeVcsGuestNetworkGuru extends GuestNetworkGuru {
return null;
}
s_logger.debug("Physical isolation type is VCS, asking GuestNetworkGuru to design this network");
NetworkVO networkObject = (NetworkVO)super.design(offering, plan, userSpecified, owner);
NetworkVO networkObject = (NetworkVO)super.design(offering, plan, userSpecified, name, vpcId, owner);
if (networkObject == null) {
return null;
}

View File

@ -170,7 +170,7 @@ public class BrocadeVcsGuestNetworkGuruTest {
final Network network = mock(Network.class);
final Account account = mock(Account.class);
final Network designednetwork = guru.design(offering, plan, network, account);
final Network designednetwork = guru.design(offering, plan, network, "", 1L, account);
assertTrue(designednetwork != null);
assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Vcs);
}
@ -191,7 +191,7 @@ public class BrocadeVcsGuestNetworkGuruTest {
final Network network = mock(Network.class);
final Account account = mock(Account.class);
final Network designednetwork = guru.design(offering, plan, network, account);
final Network designednetwork = guru.design(offering, plan, network, "", 1L, account);
assertTrue(designednetwork == null);
}
@ -213,7 +213,7 @@ public class BrocadeVcsGuestNetworkGuruTest {
final Network network = mock(Network.class);
final Account account = mock(Account.class);
final Network designednetwork = guru.design(offering, plan, network, account);
final Network designednetwork = guru.design(offering, plan, network, "", 1L, account);
assertTrue(designednetwork == null);
}

View File

@ -119,7 +119,7 @@ public class ContrailGuru extends AdapterBase implements NetworkGuru {
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner) {
// Check of the isolation type of the related physical network is L3VPN
PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
DataCenter dc = _dcDao.findById(plan.getDataCenterId());

View File

@ -111,7 +111,7 @@ public class ManagementNetworkGuru extends ContrailGuru {
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner) {
if (!canHandle(offering)) {
return null;

View File

@ -138,7 +138,7 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru implements Netwo
}
@Override
public Network design(final NetworkOffering offering, final DeploymentPlan plan, final Network userSpecified, final Account owner) {
public Network design(final NetworkOffering offering, final DeploymentPlan plan, final Network userSpecified, String name, Long vpcId, final Account owner) {
// Check of the isolation type of the related physical network is supported
final PhysicalNetworkVO physnet = physicalNetworkDao.findById(plan.getPhysicalNetworkId());
final DataCenter dc = _dcDao.findById(plan.getDataCenterId());
@ -155,7 +155,7 @@ public class NiciraNvpGuestNetworkGuru extends GuestNetworkGuru implements Netwo
s_logger.debug("Nicira Nvp " + devices.get(0).getUuid() + " found on physical network " + physnet.getId());
s_logger.debug("Physical isolation type is supported, asking GuestNetworkGuru to design this network");
final NetworkVO networkObject = (NetworkVO) super.design(offering, plan, userSpecified, owner);
final NetworkVO networkObject = (NetworkVO) super.design(offering, plan, userSpecified, name, vpcId, owner);
if (networkObject == null) {
return null;
}

View File

@ -168,7 +168,7 @@ public class NiciraNvpGuestNetworkGuruTest {
final Network network = mock(Network.class);
final Account account = mock(Account.class);
final Network designednetwork = guru.design(offering, plan, network, account);
final Network designednetwork = guru.design(offering, plan, network, "", 1L, account);
assertTrue(designednetwork != null);
assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Lswitch);
}
@ -192,7 +192,7 @@ public class NiciraNvpGuestNetworkGuruTest {
final Network network = mock(Network.class);
final Account account = mock(Account.class);
final Network designednetwork = guru.design(offering, plan, network, account);
final Network designednetwork = guru.design(offering, plan, network, "", 1L, account);
assertTrue(designednetwork == null);
}
@ -215,7 +215,7 @@ public class NiciraNvpGuestNetworkGuruTest {
final Network network = mock(Network.class);
final Account account = mock(Account.class);
final Network designednetwork = guru.design(offering, plan, network, account);
final Network designednetwork = guru.design(offering, plan, network, "", 1L, account);
assertTrue(designednetwork == null);
}
@ -241,7 +241,7 @@ public class NiciraNvpGuestNetworkGuruTest {
final Network network = mock(Network.class);
final Account account = mock(Account.class);
final Network designednetwork = guru.design(offering, plan, network, account);
final Network designednetwork = guru.design(offering, plan, network, "", 1L, account);
assertTrue(designednetwork == null);
}

View File

@ -76,7 +76,7 @@ public class NsxGuestNetworkGuru extends GuestNetworkGuru implements NetworkMigr
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner) {
PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
@ -85,7 +85,7 @@ public class NsxGuestNetworkGuru extends GuestNetworkGuru implements NetworkMigr
return null;
}
NetworkVO network = (NetworkVO) super.design(offering, plan, userSpecified, owner);
NetworkVO network = (NetworkVO) super.design(offering, plan, userSpecified, name, vpcId, owner);
network.setBroadcastDomainType(Networks.BroadcastDomainType.NSX);
if (network == null) {
return null;
@ -104,6 +104,38 @@ public class NsxGuestNetworkGuru extends GuestNetworkGuru implements NetworkMigr
network.setBroadcastDomainType(Networks.BroadcastDomainType.NSX);
network.setState(Network.State.Allocated);
NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(),
network.getBroadcastDomainType(), network.getNetworkOfferingId(), Network.State.Implemented,
network.getDataCenterId(), network.getPhysicalNetworkId(), offering.isRedundantRouter());
implemented.setAccountId(owner.getAccountId());
if (network.getGateway() != null) {
implemented.setGateway(network.getGateway());
}
if (network.getCidr() != null) {
implemented.setCidr(network.getCidr());
}
if (vpcId != null) {
implemented.setVpcId(vpcId);
}
if (name != null) {
implemented.setName(name);
}
implemented.setBroadcastUri(Networks.BroadcastDomainType.NSX.toUri("nsx"));
try {
long zoneId = network.getDataCenterId();
DataCenter zone = zoneDao.findById(zoneId);
if (isNull(zone)) {
throw new CloudRuntimeException(String.format("Failed to find zone with id: %s", zoneId));
}
createNsxSegment(implemented, zone);
} catch (Exception ex) {
throw new CloudRuntimeException("unable to create NSX network " + network.getUuid() + "due to: " + ex.getMessage());
}
return network;
}
@ -137,16 +169,16 @@ public class NsxGuestNetworkGuru extends GuestNetworkGuru implements NetworkMigr
implemented.setName(network.getName());
}
implemented.setBroadcastUri(Networks.BroadcastDomainType.NSX.toUri("nsx"));
try {
long zoneId = network.getDataCenterId();
DataCenter zone = zoneDao.findById(zoneId);
if (isNull(zone)) {
throw new CloudRuntimeException(String.format("Failed to find zone with id: %s", zoneId));
}
createNsxSegment(implemented, zone);
} catch (Exception ex) {
throw new CloudRuntimeException("unable to create NSX network " + network.getUuid() + "due to: " + ex.getMessage());
}
// try {
// long zoneId = network.getDataCenterId();
// DataCenter zone = zoneDao.findById(zoneId);
// if (isNull(zone)) {
// throw new CloudRuntimeException(String.format("Failed to find zone with id: %s", zoneId));
// }
// createNsxSegment(implemented, zone);
// } catch (Exception ex) {
// throw new CloudRuntimeException("unable to create NSX network " + network.getUuid() + "due to: " + ex.getMessage());
// }
return implemented;
}

View File

@ -99,7 +99,7 @@ public class OpendaylightGuestNetworkGuru extends GuestNetworkGuru {
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner) {
PhysicalNetworkVO physnet = physicalNetworkDao.findById(plan.getPhysicalNetworkId());
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
if (!canHandle(offering, dc.getNetworkType(), physnet)) {
@ -115,7 +115,7 @@ public class OpendaylightGuestNetworkGuru extends GuestNetworkGuru {
s_logger.debug("Controller " + devices.get(0).getUuid() + " found on physical network " + physnet.getId());
s_logger.debug("Physical isolation type is ODL, asking GuestNetworkGuru to design this network");
NetworkVO networkObject = (NetworkVO)super.design(offering, plan, userSpecified, owner);
NetworkVO networkObject = (NetworkVO)super.design(offering, plan, userSpecified, name, vpcId, owner);
if (networkObject == null) {
return null;
}

View File

@ -97,7 +97,7 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan,
Network userSpecified, Account owner) {
Network userSpecified, String name, Long vpcId, Account owner) {
PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan
.getPhysicalNetworkId());
@ -107,7 +107,7 @@ public class OvsGuestNetworkGuru extends GuestNetworkGuru {
return null;
}
NetworkVO config = (NetworkVO)super.design(offering, plan,
userSpecified, owner);
userSpecified, name, vpcId, owner);
if (config == null) {
return null;
}

View File

@ -147,7 +147,7 @@ public class TungstenGuestNetworkGuru extends GuestNetworkGuru implements Networ
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner) {
PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
@ -157,7 +157,7 @@ public class TungstenGuestNetworkGuru extends GuestNetworkGuru implements Networ
return null;
}
NetworkVO network = (NetworkVO) super.design(offering, plan, userSpecified, owner);
NetworkVO network = (NetworkVO) super.design(offering, plan, userSpecified, name, vpcId, owner);
if (network == null) {
return null;

View File

@ -233,7 +233,7 @@ public class TungstenGuestNetworkGuruTest {
final Network network = mock(Network.class);
final Account account = mock(Account.class);
final Network designedNetwork = guru.design(offering, plan, network, account);
final Network designedNetwork = guru.design(offering, plan, network, "", 1L, account);
assertNotNull(designedNetwork);
assertSame(Networks.BroadcastDomainType.TUNGSTEN, designedNetwork.getBroadcastDomainType());
assertSame(Network.State.Allocated, designedNetwork.getState());

View File

@ -68,8 +68,8 @@ public class VxlanGuestNetworkGuru extends GuestNetworkGuru {
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
NetworkVO network = (NetworkVO)super.design(offering, plan, userSpecified, owner);
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner) {
NetworkVO network = (NetworkVO)super.design(offering, plan, userSpecified, name, vpcId, owner);
if (network == null) {
return null;
}

View File

@ -138,7 +138,7 @@ public class VxlanGuestNetworkGuruTest {
Network network = mock(Network.class);
Account account = mock(Account.class);
Network designednetwork = guru.design(offering, plan, network, account);
Network designednetwork = guru.design(offering, plan, network, "", 1L, account);
assertTrue(designednetwork != null);
assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Vxlan);
}

View File

@ -459,7 +459,7 @@ public class NetworkMigrationManagerImpl implements NetworkMigrationManager {
DataCenterDeployment plan = new DataCenterDeployment(network.getDataCenterId(), null, null, null, null, newPhysicalNetworkId);
for (final NetworkGuru guru : _networkMgr.getNetworkGurus()) {
final Network designedNetwork = guru.design(newOffering, plan, network, networkAccount);
final Network designedNetwork = guru.design(newOffering, plan, network, network.getName(), vpcId, networkAccount);
if (designedNetwork == null) {
continue;
}

View File

@ -90,7 +90,7 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network specifiedConfig, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network specifiedConfig, String name, Long vpcId, Account owner) {
if (!canHandle(offering)) {
return null;
}

View File

@ -162,7 +162,7 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner) {
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());

View File

@ -110,13 +110,13 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner) {
if (_networkModel.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.Connectivity)) {
return null;
}
NetworkVO config = (NetworkVO)super.design(offering, plan, userSpecified, owner);
NetworkVO config = (NetworkVO)super.design(offering, plan, userSpecified, name, vpcId, owner);
if (config == null) {
return null;
} else if (_networkModel.networkIsConfiguredForExternalNetworking(plan.getDataCenterId(), config.getId())) {

View File

@ -219,7 +219,7 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
protected abstract boolean canHandle(NetworkOffering offering, final NetworkType networkType, PhysicalNetwork physicalNetwork);
@Override
public Network design(final NetworkOffering offering, final DeploymentPlan plan, final Network userSpecified, final Account owner) {
public Network design(final NetworkOffering offering, final DeploymentPlan plan, final Network userSpecified, String name, Long vpcId, final Account owner) {
final DataCenter dc = _dcDao.findById(plan.getDataCenterId());
final PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());

View File

@ -76,7 +76,7 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner) {
TrafficType type = offering.getTrafficType();
if (!isMyTrafficType(type)) {

View File

@ -98,7 +98,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner) {
DataCenter dc = _entityMgr.findById(DataCenter.class, plan.getDataCenterId());
if (!canHandle(offering, dc)) {
return null;

View File

@ -100,7 +100,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network network, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network network, String name, Long vpcId, Account owner) {
if (!canHandle(offering)) {
return null;
}

View File

@ -82,7 +82,7 @@ public class StorageNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
}
@Override
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner) {
if (!canHandle(offering)) {
return null;
}

View File

@ -134,7 +134,7 @@ public class DirectNetworkGuruTest {
when(networkModel.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.SecurityGroup)).thenReturn(true);
assertNotNull(guru.design(offering, plan, network, owner));
assertNotNull(guru.design(offering, plan, network, "", 1L, owner));
}
@Test
@ -151,7 +151,7 @@ public class DirectNetworkGuruTest {
when(networkModel.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.SecurityGroup)).thenReturn(false);
Network config = guru.design(offering, plan, network, owner);
Network config = guru.design(offering, plan, network, "", 1L, owner);
assertNotNull(config);
assertEquals(ip4Dns[0], config.getDns1());
assertEquals(ip4Dns[1], config.getDns2());

View File

@ -75,7 +75,7 @@ public class ExternalGuestNetworkGuruTest {
Mockito.when(network.getIp6Dns1()).thenReturn(ip6Dns[0]);
Mockito.when(network.getIp6Dns2()).thenReturn(ip6Dns[1]);
Account owner = Mockito.mock(Account.class);
Network config = guru.design(networkOffering, plan, network, owner);
Network config = guru.design(networkOffering, plan, network, "", 1L, owner);
assertNotNull(config);
assertEquals(ip4Dns[0], config.getDns1());
assertEquals(ip4Dns[1], config.getDns2());