Commit 90d38a4b authored by Loïc Dachary's avatar Loïc Dachary

Merge branch 'wip-delete' into 'master'

enough: delete the security group along with the host

Closes #255

See merge request !296
parents c8e22d01 d9d7ab11
Pipeline #1025 passed with stage
in 23 minutes and 42 seconds
......@@ -173,6 +173,7 @@ class Stack(OpenStackBase):
network = self.definition.get('internal_network', OpenStackBase.INTERNAL_NETWORK)
o = OpenStack(self.config_dir, **self.args)
o.delete_security_group(name)
o.network_delete_if_not_used(network)
def delete(self):
......@@ -397,6 +398,13 @@ class OpenStack(OpenStackBase):
def run(self, *args):
return self.o(*args)
def delete_security_group(self, name):
try:
self.o.security.group.delete(name)
except sh.ErrorReturnCode_1:
return False
return True
def network_exists(self, name):
network = self.o.network.list('--format=value', '-c', 'Name', '--name', name)
return network.strip() == name
......
......@@ -229,3 +229,12 @@ def test_openstack_volume_resize_no_volume(openstack_name):
with pytest.raises(openstack.OpenStackVolumeResizeMissing):
o.volume_resize(openstack_name, openstack_name, 1)
@pytest.mark.skipif('SKIP_OPENSTACK_INTEGRATION_TESTS' in os.environ,
reason='skip integration test')
def test_openstack_security_group(openstack_name):
o = OpenStack(settings.CONFIG_DIR)
o.o.security.group.create(openstack_name)
assert o.delete_security_group(openstack_name) is True
assert o.delete_security_group(openstack_name) is False
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment