use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3HypervisorSupport method masterCheck.
/**
* materCheck
*
* @return
*/
public boolean masterCheck() {
if ("".equals(config.getOvm3PoolVip())) {
LOGGER.debug("No cluster vip, not checking for master");
return false;
}
try {
CloudstackPlugin cSp = new CloudstackPlugin(c);
if (cSp.dom0HasIp(config.getOvm3PoolVip())) {
LOGGER.debug(config.getAgentHostname() + " is a master, already has vip " + config.getOvm3PoolVip());
config.setAgentIsMaster(true);
} else if (cSp.ping(config.getOvm3PoolVip())) {
LOGGER.debug(config.getAgentHostname() + " has a master, someone has vip " + config.getOvm3PoolVip());
config.setAgentHasMaster(true);
} else {
LOGGER.debug(config.getAgentHostname() + " becomes a master, no one has vip " + config.getOvm3PoolVip());
config.setAgentIsMaster(true);
}
} catch (Ovm3ResourceException e) {
LOGGER.debug(config.getAgentHostname() + " can't reach master: " + e.getMessage());
config.setAgentHasMaster(false);
}
return config.getAgentIsMaster();
}
use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3HypervisorNetwork method createVlanBridge.
private String createVlanBridge(String networkName, Integer vlanId) throws Ovm3ResourceException {
if (vlanId < 1 || vlanId > 4094) {
String msg = "Incorrect vlan " + vlanId + ", needs to be between 1 and 4094";
LOGGER.error(msg);
throw new CloudRuntimeException(msg);
}
Network net = new Network(c);
/* figure out if our bridged vlan exists, if not then create */
String brName = networkName + "." + vlanId.toString();
try {
String physInterface = net.getPhysicalByBridgeName(networkName);
if (net.getInterfaceByName(brName) == null) {
net.startOvsVlanBridge(brName, physInterface, vlanId);
} else {
LOGGER.debug("Interface " + brName + " already exists");
}
} catch (Ovm3ResourceException e) {
String msg = "Unable to create vlan " + vlanId.toString() + " bridge for " + networkName;
LOGGER.warn(msg + ": " + e);
throw new CloudRuntimeException(msg + ":" + e.getMessage());
}
return brName;
}
use of com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException in project cloudstack by apache.
the class Ovm3HypervisorNetwork method isNetworkSetupByName.
/**/
private boolean isNetworkSetupByName(String nameTag) {
if (nameTag != null) {
LOGGER.debug("Looking for network setup by name " + nameTag);
try {
Network net = new Network(c);
net.getInterfaceList();
if (net.getBridgeByName(nameTag) != null) {
LOGGER.debug("Found bridge with name: " + nameTag);
return true;
}
} catch (Ovm3ResourceException e) {
LOGGER.debug("Unxpected error looking for name: " + nameTag, e);
return false;
}
}
LOGGER.debug("No bridge with name: " + nameTag);
return false;
}
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.
/**
* Gets statistics for storage.
*
* @param cmd
* @return
*/
public GetStorageStatsAnswer execute(final GetStorageStatsCommand cmd) {
LOGGER.debug("Getting stats for: " + cmd.getStorageId());
try {
Linux host = new Linux(c);
Linux.FileSystem fs = host.getFileSystemByUuid(cmd.getStorageId(), "nfs");
StoragePlugin store = new StoragePlugin(c);
String propUuid = store.deDash(cmd.getStorageId());
String mntUuid = cmd.getStorageId();
if (store == null || propUuid == null || mntUuid == null || fs == null) {
String msg = "Null returned when retrieving stats for " + cmd.getStorageId();
LOGGER.error(msg);
return new GetStorageStatsAnswer(cmd, msg);
}
/* or is it mntUuid ish ? */
StorageDetails sd = store.storagePluginGetFileSystemInfo(propUuid, mntUuid, fs.getHost(), fs.getDevice());
/*
* FIXME: cure me or kill me, this needs to trigger a reinit of
* primary storage, actually the problem is more deeprooted, as when
* the hypervisor reboots it looses partial context and needs to be
* reinitiated.... actually a full configure round... how to trigger
* that ?
*/
if ("".equals(sd.getSize())) {
String msg = "No size when retrieving stats for " + cmd.getStorageId();
LOGGER.debug(msg);
return new GetStorageStatsAnswer(cmd, msg);
}
long total = Long.parseLong(sd.getSize());
long used = total - Long.parseLong(sd.getFreeSize());
return new GetStorageStatsAnswer(cmd, total, used);
} catch (Ovm3ResourceException e) {
LOGGER.debug("GetStorageStatsCommand for " + cmd.getStorageId() + " failed", e);
return new GetStorageStatsAnswer(cmd, e.getMessage());
}
}
Aggregations