use of com.cloud.agent.resource.virtualnetwork.model.DhcpConfig in project cloudstack by apache.
the class DnsMasqConfigItem method generateConfig.
@Override
public List<ConfigItem> generateConfig(final NetworkElementCommand cmd) {
final DnsMasqConfigCommand command = (DnsMasqConfigCommand) cmd;
final LinkedList<DhcpConfigEntry> entries = new LinkedList<DhcpConfigEntry>();
for (final DhcpTO dhcpTo : command.getIps()) {
final DhcpConfigEntry entry = new DhcpConfigEntry(dhcpTo.getRouterIp(), dhcpTo.getGateway(), dhcpTo.getNetmask(), dhcpTo.getStartIpOfSubnet());
entries.add(entry);
}
return generateConfigItems(new DhcpConfig(entries));
}
use of com.cloud.agent.resource.virtualnetwork.model.DhcpConfig 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