Commit 4216a3b1 authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

snf-ci: Add delete command

This patch adds the delete command to snf-ci which deletes
ci's created servers. Also it delete the floating IP attached
to the deleted server.
parent 42090b30
......@@ -11,6 +11,7 @@ import utils
from optparse import OptionParser
CREATE_SERVER_CMD = "create"
DELETE_SERVER_CMD = "delete"
BUILD_SYNNEFO_CMD = "build"
BUILD_DOCS_SYNNEFO_CMD = "docs"
DEPLOY_SYNNEFO_CMD = "deploy"
......@@ -30,6 +31,7 @@ COMMANDS_IN_ALL_MODE = [
AVAILABLE_COMMANDS = [
CREATE_X2GO_FILE,
DELETE_SERVER_CMD,
] + COMMANDS_IN_ALL_MODE
USAGE = """usage: %%prog [options] command[,command...]
......@@ -42,6 +44,7 @@ command:
* %s: Run Synnefo unittests
* %s: Run snf-burnin in the deployed Synnefo
* %s: Create x2go plugin file
* %s: Delete the slave server
* %s: Run all the available commands
""" % tuple([CREATE_SERVER_CMD,
......@@ -51,6 +54,7 @@ command:
TEST_SYNNEFO_CMD,
RUN_BURNIN_CMD,
CREATE_X2GO_FILE,
DELETE_SERVER_CMD,
ALL_CMDS])
......@@ -166,6 +170,8 @@ def main(): # Too many branches. pylint: disable-msg=R0912
synnefo_ci.run_burnin()
if getattr(options, CREATE_X2GO_FILE, False):
synnefo_ci.x2go_plugin(options.x2go_output)
if getattr(options, DELETE_SERVER_CMD, False):
synnefo_ci.destroy_server()
if __name__ == "__main__":
......
......@@ -253,10 +253,16 @@ class SynnefoCI(object):
def destroy_server(self, wait=True):
"""Destroy slave server"""
server_id = int(self.read_temp_config('server_id'))
fips = [f for f in self.network_client.list_floatingips()
if str(f['instance_id']) == str(server_id)]
self.logger.info("Destoying server with id %s " % server_id)
self.cyclades_client.delete_server(server_id)
if wait:
self._wait_transition(server_id, "ACTIVE", "DELETED")
for fip in fips:
self.logger.info("Destroying floating ip %s",
fip['floating_ip_address'])
self.network_client.delete_floatingip(fip['id'])
def _create_floating_ip(self):
"""Create a new floating ip"""
......
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