use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3StoragePool method prepareForPool.
/**
* Prepare a host to become part of a pool, the roles and ownership are
* important here.
*
* @return
* @throws ConfigurationException
*/
public boolean prepareForPool() throws ConfigurationException {
/* need single master uuid */
try {
Linux host = new Linux(c);
Pool pool = new Pool(c);
/* setup pool and role, needs utility to be able to do things */
if (host.getServerRoles().contentEquals(pool.getValidRoles().toString())) {
LOGGER.info("Server role for host " + config.getAgentHostname() + " is ok");
} else {
setRoles(pool);
}
if (host.getMembershipState().contentEquals("Unowned")) {
if (host.getOvmVersion().startsWith("3.2.")) {
takeOwnership(pool);
} else if (host.getOvmVersion().startsWith("3.3.")) {
takeOwnership33x(pool);
}
} else {
if (host.getManagerUuid().equals(config.getAgentOwnedByUuid())) {
String msg = "Host " + config.getAgentHostname() + " owned by us";
LOGGER.debug(msg);
return true;
} else {
String msg = "Host " + config.getAgentHostname() + " already part of a pool, and not owned by us";
LOGGER.error(msg);
throw new ConfigurationException(msg);
}
}
} catch (ConfigurationException | Ovm3ResourceException es) {
String msg = "Failed to prepare " + config.getAgentHostname() + " for pool: " + es.getMessage();
LOGGER.error(msg);
throw new ConfigurationException(msg);
}
return true;
}
use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3StoragePool method takeOwnership.
/**
* If you don't own the host you can't fiddle with it.
*
* @param pool
* @throws ConfigurationException
*/
private void takeOwnership(Pool pool) throws ConfigurationException {
try {
LOGGER.debug("Take ownership of host " + config.getAgentHostname());
pool.takeOwnership(config.getAgentOwnedByUuid(), "");
} catch (Ovm3ResourceException e) {
String msg = "Failed to take ownership of host " + config.getAgentHostname();
LOGGER.error(msg);
throw new ConfigurationException(msg);
}
}
use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3StoragePool method execute.
/**
* Get a host out of a pool/cluster, this should unmount all FSs though.
*
* @param cmd
* @return
*/
public Answer execute(DeleteStoragePoolCommand cmd) {
try {
Pool pool = new Pool(c);
pool.leaveServerPool(cmd.getPool().getUuid());
/* also connect to the master and update the pool list ? */
} catch (Ovm3ResourceException e) {
LOGGER.debug("Delete storage pool on host " + config.getAgentHostname() + " failed, however, we leave to user for cleanup and tell managment server it succeeded", e);
}
return new Answer(cmd);
}
use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class StoragePluginTest method testNFSStorageMountCreation.
@Test
public void testNFSStorageMountCreation() throws Ovm3ResourceException {
con.setResult(results.simpleResponseWrapWrapper(NFSMOUNTRESPONSEXML));
StorageDetails sd = sPt.storagePluginMountNFS(NFSHOST, NFSPATH, FSMNTUUID, NFSMNT);
con.setResult(results.simpleResponseWrapWrapper(NFSMOUNTRESPONSEXML));
NFSMNT = NFSMNT + "/" + FSMNTUUID;
sd = sPt.storagePluginMountNFS(NFSHOST, NFSPATH, FSMNTUUID, NFSMNT);
results.basicLongTest(Long.valueOf(sd.getSize()), 263166853120L);
results.basicLongTest(Long.valueOf(sd.getFreeSize()), 259377299456L);
results.basicStringTest(sd.getName(), "nfs:" + NFSPATH);
results.basicStringTest(sd.getUuid(), FSPROPUUID);
results.basicStringTest(sd.getDetailsRelationalUuid(), FSMNTUUID);
}
use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3HypervisorResourceTest method createVm.
public VirtualMachineTO createVm(String vmName) throws Ovm3ResourceException {
con = support.prepConnectionResults();
Xen vdata = new Xen(con);
Xen.Vm vm = vdata.getVmConfig(vmName);
vdata.listVm(xen.getRepoId(), xen.getVmId());
// Ovm3VmGuestTypes types = new Ovm3VmGuestTypes();
Long id = 1L;
String instanceName = vm.getVmName();
VirtualMachine.Type type = Type.User;
// vm.getVmCpus();
int cpus = 1;
Integer speed = 0;
long minRam = vm.getVmMemory();
long maxRam = vm.getVmMemory();
BootloaderType bootloader = BootloaderType.PyGrub;
String os = "Oracle Enterprise Linux 6.0 (64-bit)";
boolean enableHA = true;
boolean limitCpuUse = false;
String vncPassword = "gobbeldygoo";
// public StartCommand(VirtualMachineTO vm, Host host, boolean
// executeInSequence) {
// ./api/src/com/cloud/agent/api/to/VirtualMachineTO.java
VirtualMachineTO vmspec = new VirtualMachineTO(id, instanceName, type, cpus, speed, minRam, maxRam, bootloader, os, enableHA, limitCpuUse, vncPassword);
vmspec.setBootArgs("");
addDisksToSpec(vmspec, vm.getVmDisks());
addNicsToSpec(vmspec, vm.getVmVifs());
return vmspec;
}
Aggregations