[
https://issues.apache.org/jira/browse/CLOUDSTACK-8832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14876451#comment-14876451
]
ASF GitHub Bot commented on CLOUDSTACK-8832:
--------------------------------------------
Github user jburwell commented on a diff in the pull request:
https://github.com/apache/cloudstack/pull/801#discussion_r39902273
--- Diff:
plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java
---
@@ -201,51 +234,82 @@ public NicProfile allocate(Network network,
NicProfile nic, VirtualMachineProfil
@Override
public void reserve(NicProfile nic, Network network,
VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
throws InsufficientVirtualNetworkCapacityException,
InsufficientAddressCapacityException {
- nic.setBroadcastUri(network.getBroadcastUri());
- nic.setIsolationUri(network.getBroadcastUri());
-
- s_logger.debug("Handling reserve() call back to with Create a new
VM or add an interface to existing VM in network " + network.getName());
- DataCenter dc = _dcDao.findById(network.getDataCenterId());
- Account networksAccount =
_accountDao.findById(network.getAccountId());
- DomainVO networksDomain =
_domainDao.findById(network.getDomainId());
- //Get the Account details and find the type
- long networkOwnedBy = network.getAccountId();
- AccountVO neworkAccountDetails =
_accountDao.findById(networkOwnedBy);
- if (neworkAccountDetails.getType() ==
Account.ACCOUNT_TYPE_PROJECT) {
- throw new InsufficientVirtualNetworkCapacityException("CS
project support is " + "not yet implemented in NuageVsp", DataCenter.class,
dc.getId());
+ boolean lockedNetwork = lockNetworkForUserVm(network, vm);
+ if (lockedNetwork) {
+ s_logger.debug("Locked network " + network.getId() + " for
creation of user VM " + vm.getInstanceName());
}
- //NicProfile does not contain the NIC UUID. We need this
information to set it in the VMInterface and VPort
- //that we create in VSP
- NicVO nicFrmDB = _nicDao.findById(nic.getId());
- long networkOfferingId =
_ntwkOfferingDao.findById(network.getNetworkOfferingId()).getId();
- boolean isL3Network = isL3Network(networkOfferingId);
- Long vpcId = network.getVpcId();
- String vpcUuid = null;
- if (vpcId != null) {
- Vpc vpcObj = _vpcDao.findById(vpcId);
- vpcUuid = vpcObj.getUuid();
- }
- HostVO nuageVspHost =
getNuageVspHost(network.getPhysicalNetworkId());
- ReserveVmInterfaceVspCommand cmd = new
ReserveVmInterfaceVspCommand(nicFrmDB.getUuid(), nic.getMacAddress(),
network.getUuid(), isL3Network, vpcUuid,
- networksDomain.getUuid(), networksAccount.getUuid(),
vm.getType().equals(VirtualMachine.Type.DomainRouter),
network.getBroadcastUri().getPath().substring(1),
- vm.getInstanceName(), vm.getUuid(),
networksDomain.getUuid(), networksAccount.getUuid());
- ReserveVmInterfaceVspAnswer answer =
(ReserveVmInterfaceVspAnswer)_agentMgr.easySend(nuageVspHost.getId(), cmd);
-
- if (answer == null || !answer.getResult()) {
- s_logger.error("ReserveVmInterfaceNuageVspCommand failed");
- if ((null != answer) && (null != answer.getDetails())) {
- s_logger.error(answer.getDetails());
+ try {
+ nic.setBroadcastUri(network.getBroadcastUri());
+ nic.setIsolationUri(network.getBroadcastUri());
+
+ s_logger.debug("Handling reserve() call back to with Create a
new VM or add an interface to existing VM in network " + network.getName());
+ DataCenter dc = _dcDao.findById(network.getDataCenterId());
+ Account networksAccount =
_accountDao.findById(network.getAccountId());
+ DomainVO networksDomain =
_domainDao.findById(network.getDomainId());
+ //Get the Account details and find the type
+ long networkOwnedBy = network.getAccountId();
+ AccountVO neworkAccountDetails =
_accountDao.findById(networkOwnedBy);
+ if (neworkAccountDetails.getType() ==
Account.ACCOUNT_TYPE_PROJECT) {
+ throw new InsufficientVirtualNetworkCapacityException("CS
project support is " + "not yet implemented in NuageVsp", DataCenter.class,
dc.getId());
+ }
+
+ //NicProfile does not contain the NIC UUID. We need this
information to set it in the VMInterface and VPort
+ //that we create in VSP
+ NicVO nicFrmDB = _nicDao.findById(nic.getId());
+ NetworkOffering networkOffering =
_ntwkOfferingDao.findById(network.getNetworkOfferingId());
+ boolean isDomainRouter =
vm.getType().equals(VirtualMachine.Type.DomainRouter);
+ String domainRouterIp =
network.getBroadcastUri().getPath().substring(1);
+ boolean isL3Network = isL3Network(network);
+ boolean isSharedNetwork = networkOffering.getGuestType() ==
GuestType.Shared;
+ Long vpcId = network.getVpcId();
+ String vpcUuid = null;
+ if (vpcId != null) {
+ Vpc vpcObj = _vpcDao.findById(vpcId);
+ vpcUuid = vpcObj.getUuid();
+ }
+ HostVO nuageVspHost =
getNuageVspHost(network.getPhysicalNetworkId());
+ IPAddressVO staticNatIp =
_ipAddressDao.findByVmIdAndNetworkId(network.getId(), vm.getId());
+
+ ReserveVmInterfaceVspCommand cmd;
+ if (staticNatIp != null) {
+ VlanVO staticNatVlan =
_vlanDao.findById(staticNatIp.getVlanId());
+ cmd = new ReserveVmInterfaceVspCommand(nicFrmDB.getUuid(),
nic.getMacAddress(), network.getUuid(), isL3Network, isSharedNetwork, vpcUuid,
+ networksDomain.getUuid(),
networksAccount.getUuid(), isDomainRouter, domainRouterIp,
+ vm.getInstanceName(), vm.getUuid(),
networksDomain.getUuid(), networksAccount.getUuid(), true,
nic.getIPv4Address(), staticNatIp.getUuid(),
+ staticNatIp.getAddress().addr(),
staticNatIp.getState().equals(IpAddress.State.Allocated),
staticNatIp.isOneToOneNat(), staticNatVlan.getUuid(),
+ staticNatVlan.getVlanGateway(),
staticNatVlan.getVlanNetmask());
+ } else {
+ cmd = new ReserveVmInterfaceVspCommand(nicFrmDB.getUuid(),
nic.getMacAddress(), network.getUuid(), isL3Network, isSharedNetwork, vpcUuid,
+ networksDomain.getUuid(),
networksAccount.getUuid(),
vm.getType().equals(VirtualMachine.Type.DomainRouter), domainRouterIp,
+ vm.getInstanceName(), vm.getUuid(),
networksDomain.getUuid(), networksAccount.getUuid(), true,
nic.getIPv4Address(), null, null, false, false,
+ null, null, null);
+ }
+
+ ReserveVmInterfaceVspAnswer answer =
(ReserveVmInterfaceVspAnswer)_agentMgr.easySend(nuageVspHost.getId(), cmd);
+ if (answer == null || !answer.getResult()) {
+ s_logger.error("ReserveVmInterfaceNuageVspCommand failed");
+ if ((null != answer) && (null != answer.getDetails())) {
+ s_logger.error(answer.getDetails());
+ }
+ throw new
InsufficientVirtualNetworkCapacityException("Failed to reserve VM in Nuage
VSP.", Network.class, network.getId());
+ }
+
+ if (isDomainRouter) {
+ nic.setIPv4Address(domainRouterIp);
+ }
+
+ } finally {
+ if (network != null && lockedNetwork) {
+ _networkDao.releaseFromLockTable(network.getId());
+ s_logger.debug("Unlocked network " + network.getId() + "
for creation of user VM " + vm.getInstanceName());
--- End diff --
Wrap in a if (s_logger.isDebugEnabled()) { ... } block to avoid unnecessary
pressure on the string pool when debug logging is not enabled.
> Update Nuage VSP plugin to work with Nuage VSP release 3.2
> ----------------------------------------------------------
>
> Key: CLOUDSTACK-8832
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-8832
> Project: CloudStack
> Issue Type: Improvement
> Security Level: Public(Anyone can view this level - this is the
> default.)
> Components: Management Server
> Affects Versions: 4.6.0
> Reporter: Nick Livens
> Assignee: Nick Livens
>
> Nuage VSP 3.2 is being released, we want to bring the plugin up to date for
> this release
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)