create flavor for Apex installer
[doctor.git] / doctor_tests / installer / base.py
1 ##############################################################################
2 # Copyright (c) 2017 ZTE Corporation and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 import abc
10 import six
11
12 from doctor_tests.identity_auth import get_session
13 from doctor_tests.os_clients import nova_client
14
15
16 @six.add_metaclass(abc.ABCMeta)
17 class BaseInstaller(object):
18     def __init__(self, conf, log):
19         self.conf = conf
20         self.log = log
21
22     @abc.abstractproperty
23     def node_user_name(self):
24         """user name for login to cloud node"""
25
26     @abc.abstractmethod
27     def get_ssh_key_from_installer(self):
28         pass
29
30     @abc.abstractmethod
31     def get_host_ip_from_hostname(self, hostname):
32         pass
33
34     @abc.abstractmethod
35     def setup(self):
36         pass
37
38     @abc.abstractmethod
39     def cleanup(self):
40         pass
41
42     def create_flavor(self):
43         self.nova = \
44             nova_client(self.conf.nova_version,
45                         get_session())
46         flavors = {flavor.name: flavor for flavor in self.nova.flavors.list()}
47         if self.conf.flavor not in flavors:
48             self.nova.flavors.create(self.conf.flavor, 512, 1, 1)