use of net.nuage.vsp.acs.client.api.model.VspDomainCleanUp in project cloudstack by apache.
the class NuageVspEntityBuilder method buildVspDomainCleanUp.
public VspDomainCleanUp buildVspDomainCleanUp(Domain domain) {
VspDomainCleanUp.Builder vspDomainCleanUpBuilder = new VspDomainCleanUp.Builder().uuid(domain.getUuid());
Map<String, List<String>> sharedNetworkUuids = Maps.newHashMap();
List<NetworkVO> allSharedNetworks = _networkDao.listByGuestType(Network.GuestType.Shared);
for (NetworkVO sharedNetwork : allSharedNetworks) {
if (_networkModel.isNetworkAvailableInDomain(sharedNetwork.getId(), domain.getId())) {
NetworkOffering networkOffering = _networkOfferingDao.findById(sharedNetwork.getNetworkOfferingId());
String preConfiguredDomainTemplateName = NuageVspUtil.getPreConfiguredDomainTemplateName(_configurationDao, _networkDetailsDao, sharedNetwork, networkOffering);
if (!sharedNetworkUuids.containsKey(preConfiguredDomainTemplateName)) {
sharedNetworkUuids.put(preConfiguredDomainTemplateName, Lists.<String>newArrayList());
}
sharedNetworkUuids.get(preConfiguredDomainTemplateName).add(sharedNetwork.getUuid());
}
}
vspDomainCleanUpBuilder.sharedNetworkUuids(sharedNetworkUuids);
return vspDomainCleanUpBuilder.build();
}
use of net.nuage.vsp.acs.client.api.model.VspDomainCleanUp in project cloudstack by apache.
the class NuageVspManagerImpl method auditDomainsOnVsp.
private boolean auditDomainsOnVsp(HostVO host, boolean add) {
List<NuageVspDeviceVO> nuageVspDevices = _nuageVspDao.listByHost(host.getId());
if (CollectionUtils.isEmpty(nuageVspDevices)) {
return true;
}
final SyncDomainCommand.Type action = add ? SyncDomainCommand.Type.ADD : SyncDomainCommand.Type.REMOVE;
_hostDao.loadDetails(host);
List<DomainVO> allDomains = _domainDao.listAll();
for (DomainVO domain : allDomains) {
if (action == SyncDomainCommand.Type.REMOVE) {
VspDomainCleanUp vspDomainCleanUp = _nuageVspEntityBuilder.buildVspDomainCleanUp(domain);
CleanUpDomainCommand cmd = new CleanUpDomainCommand(vspDomainCleanUp);
Answer answer = _agentMgr.easySend(host.getId(), cmd);
if (!answer.getResult()) {
return false;
}
}
VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(domain);
SyncDomainCommand cmd = new SyncDomainCommand(vspDomain, action);
Answer answer = _agentMgr.easySend(host.getId(), cmd);
if (!answer.getResult()) {
return false;
}
}
return true;
}
use of net.nuage.vsp.acs.client.api.model.VspDomainCleanUp in project cloudstack by apache.
the class NuageVspManagerImpl method initMessageBusListeners.
@DB
private void initMessageBusListeners() {
// Create corresponding enterprise and profile in VSP when creating a CS Domain
_messageBus.subscribe(DomainManager.MESSAGE_ADD_DOMAIN_EVENT, new MessageSubscriber() {
@Override
public void onPublishMessage(String senderAddress, String subject, Object args) {
Long domainId = (Long) args;
Domain domain = _domainDao.findById(domainId);
try {
_domainDao.acquireInLockTable(domain.getId());
List<NuageVspDeviceVO> nuageVspDevices = _nuageVspDao.listAll();
for (NuageVspDeviceVO nuageVspDevice : nuageVspDevices) {
VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(domain);
SyncDomainCommand cmd = new SyncDomainCommand(vspDomain, SyncDomainCommand.Type.ADD);
_agentMgr.easySend(nuageVspDevice.getHostId(), cmd);
}
} finally {
_domainDao.releaseFromLockTable(domain.getId());
}
}
});
// Clean up corresponding resources in VSP when deleting a CS Domain
_messageBus.subscribe(DomainManager.MESSAGE_PRE_REMOVE_DOMAIN_EVENT, new MessageSubscriber() {
@Override
public void onPublishMessage(String senderAddress, String subject, Object args) {
DomainVO domain = (DomainVO) args;
List<NuageVspDeviceVO> nuageVspDevices = _nuageVspDao.listAll();
for (NuageVspDeviceVO nuageVspDevice : nuageVspDevices) {
VspDomainCleanUp vspDomainCleanUp = _nuageVspEntityBuilder.buildVspDomainCleanUp(domain);
CleanUpDomainCommand cmd = new CleanUpDomainCommand(vspDomainCleanUp);
_agentMgr.easySend(nuageVspDevice.getHostId(), cmd);
}
}
});
// Delete corresponding enterprise and profile in VSP when deleting a CS Domain
_messageBus.subscribe(DomainManager.MESSAGE_REMOVE_DOMAIN_EVENT, new MessageSubscriber() {
@Override
public void onPublishMessage(String senderAddress, String subject, Object args) {
DomainVO domain = (DomainVO) args;
List<NuageVspDeviceVO> nuageVspDevices = _nuageVspDao.listAll();
for (NuageVspDeviceVO nuageVspDevice : nuageVspDevices) {
VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(domain);
SyncDomainCommand syncCmd = new SyncDomainCommand(vspDomain, SyncDomainCommand.Type.REMOVE);
_agentMgr.easySend(nuageVspDevice.getHostId(), syncCmd);
}
}
});
}
Aggregations