openvcloud / 0-templates

Apache License 2.0
1 stars 5 forks source link

Users parameter in the account section in the blueprint is throwing an error. #54

Closed john-kheir closed 6 years ago

john-kheir commented 6 years ago

Scenario

1- Run a blueprint to create an account with certain user, should succeed.

services:
  - github.com/openvcloud/0-templates/openvcloud/0.0.1__87c47d6d:
      address: 'be-g8-3.demo.greenitglobe.com'
      login: 'gig_qa_1@itsyouonline'
      token: '****'
      location: 'be-g8-3'
  - github.com/openvcloud/0-templates/vdcuser/0.0.1__gig_qa_1:
      email: dina.magdy.mohammed+123@gmail.com
      provider: itsyouonline
      openvcloud: 87c47d6d

  - github.com/openvcloud/0-templates/account/0.0.1__test2:
      maxDiskCapacity: 20
      maxMemoryCapacity: 22
      maxCPUCapacity: 15
      openvcloud: 87c47d6d
      maxNumPublicIP: 18
      users:
         - name: gig_qa_1
         - accesstype: CXDRAU

actions:
  - template: github.com/openvcloud/0-templates/account/0.0.1
    actions: ['install']
  - template: github.com/openvcloud/0-templates/vdcuser/0.0.1
    actions: ['install']

Actual Result

Blueprint hasn't been executed, throwing the following error in the server

[2018-03-15 08:37:59,039] ERROR in app: Exception on /blueprints [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/root/0-robot/zerorobot/server/blueprints_api.py", line 16, in ExecuteBlueprint
    return handlers.ExecuteBlueprintHandler()
  File "/root/0-robot/zerorobot/server/handlers/ExecuteBlueprintHandler.py", line 45, in ExecuteBlueprintHandler
    _instanciate_services(service)
  File "/root/0-robot/zerorobot/server/handlers/ExecuteBlueprintHandler.py", line 66, in _instanciate_services
    srv = tcol.instantiate_service(service_descr['template'], service_descr['service'], service_descr.get('data', None))
  File "/root/0-robot/zerorobot/template_collection.py", line 112, in instantiate_service
    service.validate()
  File "/opt/code/github/openvcloud/0-templates/templates/account/account.py", line 28, in validate
    users = self.api.services.find(template_uid=self.VDCUSER_TEMPLATE, name=user['name'])
KeyError: 'name'
chrisvdg commented 6 years ago

@john-kheir

      users:
         - name: gig_qa_1
         - accesstype: CXDRAU

These are 2 items in a YAML list, therefor the name attribute is missing in the second item. You should use this instead for this template:

      users:
         - name: gig_qa_1
           accesstype: CXDRAU

Error message is not really clear though, will look into that

chrisvdg commented 6 years ago

Closed down PR because users are now not provided anymore throught the service but by actions (user_add). This also makes this issue not relevant anymore for the current code