diff options
author | jose.lausuch <jose.lausuch@ericsson.com> | 2016-06-30 14:12:54 +0200 |
---|---|---|
committer | Jose Lausuch <jose.lausuch@ericsson.com> | 2016-07-04 07:27:32 +0000 |
commit | bbc47d487f06da2906116e5ade134e11c4221786 (patch) | |
tree | d52c4ded1b3774b449c8d89b961ab17b0d28e7c5 /cli | |
parent | 7388d059ff9f4efed594582ded843f795e56c9fa (diff) |
Change OpenStack clean behaviour
JIRA: FUNCTEST-236
The openstack snapshot generation is now triggered before running
a test case and removed from prepare_env
Change-Id: I4d1bc95dedd7f59d4b1d5866f288e1c1a70ec69e
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'cli')
-rw-r--r-- | cli/commands/cli_os.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/cli/commands/cli_os.py b/cli/commands/cli_os.py index 23b7beaa..b007842b 100644 --- a/cli/commands/cli_os.py +++ b/cli/commands/cli_os.py @@ -7,15 +7,15 @@ # http://www.apache.org/licenses/LICENSE-2.0 # -import click + import os +import click +import functest.utils.functest_utils as ft_utils +import functest.utils.openstack_clean as os_clean +import functest.utils.openstack_snapshot as os_snapshot import yaml -import functest.utils.clean_openstack as clean_os -import functest.utils.functest_utils as ft_utils -import functest.utils.generate_defaults as gen_def -""" global variables """ with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f: functest_yaml = yaml.safe_load(f) @@ -24,10 +24,12 @@ FUNCTEST_REPO = ("%s/functest/" % REPOS_DIR) FUNCTEST_CONF_DIR = functest_yaml.get("general").get( "directories").get("dir_functest_conf") RC_FILE = os.getenv('creds') -OS_DEFAULTS_FILE = FUNCTEST_CONF_DIR + '/os_defaults.yaml' +OS_SNAPSHOT_FILE = ft_utils.get_parameter_from_yaml( + "general.openstack.snapshot_file") class CliOpenStack: + def __init__(self): self.os_auth_url = os.getenv('OS_AUTH_URL') self.endpoint_ip = None @@ -86,7 +88,7 @@ class CliOpenStack: def snapshot_create(self): self.ping_endpoint() - if os.path.isfile(OS_DEFAULTS_FILE): + if os.path.isfile(OS_SNAPSHOT_FILE): answer = raw_input("It seems there is already an OpenStack " "snapshot. Do you want to overwrite it with " "the current OpenStack status? [y|n]\n") @@ -99,22 +101,22 @@ class CliOpenStack: answer = raw_input("Invalid answer. Please type [y|n]\n") click.echo("Generating Openstack snapshot...") - gen_def.main() + os_snapshot.main() def snapshot_show(self): - if not os.path.isfile(OS_DEFAULTS_FILE): + if not os.path.isfile(OS_SNAPSHOT_FILE): click.echo("There is no OpenStack snapshot created. To create " "one run the command 'functest env os-create-snapshot'") return - with open(OS_DEFAULTS_FILE, 'r') as yaml_file: + with open(OS_SNAPSHOT_FILE, 'r') as yaml_file: click.echo("\n%s" % yaml_file.read()) def clean(self): self.ping_endpoint() - if not os.path.isfile(OS_DEFAULTS_FILE): + if not os.path.isfile(OS_SNAPSHOT_FILE): click.echo("Not possible to clean OpenStack without a snapshot. " "This could cause problems. " "Run first the command 'os-create-shapshot'.") return - clean_os.main() + os_clean.main() |