diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2008-07-14 11:03:47 -0400 |
---|---|---|
committer | Michael DeHaan <mdehaan@redhat.com> | 2008-07-14 11:03:47 -0400 |
commit | f7744eef540cd0c741c471f3f54e98a1ba3d1473 (patch) | |
tree | c3325dabcf9f5df433c533bf99513bb706d1f3f2 | |
parent | 95ba97eec620e15f4083827694218c855fe29584 (diff) | |
parent | 09841e3c252e1a5c13b2b3d077ae54d751b006b1 (diff) | |
download | func-f7744eef540cd0c741c471f3f54e98a1ba3d1473.tar.gz func-f7744eef540cd0c741c471f3f54e98a1ba3d1473.tar.xz func-f7744eef540cd0c741c471f3f54e98a1ba3d1473.zip |
Merge branch 'mhicks_submit'
-rw-r--r-- | contrib/find_resources.py | 62 | ||||
-rwxr-xr-x | contrib/func-find-resources | 11 | ||||
-rw-r--r-- | func/minion/modules/virt.py | 7 |
3 files changed, 43 insertions, 37 deletions
diff --git a/contrib/find_resources.py b/contrib/find_resources.py index c4e30bd..e43bb85 100644 --- a/contrib/find_resources.py +++ b/contrib/find_resources.py @@ -43,17 +43,17 @@ class FindResources(object): dest="memory", default="512", help="the memory requirements in megabytes, default: '512'") - p.add_option("-d", "--disk", - dest="disk", - default="20", - help="the disk storage requirements in gigabytes, default: '20'") + p.add_option("-a", "--arch", + dest="arch", + default="i386", + help="the architecture requirements, default: 'i386'") (options, args) = p.parse_args(args) self.options = options # convert the memory and storage to integers for later comparisons memory = int(options.memory) - storage = int(options.disk) + arch = options.arch # see what hosts have enough RAM avail_hosts = {} @@ -69,42 +69,34 @@ class FindResources(object): if (freemem-256) >= memory: avail_hosts[host] = {'memory': freemem} - # figure out which of these machines have enough storage - for avail_host in avail_hosts.keys(): - # see what hosts have the required storage - host_volume_groups = func_client.Client(avail_host).storage.vgs() - - for (host, vol_groups) in host_volume_groups.iteritems(): - if utils.is_error(vol_groups): - print "-- connection refused: %s" % host - continue - - avail_vol_groups = [] - for vol_group, attrs in vol_groups.iteritems(): - free_space = int(float(attrs['free'][:-1])) - if free_space >= storage: - avail_vol_groups.append((vol_group, free_space)) - - if len(avail_vol_groups) > 0: - avail_hosts[host]['space'] = dict(avail_vol_groups) - else: - avail_hosts.pop(host) - # Default the dest_host to nothing dest_host = None + # see what hosts have the right architecture + arch_hosts = {} + host_arch = func_client.Client(options.server_spec).command.run('uname -i') + for (host, output) in host_arch.iteritems(): + if utils.is_error(output): + print "-- connection refused: %s" % host + continue + + host_arch = output[1].rstrip() + + # If the host_arch is 64 bit, allow 32 bit machines on it + if host_arch == arch or (host_arch == "x86_64" and arch == "i386"): + arch_hosts[host] = host + if len(avail_hosts) > 0: # Find the host that is the closest memory match + # and matching architecture for (host, attrs) in avail_hosts.iteritems(): - # Use a random volume group - vol_group = random.choice(attrs['space'].keys()) - - if not dest_host: - dest_host = [host, vol_group, attrs['memory']] - else: - if attrs['memory'] < dest_host[2]: - # Use the better match - dest_host = [host, vol_group, attrs['memory']] + if arch_hosts.has_key(host): + if not dest_host: + dest_host = [host, attrs['memory']] + else: + if attrs['memory'] < dest_host[1]: + # Use the better match + dest_host = [host, attrs['memory']] return dest_host diff --git a/contrib/func-find-resources b/contrib/func-find-resources new file mode 100755 index 0000000..fc85ff7 --- /dev/null +++ b/contrib/func-find-resources @@ -0,0 +1,11 @@ +#!/usr/bin/python + +import sys +import distutils.sysconfig +import func.overlord.find_resources as find_resources + +find_res = find_resources.FindResources() +avail_host = find_res.run(sys.argv) + +if avail_host: + print "%s" % avail_host[0] diff --git a/func/minion/modules/virt.py b/func/minion/modules/virt.py index 40ae274..ba5759e 100644 --- a/func/minion/modules/virt.py +++ b/func/minion/modules/virt.py @@ -202,7 +202,7 @@ class Virt(func_module.FuncModule): return memory - def install(self, server_name, target_name, system=False, virt_name=None, virt_path=None): + def install(self, server_name, target_name, system=False, virt_name=None, virt_path=None, graphics=False): """ Install a new virt system by way of a named cobbler profile. @@ -236,7 +236,10 @@ class Virt(func_module.FuncModule): if virt_path: koan_args.append("--virt-path=%s" % virt_path) - rc = sub_process.call(koan_args,shell=False) + if not graphics: + koan_args.append("--nogfx") + + rc = sub_process.call(koan_args,shell=False,close_fds=True) if rc == 0: return 0 else: |