Esempio n. 1
0
        def extend(share):
            path = None
            try:
                path = self.translate_path(share['id'])
            except RpcException:
                pass

            def get_perms():
                if share['target_type'] in ('DIRECTORY', 'DATASET', 'FILE'):
                    perms = self.dispatcher.call_sync('filesystem.stat', path)
                    return perms['permissions']

            def get_perm_type():
                if share['target_type'] == 'DATASET':
                    return self.dispatcher.call_sync(
                        'volume.dataset.query',
                        [('id', '=', share['target_path'])], {
                            'select': 'permissions_type',
                            'single': True
                        })

            share['filesystem_path'] = path
            share['permissions_type'] = lazy(get_perm_type)
            share['permissions'] = lazy(get_perms)
            return share
Esempio n. 2
0
        def extend(obj):
            def doit():
                time.sleep(1)
                return 'I am so slow: {0}'.format(obj['id'])

            def doit2():
                time.sleep(1)
                return {'foo': obj['id'] + 1, 'bar': obj['id'] + 2}

            obj['fast_value'] = obj['id'] * 5
            obj['slow_value'] = lazy(doit)
            obj['composite_slow_value'] = lazy(doit2)
            return obj
Esempio n. 3
0
        def extend(directory):
            for k, v in directory['parameters'].items():
                if k == 'password':
                    directory['parameters'][k] = Password(v)

            directory['status'] = lazy(self.dispatcher.call_sync, 'dscached.management.get_status', directory['id'])
            return directory
        def extend(directory):
            for k, v in directory['parameters'].items():
                if k == 'password':
                    directory['parameters'][k] = Password(v)

            directory['status'] = lazy(self.dispatcher.call_sync, 'dscached.management.get_status', directory['id'])
            return directory
Esempio n. 5
0
        def extend(obj):
            def doit():
                time.sleep(1)
                return 'I am so slow: {0}'.format(obj['id'])

            def doit2():
                time.sleep(1)
                return {
                    'foo': obj['id'] + 1,
                    'bar': obj['id'] + 2
                }

            obj['fast_value'] = obj['id'] * 5
            obj['slow_value'] = lazy(doit)
            obj['composite_slow_value'] = lazy(doit2)
            return obj
Esempio n. 6
0
        def extend_query():
            for i in self.datastore.query_stream('peers', ('type', '=', 'vmware')):
                password = q.get(i, 'credentials.password')
                if password:
                    q.set(i, 'credentials.password', Password(password))

                i['status'] = lazy(self.get_status, i['id'])

                yield i
Esempio n. 7
0
        def extend_query():
            for i in self.datastore.query_stream('peers', ('type', '=', 'vmware')):
                password = q.get(i, 'credentials.password')
                if password:
                    q.set(i, 'credentials.password', Password(password))

                i['status'] = lazy(self.get_status, i['id'])

                yield i
Esempio n. 8
0
        def extend(i):
            lazy_status = lazy(get_status, self.dispatcher, self.datastore, i)
            entry = {
                'id': i['id'],
                'name': i['name'],
                'labels': None,
                'state': lazy(lambda: lazy_status()[0]),
                'error': lazy(lambda: lazy_status()[1]),
            }

            if 'launchd' in i:
                launchd = i['launchd']
                jobs = [launchd] if isinstance(launchd, dict) else launchd
                entry['labels'] = [j['Label'] for j in jobs]

            entry['pid'] = lazy(lambda: lazy_status()[2]),
            entry['builtin'] = i['builtin']
            entry['config'] = lazy(self.get_service_config, i['id'])
            return entry
Esempio n. 9
0
        def extend(i):
            lazy_status = lazy(get_status, self.dispatcher, self.datastore, i)
            entry = {
                'id': i['id'],
                'name': i['name'],
                'dependencies': i.get('dependencies', []),
                'labels': None,
                'state': lazy(lambda: lazy_status()[0]),
                'error': lazy(lambda: lazy_status()[1]),
            }

            if 'launchd' in i:
                launchd = i['launchd']
                jobs = [launchd] if isinstance(launchd, dict) else launchd
                entry['labels'] = [j['Label'] for j in jobs]

            entry['pid'] = lazy(lambda: lazy_status()[2]),
            entry['builtin'] = i['builtin']
            entry['config'] = lazy(self.get_service_config, i['id'])
            return entry
Esempio n. 10
0
 def extend(directory):
     directory['status'] = lazy(self.dispatcher.call_sync,
                                'dscached.management.get_status',
                                directory['id'])
     return directory
Esempio n. 11
0
 def extend(obj):
     obj['capabilities'] = drivers[obj['type']]
     obj['state'] = lazy(self.dispatcher.call_sync,
                         f'vm.datastore.{obj["type"]}.get_state',
                         obj['id'])
     return obj
Esempio n. 12
0
 def extend_query():
     for i in self.datastore.query_stream('peers',
                                          ('type', '=', 'amazon-s3')):
         i['status'] = lazy(self.get_status, i['id'])
         yield i
Esempio n. 13
0
 def extend_query():
     for i in self.datastore.query_stream('peers', ('type', '=', 'freenas')):
         i['status'] = lazy(self.get_status, i['id'])
         yield i