SatelliteQE / satellite-populate

This new module adds tools and commands to populate and validate entities in the system based in YAML file.
Other
8 stars 10 forks source link

Can't add required information for AbstractComputeResource entity #88

Open chbrown13 opened 7 years ago

chbrown13 commented 7 years ago

Description

When trying to create an AbstractComputeResource with certain EC2 provider types (EC2, VMware, GCE, Openstack, Ovirt, Rackspace), satellite-populate fails because they require additional information such as a username, email, password, etc. that can't be blank. However the missing values can't be added to the yaml file because satellite-populate still fails since they aren't valid parameters for the entity.

What I Did

test_abstractcomputeresource_gce.yaml test_abstractcomputeresource_gce2.yaml

[root@localhost satellite]# satellite-populate abstractcomputeresource.yaml --no-output
2017-08-15 14:22:41 - satellite_populate.base - INFO - Starting in populate mode
2017-08-15 14:22:41 - satellite_populate.base - INFO - CREATE: test_entity
2017-08-15 14:22:41 - nailgun.client - DEBUG - Making HTTP GET request to https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/compute_resources with options {'verify': False, 'data': '{"provider": "GCE", "description": "{ desc }", "name": "{ name }"}', 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}} and no data.
2017-08-15 14:22:41 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): hp-xl420gen9-01.khw.lab.eng.bos.redhat.com
2017-08-15 14:22:42 - requests.packages.urllib3.connectionpool - DEBUG - https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com:443 "GET /api/v2/compute_resources HTTP/1.1" 200 111
2017-08-15 14:22:42 - nailgun.client - DEBUG - Received HTTP 200 response: {
  "total": 0,
  "subtotal": 0,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": []
}

2017-08-15 14:22:42 - satellite_populate.base - INFO - search: AbstractComputeResource {'provider': 'GCE', 'description': '{ desc }', 'name': '{ name }'} returned empty result
2017-08-15 14:22:42 - nailgun.client - DEBUG - Making HTTP POST request to https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/compute_resources with options {'verify': False, 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}} and data {"compute_resource": {"name": "{ name }", "provider": "GCE", "url": "ftp://vfoFfgYQru.biz", "description": "{ desc }"}}.
2017-08-15 14:22:42 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): hp-xl420gen9-01.khw.lab.eng.bos.redhat.com
2017-08-15 14:22:42 - requests.packages.urllib3.connectionpool - DEBUG - https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com:443 "POST /api/v2/compute_resources HTTP/1.1" 422 None
2017-08-15 14:22:42 - nailgun.client - WARNING - Received HTTP 422 response: {
  "error": {"id":null,"errors":{"key_path":["can't be blank"],"project":["can't be blank"],"email":["can't be blank"]},"full_messages":["Key path can't be blank","Project can't be blank","Email can't be blank"]}
}

2017-08-15 14:22:42 - satellite_populate.base - ERROR - populate: 422 Client Error: Unprocessable Entity for url: https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/compute_resources {'log_message': u'test_entity', 'model': 'AbstractComputeResource', 'register': 'test_entity', 'data': {'description': '{ desc }', 'name': '{ name }', 'provider': 'GCE'}}{
  "error": {"id":null,"errors":{"key_path":["can't be blank"],"project":["can't be blank"],"email":["can't be blank"]},"full_messages":["Key path can't be blank","Project can't be blank","Email can't be blank"]}
}

2017-08-15 14:22:42 - satellite_populate.base - INFO - UPDATE: test_entity
2017-08-15 14:22:42 - nailgun.client - DEBUG - Making HTTP GET request to https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/compute_resources with options {'verify': False, 'data': '{"name": "{ entity_name }"}', 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}} and no data.
2017-08-15 14:22:42 - requests.packages.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): hp-xl420gen9-01.khw.lab.eng.bos.redhat.com
2017-08-15 14:22:42 - requests.packages.urllib3.connectionpool - DEBUG - https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com:443 "GET /api/v2/compute_resources HTTP/1.1" 200 111
2017-08-15 14:22:42 - nailgun.client - DEBUG - Received HTTP 200 response: {
  "total": 0,
  "subtotal": 0,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": []
}

2017-08-15 14:22:42 - satellite_populate.base - INFO - search: AbstractComputeResource {'name': '{ entity_name }'} returned empty result
2017-08-15 14:22:42 - satellite_populate.base - ERROR - populate: update: Cannot find entity {'search_query': {'name': '{ entity_name }'}, 'register': 'test_entity', 'action': 'update', 'log_message': u'test_entity', 'model': 'AbstractComputeResource', 'data': {'description': '{ update_desc }'}}
Traceback (most recent call last):
  File "/usr/bin/satellite-populate", line 9, in <module>
    load_entry_point('satellite-populate==0.1.3', 'console_scripts', 'satellite-populate')()
  File "/usr/lib64/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib64/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib64/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/satellite_populate/commands.py", line 161, in main
    hostname, username, password, report, enable_output)
  File "/usr/lib/python2.7/site-packages/satellite_populate/commands.py", line 47, in execute_populate
    enable_output=enable_output
  File "/usr/lib/python2.7/site-packages/satellite_populate/main.py", line 62, in populate
    populator.execute()
  File "/usr/lib/python2.7/site-packages/satellite_populate/base.py", line 180, in execute
    entity_data, action_data, search, action
  File "/usr/lib/python2.7/site-packages/satellite_populate/api.py", line 39, in populate
    rendered_action_data, action_data, search, model, silent_errors
  File "/usr/lib/python2.7/site-packages/satellite_populate/api.py", line 90, in action_update
    raise RuntimeError("update: Cannot find entity")
RuntimeError: update: Cannot find entity

---------------------Added missing values--------------------------------------------------------------------------------
[root@localhost satellite]# satellite-populate abstractcomputeresource2.yaml --no-output
2017-08-15 14:24:49 - satellite_populate.base - INFO - Starting in populate mode
2017-08-15 14:24:49 - satellite_populate.base - INFO - CREATE: test_entity
2017-08-15 14:24:49 - satellite_populate.base - ERROR - populate: Valid fields are ['provider_friendly_name', 'url', 'name', 'location', 'provider', 'organization', 'id', 'description'], but received ['description', 'project', 'key_path', 'provider', 'email', 'name'] instead. {'log_message': u'test_entity', 'model': 'AbstractComputeResource', 'register': 'test_entity', 'data': {'project': 'satellite', 'name': '{ name }', 'provider': 'GCE', 'description': '{ desc }', 'email': 'dbrownjr@redhat.com', 'key_path': '/home'}}
Traceback (most recent call last):
  File "/usr/bin/satellite-populate", line 9, in <module>
    load_entry_point('satellite-populate==0.1.3', 'console_scripts', 'satellite-populate')()
  File "/usr/lib64/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib64/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib64/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib64/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/satellite_populate/commands.py", line 161, in main
    hostname, username, password, report, enable_output)
  File "/usr/lib/python2.7/site-packages/satellite_populate/commands.py", line 47, in execute_populate
    enable_output=enable_output
  File "/usr/lib/python2.7/site-packages/satellite_populate/main.py", line 62, in populate
    populator.execute()
  File "/usr/lib/python2.7/site-packages/satellite_populate/base.py", line 180, in execute
    entity_data, action_data, search, action
  File "/usr/lib/python2.7/site-packages/satellite_populate/api.py", line 39, in populate
    rendered_action_data, action_data, search, model, silent_errors
  File "/usr/lib/python2.7/site-packages/satellite_populate/api.py", line 58, in action_create
    model, search, unique=True, silent_errors=silent_errors
  File "/usr/lib/python2.7/site-packages/satellite_populate/base.py", line 595, in get_search_result
    result = model(**search['data']).search(**search['options'])
  File "/usr/lib/python2.7/site-packages/nailgun/entities.py", line 750, in __init__
    super(AbstractComputeResource, self).__init__(server_config, **kwargs)
  File "/usr/lib/python2.7/site-packages/nailgun/entity_mixins.py", line 399, in __init__
    .format(self._fields.keys(), kwargs.keys())
nailgun.entity_mixins.NoSuchFieldError: Valid fields are ['provider_friendly_name', 'url', 'name', 'location', 'provider', 'organization', 'id', 'description'], but received ['description', 'project', 'key_path', 'provider', 'email', 'name'] instead.