From ebb13397ac064e2d85861908fa68523d2c1aa942 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 13 Apr 2015 11:43:06 +0200 Subject: [PATCH] run -g with bonding build can provision node (and locate free IP) and run most usual targets do not use plain bootstrapfs anymore dropped hack for adding epel repo on centos5 --- system/TestBonding.py | 49 ++++++++++++++++++++++++++++++++++++++++ system/TestNode.py | 5 +--- system/TestPlc.py | 16 ++++++------- system/config_default.py | 5 +++- 4 files changed, 62 insertions(+), 13 deletions(-) diff --git a/system/TestBonding.py b/system/TestBonding.py index d94e4e9..9f4c432 100644 --- a/system/TestBonding.py +++ b/system/TestBonding.py @@ -61,6 +61,10 @@ class TestBonding(object): so we can configure the local myplc (test_plc) for multi-flavour nodes and slices options is a TestMain options + + details for a bonding node (like hostname and IP) are + computed from the underlying Substrate object and + stored in arg-bonding-{buildname} """ def __init__(self, test_plc, bonding_spec, substrate, options): @@ -75,9 +79,54 @@ class TestBonding(object): self.bonding_spec = bonding_spec self.substrate = substrate self.options = options + # a little hacky : minimal provisioning and modify plc_spec on the fly + self.provision() + def nodefamily(self): return "{pldistro}-{fcdistro}-{arch}".format(**self.bonding_spec) + #################### provisioning + def persistent_name(self): + return "arg-bonding-{}".format(self.bonding_spec['buildname']) + def persistent_store(self): + with open(self.persistent_name(),'w') as f: + f.write("{} {}\n".format(self.vnode_hostname, self.vnode_ip)) + def persistent_load(self): + try: + with open(self.persistent_name()) as f: + self.vnode_hostname, self.vnode_ip = f.read().strip().split() + return True + except: + return False + + def provision(self): + # locate the first node in our own spec + site_spec = self.test_plc.plc_spec['sites'][0] + node_spec = site_spec['nodes'][0] + # find a free IP for node + if self.persistent_load(): + print("Re-using bonding nodes attributes from {}".format(self.persistent_name())) + else: + print("Could not load bonding nodes attributes from {}".format(self.persistent_name())) + vnode_pool = self.substrate.vnode_pool + vnode_pool.sense() + try: + hostname, mac = vnode_pool.next_free() + self.vnode_hostname = self.substrate.fqdn(hostname) + self.vnode_ip = vnode_pool.get_ip(hostname) + self.vnode_mac = mac + self.persistent_store() + except: + raise Exception("Cannot provision bonding node") + + # implement the node on another IP + node_spec['node_fields']['hostname'] = self.vnode_hostname + node_spec['interface_fields']['ip'] = self.vnode_ip + # with the node flavour that goes with bonding plc + for tag in ['arch', 'fcdistro', 'pldistro']: + node_spec['tags'][tag] = self.bonding_spec[tag] + + #################### steps def init_partial(self): """ runs partial-repo.sh for the bonding build diff --git a/system/TestNode.py b/system/TestNode.py index 1844dcb..59a7924 100644 --- a/system/TestNode.py +++ b/system/TestNode.py @@ -97,11 +97,8 @@ class TestNode: node_id = server.AddNode(userauth, self.test_site.site_spec['site_fields']['login_base'], self.node_spec['node_fields']) - server.SetNodePlainBootstrapfs(userauth, - self.node_spec['node_fields']['hostname'], - 'YES') # create as reinstall to avoid user confirmation - server.UpdateNode(userauth, self.name(), {'boot_state':'reinstall'}) + server.UpdateNode(userauth, self.name(), { 'boot_state' : 'reinstall' }) # you are supposed to make sure the tags exist for tagname, tagvalue in self.node_spec['tags'].items(): diff --git a/system/TestPlc.py b/system/TestPlc.py index 72d2060..177cad6 100644 --- a/system/TestPlc.py +++ b/system/TestPlc.py @@ -161,8 +161,7 @@ class TestPlc: # keep this our of the way for now 'check_vsys_defaults_ignore', SEP, # run this first off so it's easier to re-run on another qemu box - 'qemu_kill_mine', SEP, - 'nodestate_reinstall', 'qemu_local_init','bootcd', 'qemu_local_config', SEP, + 'qemu_kill_mine', 'nodestate_reinstall', 'qemu_local_init','bootcd', 'qemu_local_config', SEP, 'qemu_clean_mine', 'qemu_export', 'qemu_start', 'qemu_timestamp', SEP, 'sfa_install_all', 'sfa_configure', 'cross_sfa_configure', 'sfa_start', 'sfa_import', SEPSFA, 'sfi_configure@1', 'sfa_register_site@1','sfa_register_pi@1', SEPSFA, @@ -706,11 +705,10 @@ class TestPlc: ### install_rpm def plc_install(self): - "yum install myplc, noderepo, and the plain bootstrapfs" - - # workaround for getting pgsql8.2 on centos5 - if self.options.fcdistro == "centos5": - self.run_in_guest("rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm") + """ + yum install myplc, noderepo + plain bootstrapfs is not installed anymore + """ # compute nodefamily if self.options.personality == "linux32": @@ -725,7 +723,6 @@ class TestPlc: pkgs_list.append("slicerepo-{}".format(nodefamily)) pkgs_list.append("myplc") pkgs_list.append("noderepo-{}".format(nodefamily)) - pkgs_list.append("nodeimage-{}-plain".format(nodefamily)) pkgs_string=" ".join(pkgs_list) return self.yum_install(pkgs_list) @@ -1288,6 +1285,9 @@ class TestPlc: def keys_clear_known_hosts(self): pass def plcapi_urls(self): + """ + attempts to reach the PLCAPI with various forms for the URL + """ return PlcapiUrlScanner(self.auth_root(), ip=self.vserverip).scan() def speed_up_slices(self): diff --git a/system/config_default.py b/system/config_default.py index 3a840fe..6ff71f0 100644 --- a/system/config_default.py +++ b/system/config_default.py @@ -68,7 +68,10 @@ def nodes(options, index): }, 'bootmedium_options' : [ 'serial', 'no-hangcheck', 'systemd-debug' ], # provision for bonding - 'tags' : {}, + 'tags' : { + # not needed anymore + # 'plain-bootstrapfs' : 'YES' + }, # boot cd settings # we should have tags here instead of the hard-wired # options set for GetBootMedium in TestNode.py -- 2.43.0