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);
}
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);
}
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);
}
Aggregations