diff --git a/agent/bindir/cloud-setup-agent.in b/agent/bindir/cloud-setup-agent.in index 9ec24994e52..e8f8f2f452f 100755 --- a/agent/bindir/cloud-setup-agent.in +++ b/agent/bindir/cloud-setup-agent.in @@ -6,9 +6,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -65,7 +65,7 @@ def getUserInputs(): if oldHypervisor == "": oldHypervisor = "kvm" - hypervisor = raw_input("Please input the Hypervisor type kvm/lxc:[%s]"%oldCluster) + hypervisor = raw_input("Please input the Hypervisor type kvm/lxc:[%s]"%oldHypervisor) if hypervisor == "": hypervisor = oldHypervisor @@ -138,7 +138,7 @@ if __name__ == '__main__': glbEnv.nics.append(options.prvNic) glbEnv.nics.append(options.pubNic) glbEnv.nics.append(options.guestNic) - + print "Starting to configure your system:" syscfg = sysConfigFactory.getSysConfigFactory(glbEnv) try: diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index c9242ea065d..45acef0e5c9 100755 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -312,7 +312,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv private String _ovsPvlanVmPath; private String _routerProxyPath; private String _ovsTunnelPath; - private String _setupCgroupPath; private String _host; private String _dcId; private String _pod; @@ -718,17 +717,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv _hypervisorType = HypervisorType.KVM; } - //Verify that cpu,cpuacct cgroups are not co-mounted - if(HypervisorType.LXC.equals(getHypervisorType())){ - _setupCgroupPath = Script.findScript(kvmScriptsDir, "setup-cgroups.sh"); - if (_setupCgroupPath == null) { - throw new ConfigurationException("Unable to find the setup-cgroups.sh"); - } - if(!checkCgroups()){ - throw new ConfigurationException("cpu,cpuacct cgroups are co-mounted"); - } - } - _hypervisorURI = (String)params.get("hypervisor.uri"); if (_hypervisorURI == null) { _hypervisorURI = LibvirtConnection.getHypervisorURI(_hypervisorType.toString()); @@ -5308,17 +5296,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv return _hypervisorType; } - private boolean checkCgroups(){ - final Script command = new Script(_setupCgroupPath, 5 * 1000, s_logger); - String result; - result = command.execute(); - if (result != null) { - s_logger.debug("cgroup check failed:" + result); - return false; - } - return true; - } - public String mapRbdDevice(KVMPhysicalDisk disk){ KVMStoragePool pool = disk.getPool(); //Check if rbd image is already mapped diff --git a/python/lib/cloud_utils.py b/python/lib/cloud_utils.py index 243bb408d41..b01cd9c1a23 100644 --- a/python/lib/cloud_utils.py +++ b/python/lib/cloud_utils.py @@ -6,9 +6,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -18,7 +18,7 @@ - + # -*- coding: utf-8 -*- """CloudStack Python utility library""" @@ -106,7 +106,7 @@ def exit(errno=E_GENERIC,message=None,*args): def resolve(host,port): return [ (x[4][0],len(x[4])+2) for x in socket.getaddrinfo(host,port,socket.AF_UNSPEC,socket.SOCK_STREAM, 0, socket.AI_PASSIVE) ] - + def resolves_to_ipv6(host,port): return resolve(host,port)[0][1] == IPV6 @@ -119,7 +119,7 @@ else: self.returncode = returncode ; self.cmd = cmd def __str__(self): return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode) subprocess.CalledProcessError = CalledProcessError - + def check_call(*popenargs, **kwargs): retcode = subprocess.call(*popenargs, **kwargs) cmd = kwargs.get("args") @@ -183,7 +183,7 @@ class Command: self.stdout = stdout self.stderr = stderr return CommandOutput(*m) - + def __get_recursive_name(self,sep=None): m = self l = [] @@ -195,7 +195,7 @@ class Command: else: return l def __str__(self): return ''%self.__get_recursive_name(sep=" ") - + def __repr__(self): return self.__str__() kvmok = Command("kvm-ok") @@ -275,7 +275,7 @@ def replace_line(f,startswith,stanza,always_add=False): def replace_or_add_line(f,startswith,stanza): return replace_line(f,startswith,stanza,always_add=True) - + # ==================================== CHECK FUNCTIONS ========================== # If they return without exception, it's okay. If they raise a CheckFailed exception, that means a condition @@ -410,8 +410,8 @@ class SetupNetworking(ConfigTask): else: self.nmservice = 'network-manager' self.netservice = 'networking' - - + + def done(self): try: alreadysetup = False @@ -422,7 +422,7 @@ class SetupNetworking(ConfigTask): alreadysetup = alreadysetup or augtool._print("/files/etc/sysconfig/network-scripts/ifcfg-%s"%self.prvNic).stdout.strip() if not alreadysetup: alreadysetup = augtool._print("/files/etc/sysconfig/network-scripts/ifcfg-%s"%self.brname).stdout.strip() - + else: if self.pubNic != None: alreadysetup = alreadysetup or augtool._print("/files/etc/network/interfaces/iface",self.pubNic).stdout.strip() @@ -437,14 +437,14 @@ class SetupNetworking(ConfigTask): def restore_state(self): if not self.runtime_state_changed: return - + try: o = ifconfig(self.brname) bridge_exists = True except CalledProcessError,e: print e.stdout + e.stderr bridge_exists = False - + if bridge_exists: ifconfig(self.brname,"0.0.0.0") if hasattr(self,"old_net_device"): @@ -458,8 +458,8 @@ class SetupNetworking(ConfigTask): except CalledProcessError: pass try: ifdown("--force",self.brname) except CalledProcessError: pass - - + + if self.was_net_service_running is None: # we do nothing pass @@ -475,7 +475,7 @@ class SetupNetworking(ConfigTask): if e.returncode == 1: pass else: raise time.sleep(1) - + if self.was_nm_service_running is None: # we do nothing pass @@ -488,7 +488,7 @@ class SetupNetworking(ConfigTask): time.sleep(1) start_service(self.nmservice,force=True) time.sleep(1) - + self.runtime_state_changed = False def execute(self): @@ -496,12 +496,12 @@ class SetupNetworking(ConfigTask): routes = ip.route().stdout.splitlines() defaultroute = [ x for x in routes if x.startswith("default") ] if not defaultroute: raise TaskFailed("Your network configuration does not have a default route") - + dev = defaultroute[0].split()[4] yield "Default route assigned to device %s"%dev - + self.old_net_device = dev - + if distro in (Fedora, CentOS, RHEL6): inconfigfile = "/".join(augtool.match("/files/etc/sysconfig/network-scripts/*/DEVICE",dev).stdout.strip().split("/")[:-1]) if not inconfigfile: raise TaskFailed("Device %s has not been set up in /etc/sysconfig/network-scripts"%dev) @@ -514,7 +514,7 @@ class SetupNetworking(ConfigTask): if not automatic: if distro is Fedora: raise TaskFailed("Device %s has not been set up in %s as automatic on boot"%dev,pathtoconfigfile) else: raise TaskFailed("Device %s has not been set up in /etc/network/interfaces as automatic on boot"%dev) - + if distro not in (Fedora , CentOS, RHEL6): inconfigfile = augtool.match("/files/etc/network/interfaces/iface",dev).stdout.strip() if not inconfigfile: raise TaskFailed("Device %s has not been set up in /etc/network/interfaces"%dev) @@ -534,12 +534,12 @@ class SetupNetworking(ConfigTask): disable_service(self.nmservice) else: self.was_nm_service_running = False - + if is_service_running(self.netservice): self.was_net_service_running = True else: self.was_net_service_running = False - + yield "Creating Cloud bridging device and making device %s member of this bridge"%dev if distro in (Fedora, CentOS, RHEL6): @@ -574,9 +574,9 @@ save"""%(innewconfigfile,self.brname,innewconfigfile,self.brname,innewconfigfile innewconfigfile,innewconfigfile,innewconfigfile,innewconfigfile, inconfigfile,inconfigfile,inconfigfile,inconfigfile,inconfigfile,inconfigfile, inconfigfile,self.brname) - + yield "Executing the following reconfiguration script:\n%s"%script - + try: returned = augtool < script if "Saved 2 file" not in returned.stdout: @@ -597,9 +597,9 @@ save"""%(innewconfigfile,self.brname,innewconfigfile,self.brname,innewconfigfile set %s %s set %s/bridge_ports %s save"""%(automatic,self.brname,inconfigfile,self.brname,inconfigfile,dev) - + yield "Executing the following reconfiguration script:\n%s"%script - + try: returned = augtool < script if "Saved 1 file" not in returned.stdout: @@ -611,16 +611,16 @@ save"""%(automatic,self.brname,inconfigfile,self.brname,inconfigfile,dev) #restore() print e.stdout + e.stderr raise TaskFailed("Network reconfiguration failed") - + yield "We are going to restart network services now, to make the network changes take effect. Hit ENTER when you are ready." if self.isAutoMode(): pass else: raw_input() - + # if we reach here, then if something goes wrong we should attempt to revert the runinng state # if not, then no point self.runtime_state_changed = True - + yield "Enabling and restarting non-NetworkManager networking" if distro is Ubuntu: ifup(self.brname,stdout=None,stderr=None) stop_service(self.netservice) @@ -628,28 +628,28 @@ save"""%(automatic,self.brname,inconfigfile,self.brname,inconfigfile,dev) except CalledProcessError,e: if e.returncode == 1: pass else: raise - + yield "Verifying that the bridge is up" try: o = ifconfig(self.brname) except CalledProcessError,e: print e.stdout + e.stderr raise TaskFailed("The bridge could not be set up properly") - + yield "Networking restart done" class SetupCgConfig(ConfigTask): name = "control groups configuration" - + def done(self): - + try: return "group virt" in file("/etc/cgconfig.conf","r").read(-1) except IOError,e: if e.errno is 2: raise TaskFailed("cgconfig has not been properly installed on this system") raise - + def execute(self): cgconfig = file("/etc/cgconfig.conf","r").read(-1) cgconfig = cgconfig + """ @@ -660,7 +660,7 @@ group virt { } """ file("/etc/cgconfig.conf","w").write(cgconfig) - + stop_service("cgconfig") enable_service("cgconfig",forcestart=True) @@ -668,53 +668,35 @@ group virt { class SetupCgRules(ConfigTask): name = "control group rules setup" cfgline = "root:/usr/sbin/libvirtd cpu virt/" - + def done(self): try: return self.cfgline in file("/etc/cgrules.conf","r").read(-1) except IOError,e: if e.errno is 2: raise TaskFailed("cgrulesd has not been properly installed on this system") raise - + def execute(self): cgrules = file("/etc/cgrules.conf","r").read(-1) cgrules = cgrules + "\n" + self.cfgline + "\n" file("/etc/cgrules.conf","w").write(cgrules) - + stop_service("cgred") enable_service("cgred") -class SetupCgroupControllers(ConfigTask): - name = "qemu cgroup controllers setup" - cfgline = "cgroup_controllers = [ \"cpu\" ]" - filename = "/etc/libvirt/qemu.conf" - - def done(self): - try: - return self.cfgline in file(self.filename,"r").read(-1) - except IOError,e: - if e.errno is 2: raise TaskFailed("qemu has not been properly installed on this system") - raise - - def execute(self): - libvirtqemu = file(self.filename,"r").read(-1) - libvirtqemu = libvirtqemu + "\n" + self.cfgline + "\n" - file("/etc/libvirt/qemu.conf","w").write(libvirtqemu) - - class SetupSecurityDriver(ConfigTask): name = "security driver setup" cfgline = "security_driver = \"none\"" filename = "/etc/libvirt/qemu.conf" - + def done(self): try: return self.cfgline in file(self.filename,"r").read(-1) except IOError,e: if e.errno is 2: raise TaskFailed("qemu has not been properly installed on this system") raise - + def execute(self): libvirtqemu = file(self.filename,"r").read(-1) libvirtqemu = libvirtqemu + "\n" + self.cfgline + "\n" @@ -733,7 +715,7 @@ class SetupLibvirt(ConfigTask): except IOError,e: if e.errno is 2: raise TaskFailed("libvirt has not been properly installed on this system") raise - + def execute(self): if distro in (Fedora,CentOS, RHEL6): libvirtfile = "/etc/sysconfig/libvirtd" elif distro is Ubuntu: libvirtfile = "/etc/default/libvirt-bin" @@ -741,7 +723,7 @@ class SetupLibvirt(ConfigTask): libvirtbin = file(libvirtfile,"r").read(-1) libvirtbin = libvirtbin + "\n" + self.cfgline + "\n" file(libvirtfile,"w").write(libvirtbin) - + if distro in (CentOS, Fedora, RHEL6): svc = "libvirtd" else: svc = "libvirt-bin" stop_service(svc) @@ -755,7 +737,7 @@ class SetupLiveMigration(ConfigTask): 'auth_tcp="none"', "listen_tls=0", ) - + def done(self): try: lines = [ s.strip() for s in file("/etc/libvirt/libvirtd.conf").readlines() ] @@ -763,25 +745,25 @@ class SetupLiveMigration(ConfigTask): except IOError,e: if e.errno is 2: raise TaskFailed("libvirt has not been properly installed on this system") raise - + def execute(self): - + for stanza in self.stanzas: startswith = stanza.split("=")[0] + '=' replace_or_add_line("/etc/libvirt/libvirtd.conf",startswith,stanza) if distro in (Fedora, RHEL6): replace_or_add_line("/etc/sysconfig/libvirtd","LIBVIRTD_ARGS=","LIBVIRTD_ARGS=-l") - + elif distro is Ubuntu: if os.path.exists("/etc/init/libvirt-bin.conf"): replace_line("/etc/init/libvirt-bin.conf", "exec /usr/sbin/libvirtd","exec /usr/sbin/libvirtd -d -l") else: replace_or_add_line("/etc/default/libvirt-bin","libvirtd_opts=","libvirtd_opts='-l -d'") - + else: raise AssertionError("Unsupported distribution") - + if distro in (CentOS, Fedora, RHEL6): svc = "libvirtd" else: svc = "libvirt-bin" stop_service(svc) @@ -790,13 +772,13 @@ class SetupLiveMigration(ConfigTask): class SetupRequiredServices(ConfigTask): name = "required services setup" - + def done(self): if distro in (Fedora, RHEL6): nfsrelated = "rpcbind nfslock" elif distro is CentOS: nfsrelated = "portmap nfslock" else: return True return all( [ is_service_running(svc) for svc in nfsrelated.split() ] ) - + def execute(self): if distro in (Fedora, RHEL6): nfsrelated = "rpcbind nfslock" @@ -808,9 +790,9 @@ class SetupRequiredServices(ConfigTask): class SetupFirewall(ConfigTask): name = "firewall setup" - + def done(self): - + if distro in (Fedora, CentOS,RHEL6): if not os.path.exists("/etc/sysconfig/iptables"): return True if ":on" not in chkconfig("--list","iptables").stdout: return True @@ -820,7 +802,7 @@ class SetupFirewall(ConfigTask): rule = "-p tcp -m tcp --dport 16509 -j ACCEPT" if rule in iptablessave().stdout: return True return False - + def execute(self): ports = "22 1798 16509".split() if distro in (Fedora , CentOS, RHEL6): @@ -836,9 +818,9 @@ class SetupFirewall2(ConfigTask): def __init__(self,brname): ConfigTask.__init__(self) self.brname = brname - + def done(self): - + if distro in (Fedora, CentOS, RHEL6): if not os.path.exists("/etc/sysconfig/iptables"): return True if ":on" not in chkconfig("--list","iptables").stdout: return True @@ -847,13 +829,13 @@ class SetupFirewall2(ConfigTask): if "Status: active" not in ufw.status().stdout: return True if not os.path.exists("/etc/ufw/before.rules"): return True return False - + def execute(self): - + yield "Permitting traffic in the bridge interface, migration port and for VNC ports" - + if distro in (Fedora , CentOS, RHEL6): - + for rule in ( "-I INPUT 1 -p tcp --dport 5900:6100 -j ACCEPT", "-I INPUT 1 -p tcp --dport 49152:49216 -j ACCEPT", @@ -861,9 +843,9 @@ class SetupFirewall2(ConfigTask): args = rule.split() o = iptables(*args) service.iptables.save(stdout=None,stderr=None) - + else: - + ufw.allow.proto.tcp("from","any","to","any","port","5900:6100") ufw.allow.proto.tcp("from","any","to","any","port","49152:49216") @@ -887,7 +869,6 @@ def config_tasks(brname, pubNic, prvNic): SetupNetworking(brname, pubNic, prvNic), SetupCgConfig(), SetupCgRules(), - SetupCgroupControllers(), SetupSecurityDriver(), SetupLibvirt(), SetupLiveMigration(), @@ -914,31 +895,31 @@ def remove_backup(targetdir): def list_zonespods(host): text = urllib2.urlopen('http://%s:8096/client/api?command=listPods'%host).read(-1) - dom = xml.dom.minidom.parseString(text) + dom = xml.dom.minidom.parseString(text) x = [ (zonename,podname) - for pod in dom.childNodes[0].childNodes - for podname in [ x.childNodes[0].wholeText for x in pod.childNodes if x.tagName == "name" ] + for pod in dom.childNodes[0].childNodes + for podname in [ x.childNodes[0].wholeText for x in pod.childNodes if x.tagName == "name" ] for zonename in [ x.childNodes[0].wholeText for x in pod.childNodes if x.tagName == "zonename" ] ] return x - + def prompt_for_hostpods(zonespods): """Ask user to select one from those zonespods Returns (zone,pod) or None if the user made the default selection.""" while True: stderr("Type the number of the zone and pod combination this host belongs to (hit ENTER to skip this step)") - print " N) ZONE, POD" + print " N) ZONE, POD" print "================" for n,(z,p) in enumerate(zonespods): print "%3d) %s, %s"%(n,z,p) print "================" print "> ", zoneandpod = raw_input().strip() - + if not zoneandpod: # we go with default, do not touch anything, just break return None - + try: # if parsing fails as an int, just vomit and retry zoneandpod = int(zoneandpod) @@ -946,10 +927,10 @@ def prompt_for_hostpods(zonespods): except ValueError,e: stderr(str(e)) continue # re-ask - + # oh yeah, the int represents an valid zone and pod index in the array return zonespods[zoneandpod] - + # this configures the agent def device_exist(devName): @@ -961,8 +942,8 @@ def device_exist(devName): alreadysetup = augtool.match("/files/etc/network/interfaces/iface",devName).stdout.strip() return alreadysetup except OSError,e: - return False - + return False + def setup_agent_config(configfile, host, zone, pod, cluster, guid, pubNic, prvNic): stderr("Examining Agent configuration") fn = configfile @@ -970,14 +951,14 @@ def setup_agent_config(configfile, host, zone, pod, cluster, guid, pubNic, prvNi lines = [ s.strip() for s in text.splitlines() ] confopts = dict([ m.split("=",1) for m in lines if "=" in m and not m.startswith("#") ]) confposes = dict([ (m.split("=",1)[0],n) for n,m in enumerate(lines) if "=" in m and not m.startswith("#") ]) - + if guid != None: confopts['guid'] = guid else: if not "guid" in confopts: stderr("Generating GUID for this Agent") confopts['guid'] = uuidgen().stdout.strip() - + if host == None: try: host = confopts["host"] except KeyError: host = "localhost" @@ -987,19 +968,19 @@ def setup_agent_config(configfile, host, zone, pod, cluster, guid, pubNic, prvNi if newhost: host = newhost confopts["host"] = host - + if pubNic != None and device_exist(pubNic): - confopts["public.network.device"] = pubNic + confopts["public.network.device"] = pubNic if prvNic == None or not device_exist(prvNic): - confopts["private.network.device"] = pubNic - + confopts["private.network.device"] = pubNic + if prvNic != None and device_exist(prvNic): - confopts["private.network.device"] = prvNic + confopts["private.network.device"] = prvNic if pubNic == None or not device_exist(pubNic): - confopts["public.network.device"] = prvNic + confopts["public.network.device"] = prvNic stderr("Querying %s for zones and pods",host) - + try: if zone == None or pod == None: x = list_zonespods(confopts['host']) @@ -1020,7 +1001,7 @@ def setup_agent_config(configfile, host, zone, pod, cluster, guid, pubNic, prvNi line = "=".join([opt,val]) if opt not in confposes: lines.append(line) else: lines[confposes[opt]] = line - + text = "\n".join(lines) file(fn,"w").write(text) @@ -1046,7 +1027,7 @@ def setup_consoleproxy_config(configfile, host, zone, pod): confopts["host"] = host stderr("Querying %s for zones and pods",host) - + try: if zone == None or pod == None: x = list_zonespods(confopts['host']) @@ -1066,7 +1047,7 @@ def setup_consoleproxy_config(configfile, host, zone, pod): line = "=".join([opt,val]) if opt not in confposes: lines.append(line) else: lines[confposes[opt]] = line - + text = "\n".join(lines) file(fn,"w").write(text) @@ -1083,22 +1064,22 @@ INITIAL_LEVEL = '-' class Migrator: """Migrator class. - + The migrator gets a list of Python objects, and discovers MigrationSteps in it. It then sorts the steps into a chain, based on the attributes from_level and to_level in each one of the steps. - + When the migrator's run(context) is called, the chain of steps is applied sequentially on the context supplied to run(), in the order of the chain of steps found at discovery time. See the documentation for the MigrationStep class for information on how that happens. """ - + def __init__(self,evolver_source): self.discover_evolvers(evolver_source) self.sort_evolvers() - + def discover_evolvers(self,source): self.evolvers = [] for val in source: if hasattr(val,"from_level") and hasattr(val,"to_level") and val.to_level: self.evolvers.append(val) - + def sort_evolvers(self): new = [] while self.evolvers: @@ -1114,30 +1095,30 @@ class Migrator: raise IndexError, "no evolver could be found to evolve from level %s"%new[-1].to_level new.append(self.evolvers.pop(idx)) self.evolvers = new - + def get_evolver_chain(self): return [ (s.from_level, s.to_level, s) for s in self.evolvers ] - + def get_evolver_by_starting_level(self,level): try: return [ s for s in self.evolvers if s.from_level == level][0] except IndexError: raise NoMigrator, "No evolver knows how to evolve the database from schema level %r"%level - + def get_evolver_by_ending_level(self,level): try: return [ s for s in self.evolvers if s.to_level == level][0] except IndexError: raise NoMigrator, "No evolver knows how to evolve the database to schema level %r"%level - + def run(self, context, dryrun = False, starting_level = None, ending_level = None): """Runs each one of the steps in sequence, passing the migration context to each. At the end of the process, context.commit() is called to save the changes, or context.rollback() is called if dryrun = True. - + If starting_level is not specified, then the context.get_schema_level() is used to find out at what level the context is at. Then starting_level is set to that. - + If ending_level is not specified, then the evolvers will run till the end of the chain.""" - + assert dryrun is False # NOT IMPLEMENTED, prolly gonna implement by asking the context itself to remember its state - + starting_level = starting_level or context.get_schema_level() or self.evolvers[0].from_level ending_level = ending_level or self.evolvers[-1].to_level - + evolution_path = self.evolvers idx = evolution_path.index(self.get_evolver_by_starting_level(starting_level)) evolution_path = evolution_path[idx:] @@ -1146,9 +1127,9 @@ class Migrator: raise NoEvolutionPath, "No evolution path from schema level %r to schema level %r" % \ (starting_level,ending_level) evolution_path = evolution_path[:idx+1] - + logging.info("Starting migration on %s"%context) - + for ec in evolution_path: assert ec.from_level == context.get_schema_level() evolver = ec(context=context) @@ -1164,36 +1145,36 @@ class Migrator: context.set_schema_level(evolver.to_level) #context.commit() logging.info("%s is now at level %s",context,context.get_schema_level()) - + #if dryrun: # implement me with backup and restore #logging.info("Rolling back changes on %s",context) #context.rollback() #else: #logging.info("Committing changes on %s",context) #context.commit() - + logging.info("Migration finished") - + class MigrationStep: """Base MigrationStep class, aka evolver. - + You develop your own steps, and then pass a list of those steps to the Migrator instance that will run them in order. - + When the migrator runs, it will take the list of steps you gave him, and, for each step: - + a) instantiate it, passing the context you gave to the migrator into the step's __init__(). b) run() the method in the migration step. - + As you can see, the default MigrationStep constructor makes the passed context available as self.context in the methods of your step. - + Each step has two member vars that determine in which order they are run, and if they need to run: - + - from_level = the schema level that the database should be at, before running the evolver The value None has special meaning here, it @@ -1202,14 +1183,14 @@ class MigrationStep: - to_level = the schema level number that the database will be at after the evolver has run """ - + # Implement these attributes in your steps from_level = None to_level = None - + def __init__(self,context): self.context = context - + def run(self): raise NotImplementedError @@ -1220,5 +1201,3 @@ class MigrationContext: def rollback(self):raise NotImplementedError def get_schema_level(self):raise NotImplementedError def set_schema_level(self,l):raise NotImplementedError - - diff --git a/python/lib/cloudutils/serviceConfig.py b/python/lib/cloudutils/serviceConfig.py index 86f5a904f2d..292c9a77d76 100755 --- a/python/lib/cloudutils/serviceConfig.py +++ b/python/lib/cloudutils/serviceConfig.py @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -56,7 +56,7 @@ class serviceCfgBase(object): if self.syscfg.env.mode == "Server": raise CloudRuntimeException("Configure %s failed, Please check the /var/log/cloudstack/setupManagement.log for detail"%self.serviceName) else: - raise CloudRuntimeException("Configure %s failed, Please check the /var/log/cloudstack/setupAgent.log for detail"%self.serviceName) + raise CloudRuntimeException("Configure %s failed, Please check the /var/log/cloudstack/agent/setup.log for detail"%self.serviceName) def backup(self): if self.status is None: @@ -428,7 +428,7 @@ class securityPolicyConfigUbuntu(serviceCfgBase): return True except: - raise CloudRuntimeException("Failed to configure apparmor, please see the /var/log/cloudstack/setupAgent.log for detail, \ + raise CloudRuntimeException("Failed to configure apparmor, please see the /var/log/cloudstack/agent/setup.log for detail, \ or you can manually disable it before starting myCloud") def restore(self): @@ -458,7 +458,7 @@ class securityPolicyConfigRedhat(serviceCfgBase): cfo.replace_line("SELINUX=", "SELINUX=permissive") return True except: - raise CloudRuntimeException("Failed to configure selinux, please see the /var/log/cloudstack/setupAgent.log for detail, \ + raise CloudRuntimeException("Failed to configure selinux, please see the /var/log/cloudstack/agent/setup.log for detail, \ or you can manually disable it before starting myCloud") else: return True @@ -493,7 +493,6 @@ class libvirtConfigRedhat(serviceCfgBase): filename = "/etc/libvirt/qemu.conf" cfo = configFileOps(filename, self) - cfo.addEntry("cgroup_controllers", "[\"cpu\"]") cfo.addEntry("security_driver", "\"none\"") cfo.addEntry("user", "\"root\"") cfo.addEntry("group", "\"root\"") diff --git a/python/lib/cloudutils/utilities.py b/python/lib/cloudutils/utilities.py index 88e2d1c6f9b..1fe5bd3d2cd 100755 --- a/python/lib/cloudutils/utilities.py +++ b/python/lib/cloudutils/utilities.py @@ -5,9 +5,9 @@ # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -53,25 +53,25 @@ class bash: except: raise CloudRuntimeException(formatExceptionInfo()) - if not self.success: + if not self.success: logging.debug("Failed to execute:" + self.getErrMsg()) def isSuccess(self): return self.success - + def getStdout(self): return self.stdout.strip("\n") - + def getLines(self): return self.stdout.split("\n") def getStderr(self): return self.stderr.strip("\n") - + def getErrMsg(self): if self.isSuccess(): return "" - + if self.getStderr() is None or self.getStderr() == "": return self.getStdout() else: @@ -80,11 +80,11 @@ class bash: def initLoging(logFile=None): try: if logFile is None: - logging.basicConfig(level=logging.DEBUG) - else: - logging.basicConfig(filename=logFile, level=logging.DEBUG) + logging.basicConfig(level=logging.DEBUG) + else: + logging.basicConfig(filename=logFile, level=logging.DEBUG) except: - logging.basicConfig(level=logging.DEBUG) + logging.basicConfig(level=logging.DEBUG) def writeProgressBar(msg, result): output = "[%-6s]\n"%"Failed" @@ -100,7 +100,7 @@ def writeProgressBar(msg, result): class UnknownSystemException(Exception): "This Excption is raised if the current operating enviornment is unknown" pass - + class Distribution: def __init__(self): self.distro = "Unknown" @@ -112,7 +112,7 @@ class Distribution: version = file("/etc/redhat-release").readline() if version.find("Red Hat Enterprise Linux Server release 6") != -1 or version.find("Scientific Linux release 6") != -1 or version.find("CentOS Linux release 6") != -1 or version.find("CentOS release 6.") != -1: self.distro = "RHEL6" - elif version.find("Red Hat Enterprise Linux Server release 7") != -1: + elif version.find("Red Hat Enterprise Linux Server release 7") != -1 or version.find("Scientific Linux release 7") != -1 or version.find("CentOS Linux release 7") != -1 or version.find("CentOS release 7.") != -1: self.distro = "RHEL7" elif version.find("CentOS release") != -1: self.distro = "CentOS" @@ -132,17 +132,17 @@ class Distribution: self.distro = "Ubuntu" else: raise UnknownSystemException(distributor) - else: + else: raise UnknownSystemException def getVersion(self): - return self.distro + return self.distro def getRelease(self): return self.release def getArch(self): return self.arch - - + + class serviceOps: pass class serviceOpsRedhat(serviceOps): @@ -159,7 +159,7 @@ class serviceOpsRedhat(serviceOps): def stopService(self, servicename,force=False): if self.isServiceRunning(servicename) or force: return bash("service " + servicename +" stop").isSuccess() - + return True def disableService(self, servicename): result = self.stopService(servicename) @@ -174,13 +174,13 @@ class serviceOpsRedhat(serviceOps): def enableService(self, servicename,forcestart=False): bash("chkconfig --level 2345 " + servicename + " on") return self.startService(servicename,force=forcestart) - + def isKVMEnabled(self): if os.path.exists("/dev/kvm"): return True else: return False - + class serviceOpsUbuntu(serviceOps): def isServiceRunning(self, servicename): try: @@ -200,7 +200,7 @@ class serviceOpsUbuntu(serviceOps): result = self.stopService(servicename) bash("sudo update-rc.d -f " + servicename + " remove") return result - + def startService(self, servicename,force=True): if not self.isServiceRunning(servicename) or force: return bash("sudo /usr/sbin/service " + servicename + " start").isSuccess() @@ -211,7 +211,7 @@ class serviceOpsUbuntu(serviceOps): return self.startService(servicename,force=forcestart) def isKVMEnabled(self): - return bash("kvm-ok").isSuccess() + return bash("kvm-ok").isSuccess() class serviceOpsRedhat7(serviceOps): def isServiceRunning(self, servicename): diff --git a/scripts/vm/hypervisor/kvm/setup-cgroups.sh b/scripts/vm/hypervisor/kvm/setup-cgroups.sh deleted file mode 100755 index 6b00b028311..00000000000 --- a/scripts/vm/hypervisor/kvm/setup-cgroups.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - - - -# Script to fix cgroups co-mounted issue -# Applies to RHEL 7 versions (and family member CentOS 7) only -# Detect if cpu,cpuacct cgroups are co-mounted -# If co-mounted, unmount and mount them seperately - -#set -x - -# Check distribution version for RHEL -if [ -f '/etc/redhat-release' ]; then - # Check RHEL version for 7 - if grep -E 'Red Hat Enterprise Linux Server release 7|CentOS Linux release 7' /etc/redhat-release > /dev/null; then - # Check if cgroups if co-mounted - if [ -d '/sys/fs/cgroup/cpu,cpuacct' ]; then - # cgroups co-mounted. Requires remount - umount /sys/fs/cgroup/cpu,cpuacct - rm /sys/fs/cgroup/cpu - rm /sys/fs/cgroup/cpuacct - rm -rf /sys/fs/cgroup/cpu,cpuacct - mkdir -p /sys/fs/cgroup/cpu - mkdir -p /sys/fs/cgroup/cpuacct - mount -t cgroup -o cpu cpu "/sys/fs/cgroup/cpu" - mount -t cgroup -o cpuacct cpuacct "/sys/fs/cgroup/cpuacct" - # Verify that cgroups are not co-mounted - if [ -d '/sys/fs/cgroup/cpu,cpuacct' ]; then - echo "cgroups still co-mounted" - exit 1; - fi - fi - fi -fi - -exit 0 diff --git a/setup/db/db/schema-421to430.sql b/setup/db/db/schema-421to430.sql index 3f2ad023d26..0a96ea0ad9b 100644 --- a/setup/db/db/schema-421to430.sql +++ b/setup/db/db/schema-421to430.sql @@ -111,8 +111,7 @@ CREATE TABLE `cloud`.`async_job_join_map` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; #realhostip changes, before changing table and adding default value -UPDATE `cloud`.`configuration` SET value = CONCAT("*.",(SELECT `temptable`.`value` FROM (SELECT * FROM `cloud`.`configuration` WHERE `name`="consoleproxy.url.domain") AS `temptable` WHERE `temptable`.`name`="consoleproxy.url.domain")) WHERE `name`="consoleproxy.url.domain"; -UPDATE `cloud`.`configuration` SET `value` = CONCAT("*.",(SELECT `temptable`.`value` FROM (SELECT * FROM `cloud`.`configuration` WHERE `name`="secstorage.ssl.cert.domain") AS `temptable` WHERE `temptable`.`name`="secstorage.ssl.cert.domain")) WHERE `name`="secstorage.ssl.cert.domain"; +UPDATE `cloud`.`configuration` SET value=CONCAT("*.",value) WHERE `name`="consoleproxy.url.domain" OR `name`="secstorage.ssl.cert.domain"; ALTER TABLE `cloud`.`configuration` ADD COLUMN `default_value` VARCHAR(4095) COMMENT 'Default value for a configuration parameter'; ALTER TABLE `cloud`.`configuration` ADD COLUMN `updated` datetime COMMENT 'Time this was updated by the server. null means this row is obsolete.';