params.put(ApiConstants.PRIVATE_IP, ipmiIp);
params.put(ApiConstants.USERNAME, username);
params.put(ApiConstants.PASSWORD, password);
String resourceClassName = _configDao.getValue(Config.ExternalBaremetalResourceClassName.key());
BareMetalResourceBase resource = null;
if (resourceClassName != null) {
Class<?> clazz = Class.forName(resourceClassName);
resource = (BareMetalResourceBase) clazz.newInstance();
String externalUrl = _configDao.getValue(Config.ExternalBaremetalSystemUrl.key());
if (externalUrl == null) {
throw new IllegalArgumentException(String.format("You must specify ExternalBaremetalSystemUrl in global config page as ExternalBaremetalResourceClassName is not null"));
}
details.put(BaremetalManager.ExternalBaremetalSystemUrl, externalUrl);
} else {
resource = new BareMetalResourceBase();
}
resource.configure("Bare Metal Agent", params);
String memCapacity = (String)params.get(ApiConstants.MEMORY);
String cpuCapacity = (String)params.get(ApiConstants.CPU_SPEED);
String cpuNum = (String)params.get(ApiConstants.CPU_NUMBER);
String mac = (String)params.get(ApiConstants.HOST_MAC);
if (hostTags != null && hostTags.size() != 0) {
details.put("hostTag", hostTags.get(0));
}
details.put(ApiConstants.MEMORY, memCapacity);
details.put(ApiConstants.CPU_SPEED, cpuCapacity);
details.put(ApiConstants.CPU_NUMBER, cpuNum);
details.put(ApiConstants.HOST_MAC, mac);
details.put(ApiConstants.USERNAME, username);
details.put(ApiConstants.PASSWORD, password);
details.put(ApiConstants.PRIVATE_IP, ipmiIp);
String vmIp = (String)params.get(ApiConstants.IP_ADDRESS);
if (vmIp != null) {
details.put(ApiConstants.IP_ADDRESS, vmIp);
}
String isEchoScAgent = _configDao.getValue(Config.EnableBaremetalSecurityGroupAgentEcho.key());
details.put(BaremetalManager.EchoSecurityGroupAgent, isEchoScAgent);
resources.put(resource, details);
resource.start();
zone.setGatewayProvider(Network.Provider.ExternalGateWay.getName());
zone.setDnsProvider(Network.Provider.ExternalDhcpServer.getName());
zone.setDhcpProvider(Network.Provider.ExternalDhcpServer.getName());
_dcDao.update(zone.getId(), zone);