X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2FTestSlice.py;h=f062884d9c469e05749b3c5a11cfeac4850d4812;hb=2ce3c411bd50cf2b303d3fc440e8f918d311f735;hp=31bd70b28816294d668990b20bf9ea1bf0ef2a21;hpb=3546376d221cf58aa1783958e0fb1b4d349ecb2c;p=tests.git diff --git a/system/TestSlice.py b/system/TestSlice.py index 31bd70b..f062884 100644 --- a/system/TestSlice.py +++ b/system/TestSlice.py @@ -74,9 +74,9 @@ class TestSlice: # trash the slice altogether def delete_slice(self): - utils.header("Deleting slice %s"%slice_name) auth = self.owner_auth() slice_name = self.slice_name() + utils.header("Deleting slice %s"%slice_name) self.test_plc.apiserver.DeleteSlice(auth,slice_name) # keep the slice alive and just delete nodes @@ -90,36 +90,29 @@ class TestSlice: (len(node_ids),slice_name)) self.test_plc.apiserver.DeleteSliceFromNodes (auth,slice_name, node_ids) - def locate_key(self): - # locate the first avail. key - found=False + def locate_private_key(self): + key_names=[] for username in self.slice_spec['usernames']: user_spec=self.test_site.locate_user(username) - for keyname in user_spec['keynames']: - key_spec=self.test_plc.locate_key(keyname) - test_key=TestKey(self.test_plc,key_spec) - publickey=test_key.publicpath() - privatekey=test_key.privatepath() - keyname=test_key.name() - if os.path.isfile(publickey) and os.path.isfile(privatekey): - found=True - return (found,privatekey) - + key_names += user_spec['key_names'] + return self.test_plc.locate_private_key_from_key_names (key_names) # trying to reach the slice through ssh - expected to answer def ssh_slice (self, options, *args, **kwds): + "tries to ssh-enter the slice with the user key, to ensure slice creation" return self.do_ssh_slice(options, expected=True, *args, **kwds) # when we expect the slice is not reachable def ssh_slice_off (self, options, *args, **kwds): + "tries to ssh-enter the slice with the user key, expecting it to be unreachable" return self.do_ssh_slice(options, expected=False, *args, **kwds) def do_ssh_slice(self,options,expected=True,timeout_minutes=20,silent_minutes=10,period=15): timeout = datetime.datetime.now()+datetime.timedelta(minutes=timeout_minutes) graceout = datetime.datetime.now()+datetime.timedelta(minutes=silent_minutes) # locate a key - (found,remote_privatekey)=self.locate_key() - if not found : + private_key=self.locate_private_key() + if not private_key : utils.header("WARNING: Cannot find a valid key for slice %s"%self.name()) return False @@ -140,9 +133,10 @@ class TestSlice: while tocheck: for hostname in tocheck: (site_spec,node_spec) = self.test_plc.locate_hostname(hostname) - date_test_ssh = TestSsh (hostname,key=remote_privatekey,username=self.name()) + date_test_ssh = TestSsh (hostname,key=private_key,username=self.name()) command = date_test_ssh.actual_command("echo hostname ; hostname; echo id; id; echo uname -a ; uname -a") date = utils.system (command, silent=datetime.datetime.now() < graceout) + if getattr(options,'dry_run',None): return True if expected: success = date==0 else: success = date!=0 @@ -157,7 +151,7 @@ class TestSlice: # nm restart after first failure, if requested if options.forcenm and hostname not in restarted: utils.header ("forcenm option : restarting nm on %s"%hostname) - restart_test_ssh=TestSsh(hostname,key="keys/key1.rsa") + restart_test_ssh=TestSsh(hostname,key="keys/key_admin.rsa") access=restart_test_ssh.actual_command('service nm restart') if (access==0): utils.header('nm restarted on %s'%hostname)