Search in sources :

Example 1 with VspDhcpDomainOption

use of net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption in project cloudstack by apache.

the class NuageVspElement method implement.

@Override
public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Entering NuageElement implement function for network " + network.getDisplayText() + " (state " + network.getState() + ")");
    }
    if (network.getVpcId() != null) {
        return applyACLRulesForVpc(network, offering);
    }
    if (!canHandle(network, offering, Service.Connectivity)) {
        return false;
    }
    if (network.getBroadcastUri() == null) {
        s_logger.error("Nic has no broadcast Uri with the virtual router IP");
        return false;
    }
    VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network);
    List<VspAclRule> ingressFirewallRules = getFirewallRulesToApply(network, FirewallRule.TrafficType.Ingress);
    List<VspAclRule> egressFirewallRules = getFirewallRulesToApply(network, FirewallRule.TrafficType.Egress);
    List<IPAddressVO> ips = _ipAddressDao.listStaticNatPublicIps(network.getId());
    List<String> floatingIpUuids = new ArrayList<String>();
    for (IPAddressVO ip : ips) {
        floatingIpUuids.add(ip.getUuid());
    }
    VspDhcpDomainOption vspDhcpOptions = _nuageVspEntityBuilder.buildNetworkDhcpOption(network, offering);
    HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(network.getPhysicalNetworkId());
    ImplementVspCommand cmd = new ImplementVspCommand(vspNetwork, ingressFirewallRules, egressFirewallRules, floatingIpUuids, vspDhcpOptions);
    Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
    if (answer == null || !answer.getResult()) {
        s_logger.error("ImplementVspCommand for network " + network.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname"));
        if ((null != answer) && (null != answer.getDetails())) {
            throw new ResourceUnavailableException(answer.getDetails(), Network.class, network.getId());
        }
    }
    return true;
}
Also used : ArrayList(java.util.ArrayList) VspDhcpDomainOption(net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption) HostVO(com.cloud.host.HostVO) Answer(com.cloud.agent.api.Answer) VspAclRule(net.nuage.vsp.acs.client.api.model.VspAclRule) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) IPAddressVO(com.cloud.network.dao.IPAddressVO) ImplementVspCommand(com.cloud.agent.api.element.ImplementVspCommand) VspNetwork(net.nuage.vsp.acs.client.api.model.VspNetwork)

Example 2 with VspDhcpDomainOption

use of net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption in project cloudstack by apache.

the class NuageVspResourceTest method testImplementNetworkVspCommand.

@Test
public void testImplementNetworkVspCommand() throws Exception {
    _resource.configure("NuageVspResource", _hostDetails);
    VspNetwork vspNetwork = buildVspNetwork();
    VspDhcpDomainOption vspDhcpOptions = buildspDhcpDomainOption();
    ImplementNetworkVspCommand cmd = new ImplementNetworkVspCommand(vspNetwork, vspDhcpOptions);
    com.cloud.agent.api.Answer implNtwkAns = _resource.executeRequest(cmd);
    assertTrue(implNtwkAns.getResult());
    verify(_mockNuageVspGuruClient).implement(vspNetwork, vspDhcpOptions);
}
Also used : ImplementNetworkVspCommand(com.cloud.agent.api.guru.ImplementNetworkVspCommand) VspDhcpDomainOption(net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption) Answer(com.cloud.agent.api.Answer) VspNetwork(net.nuage.vsp.acs.client.api.model.VspNetwork) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 3 with VspDhcpDomainOption

use of net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption in project cloudstack by apache.

the class NuageVspElement method shutdown.

@Override
public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException {
    if (!canHandle(network, Service.Connectivity)) {
        return false;
    }
    if (cleanup && isDnsSupportedByVR(network)) {
        // The network is restarted, possibly the domain name is changed, update the dhcpOptions as soon as possible
        NetworkOfferingVO networkOfferingVO = _ntwkOfferingDao.findById(network.getNetworkOfferingId());
        VspDhcpDomainOption vspDhcpOptions = _nuageVspEntityBuilder.buildNetworkDhcpOption(network, networkOfferingVO);
        VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network);
        HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(network.getPhysicalNetworkId());
        ShutDownVspCommand cmd = new ShutDownVspCommand(vspNetwork, vspDhcpOptions);
        Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
        if (answer == null || !answer.getResult()) {
            s_logger.error("ShutDownVspCommand for network " + network.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname"));
            if ((null != answer) && (null != answer.getDetails())) {
                throw new ResourceUnavailableException(answer.getDetails(), Network.class, network.getId());
            }
        }
    }
    return true;
}
Also used : Answer(com.cloud.agent.api.Answer) VspDhcpDomainOption(net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) VspNetwork(net.nuage.vsp.acs.client.api.model.VspNetwork) ShutDownVspCommand(com.cloud.agent.api.element.ShutDownVspCommand) HostVO(com.cloud.host.HostVO)

Aggregations

Answer (com.cloud.agent.api.Answer)3 VspDhcpDomainOption (net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption)3 VspNetwork (net.nuage.vsp.acs.client.api.model.VspNetwork)3 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)2 HostVO (com.cloud.host.HostVO)2 NuageTest (com.cloud.NuageTest)1 ImplementVspCommand (com.cloud.agent.api.element.ImplementVspCommand)1 ShutDownVspCommand (com.cloud.agent.api.element.ShutDownVspCommand)1 ImplementNetworkVspCommand (com.cloud.agent.api.guru.ImplementNetworkVspCommand)1 IPAddressVO (com.cloud.network.dao.IPAddressVO)1 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)1 ArrayList (java.util.ArrayList)1 VspAclRule (net.nuage.vsp.acs.client.api.model.VspAclRule)1 Test (org.junit.Test)1