X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2FTestNode.py;h=dad8546ccbc80fe3ada7e506d52a185e1954d20b;hb=8f314a0560012830f55b1565b65646074365644a;hp=b018598a77cb7e75775d9e07dde7e39a7b83b99c;hpb=8666ae7f0291e8d115e166ef555f02abafc40fc8;p=tests.git diff --git a/system/TestNode.py b/system/TestNode.py index b018598..dad8546 100644 --- a/system/TestNode.py +++ b/system/TestNode.py @@ -97,16 +97,17 @@ 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(): + server.AddNodeTag(userauth, node_id, tagname, tagvalue) + if not self.test_plc.has_addresses_api(): # print 'USING OLD INTERFACE' # populate network interfaces - primary - server.AddInterface(userauth,self.name(), + server.AddInterface(userauth, self.name(), self.node_spec['interface_fields']) else: # print 'USING NEW INTERFACE with separate ip addresses' @@ -121,31 +122,32 @@ class TestNode: # populate network interfaces - others if 'extra_interfaces' in self.node_spec: for interface in self.node_spec['extra_interfaces']: - server.AddInterface(userauth,self.name(), interface['interface_fields']) + server.AddInterface(userauth, self.name(), interface['interface_fields']) if 'settings' in interface: for attribute, value in interface['settings'].items(): # locate node network - interface = server.GetInterfaces(userauth,{'ip':interface['interface_fields']['ip']})[0] + interface = server.GetInterfaces( userauth, + {'ip' : interface['interface_fields']['ip']})[0] interface_id = interface['interface_id'] # locate or create node network attribute type try: - interface_tagtype = server.GetTagTypes(userauth,{'name':attribute})[0] + interface_tagtype = server.GetTagTypes(userauth, {'name' : attribute})[0] except: - interface_tagtype = server.AddTagType(rootauth,{'category':'test', - 'tagname':attribute}) + interface_tagtype = server.AddTagType(rootauth,{'category' : 'test', + 'tagname' : attribute}) # attach value - server.AddInterfaceTag(userauth,interface_id,attribute,value) + server.AddInterfaceTag(userauth, interface_id, attribute, value) def delete_node(self): # uses the right auth as far as poss. try: ownername = self.node_spec['owner'] user_spec = self.test_site.locate_user(ownername) - test_user = TestUser(self.test_plc,self.test_site,user_spec) + test_user = TestUser(self.test_plc, self.test_site, user_spec) auth = test_user.auth() except: auth = self.test_plc.auth_root() - self.test_plc.apiserver.DeleteNode(auth,self.name()) + self.test_plc.apiserver.DeleteNode(auth, self.name()) # Do most of the stuff locally - will be pushed on host_box - *not* the plc - later if needed def qemu_local_init(self): @@ -161,13 +163,9 @@ class TestNode: "all nodes: invoke GetBootMedium and store result locally" utils.header("Calling GetBootMedium for {}".format(self.name())) # this would clearly belong in the config but, well .. - options = [] - if self.is_qemu(): - options.append('serial') - options.append('no-hangcheck') - options.append('systemd-debug') - encoded = self.test_plc.apiserver.GetBootMedium(self.test_plc.auth_root(), - self.name(), 'node-iso', '', options) + options = self.node_spec['bootmedium_options'] if 'bootmedium_options' in self.node_spec else [] + encoded = self.test_plc.apiserver.GetBootMedium( + self.test_plc.auth_root(), self.name(), 'node-iso', '', options) if encoded == '': raise Exception('GetBootmedium failed') @@ -195,6 +193,12 @@ class TestNode: self.name(),{'boot_state':'reinstall'}) return True + def nodestate_upgrade(self): + "all nodes: mark PLCAPI boot_state as upgrade" + self.test_plc.apiserver.UpdateNode(self.test_plc.auth_root(), + self.name(),{'boot_state':'upgrade'}) + return True + def nodestate_safeboot(self): "all nodes: mark PLCAPI boot_state as safeboot" self.test_plc.apiserver.UpdateNode(self.test_plc.auth_root(), @@ -213,9 +217,51 @@ class TestNode: print("Dry_run: skipped getting current node state") return True state = self.test_plc.apiserver.GetNodes(self.test_plc.auth_root(), self.name(), ['boot_state'])[0]['boot_state'] - print(self.name(),':',state) + print("boot_state for {} : {}".format(self.name(), state)) return True + def nodedistro_f14(self): + return self.nodedistro_set('f14') + def nodedistro_f18(self): + return self.nodedistro_set('f18') + def nodedistro_f20(self): + return self.nodedistro_set('f20') + def nodedistro_f21(self): + return self.nodedistro_set('f21') + def nodedistro_set(self, distro): + "set the fcdistro tag to distro, passed in arg" + self.test_plc.apiserver.SetNodeFcdistro(self.test_plc.auth_root(), + self.name(), distro) + return True + def nodeflavour_show(self): + "display the fcdistro tag - or flavour actually - of node" + if self.dry_run(): + print("Dry_run: would fetch node flavour") + return True + flavour = self.test_plc.apiserver.GetNodeFlavour(self.test_plc.auth_root(), + self.name()) + print("Flavour for {} : {}".format(self.name(), flavour)) + return True + + def nodeplain_set(self, plain): + " set bootstrapfs-plain tag on nodes" + self.test_plc.apiserver.SetNodePlainBootstrapfs(self.test_plc.auth_root(), + self.name(), plain) + return True + def nodeplain_on(self): + return self.nodeplain_set("True") + def nodeplain_off(self): + return self.nodeplain_set("") + def nodeplain_show(self): + "display bootstrapfs-plain tag" + if self.dry_run(): + print("Dry_run: would fetch node plain-bootstrapfs tag") + return True + plain = self.test_plc.apiserver.GetNodePlainBootstrapfs(self.test_plc.auth_root(), + self.name()) + print("Plain bootstrapfs for {} is {}".format(self.name(), plain)) + return True + def qemu_local_config(self): "all nodes: compute qemu config qemu.conf and store it locally" if not self.is_qemu(): @@ -276,6 +322,18 @@ class TestNode: return test_box.run_in_buildname("echo {:d} > {}/timestamp"\ .format(now, self.nodedir()), dry_run=self.dry_run()) == 0 + def qemu_nodefamily(self): + "write nodefamily stamp in qemu working dir" + auth = self.test_plc.auth_root() + hostname = self.node_spec['node_fields']['hostname'] + nodeflavour = self.test_plc.apiserver.GetNodeFlavour(auth, hostname) + if self.dry_run(): + return True + nodedir = self.nodedir() + nodefamily = nodeflavour['nodefamily'] + self.test_box().run_in_buildname("echo {nodefamily} > {nodedir}/nodefamily".format(**locals())) + return True + def start_qemu(self): test_box = self.test_box() utils.header("Starting qemu node {} on {}".format(self.name(), test_box.hostname()))