Search in sources :

Example 1 with VspNic

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

the class NuageVspEntityBuilderTest method testBuildVspNic.

@Test
public void testBuildVspNic() {
    VspNic vspNic = _nuageVspEntityBuilder.buildVspNic("nicUuid", _mockedNicProfile);
    validateVspNic(vspNic);
    vspNic = _nuageVspEntityBuilder.buildVspNic(_mockedNic);
    validateVspNic(vspNic);
}
Also used : VspNic(net.nuage.vsp.acs.client.api.model.VspNic) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 2 with VspNic

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

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

the class NuageVspGuestNetworkGuru method deallocate.

@Override
@DB
public void deallocate(Network network, NicProfile nic, VirtualMachineProfile vm) {
    boolean lockedNetwork = lockNetworkForUserVm(network, vm);
    if (lockedNetwork && s_logger.isDebugEnabled()) {
        s_logger.debug("Locked network " + network.getId() + " for deallocation of user VM " + vm.getInstanceName());
    }
    try {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Handling deallocate() call back, which is called when a VM is destroyed or interface is removed, " + "to delete VM Interface with IP " + nic.getIPv4Address() + " from a VM " + vm.getInstanceName() + " with state " + vm.getVirtualMachine().getState());
        }
        NicVO nicFromDb = _nicDao.findById(nic.getId());
        VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(vm.getVirtualMachine().getDomainId(), network);
        VspVm vspVm = _nuageVspEntityBuilder.buildVspVm(vm.getVirtualMachine(), network);
        VspNic vspNic = _nuageVspEntityBuilder.buildVspNic(nicFromDb.getUuid(), nic);
        HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(network.getPhysicalNetworkId());
        DeallocateVmVspCommand cmd = new DeallocateVmVspCommand(vspNetwork, vspVm, vspNic);
        Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
        if (answer == null || !answer.getResult()) {
            s_logger.error("DeallocateVmNuageVspCommand for VM " + vm.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname"));
            if ((null != answer) && (null != answer.getDetails())) {
                s_logger.error(answer.getDetails());
            }
        }
        // because it is still allocated for the VR.
        if (vspNetwork.isShared() && VirtualMachine.Type.User.equals(vm.getType()) && nic.getIPv4Address().equals(vspNetwork.getVirtualRouterIp())) {
            nic.deallocate();
        } else {
            super.deallocate(network, nic, vm);
        }
    } finally {
        if (network != null && lockedNetwork) {
            _networkDao.releaseFromLockTable(network.getId());
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Unlocked network " + network.getId() + " for deallocation of user VM " + vm.getInstanceName());
            }
        }
    }
}
Also used : Answer(com.cloud.agent.api.Answer) DeallocateVmVspCommand(com.cloud.agent.api.guru.DeallocateVmVspCommand) 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) NicVO(com.cloud.vm.NicVO) HostVO(com.cloud.host.HostVO) DB(com.cloud.utils.db.DB)

Example 4 with VspNic

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

the class NuageVspResourceTest method testDeallocateVmVspCommand.

@Test
public void testDeallocateVmVspCommand() throws Exception {
    _resource.configure("NuageVspResource", _hostDetails);
    VspNetwork vspNetwork = buildVspNetwork();
    VspVm vspVm = buildVspVm();
    VspNic vspNic = buildVspNic();
    DeallocateVmVspCommand cmd = new DeallocateVmVspCommand(vspNetwork, vspVm, vspNic);
    Answer dellocateVmAns = _resource.executeRequest(cmd);
    assertTrue(dellocateVmAns.getResult());
}
Also used : Answer(com.cloud.agent.api.Answer) DeallocateVmVspCommand(com.cloud.agent.api.guru.DeallocateVmVspCommand) 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) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 5 with VspNic

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

VspNic (net.nuage.vsp.acs.client.api.model.VspNic)7 VspNetwork (net.nuage.vsp.acs.client.api.model.VspNetwork)5 Answer (com.cloud.agent.api.Answer)4 VspVm (net.nuage.vsp.acs.client.api.model.VspVm)4 NuageTest (com.cloud.NuageTest)3 VspStaticNat (net.nuage.vsp.acs.client.api.model.VspStaticNat)3 Test (org.junit.Test)3 DeallocateVmVspCommand (com.cloud.agent.api.guru.DeallocateVmVspCommand)2 ReserveVmInterfaceVspCommand (com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand)2 HostVO (com.cloud.host.HostVO)2 Network (com.cloud.network.Network)2 NetworkOffering (com.cloud.offering.NetworkOffering)2 NicVO (com.cloud.vm.NicVO)2 VspDhcpVMOption (net.nuage.vsp.acs.client.api.model.VspDhcpVMOption)2 DataCenter (com.cloud.dc.DataCenter)1 VlanVO (com.cloud.dc.VlanVO)1 InsufficientVirtualNetworkCapacityException (com.cloud.exception.InsufficientVirtualNetworkCapacityException)1 PhysicalNetwork (com.cloud.network.PhysicalNetwork)1 IPAddressVO (com.cloud.network.dao.IPAddressVO)1 AccountVO (com.cloud.user.AccountVO)1