Beispiel #1
0
 def list(self, request):
     datacenter = DataCenter.get_default()
     LOG.info("****** signup get method ********")
     rc = create_rc_by_dc(datacenter)
     LOG.info("****** signup get method ********")
     tenants = keystone.keystoneclient(rc).tenants.list()
     tenants_id = []
     for tenant in tenants:
         if str(tenant.name) not in ["admin", "demo", "services"]:
             tenants_id.append({'name': tenant.name, 'id': tenant.id})
     LOG.info("********* tenants_id is **************" + str(tenants_id))
     return Response(tenants_id)
 def list(self, request):
     datacenter = DataCenter.get_default()
     LOG.info("****** signup get method ********")
     rc = create_rc_by_dc(datacenter)
     LOG.info("****** signup get method ********")
     tenants = keystone.keystoneclient(rc).tenants.list()
     tenants_id = [] 
     for tenant in tenants:
         if str(tenant.name) not in ["admin", "demo", "services"]:
             tenants_id.append({'name': tenant.name, 'id': tenant.id})
     LOG.info("********* tenants_id is **************" + str(tenants_id))
     return Response(tenants_id)
Beispiel #3
0
def update_user(request):

    LOG.info("******* data is ******" + str(request.data))
    LOG.info("****** username is ******" + str(request.data['username']))
    posted_username = request.data['username']
    email = request.data['email']
    mobile = request.data['mobile']
    user_id = request.data['id']
    user = User.objects.all().get(id = request.data['id'])
    userprofile = UserProfile.objects.all().get(user = user)
    LOG.info(user_id)
    if User.objects.filter(username = posted_username).exists():
        if User.objects.get(username = posted_username).id != int(user_id):
            return Response({"success": False,
                     "msg": _("Duplicated user name.Please enter another user name.")})
    if User.objects.filter(email = email).exists():
        if User.objects.get(email = email).id != int(user_id):
            return Response({"success": False,
                     "msg": _("Duplicated email.Please enter another email address.")})
    if UserProfile.objects.filter(mobile = mobile).exists():
        if UserProfile.objects.get(mobile = mobile).user != user:
            return Response({"success": False,
                     "msg": _("Duplicated mobile.Please enter another mobile.")})
    if str(posted_username) in ['neutron', 'cinder', 'keystone', 'nova', 'glance', 'heat', 'swift', 'admin', 'ceilometer']:     
        return Response({"success": False,
                     "msg": _("Service user must not be created.")})
    LOG.info("uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu")
    LOG.info("uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu")
    LOG.info("uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu")
    try:
        user_data_center = UserDataCenter.objects.all().get(user = user)
        keystone_user_id = user_data_center.keystone_user_id
        rc = create_rc_by_dc(DataCenter.get_default())
        keystone_user = keystone.user_get(rc, keystone_user_id)
        LOG.info(keystone_user)
        manager = keystone.keystoneclient(rc, admin=True).users
        update_user = manager.update(keystone_user, name = posted_username, email = email)
        #keystone.user_update(rc, keystone_user, name = posted_username, email = email)
        keystone_user = keystone.user_get(rc, keystone_user_id)
        LOG.info(keystone_user)
    except Exception as e:
        traceback.print_exc()
        return Response({"success":False, "msg":str(e)})
    try:
        user.username = posted_username
        user.email = email
        userprofile.mobile = mobile
        user.save()
        userprofile.save()
    except:
        traceback.print_exc()
    return Response({"success":True})
Beispiel #4
0
 def get(self, request):
     LOG.info("****** signup get method ********")
     datacenter = DataCenter.get_default()
     LOG.info("****** signup get method ********")
     rc = create_rc_by_dc(datacenter)
     LOG.info("****** signup get method ********")
     tenants = keystone.keystoneclient(rc).tenants.list()
     tenants_id = {}
     for tenant in tenants:
         if str(tenant.name) not in ["admin", "demo", "services"]:
             tenants_id[tenant.id] = tenant.name
     LOG.info("********* tenants_id is **************" + str(tenants_id))
     return self.response(request, CloudUserCreateForm(
         initial={'username': '',  'email': '', 'mobile': ''}), tenants_id)
Beispiel #5
0
    def list(self, reqeust):

        datacenter = DataCenter.get_default()
        LOG.info("ccc")
        rc = create_rc_by_dc(datacenter)
        LOG.info("ccc")
        tenants = keystone.keystoneclient(rc).tenants.list()
        LOG.info("cccccccc")
        tenants_id = [] 
        for tenant in tenants:
            if str(tenant.name) not in ["admin", "demo", "services"]:
                tenants_id.append({'tenant_id': tenant.id, 'tenant_name':tenant.name, 'description': tenant.description})
        LOG.info("tenants_id is" + str(tenants_id))
        return Response(tenants_id)
Beispiel #6
0
    def list(self, reqeust):

        datacenter = DataCenter.get_default()
        LOG.info("ccc")
        rc = create_rc_by_dc(datacenter)
        LOG.info("ccc")
        tenants = keystone.keystoneclient(rc).tenants.list()
        LOG.info("cccccccc")
        tenants_id = []
        for tenant in tenants:
            if str(tenant.name) not in ["admin", "demo", "services"]:
                tenants_id.append({
                    'tenant_id': tenant.id,
                    'tenant_name': tenant.name,
                    'description': tenant.description
                })
        LOG.info("tenants_id is" + str(tenants_id))
        return Response(tenants_id)
Beispiel #7
0
 def get(self, request):
     LOG.info("****** signup get method ********")
     datacenter = DataCenter.get_default()
     LOG.info("****** signup get method ********")
     rc = create_rc_by_dc(datacenter)
     LOG.info("****** signup get method ********")
     tenants = keystone.keystoneclient(rc).tenants.list()
     tenants_id = {}
     for tenant in tenants:
         if str(tenant.name) not in ["admin", "demo", "services"]:
             tenants_id[tenant.id] = tenant.name
     LOG.info("********* tenants_id is **************" + str(tenants_id))
     return self.response(
         request,
         CloudUserCreateForm(initial={
             'username': '',
             'email': '',
             'mobile': ''
         }), tenants_id)
Beispiel #8
0
    def response(self, request, form, tenants_id=None, errors=None):

        LOG.info("****** signup get method ********")
        datacenter = DataCenter.get_default()
        LOG.info("****** signup get method ********")
        rc = create_rc_by_dc(datacenter)
        LOG.info("****** signup get method ********")
        tenants = keystone.keystoneclient(rc).tenants.list()
        tenants_id = {}
        for tenant in tenants:
            if str(tenant.name) not in ["admin", "demo", "services"]:
                tenants_id[tenant.id] = tenant.name
        LOG.info("********* tenants_id is **************" + str(tenants_id))

        context = {
            "BRAND": settings.BRAND,
            "form": form,
            "errors": errors,
            "tenants_id": tenants_id
        }

        return render(request, 'signup.html', context)
Beispiel #9
0
    def response(self, request, form, tenants_id=None, errors=None):

        LOG.info("****** signup get method ********")
        datacenter = DataCenter.get_default()
        LOG.info("****** signup get method ********")
        rc = create_rc_by_dc(datacenter)
        LOG.info("****** signup get method ********")
        tenants = keystone.keystoneclient(rc).tenants.list()
        tenants_id = {}
        for tenant in tenants:
            if str(tenant.name) not in ["admin", "demo", "services"]:
                tenants_id[tenant.id] = tenant.name
        LOG.info("********* tenants_id is **************" + str(tenants_id))

        context = {
            "BRAND": settings.BRAND,
            "form": form,
            "errors": errors,
            "tenants_id": tenants_id
        }

        return render(request, 'signup.html', context)