use of com.cloud.agent.api.element.ShutDownVpcVspCommand in project cloudstack by apache.
the class NuageVspResourceTest method testShutDownVpcVspCommand.
@Test
public void testShutDownVpcVspCommand() throws Exception {
_resource.configure("NuageVspResource", _hostDetails);
ShutDownVpcVspCommand cmd = new ShutDownVpcVspCommand("domainUuid", "vpcUuid", "domainTemplateName", Lists.<String>newArrayList());
Answer shutVpcAns = _resource.executeRequest(cmd);
assertTrue(shutVpcAns.getResult());
}
use of com.cloud.agent.api.element.ShutDownVpcVspCommand in project cloudstack by apache.
the class NuageVspElement method shutdownVpc.
@Override
public boolean shutdownVpc(Vpc vpc, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
if (vpc.getState().equals(Vpc.State.Inactive)) {
List<DomainRouterVO> routers = _routerDao.listByVpcId(vpc.getId());
if (CollectionUtils.isEmpty(routers)) {
routers = _routerDao.listIncludingRemovedByVpcId(vpc.getId());
}
List<String> domainRouterUuids = Lists.transform(routers, new Function<DomainRouterVO, String>() {
@Nullable
@Override
public String apply(@Nullable DomainRouterVO input) {
return input != null ? input.getUuid() : null;
}
});
Domain vpcDomain = _domainDao.findById(vpc.getDomainId());
HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(getPhysicalNetworkId(vpc.getZoneId()));
String preConfiguredDomainTemplateName;
VpcDetailVO domainTemplateNameDetail = _vpcDetailsDao.findDetail(vpc.getId(), NuageVspManager.nuageDomainTemplateDetailName);
if (domainTemplateNameDetail != null) {
preConfiguredDomainTemplateName = domainTemplateNameDetail.getValue();
} else {
preConfiguredDomainTemplateName = _configDao.getValue(NuageVspManager.NuageVspVpcDomainTemplateName.key());
}
ShutDownVpcVspCommand cmd = new ShutDownVpcVspCommand(vpcDomain.getUuid(), vpc.getUuid(), preConfiguredDomainTemplateName, domainRouterUuids);
Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
if (answer == null || !answer.getResult()) {
s_logger.error("ShutDownVpcVspCommand for VPC " + vpc.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname"));
if ((null != answer) && (null != answer.getDetails())) {
throw new ResourceUnavailableException(answer.getDetails(), Vpc.class, vpc.getId());
}
}
}
return true;
}
Aggregations