Example #1
0
def update_user(auth, id, **fields):
    user = authenticate(username=auth.get('username'),
                        password=auth.get('password'))
    auth['tenant'] = user.site.login_base

    users = User.objects.filter(id=id)
    if not users:
        return

    user = users[0]
    nova_fields = {}
    if 'email' in fields:
        nova_fields['name'] = fields['email'][:self.email.find('@')]
        nova_fields['email'] = fields['email']
    if 'password' in fields:
        nova_fields['password'] = fields['password']
    if 'enabled' in fields:
        nova_fields['enabled'] = fields['enabled']
    sites = _get_sites(fields.get('site'))
    if sites: fields['site'] = sites[0]
    user.os_manager = OpenStackManager(auth=auth, caller = user)
    for (k,v) in fields.items():
        setattr(user, k, v)    
    user.save()
    return user 
Example #2
0
def update_user(auth, id, **fields):
    user = authenticate(username=auth.get('username'),
                        password=auth.get('password'))
    auth['tenant'] = user.site.login_base

    users = User.objects.filter(id=id)
    if not users:
        return

    user = users[0]
    nova_fields = {}
    if 'email' in fields:
        nova_fields['name'] = fields['email'][:self.email.find('@')]
        nova_fields['email'] = fields['email']
    if 'password' in fields:
        nova_fields['password'] = fields['password']
    if 'enabled' in fields:
        nova_fields['enabled'] = fields['enabled']
    sites = _get_sites(fields.get('site'))
    if sites: fields['site'] = sites[0]
    user.os_manager = OpenStackManager(auth=auth, caller=user)
    for (k, v) in fields.items():
        setattr(user, k, v)
    user.save()
    return user
Example #3
0
File: slices.py Project: xuys50/xos
def get_slices(auth, filter={}):
    user = authenticate(username=auth.get('username'),
                        password=auth.get('password'))
    if 'site' in filter:
        sites = _get_sites(filter.get('site'))
        if sites: filter['site'] = sites[0]
    slices = _get_slices(filter)
    return slices
Example #4
0
def add_user(auth, fields):
    user = authenticate(username=auth.get('username'),
                        password=auth.get('password'))
    auth['tenant'] = user.site.login_base

    sites = _get_sites(fields.get('site'))
    if sites: fields['site'] = sites[0]
    user = User(**fields)
    user.os_manager = OpenStackManager(auth=auth, caller=user)
    user.save()
    return user
Example #5
0
def add_user(auth, fields):
    user = authenticate(username=auth.get('username'),
                        password=auth.get('password'))
    auth['tenant'] = user.site.login_base

    sites = _get_sites(fields.get('site')) 
    if sites: fields['site'] = sites[0]     
    user = User(**fields)
    user.os_manager = OpenStackManager(auth=auth, caller = user)
    user.save()
    return user
Example #6
0
File: slices.py Project: xuys50/xos
def add_slice(auth, fields):
    user = authenticate(username=auth.get('username'),
                        password=auth.get('password'))
    auth['tenant'] = user.site.login_base

    login_base = fields['name'][:fields['name'].find('_')]
    sites = _get_sites(login_base)
    if sites: fields['site'] = sites[0]
    slice = Slice(**fields)
    slice.os_manager = OpenStackManager(auth=auth, caller=user)
    slice.save()
    return slice
Example #7
0
File: slices.py Project: xuys50/xos
def update_slice(auth, id, **fields):
    user = authenticate(username=auth.get('username'),
                        password=auth.get('password'))
    auth['tenant'] = user.site.login_base

    slices = _get_slices(id)
    if not slices:
        return
    slice = slices[0]
    sites = _get_sites(fields.get('site'))
    if sites: fields['site'] = sites[0]

    slice.os_manager = OpenStackManager(auth=auth, caller=user)
    for (k, v) in fields.items():
        setattr(slice, k, v)
    slice.save()

    return slice