Exemple #1
0
def is_paused():
    """Is the unit paused?"""
    with HookData()():
        if kv().get('unit-paused'):
            return True
        else:
            return False
Exemple #2
0
def resume(args):
    """Resume all the swift services.

    @raises Exception if any services fail to start
    """
    for service in args.services:
        started = service_resume(service)
        if not started:
            raise Exception("{} didn't start cleanly.".format(service))
    with HookData()():
        kv().set('unit-paused', False)
    set_os_workload_status(CONFIGS,
                           REQUIRED_INTERFACES,
                           charm_func=assess_status)
Exemple #3
0
    def test_hook_data_records(self, cdir, ctx, name):
        name.return_value = 'config-changed'
        ctx.return_value = {
            'rels': {}, 'conf': {'a': 1}, 'env': {}, 'unit': 'someunit'}
        cdir.return_value = self.charm_dir
        with open(os.path.join(self.charm_dir, 'revision'), 'w') as fh:
            fh.write('1')
        hook_data = HookData()

        with hook_data():
            self.assertEqual(kv(), hook_data.kv)
            self.assertEqual(kv().get('charm_revisions'), ['1'])
            self.assertEqual(kv().get('unit'), 'someunit')
            self.assertEqual(list(hook_data.conf), ['a'])
            self.assertEqual(tuple(hook_data.conf.a), (None, 1))