Search in sources :

Example 1 with AbstractConfigItemFacade

use of com.cloud.agent.resource.virtualnetwork.facade.AbstractConfigItemFacade in project cloudstack by apache.

the class ConfigHelperTest method testSetPortForwardingRulesVpc.

@Test
public void testSetPortForwardingRulesVpc() {
    final SetPortForwardingRulesVpcCommand command = generateSetPortForwardingRulesVpcCommand();
    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 ForwardingRules jsonClass = gson.fromJson(fileContents, ForwardingRules.class);
    assertNotNull(jsonClass);
    assertEquals(jsonClass.getType(), "forwardrules");
    final ForwardingRule[] rules = jsonClass.getRules();
    assertNotNull(rules);
    assertTrue(rules.length == 2);
    assertEquals(rules[0].getSourceIpAddress(), "64.1.1.10");
    final ConfigItem scriptConfig = config.get(1);
    assertNotNull(scriptConfig);
    assertTrue(scriptConfig instanceof ScriptConfigItem);
}
Also used : ForwardingRule(com.cloud.agent.resource.virtualnetwork.model.ForwardingRule) AbstractConfigItemFacade(com.cloud.agent.resource.virtualnetwork.facade.AbstractConfigItemFacade) SetPortForwardingRulesVpcCommand(com.cloud.agent.api.routing.SetPortForwardingRulesVpcCommand) ForwardingRules(com.cloud.agent.resource.virtualnetwork.model.ForwardingRules) Test(org.junit.Test)

Example 2 with AbstractConfigItemFacade

use of com.cloud.agent.resource.virtualnetwork.facade.AbstractConfigItemFacade in project cloudstack by apache.

the class ConfigHelperTest method testGenerateCommandCfgLoadBalancer.

@Test
public void testGenerateCommandCfgLoadBalancer() {
    final LoadBalancerConfigCommand command = generateLoadBalancerConfigCommand();
    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 LoadBalancerRules jsonClass = gson.fromJson(fileContents, LoadBalancerRules.class);
    assertNotNull(jsonClass);
    assertEquals(jsonClass.getType(), "loadbalancer");
    final List<LoadBalancerRule> rules = jsonClass.getRules();
    assertNotNull(rules);
    assertTrue(rules.size() == 1);
    assertEquals(rules.get(0).getRouterIp(), "10.1.10.2");
    final ConfigItem scriptConfig = config.get(1);
    assertNotNull(scriptConfig);
    assertTrue(scriptConfig instanceof ScriptConfigItem);
}
Also used : LoadBalancerRule(com.cloud.agent.resource.virtualnetwork.model.LoadBalancerRule) AbstractConfigItemFacade(com.cloud.agent.resource.virtualnetwork.facade.AbstractConfigItemFacade) LoadBalancerRules(com.cloud.agent.resource.virtualnetwork.model.LoadBalancerRules) LoadBalancerConfigCommand(com.cloud.agent.api.routing.LoadBalancerConfigCommand) Test(org.junit.Test)

Example 3 with AbstractConfigItemFacade

use of com.cloud.agent.resource.virtualnetwork.facade.AbstractConfigItemFacade 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 4 with AbstractConfigItemFacade

use of com.cloud.agent.resource.virtualnetwork.facade.AbstractConfigItemFacade 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)

Example 5 with AbstractConfigItemFacade

use of com.cloud.agent.resource.virtualnetwork.facade.AbstractConfigItemFacade in project cloudstack by apache.

the class ConfigHelperTest method testDnsMasqConfig.

@Test
public void testDnsMasqConfig() {
    final DnsMasqConfigCommand command = generateDnsMasqConfigCommand();
    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 DhcpConfig jsonClass = gson.fromJson(fileContents, DhcpConfig.class);
    assertNotNull(jsonClass);
    assertEquals(jsonClass.getType(), "dhcpconfig");
    final List<DhcpConfigEntry> entries = jsonClass.getEntries();
    assertNotNull(entries);
    assertTrue(entries.size() == 2);
    assertEquals(entries.get(0).getRouterIpAddress(), "10.1.20.2");
    final ConfigItem scriptConfig = config.get(1);
    assertNotNull(scriptConfig);
    assertTrue(scriptConfig instanceof ScriptConfigItem);
}
Also used : AbstractConfigItemFacade(com.cloud.agent.resource.virtualnetwork.facade.AbstractConfigItemFacade) DhcpConfig(com.cloud.agent.resource.virtualnetwork.model.DhcpConfig) DhcpConfigEntry(com.cloud.agent.resource.virtualnetwork.model.DhcpConfigEntry) DnsMasqConfigCommand(com.cloud.agent.api.routing.DnsMasqConfigCommand) Test(org.junit.Test)

Aggregations

AbstractConfigItemFacade (com.cloud.agent.resource.virtualnetwork.facade.AbstractConfigItemFacade)6 Test (org.junit.Test)5 DeleteIpAliasCommand (com.cloud.agent.api.routing.DeleteIpAliasCommand)1 DnsMasqConfigCommand (com.cloud.agent.api.routing.DnsMasqConfigCommand)1 IpAssocVpcCommand (com.cloud.agent.api.routing.IpAssocVpcCommand)1 LoadBalancerConfigCommand (com.cloud.agent.api.routing.LoadBalancerConfigCommand)1 SetPortForwardingRulesVpcCommand (com.cloud.agent.api.routing.SetPortForwardingRulesVpcCommand)1 DhcpConfig (com.cloud.agent.resource.virtualnetwork.model.DhcpConfig)1 DhcpConfigEntry (com.cloud.agent.resource.virtualnetwork.model.DhcpConfigEntry)1 ForwardingRule (com.cloud.agent.resource.virtualnetwork.model.ForwardingRule)1 ForwardingRules (com.cloud.agent.resource.virtualnetwork.model.ForwardingRules)1 IpAddress (com.cloud.agent.resource.virtualnetwork.model.IpAddress)1 IpAddressAlias (com.cloud.agent.resource.virtualnetwork.model.IpAddressAlias)1 IpAliases (com.cloud.agent.resource.virtualnetwork.model.IpAliases)1 IpAssociation (com.cloud.agent.resource.virtualnetwork.model.IpAssociation)1 LoadBalancerRule (com.cloud.agent.resource.virtualnetwork.model.LoadBalancerRule)1 LoadBalancerRules (com.cloud.agent.resource.virtualnetwork.model.LoadBalancerRules)1