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());
}
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();
}
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;
}
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);
}
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());
}
Aggregations