openvcloud / 0-templates

Apache License 2.0
1 stars 5 forks source link

Can't add a user to a certain account (or vdc, ..) #77

Closed john-kheir closed 6 years ago

john-kheir commented 6 years ago

Scenario

1- Run a blueprint to create an account

github.com/openvcloud/0-templates/account/0.0.1 - 41ef8d86-a09f-42d3-9819-792525694345 - johnacc33
github.com/openvcloud/0-templates/openvcloud/0.0.1 - 28b96bb5-d554-4942-82ff-1f408838630e - be-g8-3
github.com/openvcloud/0-templates/sshkey/0.0.1 - b4cd10b8-3876-47ab-b91c-910d0019adff - key
github.com/openvcloud/0-templates/vdcuser/0.0.1 - 239b900d-cfcc-4c95-9fc5-1231aa43dc4c - gig_qa_1
github.com/openvcloud/0-templates/vdcuser/0.0.1 - 0ead7e1a-c65c-4b4a-85e8-04641727e2c0 - test98
root@0-robot0:~/blueprints# 

2- Run a blueprint to add a user

Blueprint

services:
    - github.com/openvcloud/0-templates/sshkey/0.0.1__key:
        dir: '/root/.ssh/'
        passphrase: 'tesing'
    - github.com/openvcloud/0-templates/openvcloud/0.0.1__be-g8-3:
        address: 'be-g8-3.demo.greenitglobe.com'
        login: 'kheirj@itsyouonline'
        token: '****************'
        location: be-g8-3
    - github.com/openvcloud/0-templates/vdcuser/0.0.1__gig_qa_1:
        openvcloud: be-g8-3
        provider: itsyouonline
        email: dina.magdy.mohammed+123@gmail.com
    - github.com/openvcloud/0-templates/vdcuser/0.0.1__test98:
        openvcloud: be-g8-3
        provider: itsyouonline
        email: test@greenitglobe.com
        groups: ['user']
    - github.com/openvcloud/0-templates/account/0.0.1__johnacc33:
        openvcloud: be-g8-3

actions:
    - template: github.com/openvcloud/0-templates/account/0.0.1
      actions: ['user_add']
      args:
        user:
          name: test98@itsyouonline
          accesstype: R

Error

[Sun25 10:34] - base.py           :191 :service-41ef8d86-a09f-42d3-9819-792525694345 - ERROR    - error executing action user_add:
Traceback (most recent call last):
  File "/root/0-robot/zerorobot/task/task.py", line 76, in execute
    self._result = self.func(**self._args)
  File "/opt/code/github/openvcloud/0-templates/templates/account/account.py", line 107, in user_add
    raise ValueError('no account service found with name "%s"', user['name'])
ValueError: ('no account service found with name "%s"', 'test98@itsyouonline')
katia-e commented 6 years ago

@john-kheir , in order to add a new user test98@itsyouonline, vdcuser service with name test98 should be installed. The error message is indeed wrong (should be service for user 'test98' is not found), I'll fix the typo and add more detailed doc to #75.

john-kheir commented 6 years ago

@katia-e Please read my first step .. vdcuser "test98" is already installed.

katia-e commented 6 years ago

@john-kheir , yes, sorry, already installed. I think the error comes from the fact that username is given in format test98@itsyouonline, while the service name for this user is test98. I'm not sure what behavior should be: either we require to provide username without @itsyouonline suffix, or we check both options.

john-kheir commented 6 years ago

@katia-e if you passed user: test98, you will get this error

[Sun25 12:42] - base.py           :191 :service-c0b547e3-b6e3-4744-8949-6619c8501ed1 - ERROR    - error executing action user_add:
Traceback (most recent call last):
  File "/root/0-robot/zerorobot/task/task.py", line 76, in execute
    self._result = self.func(**self._args)
  File "/opt/code/github/openvcloud/0-templates/templates/account/account.py", line 128, in user_add
    if self.account.authorize_user(username=name, right=accesstype) == True:
  File "/opt/code/github/jumpscale/lib9/JumpScale9Lib/clients/openvcloud/Authorizables.py", line 39, in authorize_user
    self._addUser(username, right)
  File "/opt/code/github/jumpscale/lib9/JumpScale9Lib/clients/openvcloud/Account.py", line 112, in _addUser
    accountId=self.id, userId=username, accesstype=right)
  File "/opt/code/github/jumpscale/lib9/JumpScale9Lib/clients/portal/PortalClient.py", line 57, in __call__
    raise ApiError(response)
JumpScale9Lib.clients.portal.PortalClient.ApiError: 404 Not Found
User is not registered on the system
katia-e commented 6 years ago

@john-kheir , is user test98 registered in itsyouonline? From what I saw, portal returns this error if user doesn't exist in itsyouonline.

john-kheir commented 6 years ago

@katia-e it actually returns this error because this user doesn't exist in OVC since the user that exists in OVC is test98@itsyouonline not test98

katia-e commented 6 years ago

@john-kheir , yes indeed, I think I fixed it just now in #75