Search in sources :

Example 1 with IpAliases

use of com.cloud.agent.resource.virtualnetwork.model.IpAliases 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);
}
Also used : IpAddressAlias(com.cloud.agent.resource.virtualnetwork.model.IpAddressAlias) CreateIpAliasCommand(com.cloud.agent.api.routing.CreateIpAliasCommand) IpAliasTO(com.cloud.agent.api.routing.IpAliasTO) IpAliases(com.cloud.agent.resource.virtualnetwork.model.IpAliases) LinkedList(java.util.LinkedList)

Example 2 with IpAliases

use of com.cloud.agent.resource.virtualnetwork.model.IpAliases 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);
}
Also used : IpAddressAlias(com.cloud.agent.resource.virtualnetwork.model.IpAddressAlias) DeleteIpAliasCommand(com.cloud.agent.api.routing.DeleteIpAliasCommand) IpAliasTO(com.cloud.agent.api.routing.IpAliasTO) IpAliases(com.cloud.agent.resource.virtualnetwork.model.IpAliases) LinkedList(java.util.LinkedList)

Example 3 with IpAliases

use of com.cloud.agent.resource.virtualnetwork.model.IpAliases 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);
}
Also used : IpAddressAlias(com.cloud.agent.resource.virtualnetwork.model.IpAddressAlias) AbstractConfigItemFacade(com.cloud.agent.resource.virtualnetwork.facade.AbstractConfigItemFacade) DeleteIpAliasCommand(com.cloud.agent.api.routing.DeleteIpAliasCommand) IpAliases(com.cloud.agent.resource.virtualnetwork.model.IpAliases) Test(org.junit.Test)

Aggregations

IpAddressAlias (com.cloud.agent.resource.virtualnetwork.model.IpAddressAlias)3 IpAliases (com.cloud.agent.resource.virtualnetwork.model.IpAliases)3 DeleteIpAliasCommand (com.cloud.agent.api.routing.DeleteIpAliasCommand)2 IpAliasTO (com.cloud.agent.api.routing.IpAliasTO)2 LinkedList (java.util.LinkedList)2 CreateIpAliasCommand (com.cloud.agent.api.routing.CreateIpAliasCommand)1 AbstractConfigItemFacade (com.cloud.agent.resource.virtualnetwork.facade.AbstractConfigItemFacade)1 Test (org.junit.Test)1