mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
NaaS: Add back service offering ID for network offering
It would be used to adjust service offering of virtual router
This commit is contained in:
parent
3e20c60d6d
commit
b646f07f9c
@ -70,6 +70,9 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.NETWORKRATE, type=CommandType.INTEGER, description="data transfer rate in megabits per second allowed.")
|
||||
private Integer networkRate;
|
||||
|
||||
@Parameter(name=ApiConstants.SERVICE_OFFERING_ID, type=CommandType.LONG, description="the service offering ID used by virtual router provider")
|
||||
private Long serviceOfferingId;
|
||||
|
||||
@Parameter(name=ApiConstants.DHCP_SERVICE, type=CommandType.BOOLEAN, description="true if network offering supports dhcp service")
|
||||
private Boolean dhcpService;
|
||||
|
||||
@ -153,6 +156,10 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||
return maxConnections;
|
||||
}
|
||||
|
||||
public Long getServiceOfferingId() {
|
||||
return serviceOfferingId;
|
||||
}
|
||||
|
||||
public Boolean getDhcpService() {
|
||||
return dhcpService == null ? false : dhcpService;
|
||||
}
|
||||
|
||||
@ -93,4 +93,6 @@ public interface NetworkOffering {
|
||||
State getState();
|
||||
|
||||
GuestType getGuestType();
|
||||
|
||||
Long getServiceOfferingId();
|
||||
}
|
||||
|
||||
@ -182,10 +182,11 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
|
||||
* @param systemOnly TODO
|
||||
* @param id
|
||||
* @param specifyVlan;
|
||||
* @param serviceOfferingId
|
||||
* @return network offering object
|
||||
*/
|
||||
|
||||
NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, Availability availability, Integer networkRate, Map<Service, Set<Provider>> serviceProviderMap, boolean isDefault, Network.GuestType type, boolean systemOnly);
|
||||
NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, Availability availability, Integer networkRate, Map<Service, Set<Provider>> serviceProviderMap, boolean isDefault, Network.GuestType type, boolean systemOnly, Long serviceOfferingId);
|
||||
|
||||
Vlan createVlanAndPublicIpRange(Long userId, Long zoneId, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, boolean forVirtualNetwork, String vlanId, Account account, Long networkId, Long physicalNetworkId) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException;
|
||||
|
||||
|
||||
@ -2845,6 +2845,18 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
|
||||
Integer maxConnections = cmd.getMaxconnections();
|
||||
|
||||
Long serviceOfferingId = cmd.getServiceOfferingId();
|
||||
|
||||
if (serviceOfferingId != null) {
|
||||
ServiceOfferingVO offering = _serviceOfferingDao.findById(serviceOfferingId);
|
||||
if (offering == null) {
|
||||
throw new InvalidParameterValueException("Cannot find specified service offering: " + serviceOfferingId);
|
||||
}
|
||||
if (!VirtualMachine.Type.DomainRouter.toString().equalsIgnoreCase(offering.getSystemVmType())) {
|
||||
throw new InvalidParameterValueException("The specified service offering " + serviceOfferingId + " cannot be used by virtual router!");
|
||||
}
|
||||
}
|
||||
|
||||
// configure service provider map
|
||||
Map<Network.Service, Set<Network.Provider>> serviceProviderMap = new HashMap<Network.Service, Set<Network.Provider>>();
|
||||
Set<Network.Provider> defaultProviders = new HashSet<Network.Provider>();
|
||||
@ -2927,19 +2939,23 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
}
|
||||
}
|
||||
|
||||
return createNetworkOffering(userId, name, displayText, trafficType, tags, maxConnections, specifyVlan, availability, networkRate, serviceProviderMap, false, guestType, false);
|
||||
return createNetworkOffering(userId, name, displayText, trafficType, tags, maxConnections, specifyVlan, availability, networkRate, serviceProviderMap, false, guestType, false, serviceOfferingId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan,
|
||||
Availability availability, Integer networkRate, Map<Service, Set<Provider>> serviceProviderMap, boolean isDefault, Network.GuestType type, boolean systemOnly) {
|
||||
Availability availability, Integer networkRate, Map<Service, Set<Provider>> serviceProviderMap, boolean isDefault, Network.GuestType type, boolean systemOnly, Long serviceOfferingId) {
|
||||
|
||||
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
|
||||
int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
tags = cleanupTags(tags);
|
||||
|
||||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, systemOnly, specifyVlan, networkRate, multicastRate, maxConnections, isDefault, availability, tags, type);
|
||||
|
||||
if (serviceOfferingId != null) {
|
||||
offering.setServiceOfferingId(serviceOfferingId);
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
|
||||
@ -890,18 +890,18 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
NetworkOfferingVO defaultGuestOffering = _networkOfferingDao.findByUniqueName(NetworkOffering.SystemGuestNetwork);
|
||||
if (defaultGuestOffering == null) {
|
||||
defaultGuestOffering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.SystemGuestNetwork, "System Offering for System-Guest-Network", TrafficType.Guest, null, null, false, Availability.Optional, null, defaultDirectNetworkOfferingProviders, true, Network.GuestType.Shared, false);
|
||||
defaultGuestOffering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.SystemGuestNetwork, "System Offering for System-Guest-Network", TrafficType.Guest, null, null, false, Availability.Optional, null, defaultDirectNetworkOfferingProviders, true, Network.GuestType.Shared, false, null);
|
||||
_networkOfferingDao.update(defaultGuestOffering.getId(), defaultGuestOffering);
|
||||
}
|
||||
|
||||
NetworkOfferingVO offering = null;
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultVirtualizedNetworkOffering) == null) {
|
||||
offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM,NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, null, null, false, Availability.Required, null, defaultVirtualNetworkOfferingProviders, true, Network.GuestType.Isolated, false);
|
||||
offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM,NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, null, null, false, Availability.Required, null, defaultVirtualNetworkOfferingProviders, true, Network.GuestType.Isolated, false, null);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultDirectNetworkOffering) == null) {
|
||||
offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Guest, null, null, true, Availability.Optional, null, defaultDirectNetworkOfferingProviders, true, Network.GuestType.Shared, false);
|
||||
offering = _configMgr.createNetworkOffering(Account.ACCOUNT_ID_SYSTEM, NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Guest, null, null, true, Availability.Optional, null, defaultDirectNetworkOfferingProviders, true, Network.GuestType.Shared, false, null);
|
||||
_networkOfferingDao.update(offering.getId(), offering);
|
||||
}
|
||||
|
||||
|
||||
@ -1099,15 +1099,20 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
//Router is the network element, we don't know the hypervisor type yet.
|
||||
//Try to allocate the domR twice using diff hypervisors, and when failed both times, throw the exception up
|
||||
List<HypervisorType> supportedHypervisors = _resourceMgr.getSupportedHypervisorTypes(dest.getDataCenter().getId());
|
||||
Long offering_id = _networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()).getServiceOfferingId();
|
||||
if (offering_id == null) {
|
||||
offering_id = _offering.getId();
|
||||
}
|
||||
ServiceOfferingVO routerOffering = _serviceOfferingDao.findById(offering_id);
|
||||
int retry = 0;
|
||||
for (HypervisorType hType : supportedHypervisors) {
|
||||
try {
|
||||
s_logger.debug("Allocating the domR with the hypervisor type " + hType);
|
||||
VMTemplateVO template = _templateDao.findRoutingTemplate(hType);
|
||||
|
||||
router = new DomainRouterVO(id, _offering.getId(), 0, VirtualMachineName.getRouterName(id, _instance), template.getId(), template.getHypervisorType(),
|
||||
template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), isRedundant, 0, false, RedundantState.UNKNOWN, _offering.getOfferHA(), false);
|
||||
router = _itMgr.allocate(router, template, _offering, networks, plan, null, owner);
|
||||
router = new DomainRouterVO(id, routerOffering.getId(), 0, VirtualMachineName.getRouterName(id, _instance), template.getId(), template.getHypervisorType(),
|
||||
template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), isRedundant, 0, false, RedundantState.UNKNOWN, routerOffering.getOfferHA(), false);
|
||||
router = _itMgr.allocate(router, template, routerOffering, networks, plan, null, owner);
|
||||
break;
|
||||
} catch (InsufficientCapacityException ex) {
|
||||
if (retry < 2) {
|
||||
@ -1303,6 +1308,11 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
//Router is the network element, we don't know the hypervisor type yet.
|
||||
//Try to allocate the domR twice using diff hypervisors, and when failed both times, throw the exception up
|
||||
List<HypervisorType> supportedHypervisors = _resourceMgr.getSupportedHypervisorTypes(dest.getDataCenter().getId());
|
||||
Long offering_id = _networkOfferingDao.findById(guestNetwork.getNetworkOfferingId()).getServiceOfferingId();
|
||||
if (offering_id == null) {
|
||||
offering_id = _offering.getId();
|
||||
}
|
||||
ServiceOfferingVO routerOffering = _serviceOfferingDao.findById(offering_id);
|
||||
int retry = 0;
|
||||
for (HypervisorType hType : supportedHypervisors) {
|
||||
try {
|
||||
@ -1310,10 +1320,10 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
||||
/* Before starting router, already know the hypervisor type */
|
||||
VMTemplateVO template = _templateDao.findRoutingTemplate(hType);
|
||||
|
||||
router = new DomainRouterVO(id, _offering.getId(), 0, VirtualMachineName.getRouterName(id, _instance), template.getId(), template.getHypervisorType(),
|
||||
template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), false, 0, false, RedundantState.UNKNOWN, _offering.getOfferHA(), false);
|
||||
router = new DomainRouterVO(id, routerOffering.getId(), 0, VirtualMachineName.getRouterName(id, _instance), template.getId(), template.getHypervisorType(),
|
||||
template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestNetwork.getId(), false, 0, false, RedundantState.UNKNOWN, routerOffering.getOfferHA(), false);
|
||||
router.setRole(Role.DHCP_USERDATA);
|
||||
router = _itMgr.allocate(router, template, _offering, networks, plan, null, owner);
|
||||
router = _itMgr.allocate(router, template, routerOffering, networks, plan, null, owner);
|
||||
break;
|
||||
} catch (InsufficientCapacityException ex) {
|
||||
if (retry < 2) {
|
||||
|
||||
@ -70,6 +70,9 @@ public class NetworkOfferingVO implements NetworkOffering {
|
||||
@Column(name="system_only")
|
||||
boolean systemOnly;
|
||||
|
||||
@Column(name="service_offering_id")
|
||||
Long serviceOfferingId;
|
||||
|
||||
@Column(name="tags", length=4096)
|
||||
String tags;
|
||||
|
||||
@ -201,6 +204,15 @@ public class NetworkOfferingVO implements NetworkOffering {
|
||||
return guestType;
|
||||
}
|
||||
|
||||
public void setServiceOfferingId(Long serviceOfferingId) {
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getServiceOfferingId() {
|
||||
return serviceOfferingId;
|
||||
}
|
||||
|
||||
public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections, boolean isDefault, Availability availability, String tags, Network.GuestType guestType) {
|
||||
this.name = name;
|
||||
this.displayText = displayText;
|
||||
|
||||
@ -249,6 +249,7 @@ CREATE TABLE `cloud`.`network_offerings` (
|
||||
`tags` varchar(4096) COMMENT 'tags supported by this offering',
|
||||
`system_only` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Is this network offering for system use only',
|
||||
`specify_vlan` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Should the user specify vlan',
|
||||
`service_offering_id` bigint unsigned COMMENT 'service offering id that virtual router is tied to',
|
||||
`created` datetime NOT NULL COMMENT 'time the entry was created',
|
||||
`removed` datetime DEFAULT NULL COMMENT 'time the entry was removed',
|
||||
`default` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if network offering is default',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user