Search in sources :

Example 1 with AbstractConfigItemFacade

use of com.cloud.common.virtualnetwork.facade.AbstractConfigItemFacade in project cosmic by MissionCriticalCloud.

the class VirtualRoutingResource method generateCommandCfg.

private List<ConfigItem> generateCommandCfg(final NetworkElementCommand cmd) {
    s_logger.debug("Transforming " + cmd.getClass().getCanonicalName() + " to ConfigItems");
    final AbstractConfigItemFacade configItemFacade = AbstractConfigItemFacade.getInstance(cmd.getClass());
    return configItemFacade.generateConfig(cmd);
}
Also used : AbstractConfigItemFacade(com.cloud.common.virtualnetwork.facade.AbstractConfigItemFacade)

Example 2 with AbstractConfigItemFacade

use of com.cloud.common.virtualnetwork.facade.AbstractConfigItemFacade in project cosmic by MissionCriticalCloud.

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.legacymodel.network.rules.ForwardingRule) AbstractConfigItemFacade(com.cloud.common.virtualnetwork.facade.AbstractConfigItemFacade) SetPortForwardingRulesVpcCommand(com.cloud.legacymodel.communication.command.SetPortForwardingRulesVpcCommand) ForwardingRules(com.cloud.legacymodel.network.rules.ForwardingRules) Test(org.junit.Test)

Example 3 with AbstractConfigItemFacade

use of com.cloud.common.virtualnetwork.facade.AbstractConfigItemFacade in project cosmic by MissionCriticalCloud.

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.legacymodel.network.rules.LoadBalancerRule) AbstractConfigItemFacade(com.cloud.common.virtualnetwork.facade.AbstractConfigItemFacade) LoadBalancerRules(com.cloud.legacymodel.network.rules.LoadBalancerRules) LoadBalancerConfigCommand(com.cloud.legacymodel.communication.command.LoadBalancerConfigCommand) Test(org.junit.Test)

Aggregations

AbstractConfigItemFacade (com.cloud.common.virtualnetwork.facade.AbstractConfigItemFacade)3 Test (org.junit.Test)2 LoadBalancerConfigCommand (com.cloud.legacymodel.communication.command.LoadBalancerConfigCommand)1 SetPortForwardingRulesVpcCommand (com.cloud.legacymodel.communication.command.SetPortForwardingRulesVpcCommand)1 ForwardingRule (com.cloud.legacymodel.network.rules.ForwardingRule)1 ForwardingRules (com.cloud.legacymodel.network.rules.ForwardingRules)1 LoadBalancerRule (com.cloud.legacymodel.network.rules.LoadBalancerRule)1 LoadBalancerRules (com.cloud.legacymodel.network.rules.LoadBalancerRules)1