use of com.cloud.agent.resource.virtualnetwork.model.IpAssociation 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());
ips.add(ipAddress);
}
final IpAssociation ipAssociation = new IpAssociation(ips.toArray(new IpAddress[ips.size()]));
return generateConfigItems(ipAssociation);
}
use of com.cloud.agent.resource.virtualnetwork.model.IpAssociation 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);
}
Aggregations