summaryrefslogtreecommitdiffstats
path: root/deploy/post/execute.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2017-03-14 17:53:45 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2017-03-14 18:08:07 +0800
commitf51cb39fda90a227b7fe80d06fc70f96a1ced128 (patch)
treeb1c7732e63ff476a14496b716300205cd2ba0226 /deploy/post/execute.py
parentc557362eb2a14055587feac228a4463bd96f6f4a (diff)
create m1.micro flavor for functest
Change-Id: Iacb36cb05e72b0755cec0a5bd5a6c48f3ec70c6f Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'deploy/post/execute.py')
-rw-r--r--deploy/post/execute.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/deploy/post/execute.py b/deploy/post/execute.py
index d5a0727b..9e029b11 100644
--- a/deploy/post/execute.py
+++ b/deploy/post/execute.py
@@ -7,6 +7,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import neutron
+import nova
def _config_admin_external_network():
@@ -44,10 +45,23 @@ def _config_admin_external_subnet(nid):
}
+def _create_flavor_m1_micro():
+ name = 'm1.micro'
+ novaclient = nova.Nova()
+ if not novaclient.get_flavor_by_name(name):
+ try:
+ return novaclient.create_flavor(name, ram=64, vcpus=1, disk=0)
+ except Exception as error:
+ print ('_create_flavor_m1_micro failed: {}'.format(str(error)))
+ else:
+ print ('Use existing m1.micro flavor')
+
+
def main():
neutronclient = neutron.Neutron()
nid = neutronclient.create_network(*(_config_admin_external_network()))
neutronclient.create_subnet(_config_admin_external_subnet(nid))
+ _create_flavor_m1_micro()
if __name__ == '__main__':
main()