Beispiel #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
     )
Beispiel #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
     )
Beispiel #3
0
    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]
Beispiel #4
0
 def annotated(self):
     return extend(self.value, {
         'origin': {
             'directory': self.directory.name,
             'cached_at': self.created_at,
             'ttl': self.ttl
         }
     })
Beispiel #5
0
def annotate(user, directory, name_field, cache=None):
    return extend(user, {
        'origin': {
            'directory': directory.name,
            'cached_at': None,
            'ttl': None
        }
    })
Beispiel #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]
Beispiel #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
Beispiel #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
         }
     })
Beispiel #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
        }
    })
Beispiel #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
         }
     })
Beispiel #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
        }
    })
Beispiel #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
Beispiel #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
        }
    })
Beispiel #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)
        )
Beispiel #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)
        )
Beispiel #16
0
 def __getstate__(self):
     return extend(include(self._dict, *self.__annotations__.keys()),
                   {'%type': self.json_schema_name()})
Beispiel #17
0
 def __getstate__(self):
     return extend(
         include(self._dict, *getattr(self, '__annotations__', {}).keys()),
         {'%type': self.__class__.__name__}
     )
Beispiel #18
0
def apply(obj, datastore):
    return extend(obj, {"last_name": obj["full_name"].split()[-1]})
Beispiel #19
0
def apply(obj, datastore):
    return extend(obj, {"last_name": obj["full_name"].split()[-1]})
Beispiel #20
0
 def __getstate__(self):
     return extend(
         include(self._dict,
                 *getattr(self, '__annotations__', {}).keys()),
         {'%type': self.__class__.__name__})
Beispiel #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)
Beispiel #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)