Exemplo n.º 1
0
def render(*args):
    hookenv.log("about to call the render_configs with {}".format(args))
    with charm.provide_charm_instance() as ironic_charm:
        ironic_charm.render_with_interfaces(charm.optional_interfaces(args))
        ironic_charm.configure_tls()
        ironic_charm.assess_status()
    reactive.set_state('config.complete')
def configure_ovs():
    ovsdb = reactive.endpoint_from_flag('ovsdb.available')
    with charm.provide_charm_instance() as charm_instance:
        ch_core.hookenv.log('DEBUG: {} {} {} {}'.format(
            charm_instance, charm_instance.packages, charm_instance.services,
            charm_instance.restart_map),
                            level=ch_core.hookenv.INFO)
        charm_instance.render_with_interfaces(
            charm.optional_interfaces((ovsdb, ), 'nova-compute.connected'))
        charm_instance.configure_ovs(ovsdb)
        charm_instance.assess_status()
def configure_ovs():
    ovsdb = reactive.endpoint_from_flag('ovsdb.available')
    with charm.provide_charm_instance() as charm_instance:
        if reactive.is_flag_set('config.changed.enable-dpdk'):
            # Install required packages and/or run update-alternatives
            charm_instance.install()
        charm_instance.configure_ovs(','.join(ovsdb.db_sb_connection_strs))
        charm_instance.render_with_interfaces(
            charm.optional_interfaces((ovsdb, ), 'nova-compute.connected',
                                      'amqp.connected'))
        reactive.set_flag('config.rendered')
        charm_instance.assess_status()
Exemplo n.º 4
0
def render_stuff(*args):
    """Render the configuration for Barbican when all the interfaces are
    available.

    Note that the HSM interface is optional and thus is only used if it is
    available.
    """
    hookenv.log("about to call the render_configs with {}".format(args))
    with charm.provide_charm_instance() as barbican_charm:
        barbican_charm.render_with_interfaces(
            charm.optional_interfaces(args, 'hsm.available'))
        barbican_charm.assess_status()
def render_stuff(*args):
    """Render the configuration for Barbican when all the interfaces are
    available.

    Note that the HSM interface is optional and thus is only used if it is
    available.
    """
    hookenv.log("about to call the render_configs with {}".format(args))
    with charm.provide_charm_instance() as barbican_charm:
        barbican_charm.render_with_interfaces(
            charm.optional_interfaces(args, 'hsm.available'))
        barbican_charm.assess_status()
def render(*args):
    """Render the configuration for Octavia when all interfaces are available.
    """
    with charm.provide_charm_instance() as octavia_charm:
        octavia_charm.render_with_interfaces(
            charm.optional_interfaces(
                args,
                'ovsdb-subordinate.available',
                'ovsdb-cms.available',
            ))
        octavia_charm.configure_ssl()
        octavia_charm.enable_webserver_site()
        octavia_charm.assess_status()
    reactive.set_state('config.rendered')
Exemplo n.º 7
0
def set_temp_url_secret(*args):
    """Set Temp-Url-Key on storage account"""
    if not reactive.is_flag_set('leadership.is_leader'):
        return ch_core.hookenv.action_fail('action must be run on the leader '
                                           'unit.')
    if not reactive.is_flag_set('config.complete'):
        return ch_core.hookenv.action_fail('required relations are not yet '
                                           'available, please defer action'
                                           'until deployment is complete.')
    identity_service = reactive.endpoint_from_flag(
        'identity-credentials.available')
    try:
        keystone_session = api_utils.create_keystone_session(identity_service)
    except Exception as e:
        ch_core.hookenv.action_fail(
            'Failed to create keystone session ("{}")'.format(e))

    os_cli = api_utils.OSClients(keystone_session)
    if os_cli.has_swift() is False:
        ch_core.hookenv.action_fail(
            'Swift not yet available. Please wait for deployment to finish')

    if os_cli.has_glance() is False:
        ch_core.hookenv.action_fail(
            'Glance not yet available. Please wait for deployment to finish')

    if "swift" not in os_cli.glance_stores:
        ch_core.hookenv.action_fail(
            'Glance does not support Swift storage backend. '
            'Please add relation between glance and ceph-radosgw/swift')

    current_secret = leadership.leader_get("temp_url_secret")
    current_swift_secret = os_cli.get_object_account_properties().get(
        'temp-url-key', None)

    if not current_secret or current_swift_secret != current_secret:
        secret = hashlib.sha1(str(uuid.uuid4()).encode()).hexdigest()
        os_cli.set_object_account_property("temp-url-key", secret)
        leadership.leader_set({"temp_url_secret": secret})
        # render configs on leader, and assess status. Every other unit
        # will render theirs when leader-settings-changed executes.
        shared_db = reactive.endpoint_from_flag('shared-db.available')
        ironic_api = reactive.endpoint_from_flag('ironic-api.available')
        amqp = reactive.endpoint_from_flag('amqp.available')

        with charm.provide_charm_instance() as ironic_charm:
            ironic_charm.render_with_interfaces(
                charm.optional_interfaces(
                    (identity_service, shared_db, ironic_api, amqp)))
            ironic_charm._assess_status()
Exemplo n.º 8
0
def render(*args):
    """Render the configuration for Octavia when all interfaces are available.
    """
    amp_key_name = ch_core.hookenv.config('amp-ssh-key-name')
    if amp_key_name:
        identity_service = reactive.endpoint_from_flag(
            'identity-service.available')
        api_crud.create_nova_keypair(identity_service, amp_key_name)

    with charm.provide_charm_instance() as octavia_charm:
        octavia_charm.render_with_interfaces(
            charm.optional_interfaces(
                args,
                'ovsdb-subordinate.available',
                'ovsdb-cms.available',
            ))
        octavia_charm.configure_ssl()
        octavia_charm.enable_webserver_site()
        octavia_charm.assess_status()
    reactive.set_state('config.rendered')
Exemplo n.º 9
0
def render_stuff(*args):
    with provide_charm_instance() as ironic_charm:
        ironic_charm.render_with_interfaces(optional_interfaces(args))
        ironic_charm.assess_status()
    reactive.set_state('config.complete')