use of com.cloud.agent.resource.virtualnetwork.model.IpAddressAlias in project cloudstack by apache.
the class CreateIpAliasConfigItem method generateConfig.
@Override
public List<ConfigItem> generateConfig(final NetworkElementCommand cmd) {
final CreateIpAliasCommand command = (CreateIpAliasCommand) cmd;
final List<IpAddressAlias> ipAliases = new LinkedList<IpAddressAlias>();
final List<IpAliasTO> ipAliasTOs = command.getIpAliasList();
for (final IpAliasTO ipaliasto : ipAliasTOs) {
final IpAddressAlias alias = new IpAddressAlias(false, ipaliasto.getRouterip(), ipaliasto.getNetmask(), Long.parseLong(ipaliasto.getAlias_count()));
ipAliases.add(alias);
}
final IpAliases ipAliasList = new IpAliases(ipAliases);
return generateConfigItems(ipAliasList);
}
use of com.cloud.agent.resource.virtualnetwork.model.IpAddressAlias in project cloudstack by apache.
the class DeleteIpAliasConfigItem method generateConfig.
@Override
public List<ConfigItem> generateConfig(final NetworkElementCommand cmd) {
final DeleteIpAliasCommand command = (DeleteIpAliasCommand) cmd;
final List<IpAddressAlias> ipAliases = new LinkedList<IpAddressAlias>();
final List<IpAliasTO> revokedIpAliasTOs = command.getDeleteIpAliasTos();
for (final IpAliasTO ipAliasTO : revokedIpAliasTOs) {
final IpAddressAlias alias = new IpAddressAlias(true, ipAliasTO.getRouterip(), ipAliasTO.getNetmask(), Long.parseLong(ipAliasTO.getAlias_count()));
ipAliases.add(alias);
}
final List<IpAliasTO> activeIpAliasTOs = command.getCreateIpAliasTos();
for (final IpAliasTO ipAliasTO : activeIpAliasTOs) {
final IpAddressAlias alias = new IpAddressAlias(false, ipAliasTO.getRouterip(), ipAliasTO.getNetmask(), Long.parseLong(ipAliasTO.getAlias_count()));
ipAliases.add(alias);
}
final IpAliases ipAliasList = new IpAliases(ipAliases);
return generateConfigItems(ipAliasList);
}
use of com.cloud.agent.resource.virtualnetwork.model.IpAddressAlias in project cloudstack by apache.
the class ConfigHelperTest method testDeleteIpAlias.
@Test
public void testDeleteIpAlias() {
final DeleteIpAliasCommand command = generateDeleteIpAliasCommand();
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 IpAliases jsonClass = gson.fromJson(fileContents, IpAliases.class);
assertNotNull(jsonClass);
assertEquals(jsonClass.getType(), "ipaliases");
final List<IpAddressAlias> aliases = jsonClass.getAliases();
assertNotNull(aliases);
assertTrue(aliases.size() == 6);
assertEquals(aliases.get(0).getIpAddress(), "169.254.3.10");
final ConfigItem scriptConfig = config.get(1);
assertNotNull(scriptConfig);
assertTrue(scriptConfig instanceof ScriptConfigItem);
}
Aggregations