use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3HypervisorSupport method fillHostInfo.
/**
* fillHostInfo: Startup the routing for the host.
*
* @param cmd
*/
public void fillHostInfo(StartupRoutingCommand cmd) {
try {
/* get data we need from parts */
Linux host = new Linux(c);
if (!host.getOvmVersion().startsWith("3.2.") && !host.getOvmVersion().startsWith("3.3.")) {
LOGGER.error("Hypervisor not supported: " + host.getOvmVersion());
throw new CloudRuntimeException("OVM 3.2. or 3.3. are only supported, not " + host.getOvmVersion());
} else {
LOGGER.debug("Hypervisor version: " + host.getOvmVersion());
}
cmd.setName(host.getHostName());
cmd.setSpeed(host.getCpuKhz());
cmd.setCpus(host.getTotalThreads());
cmd.setCpuSockets(host.getCpuSockets());
cmd.setMemory(host.getMemory().longValue());
BigInteger totalmem = BigInteger.valueOf(host.getMemory().longValue());
BigInteger freemem = BigInteger.valueOf(host.getFreeMemory().longValue());
cmd.setDom0MinMemory(totalmem.subtract(freemem).longValue());
// setPoolSync and setCaps.
cmd.setGuid(config.getCsHostGuid());
cmd.setDataCenter(config.getAgentZoneId().toString());
cmd.setPod(config.getAgentPodId().toString());
/* TODO: cmd.setOwner(host.getManagerUuid()); */
cmd.setCluster(config.getAgentClusterId().toString());
cmd.setHypervisorVersion(host.getOvmVersion());
cmd.setVersion(host.getAgentVersion());
cmd.setHypervisorType(HypervisorType.Ovm3);
cmd.setCaps(host.getCapabilities());
cmd.setPrivateIpAddress(c.getIp());
cmd.setStorageIpAddress(c.getIp());
Network net = new Network(c);
String defaultBridge = net.getBridgeByIp(c.getIp()).getName();
if (defaultBridge == null) {
throw new CloudRuntimeException("Unable to obtain valid bridge with " + c.getIp());
}
if (config.getAgentPublicNetworkName() == null) {
config.setAgentPublicNetworkName(defaultBridge);
}
if (config.getAgentPrivateNetworkName() == null) {
config.setAgentPrivateNetworkName(config.getAgentPublicNetworkName());
}
if (config.getAgentGuestNetworkName() == null) {
config.setAgentGuestNetworkName(config.getAgentPublicNetworkName());
}
if (config.getAgentStorageNetworkName() == null) {
config.setAgentStorageNetworkName(config.getAgentPrivateNetworkName());
}
Map<String, String> d = cmd.getHostDetails();
d.put("public.network.device", config.getAgentPublicNetworkName());
d.put("private.network.device", config.getAgentPrivateNetworkName());
d.put("guest.network.device", config.getAgentGuestNetworkName());
d.put("storage.network.device", config.getAgentStorageNetworkName());
d.put("ismaster", config.getAgentIsMaster().toString());
d.put("hasmaster", config.getAgentHasMaster().toString());
cmd.setHostDetails(d);
LOGGER.debug("Add an Ovm3 host " + config.getAgentHostname() + ":" + cmd.getHostDetails());
} catch (Ovm3ResourceException e) {
throw new CloudRuntimeException("Ovm3ResourceException: " + e.getMessage(), e);
}
}
use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3HypervisorResourceTest method createVmTest.
@Test
public void createVmTest() throws ConfigurationException, Ovm3ResourceException {
VirtualMachineTO vmspec = createVm(vmName);
hypervisor = vmActionPreparation();
StartCommand cmd = new StartCommand(vmspec, getHost(hypervisor.getName()), true);
Answer ra = hypervisor.executeRequest(cmd);
results.basicBooleanTest(ra.getResult());
}
use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3HypervisorNetwork method configureNetworking.
public void configureNetworking() throws ConfigurationException {
/* TODO: setup meta tags for the management interface (probably
* required with multiple interfaces)?
*/
try {
Network net = new Network(c);
String controlIface = config.getAgentControlNetworkName();
if (controlIface != null && net.getInterfaceByName(controlIface) == null) {
LOGGER.debug("starting " + controlIface);
net.startOvsLocalConfig(controlIface);
/* ovs replies too "fast" so the bridge can be "busy" */
int contCount = 0;
while (net.getInterfaceByName(controlIface) == null) {
LOGGER.debug("waiting for " + controlIface);
Thread.sleep(1 * 1000);
if (contCount > 9) {
throw new ConfigurationException("Unable to configure " + controlIface + " on host " + config.getAgentHostname());
}
contCount++;
}
} else {
LOGGER.debug("already have " + controlIface);
}
/*
* The bridge is remembered upon reboot, but not the IP or the
* config. Zeroconf also adds the route again by default.
*/
net.ovsIpConfig(controlIface, "static", NetUtils.getLinkLocalGateway(), NetUtils.getLinkLocalNetMask());
CloudstackPlugin cSp = new CloudstackPlugin(c);
cSp.ovsControlInterface(controlIface, NetUtils.getLinkLocalCIDR());
} catch (InterruptedException e) {
LOGGER.error("interrupted?", e);
} catch (Ovm3ResourceException e) {
String msg = "Basic configuration failed on " + config.getAgentHostname();
LOGGER.error(msg, e);
throw new ConfigurationException(msg + ", " + e.getMessage());
}
}
Aggregations