コード例 #1
0
ファイル: relations.py プロジェクト: johnsca/charms.reactive
    def remove_state(self, state):
        """
        Remove this conversation from the given state, and potentially
        deactivate the state if no more conversations are in it.

        The relation name will be interpolated in the state name, and it is
        recommended that it be included to avoid conflicts with states from
        other relations.  For example::

            conversation.remove_state('{relation_name}.state')

        If called from a converation handling the relation "foo", this will
        remove the conversation from the "foo.state" state, and, if no more
        conversations are in this the state, will deactivate it.
        """
        state = state.format(relation_name=self.relation_name)
        value = get_state(state)
        if not value:
            return
        if self.key in value['conversations']:
            value['conversations'].remove(self.key)
        if value['conversations']:
            set_state(state, value)
        else:
            remove_state(state)
コード例 #2
0
ファイル: relations.py プロジェクト: tasdomas/charms.reactive
    def remove_state(self, state):
        """
        Remove this conversation from the given state, and potentially
        deactivate the state if no more conversations are in it.

        The relation name will be interpolated in the state name, and it is
        recommended that it be included to avoid conflicts with states from
        other relations.  For example::

            conversation.remove_state('{relation_name}.state')

        If called from a converation handling the relation "foo", this will
        remove the conversation from the "foo.state" state, and, if no more
        conversations are in this the state, will deactivate it.
        """
        state = state.format(relation_name=self.relation_name)
        value = get_state(state)
        if not value:
            return
        if self.key in value['conversations']:
            value['conversations'].remove(self.key)
        if value['conversations']:
            set_state(state, value)
        else:
            remove_state(state)
コード例 #3
0
def storage_detaching():
    remove_state('platform.stopped')
    remove_state('platform.stop.failed')
    hpcc_init = HPCCInit()
    if hpcc_init.stop():
       set_state('platform.stopped')
       hookenv.status_set('maintainance', 'stopped')
    else:
       set_state('platform.stop.failed')
       hookenv.status_set('blocked', 'hpcc stop failed')
コード例 #4
0
def start_platform():
    remove_state('platform.started')
    remove_state('platform.start.failed')
    platform = HPCCSystemsPlatformConfig()
    if platform.start():
        set_state('platform.start.failed')
        hookenv.status_set('blocked', 'hpcc start failed')
    else:
        set_state('platform.started')
        hookenv.status_set('active', 'started')
コード例 #5
0
def start_platform():
    
    config = hookenv.config()
    #if config['node-type'] != 'standalone':
    #   hookenv.status_set('active', 'ready')
    #   set_state('platform.ready')
    #   return True

    remove_state('platform.started')
    remove_state('platform.start.failed')
    hpcc_init = HPCCInit()
    if hpcc_init.start():
       set_state('platform.started')
       hookenv.status_set('active', 'started')
    else:
       set_state('platform.start.failed')
       hookenv.status_set('blocked', 'hpcc start failed')
コード例 #6
0
def config_changed():

    pass  #not working correctly

    config = hookenv.config()
    if config.changed('ssh-key-private'):
        install_keys_from_config(config)

    platform = HPCCSystemsPlatformConfig()
    if config.changed('hpcc-version') or config.changed('hpcc-type'):
        hpcc_installed = platform.installed_platform()
        if (config.changed('hpcc-version') != hpcc_installed[0]) or \
           (config.changed('hpcc-type') != hpcc_installed[1]) :
            remove_state('platform.installed')
            platform.uninstall_platform()
            platform.install_platform()
            set_state('platform.installed')
コード例 #7
0
ファイル: helpers.py プロジェクト: bac/charms.reactive
def toggle_state(state, should_set):
    """
    Helper that calls either :func:`set_state` or :func:`remove_state`,
    depending on the value of `should_set`.

    Equivalent to::

        if should_set:
            set_state(state)
        else:
            remove_state(state)

    :param str state: Name of state to toggle.
    :param bool should_set: Whether to set the state, or remove it.
    """
    if should_set:
        set_state(state)
    else:
        remove_state(state)
コード例 #8
0
def toggle_state(state, should_set):
    """
    Helper that calls either :func:`set_state` or :func:`remove_state`,
    depending on the value of `should_set`.

    Equivalent to::

        if should_set:
            set_state(state)
        else:
            remove_state(state)

    :param str state: Name of state to toggle.
    :param bool should_set: Whether to set the state, or remove it.
    """
    if should_set:
        set_state(state)
    else:
        remove_state(state)
コード例 #9
0
def restart_platform(plugin):
    if is_state('platform.started'):
        remove_state('platform.started')
    if is_state('platform.start.failed'):
        remove_state('platform.start.failed')
    remove_state('hpcc-plugins.restart.platform')

    platform = HPCCSystemsPlatformConfig()
    if platform.restart():
        set_state('platform.start.failed')
        hookenv.status_set('blocked', 'hpcc start failed')
    else:
        set_state('platform.started')
        hookenv.status_set('active', 'started')
コード例 #10
0
ファイル: charm.py プロジェクト: thedac/charm-layer-openstack
 def remove_state(self, state):
     remove_state(state)