Search in sources :

Example 1 with IpAddress

use of com.cloud.agent.resource.virtualnetwork.model.IpAddress in project cloudstack by apache.

the class ConfigHelperTest method testIpAssocVpc.

@Test
public void testIpAssocVpc() {
    final IpAssocVpcCommand command = generateIpAssocVpcCommand();
    final AbstractConfigItemFacade configItemFacade = AbstractConfigItemFacade.getInstance(command.getClass());
    final List<ConfigItem> config = configItemFacade.generateConfig(command);
    assertTrue(config.size() > 0);
    final ConfigItem fileConfig = config.get(0);
    assertNotNull(fileConfig);
    assertTrue(fileConfig instanceof FileConfigItem);
    final String fileContents = ((FileConfigItem) fileConfig).getFileContents();
    assertNotNull(fileContents);
    final IpAssociation jsonClass = gson.fromJson(fileContents, IpAssociation.class);
    assertNotNull(jsonClass);
    assertEquals(jsonClass.getType(), "ips");
    final IpAddress[] ips = jsonClass.getIpAddress();
    assertNotNull(ips);
    assertTrue(ips.length == 3);
    assertEquals(ips[0].getPublicIp(), "64.1.1.10");
    final ConfigItem scriptConfig = config.get(1);
    assertNotNull(scriptConfig);
    assertTrue(scriptConfig instanceof ScriptConfigItem);
}
Also used : AbstractConfigItemFacade(com.cloud.agent.resource.virtualnetwork.facade.AbstractConfigItemFacade) IpAddress(com.cloud.agent.resource.virtualnetwork.model.IpAddress) IpAssocVpcCommand(com.cloud.agent.api.routing.IpAssocVpcCommand) IpAssociation(com.cloud.agent.resource.virtualnetwork.model.IpAssociation) Test(org.junit.Test)

Example 2 with IpAddress

use of com.cloud.agent.resource.virtualnetwork.model.IpAddress in project cloudstack by apache.

the class IpAssociationConfigItem method generateConfig.

@Override
public List<ConfigItem> generateConfig(final NetworkElementCommand cmd) {
    final IpAssocCommand command = (IpAssocCommand) cmd;
    final List<IpAddress> ips = new LinkedList<IpAddress>();
    for (final IpAddressTO ip : command.getIpAddresses()) {
        final IpAddress ipAddress = new IpAddress(ip.getPublicIp(), ip.isSourceNat(), ip.isAdd(), ip.isOneToOneNat(), ip.isFirstIP(), ip.getVlanGateway(), ip.getVlanNetmask(), ip.getVifMacAddress(), ip.getNicDevId(), ip.isNewNic(), ip.getTrafficType().toString());
        ipAddress.setPrivateGateway(ip.isPrivateGateway());
        ips.add(ipAddress);
    }
    final IpAssociation ipAssociation = new IpAssociation(ips.toArray(new IpAddress[ips.size()]));
    return generateConfigItems(ipAssociation);
}
Also used : IpAddressTO(com.cloud.agent.api.to.IpAddressTO) IpAssocCommand(com.cloud.agent.api.routing.IpAssocCommand) IpAddress(com.cloud.agent.resource.virtualnetwork.model.IpAddress) IpAssociation(com.cloud.agent.resource.virtualnetwork.model.IpAssociation) LinkedList(java.util.LinkedList)

Aggregations

IpAddress (com.cloud.agent.resource.virtualnetwork.model.IpAddress)2 IpAssociation (com.cloud.agent.resource.virtualnetwork.model.IpAssociation)2 IpAssocCommand (com.cloud.agent.api.routing.IpAssocCommand)1 IpAssocVpcCommand (com.cloud.agent.api.routing.IpAssocVpcCommand)1 IpAddressTO (com.cloud.agent.api.to.IpAddressTO)1 AbstractConfigItemFacade (com.cloud.agent.resource.virtualnetwork.facade.AbstractConfigItemFacade)1 LinkedList (java.util.LinkedList)1 Test (org.junit.Test)1