def main(): """ TODO: Add argparse, --delete : Deletes existing users in openstack (Never use in PROD) """ openstack = Provider.objects.filter( type__name__iexact="openstack").order_by("id") if not openstack: raise Provider.DoesNotExist("No OpenStack Provider Found") openstack = openstack[0] os_driver = OSAccountDriver(openstack) found = 0 create = 0 usernames = os_driver.list_usergroup_names() quota_dict = {'cpu': 10, 'memory': 20, 'storage': 10, 'storage_count': 10} higher_quota = Quota.objects.get_or_create(**quota_dict)[0] for user in usernames: # Openstack account exists, but we need the identity. ident = os_driver.create_account(user) if is_staff(ident): im = ident.identity_membership.all()[0] # Disable time allocation im.allocation = None # Raise everybody's quota im.quota = higher_quota im.save() print "Total users added to atmosphere:%s" % len(usernames)
def main(): """ TODO: Add argparse, --delete : Deletes existing users in openstack (Never use in PROD) """ openstack = Provider.objects.filter( type__name__iexact="openstack").order_by("id") if not openstack: raise Provider.DoesNotExist("No OpenStack Provider Found") openstack = openstack[0] os_driver = OSAccountDriver(openstack) found = 0 create = 0 usernames = os_driver.list_usergroup_names() quota_dict = { 'cpu': 10, 'memory': 20, 'storage': 10, 'storage_count': 10 } higher_quota = Quota.objects.get_or_create(**quota_dict)[0] for user in usernames: # Openstack account exists, but we need the identity. ident = os_driver.create_account(user) if is_staff(ident): im = ident.identity_membership.all()[0] # Disable time allocation im.allocation = None # Raise everybody's quota im.quota = higher_quota im.save() print "Total users added to atmosphere:%s" % len(usernames)
def main(): """ TODO: Add argparse, --delete : Deletes existing users in openstack (Never use in PROD) """ openstack = Provider.objects.get(location='iPlant Cloud - Tucson') os_driver = OSAccountDriver(openstack) found = 0 create = 0 quota_dict = { 'cpu': 16, 'memory': 128, 'storage': 10, 'storage_count': 10 } higher_quota = Quota.objects.get_or_create(**quota_dict)[0] usernames = os_driver.list_usergroup_names() staff = get_staff_users() staff_users = sorted(list(set(staff) & set(usernames))) non_staff = sorted(list(set(usernames) - set(staff))) for user in non_staff: # Raise everybody's quota im_list = IdentityMembership.objects.filter( identity__created_by__username=user, identity__provider=openstack) if not im_list: print "Missing user:%s" % user continue im = im_list[0] if not im.allocation: print "User missing Allocation: %s" % user im.allocation = Allocation.default_allocation() im.save() # Ignore the quota set if you are above it.. if im.quota.cpu >= quota_dict["cpu"] \ or im.quota.memory >= quota_dict["memory"]: continue print "Existing Quota CPU:%s should be %s" % (im.quota.cpu, quota_dict["cpu"]) im.quota = higher_quota im.save() print 'Found non-staff user:%s -- Update quota and add allocation' % user # for user in staff_users: # # Openstack account exists, but we need the identity. # continue # continue # #Disable time allocation print "Total users added to atmosphere:%s" % len(usernames)
def main(): """ TODO: Add argparse, --delete : Deletes existing users in openstack (Never use in PROD) """ openstack = Provider.objects.get(location='iPlant Cloud - Tucson') os_driver = OSAccountDriver(openstack) found = 0 create = 0 quota_dict = {'cpu': 16, 'memory': 128, 'storage': 10, 'storage_count': 10} higher_quota = Quota.objects.get_or_create(**quota_dict)[0] usernames = os_driver.list_usergroup_names() staff = get_staff_users() staff_users = sorted(list(set(staff) & set(usernames))) non_staff = sorted(list(set(usernames) - set(staff))) for user in non_staff: # Raise everybody's quota im_list = IdentityMembership.objects.filter( identity__created_by__username=user, identity__provider=openstack) if not im_list: print "Missing user:%s" % user continue im = im_list[0] if not im.allocation: print "User missing Allocation: %s" % user im.allocation = Allocation.default_allocation() im.save() # Ignore the quota set if you are above it.. if im.quota.cpu >= quota_dict["cpu"] \ or im.quota.memory >= quota_dict["memory"]: continue print "Existing Quota CPU:%s should be %s" % (im.quota.cpu, quota_dict["cpu"]) im.quota = higher_quota im.save() print 'Found non-staff user:%s -- Update quota and add allocation' % user # for user in staff_users: # # Openstack account exists, but we need the identity. # continue # continue # #Disable time allocation print "Total users added to atmosphere:%s" % len(usernames)