Search in sources :

Example 1 with ApplyStaticNatVspCommand

use of com.cloud.agent.api.element.ApplyStaticNatVspCommand in project cloudstack by apache.

the class NuageVspElement method applyStaticNats.

@Override
public boolean applyStaticNats(Network config, List<? extends StaticNat> rules) throws ResourceUnavailableException {
    List<VspStaticNat> vspStaticNatDetails = new ArrayList<VspStaticNat>();
    for (StaticNat staticNat : rules) {
        IPAddressVO sourceNatIp = _ipAddressDao.findById(staticNat.getSourceIpAddressId());
        VlanVO sourceNatVlan = _vlanDao.findById(sourceNatIp.getVlanId());
        checkVlanUnderlayCompatibility(sourceNatVlan);
        NicVO nicVO = _nicDao.findByIp4AddressAndNetworkId(staticNat.getDestIpAddress(), staticNat.getNetworkId());
        VspStaticNat vspStaticNat = _nuageVspEntityBuilder.buildVspStaticNat(staticNat.isForRevoke(), sourceNatIp, sourceNatVlan, nicVO);
        vspStaticNatDetails.add(vspStaticNat);
    }
    VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(config);
    HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(config.getPhysicalNetworkId());
    ApplyStaticNatVspCommand cmd = new ApplyStaticNatVspCommand(vspNetwork, vspStaticNatDetails);
    Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
    if (answer == null || !answer.getResult()) {
        s_logger.error("ApplyStaticNatNuageVspCommand for network " + config.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname"));
        if ((null != answer) && (null != answer.getDetails())) {
            throw new ResourceUnavailableException(answer.getDetails(), Network.class, config.getId());
        }
    }
    return true;
}
Also used : Answer(com.cloud.agent.api.Answer) ApplyStaticNatVspCommand(com.cloud.agent.api.element.ApplyStaticNatVspCommand) ArrayList(java.util.ArrayList) VspStaticNat(net.nuage.vsp.acs.client.api.model.VspStaticNat) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) IPAddressVO(com.cloud.network.dao.IPAddressVO) VlanVO(com.cloud.dc.VlanVO) VspNetwork(net.nuage.vsp.acs.client.api.model.VspNetwork) NicVO(com.cloud.vm.NicVO) HostVO(com.cloud.host.HostVO) VspStaticNat(net.nuage.vsp.acs.client.api.model.VspStaticNat) StaticNat(com.cloud.network.rules.StaticNat)

Example 2 with ApplyStaticNatVspCommand

use of com.cloud.agent.api.element.ApplyStaticNatVspCommand in project cloudstack by apache.

the class NuageVspResourceTest method testApplyStaticNatVspCommand.

@Test
public void testApplyStaticNatVspCommand() throws Exception {
    _resource.configure("NuageVspResource", _hostDetails);
    VspNetwork vspNetwork = buildVspNetwork();
    List<VspStaticNat> vspStaticNatDetails = Lists.newArrayList(buildVspStaticNat());
    ApplyStaticNatVspCommand cmd = new ApplyStaticNatVspCommand(vspNetwork, vspStaticNatDetails);
    Answer applyNatAns = _resource.executeRequest(cmd);
    assertTrue(applyNatAns.getResult());
}
Also used : Answer(com.cloud.agent.api.Answer) ApplyStaticNatVspCommand(com.cloud.agent.api.element.ApplyStaticNatVspCommand) VspStaticNat(net.nuage.vsp.acs.client.api.model.VspStaticNat) VspNetwork(net.nuage.vsp.acs.client.api.model.VspNetwork) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Aggregations

Answer (com.cloud.agent.api.Answer)2 ApplyStaticNatVspCommand (com.cloud.agent.api.element.ApplyStaticNatVspCommand)2 VspNetwork (net.nuage.vsp.acs.client.api.model.VspNetwork)2 VspStaticNat (net.nuage.vsp.acs.client.api.model.VspStaticNat)2 NuageTest (com.cloud.NuageTest)1 VlanVO (com.cloud.dc.VlanVO)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 HostVO (com.cloud.host.HostVO)1 IPAddressVO (com.cloud.network.dao.IPAddressVO)1 StaticNat (com.cloud.network.rules.StaticNat)1 NicVO (com.cloud.vm.NicVO)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1