Bug 8966 - Oracle VM (OVM) support

configure hostname of host for OCFS2
small fixes
This commit is contained in:
frank 2011-08-31 14:47:18 -07:00
parent 1421496f79
commit 996d6302eb
6 changed files with 55 additions and 6 deletions

View File

@ -23,6 +23,7 @@ HEARTBEAT_TIMESTAMP_FORMAT='<timestamp>%s</timestamp>'
HEARTBEAT_TIMESTAMP_PATTERN='(\<timestamp\>\d+.\d+<\/timestamp\>)'
HEARTBEAT_DIR='heart_beat'
ETC_HOSTS='/etc/hosts'
HOSTNAME_FILE='/etc/sysconfig/network'
logger = OvmLogger('OvmCommon')

4
ovm/scripts/vm/hypervisor/ovm/OvmHostModule.py Normal file → Executable file
View File

@ -63,7 +63,9 @@ class OvmHost(OvmObject):
return vmPath
def _vmNameToPath(self, vmName):
return successToMap(xen_get_vm_path(vmName))['path']
# the xen_get_vm_path always sucks!!!
#return successToMap((vmName))['path']
return self._getVmPathFromPrimaryStorage(vmName)
def _getAllDomains(self):
stdout = timeout_command(["xm", "list"])

View File

@ -2,6 +2,7 @@ from OvmCommonModule import *
from OVSSiteSR import sp_create, sr_create, sr_do
from OVSParser import parse_ocfs2_cluster_conf
from OVSXCluster import clusterm_set_ocfs2_cluster_conf, clusterm_start_o2cb_service
from OVSSiteRMServer import get_master_ip
import re
class OvmStoragePoolDecoder(json.JSONDecoder):
@ -241,6 +242,33 @@ class OvmStoragePool(OvmObject):
fd = open(ETC_HOSTS, "w")
fd.write(orignalConf)
fd.close()
def configureHostName(nodes):
myIp = successToMap(get_master_ip())['ip']
nodeName = None
for n in nodes:
if myIp == n["ip_address"]:
nodeName = n["name"]
break
if nodeName == None: raise Exception("Cannot find node equals to my ip address:%s"%myIp)
if not exists(HOSTNAME_FILE):
originalConf = ""
else:
fd = open(HOSTNAME_FILE, "r")
originalConf = fd.read()
fd.close()
pattern = r"HOSTNAME=(.*)"
# remove any old hostname
originalConf = re.sub(pattern, "", originalConf)
# remove extra empty lines
originalConf = re.sub(r"\n\s*\n*", "\n", originalConf) + "\n" + "HOSTNAME=%s"%nodeName
logger.debug(OvmStoragePool.prepareOCFS2Nodes, "Configure %s:%s\n"%(HOSTNAME_FILE,originalConf))
fd = open(HOSTNAME_FILE, "w")
fd.write(originalConf)
fd.close()
doCmd(['hostname', nodeName])
try:
nodeString = nodeString.strip(";")
@ -273,10 +301,12 @@ class OvmStoragePool(OvmObject):
lines.append("\tname = %s\n" % clusterName)
lines.append("\n")
conf = "".join(lines)
configureHostName(nodes)
configureEtcHosts(nodes)
clusterm_set_ocfs2_cluster_conf(conf)
clusterm_start_o2cb_service()
logger.debug(OvmStoragePool.prepareOCFS2Nodes, "Configure cluster.conf to:\n%s"%conf)
configureEtcHosts(nodes)
rs = SUCC()
return rs

View File

@ -216,12 +216,16 @@ public class OvmResourceBase implements ServerResource, HypervisorResource {
/* set to false so each time ModifyStoragePoolCommand will re-setup heartbeat*/
_isHeartBeat = false;
/*
try {
_canBridgeFirewall = canBridgeFirewall();
} catch (XmlRpcException e) {
s_logger.error("Failed to detect whether the host supports security groups.", e);
_canBridgeFirewall = false;
}
*/
_canBridgeFirewall = false;
s_logger.debug(_canBridgeFirewall ? "OVM host supports security groups." : "OVM host doesn't support security groups.");

View File

@ -65,7 +65,10 @@ public class OCFS2ManagerImpl implements OCFS2Manager, ResourceListener {
Integer i = 0;
List<Ternary<Integer, String, String>> lst = new ArrayList<Ternary<Integer, String, String>>();
for (HostVO h : hosts) {
String nodeName = "node_" + h.getPrivateIpAddress().replace(".", "_");
/**
* Don't show "node" in node name otherwise OVM's utils/config_o2cb.sh will be going crazy
*/
String nodeName = "ovm_" + h.getPrivateIpAddress().replace(".", "_");
Ternary<Integer, String, String> node = new Ternary<Integer, String, String>(i, h.getPrivateIpAddress(), nodeName);
lst.add(node);
i ++;
@ -103,6 +106,16 @@ public class OCFS2ManagerImpl implements OCFS2Manager, ResourceListener {
}
return clusterName;
/**
* right now let's use "ocfs2" that is default cluster name of OVM OCFS2 service.
* Using another name is fine but requires extra effort to modify OVM's "utils/config_o2cb.sh",
* currently it doesn't receive parameter specifying which cluster to start.
* And I don't see the benefit of a cluster name rather than "ocfs2"
*/
//return "ocfs2";
}
@Override

View File

@ -103,9 +103,8 @@ public class HyervisorTemplateAdapter extends TemplateAdapterBase implements Tem
if ((cmd.getFormat().equalsIgnoreCase("vhd") && (!url.toLowerCase().endsWith("vhd") && !url.toLowerCase().endsWith("vhd.zip") && !url.toLowerCase().endsWith("vhd.bz2") && !url.toLowerCase().endsWith("vhd.gz") ))
|| (cmd.getFormat().equalsIgnoreCase("qcow2") && (!url.toLowerCase().endsWith("qcow2") && !url.toLowerCase().endsWith("qcow2.zip") && !url.toLowerCase().endsWith("qcow2.bz2") && !url.toLowerCase().endsWith("qcow2.gz") ))
|| (cmd.getFormat().equalsIgnoreCase("ova") && (!url.toLowerCase().endsWith("ova") && !url.toLowerCase().endsWith("ova.zip") && !url.toLowerCase().endsWith("ova.bz2") && !url.toLowerCase().endsWith("ova.gz")))
|| (cmd.getFormat().equalsIgnoreCase("img") && !url.toLowerCase().endsWith("img"))
|| (cmd.getFormat().equalsIgnoreCase("raw") && !url.toLowerCase().endsWith("raw")) ) {
throw new InvalidParameterValueException("Please specify a valid URL. URL:" + url + " is a invalid for the format " + cmd.getFormat().toLowerCase());
|| (cmd.getFormat().equalsIgnoreCase("raw") && (!url.toLowerCase().endsWith("img") && !url.toLowerCase().endsWith("raw")))) {
throw new InvalidParameterValueException("Please specify a valid URL. URL:" + url + " is an invalid for the format " + cmd.getFormat().toLowerCase());
}
profile.setUrl(validateUrl(url));