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());
}
}
use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3VmSupportTest method MigrateCommandTest.
@Test
public void MigrateCommandTest() throws ConfigurationException, Ovm3ResourceException {
Ovm3Configuration configuration = new Ovm3Configuration(configTest.getParams());
hypervisor = support.prepare(configTest.getParams());
MigrateCommand cmd = new MigrateCommand(xen.getVmName(), configuration.getAgentIp(), false, hyperTest.createVm(xen.getVmName()), false);
Answer ra = hypervisor.executeRequest(cmd);
results.basicBooleanTest(ra.getResult());
}
use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3HypervisorResource method getCurrentStatus.
@Override
public PingCommand getCurrentStatus(long id) {
try {
/* feels useless somehow */
Common test = new Common(c);
String ping = "put";
String pong = test.echo(ping);
if (pong.contains(ping)) {
hypervisorsupport.syncState();
CloudstackPlugin cSp = new CloudstackPlugin(c);
if (!cSp.dom0CheckStorageHealthCheck(configuration.getAgentScriptsDir(), configuration.getAgentCheckStorageScript(), configuration.getCsHostGuid(), configuration.getAgentStorageCheckTimeout(), configuration.getAgentStorageCheckInterval()) && !cSp.dom0CheckStorageHealthCheck()) {
LOGGER.error("Storage health check not running on " + configuration.getAgentHostname());
} else if (cSp.dom0CheckStorageHealthCheck()) {
LOGGER.error("Storage health check started on " + configuration.getAgentHostname());
} else {
LOGGER.debug("Storage health check running on " + configuration.getAgentHostname());
}
return new PingRoutingCommand(getType(), id, hypervisorsupport.hostVmStateReport());
} else {
LOGGER.debug("Agent did not respond correctly: " + ping + " but got " + pong);
}
} catch (Ovm3ResourceException | NullPointerException e) {
LOGGER.debug("Check agent status failed", e);
return null;
}
return null;
}
Aggregations