blob: 39fd126e8c6b080efadcc4b6a546aaf2cafedc1d [file] [log] [blame]
Dennis Dmitriev6f59add2016-10-18 13:45:27 +03001# Copyright 2016 Mirantis, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15from tcp_tests import settings_oslo
16
17
18class EnvironmentManagerEmpty(object):
19 """Class-helper for creating VMs via devops environments"""
20
Dennis Dmitriev2d60c8e2017-05-12 18:34:01 +030021 __config = None
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030022
23 def __init__(self, config=None):
24 """Initializing class instance and create the environment
25
26 :param config: oslo.config object
27 :param config.hardware.conf_path: path to devops YAML template
28 :param config.hardware.current_snapshot: name of the snapshot that
29 descriebe environment status.
30 """
Dennis Dmitriev2d60c8e2017-05-12 18:34:01 +030031 self.__config = config
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030032
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030033 def get_ssh_data(self, roles=None):
34 raise Exception("EnvironmentManagerEmpty doesn't have SSH details. "
35 "Please provide SSH details in config.underlay.ssh")
36
Dennis Dmitriev411dd102017-09-15 16:04:47 +030037 def create_snapshot(self, name, **kwargs):
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030038 """Store environmetn state into the config object
39
40 - Store the state of the environment <name> to the 'config' object
41 - Save 'config' object to a file 'config_<name>.ini'
42 """
Dennis Dmitriev2d60c8e2017-05-12 18:34:01 +030043 self.__config.hardware.current_snapshot = name
44 settings_oslo.save_config(self.__config, name)
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030045
46 def revert_snapshot(self, name):
47 """Check the current state <name> of the environment
48
49 - Check that the <name> matches the current state of the environment
Dennis Dmitriev2d60c8e2017-05-12 18:34:01 +030050 that is stored in the 'self.__config.hardware.current_snapshot'
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030051 - Try to reload 'config' object from a file 'config_<name>.ini'
52 If the file not found, then pass with defaults.
53 - Set <name> as the current state of the environment after reload
54
55 :param name: string
56 """
Dennis Dmitriev2d60c8e2017-05-12 18:34:01 +030057 if self.__config.hardware.current_snapshot != name:
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030058 raise Exception(
59 "EnvironmentManagerEmpty cannot revert nodes from {} to {}"
Dennis Dmitriev2d60c8e2017-05-12 18:34:01 +030060 .format(self.__config.hardware.current_snapshot, name))
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030061
62 def start(self):
63 """Start environment"""
64 pass
65
66 def resume(self):
67 """Resume environment"""
68 pass
69
70 def suspend(self):
71 """Suspend environment"""
72 pass
73
74 def stop(self):
75 """Stop environment"""
76 pass
77
78 def has_snapshot(self, name):
Dennis Dmitriev2d60c8e2017-05-12 18:34:01 +030079 return self.__config.hardware.current_snapshot == name
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030080
81 def has_snapshot_config(self, name):
Dennis Dmitriev2d60c8e2017-05-12 18:34:01 +030082 return self.__config.hardware.current_snapshot == name
Dennis Dmitriev6f59add2016-10-18 13:45:27 +030083
84 def delete_environment(self):
85 """Delete environment"""
86 pass
Vladimir Jigulinee1faa52018-06-25 13:00:51 +040087
88 def warm_shutdown_nodes(self, underlay, nodes_prefix, timeout=600):
89 raise Exception(
90 "Node shutdown method unsupported on this environment manager")
91
92 def warm_restart_nodes(self, underlay, nodes_prefix, timeout=600):
93 raise Exception(
94 "Node restart method unsupported on this environment manager")