io-murano package installation during charm bringup done
This commit is contained in:
parent
913569bc62
commit
97f1c6c4ab
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import socket
|
||||
import subprocess
|
||||
|
||||
|
@ -9,6 +10,20 @@ import charms_openstack.ip as os_ip
|
|||
# import charms_openstack.sdn.odl as odl
|
||||
# import charms_openstack.sdn.ovs as ovs
|
||||
|
||||
RC_FILE = '/root/novarc'
|
||||
|
||||
def get_environment(env):
|
||||
with open("/root/novarc", "r") as ins:
|
||||
for line in ins:
|
||||
k, v = line.replace('export', '').replace(" ", "").split('=')
|
||||
env[k] = v.strip()
|
||||
return env
|
||||
|
||||
def run_command(cmd):
|
||||
os_env = get_environment(os.environ.copy())
|
||||
subprocess.check_call(cmd, env=os_env)
|
||||
|
||||
|
||||
def register_endpoints(keystone):
|
||||
"""When the keystone interface connects, register this unit in the keystone
|
||||
catalogue.
|
||||
|
@ -66,6 +81,22 @@ def assess_status():
|
|||
"""
|
||||
MuranoCharm.singleton.assess_status()
|
||||
|
||||
def render_novarc_config(interfaces_list):
|
||||
"""Use the singleton from the MuranoCharm to run render_novarc_config
|
||||
|
||||
@param interfaces_list: List of instances of interface classes.
|
||||
@returns: None
|
||||
"""
|
||||
MuranoCharm.singleton.render_novarc_config(interfaces_list)
|
||||
|
||||
def import_io_murano():
|
||||
"""Use the singleton from the MuranoCharm to run import io-murano
|
||||
package
|
||||
|
||||
@returns: None
|
||||
"""
|
||||
MuranoCharm.singleton.import_io_murano()
|
||||
|
||||
|
||||
class MuranoCharm(charms_openstack.charm.HAOpenStackCharm):
|
||||
|
||||
|
@ -92,10 +123,12 @@ class MuranoCharm(charms_openstack.charm.HAOpenStackCharm):
|
|||
}
|
||||
|
||||
service_type = 'murano'
|
||||
# Note that the hsm interface is optional - defined in config.yaml
|
||||
required_relations = ['shared-db', 'amqp', 'identity-service']
|
||||
|
||||
restart_map = {'/etc/murano/murano.conf': services}
|
||||
restart_map = {
|
||||
'/etc/murano/murano.conf': services,
|
||||
RC_FILE: [''],
|
||||
}
|
||||
|
||||
ha_resources = ['vips', 'haproxy']
|
||||
|
||||
|
@ -117,7 +150,29 @@ class MuranoCharm(charms_openstack.charm.HAOpenStackCharm):
|
|||
"""
|
||||
self.configure_source()
|
||||
super(MuranoCharm, self).install()
|
||||
|
||||
def render_novarc_config(self, interfaces_list):
|
||||
"""Render novarc config to bootstrap Murano service
|
||||
|
||||
@returns None
|
||||
"""
|
||||
configs = [RC_FILE]
|
||||
self.render_with_interfaces(
|
||||
interfaces_list,
|
||||
configs=configs)
|
||||
|
||||
|
||||
def import_io_murano(self):
|
||||
"""Install Core libary io-murano
|
||||
|
||||
@returns None
|
||||
"""
|
||||
io_murano_lib = "/usr/share/murano-common/io.murano.zip"
|
||||
if os.path.isfile(io_murano_lib):
|
||||
cmd = ['murano', 'package-import', io_murano_lib]
|
||||
run_command(cmd)
|
||||
|
||||
|
||||
def get_amqp_credentials(self):
|
||||
"""Provide the default amqp username and vhost as a tuple.
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
import charms_openstack.charm as charm
|
||||
import charms.reactive as reactive
|
||||
import charmhelpers.core.hookenv as hookenv
|
||||
|
||||
# This charm's library contains all of the handler code associated with
|
||||
# sdn_charm
|
||||
|
@ -28,9 +29,13 @@ charm.use_defaults(
|
|||
'config.changed',
|
||||
'update-status')
|
||||
|
||||
@reactive.when('shared-db.available')
|
||||
@reactive.when('identity-service.available')
|
||||
@reactive.when('amqp.available')
|
||||
COMPLETE_INTERFACE_STATES = [
|
||||
'shared-db.available',
|
||||
'identity-service.available',
|
||||
'amqp.available',
|
||||
]
|
||||
|
||||
@reactive.when(*COMPLETE_INTERFACE_STATES)
|
||||
def render_config(*args):
|
||||
"""Render the configuration for charm when all the interfaces are
|
||||
available.
|
||||
|
@ -38,10 +43,17 @@ def render_config(*args):
|
|||
with charm.provide_charm_instance() as charm_class:
|
||||
charm_class.render_with_interfaces(args)
|
||||
charm_class.assess_status()
|
||||
murano.render_novarc_config(args)
|
||||
reactive.set_state('config.rendered')
|
||||
|
||||
# db_sync checks if sync has been done so rerunning is a noop
|
||||
@reactive.when('config.rendered')
|
||||
def init_db():
|
||||
def init_db(*args):
|
||||
with charm.provide_charm_instance() as charm_class:
|
||||
charm_class.db_sync()
|
||||
|
||||
@reactive.when_not('io-murano.imported')
|
||||
@reactive.when(*COMPLETE_INTERFACE_STATES)
|
||||
def import_io_murano(*args):
|
||||
murano.import_io_murano()
|
||||
reactive.set_state('io-murano.imported')
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
{% if identity_service.api_version == '3' -%}
|
||||
export OS_AUTH_URL={{ identity_service.auth_protocol }}://{{ identity_service.auth_host }}:{{ identity_service.auth_port }}/v3
|
||||
export OS_USERNAME={{ identity_service.service_username }}
|
||||
export OS_PASSWORD={{ identity_service.service_password }}
|
||||
export OS_USER_DOMAIN_NAME=default
|
||||
export OS_PROJECT_DOMAIN_NAME=default
|
||||
export OS_PROJECT_NAME={{ identity_service.service_tenant }}
|
||||
export OS_REGION_NAME={{ options.region }}
|
||||
export OS_IDENTITY_API_VERSION=3
|
||||
export OS_AUTH_VERSION=3
|
||||
{% else -%}
|
||||
export OS_AUTH_URL={{ identity_service.auth_protocol }}://{{ identity_service.auth_host }}:{{ identity_service.auth_port }}/v2.0
|
||||
export OS_TENANT_NAME={{ identity_service.service_tenant }}
|
||||
export OS_USERNAME={{ identity_service.service_username }}
|
||||
export OS_PASSWORD={{ identity_service.service_password }}
|
||||
export OS_REGION_NAME={{ options.region }}
|
||||
{% endif -%}
|
Loading…
Reference in New Issue