Search in sources :

Example 1 with VspStaticNat

use of net.nuage.vsp.acs.client.api.model.VspStaticNat 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)

Example 2 with VspStaticNat

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

the class NuageVspEntityBuilder method buildVspStaticNat.

public VspStaticNat buildVspStaticNat(Boolean forRevoke, IPAddressVO staticNatIp, VlanVO staticNatVlan, NicVO nic) {
    VspStaticNat.Builder vspStaticNatBuilder = new VspStaticNat.Builder().ipUuid(staticNatIp.getUuid()).ipAddress(staticNatIp.getAddress().addr()).revoke(forRevoke).oneToOneNat(staticNatIp.isOneToOneNat()).vlanUuid(staticNatVlan.getUuid()).vlanGateway(staticNatVlan.getVlanGateway()).vlanNetmask(staticNatVlan.getVlanNetmask()).vlanUnderlay(NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, staticNatVlan));
    if (nic != null) {
        VspNic vspNic = buildVspNic(nic);
        vspStaticNatBuilder.nic(vspNic);
    }
    return vspStaticNatBuilder.build();
}
Also used : VspStaticNat(net.nuage.vsp.acs.client.api.model.VspStaticNat) VspNic(net.nuage.vsp.acs.client.api.model.VspNic)

Example 3 with VspStaticNat

use of net.nuage.vsp.acs.client.api.model.VspStaticNat 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 4 with VspStaticNat

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

the class NuageVspEntityBuilderTest method testBuildVspStaticNat.

@Test
public void testBuildVspStaticNat() {
    VspStaticNat vspStaticNat = _nuageVspEntityBuilder.buildVspStaticNat(true, _mockedStaticNatIp, _mockedStaticNatVlan, _mockedNic);
    validateVspStaticNat(vspStaticNat, true);
}
Also used : VspStaticNat(net.nuage.vsp.acs.client.api.model.VspStaticNat) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 5 with VspStaticNat

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

the class NuageVspResourceTest method testReserveVmInterfaceVspCommand.

@Test
public void testReserveVmInterfaceVspCommand() throws Exception {
    _resource.configure("NuageVspResource", _hostDetails);
    VspNetwork vspNetwork = buildVspNetwork();
    VspVm vspVm = buildVspVm();
    VspNic vspNic = buildVspNic();
    VspStaticNat vspStaticNat = buildVspStaticNat();
    VspDhcpVMOption vspDhcpOption = buildspDhcpVMOption();
    ReserveVmInterfaceVspCommand cmd = new ReserveVmInterfaceVspCommand(vspNetwork, vspVm, vspNic, vspStaticNat, vspDhcpOption);
    Answer rsrvVmInfAns = _resource.executeRequest(cmd);
    assertTrue(rsrvVmInfAns.getResult());
}
Also used : Answer(com.cloud.agent.api.Answer) VspStaticNat(net.nuage.vsp.acs.client.api.model.VspStaticNat) ReserveVmInterfaceVspCommand(com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand) VspVm(net.nuage.vsp.acs.client.api.model.VspVm) VspNetwork(net.nuage.vsp.acs.client.api.model.VspNetwork) VspNic(net.nuage.vsp.acs.client.api.model.VspNic) VspDhcpVMOption(net.nuage.vsp.acs.client.api.model.VspDhcpVMOption) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Aggregations

VspStaticNat (net.nuage.vsp.acs.client.api.model.VspStaticNat)6 Answer (com.cloud.agent.api.Answer)4 VspNetwork (net.nuage.vsp.acs.client.api.model.VspNetwork)4 NuageTest (com.cloud.NuageTest)3 VspNic (net.nuage.vsp.acs.client.api.model.VspNic)3 Test (org.junit.Test)3 ApplyStaticNatVspCommand (com.cloud.agent.api.element.ApplyStaticNatVspCommand)2 ReserveVmInterfaceVspCommand (com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand)2 VlanVO (com.cloud.dc.VlanVO)2 HostVO (com.cloud.host.HostVO)2 IPAddressVO (com.cloud.network.dao.IPAddressVO)2 NicVO (com.cloud.vm.NicVO)2 VspDhcpVMOption (net.nuage.vsp.acs.client.api.model.VspDhcpVMOption)2 VspVm (net.nuage.vsp.acs.client.api.model.VspVm)2 DataCenter (com.cloud.dc.DataCenter)1 InsufficientVirtualNetworkCapacityException (com.cloud.exception.InsufficientVirtualNetworkCapacityException)1 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)1 Network (com.cloud.network.Network)1 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1 StaticNat (com.cloud.network.rules.StaticNat)1