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