예제 #1
0
 def handle(self, request, data):
     try:
         LOG.info('Creating tenant with id "%s"' % data["id"])
         api.tenant_create(request, data["id"], data["description"], data["enabled"])
         messages.success(request, "%s was successfully created." % data["id"])
     except api_exceptions.ApiException, e:
         LOG.error(
             "ApiException while creating tenant\n"
             'Id: "%s", Description: "%s", Enabled "%s"' % (data["id"], data["description"], data["enabled"]),
             exc_info=True,
         )
         messages.error(request, "Unable to create tenant: %s" % (e.message))
예제 #2
0
 def handle(self, request, data):
     try:
         api.tenant_create(request,
                           data['id'],
                           data['description'],
                           data['enabled'])
         messages.success(request,
                          '%s was successfully created.'
                          % data['id'])
     except api_exceptions.ApiException, e:
         messages.error(request, 'Unable to create tenant: %s' %
                        (e.message))
예제 #3
0
 def handle(self, request, data):
     try:
         LOG.info('Creating tenant with name "%s"' % data['name'])
         api.tenant_create(request, data['name'], data['description'],
                           data['enabled'])
         messages.success(request,
                          _('%s was successfully created.') % data['name'])
     except api_exceptions.ApiException, e:
         LOG.exception('ApiException while creating tenant\n'
                       'Id: "%s", Description: "%s", Enabled "%s"' %
                       (data['name'], data['description'], data['enabled']))
         messages.error(request,
                        _('Unable to create tenant: %s') % (e.message))
예제 #4
0
 def handle(self, request, data):
     try:
         LOG.info('Creating tenant with name "%s"' % data['name'])
         api.tenant_create(request,
                           data['name'],
                           data['description'],
                           data['enabled'])
         messages.success(request,
                          _('%s was successfully created.')
                          % data['name'])
     except api_exceptions.ApiException, e:
         LOG.exception('ApiException while creating tenant\n'
                   'Id: "%s", Description: "%s", Enabled "%s"' %
                   (data['name'], data['description'], data['enabled']))
         messages.error(request, _('Unable to create tenant: %s') %
                        (e.message))
예제 #5
0
def create_user_with_bill(request):
    if request.method == "POST":
        form = CreateNewUserWithBill(request.POST)
        if form.is_valid():
            data = form.clean()
            # TODO Make this a real request
            try:
                LOG.info('Creating tenant with name "%s"' % data['id'])
                new_tenant = api.tenant_create(request,
                            data['id'],
                            "Tenant",
                            True)
                messages.success(request,
                    'tenant %s was successfully created.'
                    % data['id'])

                LOG.info('Creating user with name "%s"' % data['id'])
                new_user = api.user_create(request,
                                           data['id'],
                                           data['id'] + "@dammyemail",
                                           data['password'],
                                           new_tenant.id,
                                           True)
                messages.success(request,
                                 'User "%s" was successfully created.'
                                 % data['id'])
                try:
                    api.role_add_for_tenant_user(
                        request, new_tenant.id, new_user.id,
                        settings.OPENSTACK_KEYSTONE_DEFAULT_ROLE)
                except api_exceptions.ApiException, e:
                    LOG.exception('ApiException while assigning\
                                   role to new user: %s' % new_user.id)
                    messages.error(request, 'Error assigning role to user: %s'
                                             % e.message)

                accountRecord = AccountRecord(tenant_id=new_tenant.id,amount=int(data['amount']),memo="Initial addtion")
                accountRecord.save()
                msg = '%s was successfully added to %s.' % (data['amount'], new_tenant.id)
                LOG.info(msg)
                messages.success(request, msg)
                msg = """
                Please send following messege to the user:
                Your freecloud account is succesfully created.
                Url:https://www.thefreecloud.org
                Username: %s
                Password:%s
                Manual is here:(URL)
                Your inisial stack doller: %s
                """ % ( data['id'],data['password'],data['amount'])
                messages.success(request,msg)
                return shortcuts.redirect('syspanel_create_user_with_bill')

            except api_exceptions.ApiException, e:
                LOG.exception('ApiException while creating a record\n'
                          '%r' % data)
                messages.error(request,
                                 'Error creating record: %s' % e.message)
                return shortcuts.redirect('syspanel_billing')
예제 #6
0
    def test_tenant_create(self):
        DESCRIPTION = "aDescription"
        ENABLED = True

        account_api = self.stub_account_api()

        account_api.tenants = self.mox.CreateMockAnything()
        account_api.tenants.create(TEST_TENANT_ID, DESCRIPTION, ENABLED).AndReturn(TEST_RETURN)

        self.mox.ReplayAll()

        ret_val = api.tenant_create(self.request, TEST_TENANT_ID, DESCRIPTION, ENABLED)

        self.assertIsInstance(ret_val, api.Tenant)
        self.assertEqual(ret_val._apiresource, TEST_RETURN)

        self.mox.VerifyAll()