use of com.cloud.hypervisor.ovm3.objects.CloudstackPlugin in project cloudstack by apache.
the class Ovm3HypervisorSupport method primaryCheck.
/**
* primaryCheck
*
* @return
*/
public boolean primaryCheck() {
if ("".equals(config.getOvm3PoolVip())) {
LOGGER.debug("No cluster vip, not checking for primary");
return false;
}
try {
CloudstackPlugin cSp = new CloudstackPlugin(c);
if (cSp.dom0HasIp(config.getOvm3PoolVip())) {
LOGGER.debug(config.getAgentHostname() + " is a primary, already has vip " + config.getOvm3PoolVip());
config.setAgentIsPrimary(true);
} else if (cSp.ping(config.getOvm3PoolVip())) {
LOGGER.debug(config.getAgentHostname() + " has a primary, someone has vip " + config.getOvm3PoolVip());
config.setAgentHasPrimary(true);
} else {
LOGGER.debug(config.getAgentHostname() + " becomes a primary, no one has vip " + config.getOvm3PoolVip());
config.setAgentIsPrimary(true);
}
} catch (Ovm3ResourceException e) {
LOGGER.debug(config.getAgentHostname() + " can't reach primary: " + e.getMessage());
config.setAgentHasPrimary(false);
}
return config.getAgentIsPrimary();
}
use of com.cloud.hypervisor.ovm3.objects.CloudstackPlugin 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;
}
use of com.cloud.hypervisor.ovm3.objects.CloudstackPlugin in project cloudstack by apache.
the class Ovm3VirtualRoutingResource method createFileInVR.
@Override
public ExecutionResult createFileInVR(String routerIp, String path, String filename, String content) {
String error = null;
logger.debug("createFileInVR via " + agentName + " on " + routerIp + ": " + path + "/" + filename + ", content: " + content);
try {
CloudstackPlugin cSp = new CloudstackPlugin(c);
boolean result = cSp.ovsDomrUploadFile(routerIp, path, filename, content);
return new ExecutionResult(result, "");
} catch (Exception e) {
error = e.getMessage();
logger.warn("createFileInVR failed for " + path + "/" + filename + " in VR " + routerIp + " via " + agentName + ": " + error, e);
}
return new ExecutionResult(error == null, error);
}
use of com.cloud.hypervisor.ovm3.objects.CloudstackPlugin 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.CloudstackPlugin in project cloudstack by apache.
the class Ovm3StoragePool method setupPool.
/**
* Setup a pool in general, this creates a repo if it doesn't exist yet, if
* it does however we mount it.
*
* @param cmd
* @return
* @throws Ovm3ResourceException
*/
private Boolean setupPool(StorageFilerTO cmd) throws Ovm3ResourceException {
String primUuid = cmd.getUuid();
String ssUuid = ovmObject.deDash(primUuid);
String fsType = "nfs";
String clusterUuid = config.getAgentOwnedByUuid().substring(0, 15);
String managerId = config.getAgentOwnedByUuid();
String poolAlias = cmd.getHost() + ":" + cmd.getPath();
String mountPoint = String.format("%1$s:%2$s", cmd.getHost(), cmd.getPath()) + "/VirtualMachines";
Integer poolSize = 0;
Pool poolHost = new Pool(c);
PoolOCFS2 poolFs = new PoolOCFS2(c);
if (config.getAgentIsPrimary()) {
try {
LOGGER.debug("Create poolfs on " + config.getAgentHostname() + " for repo " + primUuid);
/* double check if we're not overwritting anything here!@ */
poolFs.createPoolFs(fsType, mountPoint, clusterUuid, primUuid, ssUuid, managerId);
} catch (Ovm3ResourceException e) {
throw e;
}
try {
poolHost.createServerPool(poolAlias, primUuid, config.getOvm3PoolVip(), poolSize + 1, config.getAgentHostname(), c.getIp());
} catch (Ovm3ResourceException e) {
throw e;
}
} else if (config.getAgentHasPrimary()) {
try {
poolHost.joinServerPool(poolAlias, primUuid, config.getOvm3PoolVip(), poolSize + 1, config.getAgentHostname(), c.getIp());
} catch (Ovm3ResourceException e) {
throw e;
}
}
try {
/* should contain check if we're in an OVM pool or not */
CloudstackPlugin csp = new CloudstackPlugin(c);
Boolean vip = csp.dom0CheckPort(config.getOvm3PoolVip(), 22, 60, 1);
if (!vip) {
throw new Ovm3ResourceException("Unable to reach Ovm3 Pool VIP " + config.getOvm3PoolVip());
}
/*
* should also throw exception, we need to stop pool creation here,
* or is the manual addition fine?
*/
if (!addMembers()) {
return false;
}
} catch (Ovm3ResourceException e) {
throw new Ovm3ResourceException("Unable to add members to pool" + e.getMessage());
}
return true;
}
Aggregations