Search in sources :

Example 1 with VspDomainCleanUp

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();
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO) VspDomainCleanUp(net.nuage.vsp.acs.client.api.model.VspDomainCleanUp) NetworkOffering(com.cloud.offering.NetworkOffering) List(java.util.List)

Example 2 with VspDomainCleanUp

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;
}
Also used : NuageVspDeviceVO(com.cloud.network.NuageVspDeviceVO) VspDomain(net.nuage.vsp.acs.client.api.model.VspDomain) DomainVO(com.cloud.domain.DomainVO) AgentControlAnswer(com.cloud.agent.api.AgentControlAnswer) Answer(com.cloud.agent.api.Answer) GetApiDefaultsAnswer(com.cloud.agent.api.manager.GetApiDefaultsAnswer) SyncNuageVspCmsIdAnswer(com.cloud.agent.api.sync.SyncNuageVspCmsIdAnswer) CleanUpDomainCommand(com.cloud.agent.api.manager.CleanUpDomainCommand) VspDomainCleanUp(net.nuage.vsp.acs.client.api.model.VspDomainCleanUp) SyncDomainCommand(com.cloud.agent.api.sync.SyncDomainCommand)

Example 3 with VspDomainCleanUp

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);
            }
        }
    });
}
Also used : NuageVspDeviceVO(com.cloud.network.NuageVspDeviceVO) VspDomain(net.nuage.vsp.acs.client.api.model.VspDomain) MessageSubscriber(org.apache.cloudstack.framework.messagebus.MessageSubscriber) SyncDomainCommand(com.cloud.agent.api.sync.SyncDomainCommand) DomainVO(com.cloud.domain.DomainVO) CleanUpDomainCommand(com.cloud.agent.api.manager.CleanUpDomainCommand) VspDomainCleanUp(net.nuage.vsp.acs.client.api.model.VspDomainCleanUp) ArrayList(java.util.ArrayList) List(java.util.List) VspDomain(net.nuage.vsp.acs.client.api.model.VspDomain) Domain(com.cloud.domain.Domain) DB(com.cloud.utils.db.DB)

Aggregations

VspDomainCleanUp (net.nuage.vsp.acs.client.api.model.VspDomainCleanUp)3 CleanUpDomainCommand (com.cloud.agent.api.manager.CleanUpDomainCommand)2 SyncDomainCommand (com.cloud.agent.api.sync.SyncDomainCommand)2 DomainVO (com.cloud.domain.DomainVO)2 NuageVspDeviceVO (com.cloud.network.NuageVspDeviceVO)2 List (java.util.List)2 VspDomain (net.nuage.vsp.acs.client.api.model.VspDomain)2 AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)1 Answer (com.cloud.agent.api.Answer)1 GetApiDefaultsAnswer (com.cloud.agent.api.manager.GetApiDefaultsAnswer)1 SyncNuageVspCmsIdAnswer (com.cloud.agent.api.sync.SyncNuageVspCmsIdAnswer)1 Domain (com.cloud.domain.Domain)1 NetworkVO (com.cloud.network.dao.NetworkVO)1 NetworkOffering (com.cloud.offering.NetworkOffering)1 DB (com.cloud.utils.db.DB)1 ArrayList (java.util.ArrayList)1 MessageSubscriber (org.apache.cloudstack.framework.messagebus.MessageSubscriber)1