Exemplo n.º 1
0
 def query(self, params, options):
     return self.context.call_sync(
         self.query_call,
         self.extra_query_params + params,
         extend(self.extra_query_options, options),
         timeout=self.call_timeout
     )
Exemplo n.º 2
0
 def get_one(self, name):
     return self.context.call_sync(
         self.query_call,
         self.extra_query_params + [(self.primary_key_name, '=', name)],
         extend(self.extra_query_options, {'single': True}),
         timeout=self.call_timeout
     )
Exemplo n.º 3
0
Arquivo: disks.py Projeto: freenas/cli
    def query(self, params, options):
        ret = super(DisksNamespace, self).query(params, options)
        allocations = self.context.call_sync('volume.get_disks_allocation', [d['id'] for d in ret])

        return [extend(d, {
            'allocation': allocations.get(d['id']) if d['online'] else None
        }) for d in ret]
Exemplo n.º 4
0
 def annotated(self):
     return extend(self.value, {
         'origin': {
             'directory': self.directory.name,
             'cached_at': self.created_at,
             'ttl': self.ttl
         }
     })
Exemplo n.º 5
0
def annotate(user, directory, name_field, cache=None):
    return extend(user, {
        'origin': {
            'directory': directory.name,
            'cached_at': None,
            'ttl': None
        }
    })
Exemplo n.º 6
0
    def query(self, params, options):
        ret = super(DisksNamespace, self).query(params, options)
        disks = [d['path'] for d in ret]
        allocations = self.context.call_sync('volume.get_disks_allocation', disks)

        return [extend(d, {
                'allocation': allocations.get(d['path']) if d['online'] else None
            }) for d in ret]
Exemplo n.º 7
0
def fix_passwords(user):
    """
    Warning: this function shall be called only within an RPC method context
    """
    if not privileged(user['uid']):
        return extend(user, {'unixhash': '*', 'nthash': None, 'lmhash': None})

    return user
Exemplo n.º 8
0
 def annotated(self):
     return extend(self.value, {
         'origin': {
             'directory': self.directory.name,
             'domain': self.directory.domain_name,
             'read_only': self.directory.plugin_type != 'local',
             'cached_at': self.created_at,
             'ttl': self.ttl
         }
     })
Exemplo n.º 9
0
def annotate(user, directory, name_field, cache=None):
    return extend(user, {
        'origin': {
            'directory': directory.name,
            'domain': directory.domain_name,
            'read_only': directory.plugin_type != 'local',
            'cached_at': None,
            'ttl': None
        }
    })
Exemplo n.º 10
0
 def annotated(self):
     return extend(self.value, {
         'origin': {
             'directory': self.directory.name,
             'domain': self.directory.domain_name,
             'read_only': self.directory.plugin_type != 'local',
             'cached_at': self.created_at,
             'ttl': self.ttl
         }
     })
Exemplo n.º 11
0
def annotate(user, directory, name_field, cache=None):
    return extend(user, {
        'origin': {
            'directory': directory.name,
            'domain': directory.domain_name,
            'read_only': directory.plugin_type != 'local',
            'cached_at': None,
            'ttl': None
        }
    })
Exemplo n.º 12
0
def fix_passwords(user):
    """
    Warning: this function shall be called only within an RPC method context
    """
    if not privileged(user['uid']):
        return extend(user, {
            'unixhash': '*',
            'nthash': None,
            'lmhash': None
        })

    return user
Exemplo n.º 13
0
def annotate(user, directory, name_field, cache=None):
    name = '{0}@{1}'.format(user[name_field], directory.domain_name) \
        if directory.domain_name \
        else user[name_field]

    return extend(user, {
        name_field: name,
        'origin': {
            'directory': directory.name,
            'cached_at': None,
            'ttl': None
        }
    })
Exemplo n.º 14
0
    def save(self, this, new=False):
        if new:
            newname = this.entity['id']
            if len(newname.split('/')) < 2:
                raise CommandException(_("Please specify name as a relative path starting from the dataset's parent volume."))

            self.context.submit_task(
                'volume.dataset.create',
                extend(this.entity, {'volume': self.parent.entity['id']}),
                callback=lambda s, t: post_save(this, s, t)
            )
            return

        self.context.submit_task(
            'volume.dataset.update',
            this.orig_entity['id'],
            this.get_diff(),
            callback=lambda s, t: post_save(this, s, t)
        )
Exemplo n.º 15
0
    def save(self, this, new=False):
        if new:
            newname = this.entity['id']
            if len(newname.split('/')) < 2:
                raise CommandException(_("Please specify name as a relative path starting from the dataset's parent volume."))

            self.context.submit_task(
                'volume.dataset.create',
                extend(this.entity, {'volume': self.parent.entity['id']}),
                callback=lambda s, t: post_save(this, s, t)
            )
            return

        self.context.submit_task(
            'volume.dataset.update',
            this.orig_entity['id'],
            this.get_diff(),
            callback=lambda s, t: post_save(this, s, t)
        )
Exemplo n.º 16
0
 def __getstate__(self):
     return extend(include(self._dict, *self.__annotations__.keys()),
                   {'%type': self.json_schema_name()})
Exemplo n.º 17
0
 def __getstate__(self):
     return extend(
         include(self._dict, *getattr(self, '__annotations__', {}).keys()),
         {'%type': self.__class__.__name__}
     )
Exemplo n.º 18
0
def apply(obj, datastore):
    return extend(obj, {"last_name": obj["full_name"].split()[-1]})
Exemplo n.º 19
0
def apply(obj, datastore):
    return extend(obj, {"last_name": obj["full_name"].split()[-1]})
Exemplo n.º 20
0
 def __getstate__(self):
     return extend(
         include(self._dict,
                 *getattr(self, '__annotations__', {}).keys()),
         {'%type': self.__class__.__name__})
Exemplo n.º 21
0
 def query(self, params, options):
     return self.context.call_sync(self.query_call,
                                   self.extra_query_params + params,
                                   extend(self.extra_query_options,
                                          options),
                                   timeout=self.call_timeout)
Exemplo n.º 22
0
 def get_one(self, name):
     return self.context.call_sync(
         self.query_call,
         self.extra_query_params + [(self.primary_key_name, '=', name)],
         extend(self.extra_query_options, {'single': True}),
         timeout=self.call_timeout)