This repository has been archived by the owner on May 7, 2023. It is now read-only.
/
test.py
50 lines (39 loc) · 1.5 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# coding: utf-8
import time
from fabkit import * # noqa
from keystone import Keystone
from glance import Glance
from nova import Nova
from fablib.base import SimpleBase
import utils
class Test(SimpleBase):
def __init__(self):
self.data_key = 'test_openstack'
self.data = {}
def basic(self):
data = self.init()
if env.host != env.hosts[0]:
return
keystone = Keystone()
keystone.create_user(data['user'], data['password'], [['admin', 'admin']])
glance = Glance()
image_id = glance.create_image(
data['image']['name'],
data['image']['src_url'],
)
# net_id = utils.oscmd("neutron net-list 2>/dev/null "
# "| grep ' {0} ' | awk '{{print $2}}'".format(
# env.cluster['neutron']['test_net']))
# test_stack = {
# 'image_id': image_id,
# 'net_id': net_id,
# 'flavor': 'test-flavor',
# }
# filer.template('/tmp/stack-nova.yml', src='stack/stack-nova.yml', data=test_stack)
# filer.template('/tmp/autoscale.yml', src='stack/autoscale.yml', data=test_stack)
# with api.warn_only():
# result = utils.oscmd('heat stack-list | grep stack-nova')
# if result.return_code == 0:
# utils.oscmd('heat stack-delete -y stack-nova')
# time.sleep(3)
# utils.oscmd('heat stack-create -f /tmp/stack-nova.yml stack-nova')