def test_exists(self): with patch.multiple(misc, sh=lambda cmd: self.teuthology_instance): o = OpenStackInstance("NAME") assert o.exists() def sh_raises(cmd): raise subprocess.CalledProcessError("FAIL", "BAD") with patch.multiple(misc, sh=sh_raises): o = OpenStackInstance("NAME") assert not o.exists()
def test_exists(self): with patch.multiple( misc, sh=lambda cmd: self.teuthology_instance, ): o = OpenStackInstance('NAME') assert o.exists() def sh_raises(cmd): raise subprocess.CalledProcessError('FAIL', 'BAD') with patch.multiple( misc, sh=sh_raises, ): o = OpenStackInstance('NAME') assert not o.exists()
def test_exists(self): with patch.multiple( misc, sh=lambda cmd: self.teuthology_instance, ): o = OpenStackInstance('NAME') assert o.exists() def sh_raises(cmd): raise subprocess.CalledProcessError('FAIL', 'BAD') with patch.multiple( misc, sh=sh_raises, ): o = OpenStackInstance('NAME') assert not o.exists()
def stale_openstack_instances(ctx, instances, locked_nodes): for (instance_id, instance) in instances.items(): i = OpenStackInstance(instance_id) if not i.exists(): log.debug( "stale-openstack: {instance} disappeared, ignored".format( instance=instance_id)) continue if (i.get_created() > config['max_job_time'] + OPENSTACK_DELAY): log.info("stale-openstack: destroying instance {instance}" " because it was created {created} seconds ago" " which is older than" " max_job_time {max_job_time} + {delay}".format( instance=i['name'], created=i.get_created(), max_job_time=config['max_job_time'], delay=OPENSTACK_DELAY)) if not ctx.dry_run: i.destroy() continue name = canonicalize_hostname(i['name'], user=None) if i.get_created() > OPENSTACK_DELAY and name not in locked_nodes: log.info("stale-openstack: destroying instance {instance}" " because it was created {created} seconds ago" " is older than {delay}s and it is not locked".format( instance=i['name'], created=i.get_created(), delay=OPENSTACK_DELAY)) if not ctx.dry_run: i.destroy() continue log.debug("stale-openstack: instance " + i['name'] + " OK")