Github user jburwell commented on a diff in the pull request:
https://github.com/apache/cloudstack/pull/801#discussion_r39902671
--- Diff:
plugins/network-elements/nuage-vsp/src/com/cloud/network/guru/NuageVspGuestNetworkGuru.java
---
@@ -322,35 +383,57 @@ public void shutdown(NetworkProfile profile,
NetworkOffering offering) {
@Override
public boolean trash(Network network, NetworkOffering offering) {
-
- s_logger.debug("Handling trash() call back to delete the network "
+ network.getName() + " with uuid " + network.getUuid() + " from VSP");
- long domainId = network.getDomainId();
- Domain domain = _domainDao.findById(domainId);
- Long vpcId = network.getVpcId();
- String vpcUuid = null;
- if (vpcId != null) {
- Vpc vpcObj = _vpcDao.findById(vpcId);
- vpcUuid = vpcObj.getUuid();
+ long networkId = network.getId();
+ network = _networkDao.acquireInLockTable(networkId, 1200);
+ if (network == null) {
+ throw new ConcurrentOperationException("Unable to acquire lock
on network " + networkId);
}
+
try {
- HostVO nuageVspHost =
getNuageVspHost(network.getPhysicalNetworkId());
- TrashNetworkVspCommand cmd = new
TrashNetworkVspCommand(domain.getUuid(), network.getUuid(),
isL3Network(offering.getId()), vpcUuid);
- TrashNetworkVspAnswer answer =
(TrashNetworkVspAnswer)_agentMgr.easySend(nuageVspHost.getId(), cmd);
- if (answer == null || !answer.getResult()) {
- s_logger.error("TrashNetworkNuageVspCommand for network "
+ network.getUuid() + " failed");
- if ((null != answer) && (null != answer.getDetails())) {
- s_logger.error(answer.getDetails());
+ s_logger.debug("Handling trash() call back to delete the
network " + network.getName() + " with uuid " + network.getUuid() + " from
VSP");
+ long domainId = network.getDomainId();
+ Domain domain = _domainDao.findById(domainId);
+ boolean isL3Network = isL3Network(network);
+ boolean isSharedNetwork = offering.getGuestType() ==
GuestType.Shared;
+ Long vpcId = network.getVpcId();
+ String vpcUuid = null;
+ if (vpcId != null) {
+ Vpc vpcObj = _vpcDao.findById(vpcId);
+ vpcUuid = vpcObj.getUuid();
+ }
+
+ String preConfiguredDomainTemplateName = null;
+ if (vpcUuid != null) {
+ preConfiguredDomainTemplateName =
_configDao.getValue(NuageVspManager.NuageVspVpcDomainTemplateName.key());
+ } else if (isSharedNetwork) {
+ preConfiguredDomainTemplateName =
_configDao.getValue(NuageVspManager.NuageVspSharedNetworkDomainTemplateName.key());
+ } else if (isL3Network) {
+ preConfiguredDomainTemplateName =
_configDao.getValue(NuageVspManager.NuageVspIsolatedNetworkDomainTemplateName.key());
+ }
--- End diff --
Extract the value passed into ``_configDao.getValue(...)`` into a local
variable and call ``_configDao.getValue()`` and set the value of
``preConfiguredDomainTemplateName`` in one call -- to DRY out the
implementation and make it more readable.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---