This repository has been archived by the owner on May 7, 2023. It is now read-only.
/
heat.py
66 lines (52 loc) · 1.87 KB
/
heat.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# coding: utf-8
from fabkit import env, sudo, filer
from fablib.python import Python
from fablib.base import SimpleBase
import utils
class Heat(SimpleBase):
def __init__(self):
self.data_key = 'heat'
self.data = {
}
self.packages = [
'heat-9.0.0',
]
self.services = [
'heat-api',
'heat-api-cfn',
'heat-engine',
]
def init_before(self):
self.package = env['cluster']['os_package_map']['heat']
self.prefix = self.package.get('prefix', '/opt/heat')
self.python = Python(self.prefix)
def init_after(self):
self.data.update({
'keystone': env.cluster['keystone'],
})
def setup(self):
data = self.init()
if self.is_tag('package'):
self.install_packages()
if self.is_tag('conf'):
# setup conf files
is_updated = filer.template(
'/etc/heat/heat.conf',
src='{0}/heat/heat.conf'.format(data['version']),
data=data,
)
if self.is_tag('data') and env.host == env.hosts[0]:
utils.oscmd('/opt/heat/bin/heat-keystone-setup-domain \
--stack-user-domain-name {0} \
--stack-domain-admin {1} \
--stack-domain-admin-password {2}'.format(
self.data['stack_user_domain_name'],
self.data['stack_domain_admin'],
self.data['stack_domain_admin_password']))
sudo('{0}/bin/heat-manage db_sync'.format(self.prefix))
if self.is_tag('conf', 'service'):
self.enable_services().start_services(pty=False)
if is_updated:
self.restart_services(pty=False)
def cmd(self, cmd):
return utils.oscmd('heat {0}'.format(cmd))