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

Unable to delete entities used by host #89

Open chbrown13 opened 7 years ago

chbrown13 commented 7 years ago

Description

Domain entities are unable to be deleted with satellite-populate and raise an error that the domain is being used by the satellite host.

What I Did

(test_domain.yaml)[https://gist.github.com/chbrown13/3269d8f1a99c53314d6b54f1e61eeca0]

(satellite-populate) [root@localhost satellite]# satellite-populate test_domain.yaml --no-output
2017-08-15 15:14:02 - satellite_populate.base - INFO - Starting in populate mode
2017-08-15 15:14:02 - satellite_populate.base - INFO - CREATE: test_entity
2017-08-15 15:14:02 - nailgun.client - DEBUG - Making HTTP GET request to https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/domains with options {'verify': False, 'data': '{"fullname": "domain_name.example.com", "name": "domain_name"}', 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}}, no params and no data.
2017-08-15 15:14:02 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): hp-xl420gen9-01.khw.lab.eng.bos.redhat.com
2017-08-15 15:14:02 - urllib3.connectionpool - DEBUG - https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com:443 "GET /api/v2/domains HTTP/1.1" 200 223
2017-08-15 15:14:02 - nailgun.client - DEBUG - Received HTTP 200 response: {
  "total": 1,
  "subtotal": 1,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [{"fullname":"test.domain_name.example.com","created_at":"2017-08-15 14:56:33 UTC","updated_at":"2017-08-15 19:10:18 UTC","id":1,"name":"http://www.test_domain.com","dns_id":null,"dns":null}]
}

2017-08-15 15:14:02 - satellite_populate.base - INFO - search: Domain {'fullname': u'domain_name.example.com', 'name': u'domain_name'} found unique item
2017-08-15 15:14:02 - satellite_populate.base - INFO - create: Entity already exists: Domain 1
2017-08-15 15:14:02 - satellite_populate.base - INFO - registry: Domain:1 registered as test_entity
2017-08-15 15:14:02 - satellite_populate.base - INFO - UPDATE: test_entity
2017-08-15 15:14:02 - nailgun.client - DEBUG - Making HTTP GET request to https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/domains with options {'verify': False, 'data': '{"name": "domain_name"}', 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}}, no params and no data.
2017-08-15 15:14:02 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): hp-xl420gen9-01.khw.lab.eng.bos.redhat.com
2017-08-15 15:14:03 - urllib3.connectionpool - DEBUG - https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com:443 "GET /api/v2/domains HTTP/1.1" 200 223
2017-08-15 15:14:03 - nailgun.client - DEBUG - Received HTTP 200 response: {
  "total": 1,
  "subtotal": 1,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [{"fullname":"test.domain_name.example.com","created_at":"2017-08-15 14:56:33 UTC","updated_at":"2017-08-15 19:10:18 UTC","id":1,"name":"http://www.test_domain.com","dns_id":null,"dns":null}]
}

2017-08-15 15:14:03 - satellite_populate.base - INFO - search: Domain {'name': u'domain_name'} found unique item
2017-08-15 15:14:03 - nailgun.client - DEBUG - Making HTTP PUT request to https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/domains/1 with options {'verify': False, 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}}, no params and data {"domain": {"fullname": "test.domain_name.example.com"}}.
2017-08-15 15:14:03 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): hp-xl420gen9-01.khw.lab.eng.bos.redhat.com
2017-08-15 15:14:03 - urllib3.connectionpool - DEBUG - https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com:443 "PUT /api/v2/domains/1 HTTP/1.1" 200 312
2017-08-15 15:14:03 - nailgun.client - DEBUG - Received HTTP 200 response: {"fullname":"test.domain_name.example.com","created_at":"2017-08-15 14:56:33 UTC","updated_at":"2017-08-15 19:10:18 UTC","id":1,"name":"http://www.test_domain.com","dns_id":null,"dns":null,"subnets":[],"interfaces":[{"id":1,"name":"hp-xl420gen9-01.khw.lab.eng.bos.redhat.com","ip":"10.16.184.240","ip6":"2620:52:0:10bb:3a63:bbff:fe48:c40","mac":"38:63:bb:48:0c:40","identifier":"eno1","primary":true,"provision":true,"type":"interface"}],"parameters":[],"locations":[],"organizations":[]}
2017-08-15 15:14:03 - nailgun.client - DEBUG - Making HTTP GET request to https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/domains/1 with options {'verify': False, 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}}, no params and no data.
2017-08-15 15:14:03 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): hp-xl420gen9-01.khw.lab.eng.bos.redhat.com
2017-08-15 15:14:03 - urllib3.connectionpool - DEBUG - https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com:443 "GET /api/v2/domains/1 HTTP/1.1" 200 312
2017-08-15 15:14:03 - nailgun.client - DEBUG - Received HTTP 200 response: {"fullname":"test.domain_name.example.com","created_at":"2017-08-15 14:56:33 UTC","updated_at":"2017-08-15 19:10:18 UTC","id":1,"name":"http://www.test_domain.com","dns_id":null,"dns":null,"subnets":[],"interfaces":[{"id":1,"name":"hp-xl420gen9-01.khw.lab.eng.bos.redhat.com","ip":"10.16.184.240","ip6":"2620:52:0:10bb:3a63:bbff:fe48:c40","mac":"38:63:bb:48:0c:40","identifier":"eno1","primary":true,"provision":true,"type":"interface"}],"parameters":[],"locations":[],"organizations":[]}
2017-08-15 15:14:03 - satellite_populate.base - INFO - update: <class 'nailgun.entities.Domain'> 1
2017-08-15 15:14:03 - satellite_populate.base - INFO - registry: Domain:1 registered as test_entity
2017-08-15 15:14:03 - satellite_populate.base - INFO - ASSERTION: executing...
2017-08-15 15:14:03 - satellite_populate.base - INFO - assertion: test.domain_name.example.com is eq to test.domain_name.example.com
2017-08-15 15:14:03 - satellite_populate.base - INFO - DELETE: executing...
2017-08-15 15:14:03 - nailgun.client - DEBUG - Making HTTP GET request to https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/domains with options {'verify': False, 'data': '{"name": "domain_name"}', 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}}, no params and no data.
2017-08-15 15:14:03 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): hp-xl420gen9-01.khw.lab.eng.bos.redhat.com
2017-08-15 15:14:03 - urllib3.connectionpool - DEBUG - https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com:443 "GET /api/v2/domains HTTP/1.1" 200 223
2017-08-15 15:14:03 - nailgun.client - DEBUG - Received HTTP 200 response: {
  "total": 1,
  "subtotal": 1,
  "page": 1,
  "per_page": 20,
  "search": null,
  "sort": {
    "by": null,
    "order": null
  },
  "results": [{"fullname":"test.domain_name.example.com","created_at":"2017-08-15 14:56:33 UTC","updated_at":"2017-08-15 19:10:18 UTC","id":1,"name":"http://www.test_domain.com","dns_id":null,"dns":null}]
}

2017-08-15 15:14:03 - satellite_populate.base - INFO - search: Domain {'name': u'domain_name'} found unique item
2017-08-15 15:14:03 - nailgun.client - DEBUG - Making HTTP DELETE request to https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/domains/1 with options {'verify': False, 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}}, no params and no data.
2017-08-15 15:14:03 - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): hp-xl420gen9-01.khw.lab.eng.bos.redhat.com
2017-08-15 15:14:03 - urllib3.connectionpool - DEBUG - https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com:443 "DELETE /api/v2/domains/1 HTTP/1.1" 422 None
2017-08-15 15:14:03 - nailgun.client - WARNING - Received HTTP 422 response: {
  "error": {"id":1,"errors":{"base":["http://www.test_domain.com is used by hp-xl420gen9-01.khw.lab.eng.bos.redhat.com"]},"full_messages":["http://www.test_domain.com is used by hp-xl420gen9-01.khw.lab.eng.bos.redhat.com"]}
}

2017-08-15 15:14:03 - satellite_populate.base - ERROR - populate: 422 Client Error: Unprocessable Entity for url: https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/domains/1 {'action': 'delete', 'search_query': {'name': '{{ name }}'}, 'model': 'Domain', 'log_message': u'executing...'}{
  "error": {"id":1,"errors":{"base":["http://www.test_domain.com is used by hp-xl420gen9-01.khw.lab.eng.bos.redhat.com"]},"full_messages":["http://www.test_domain.com is used by hp-xl420gen9-01.khw.lab.eng.bos.redhat.com"]}
}

2017-08-15 15:14:03 - satellite_populate.base - INFO - populate finished!
2017-08-15 15:14:03 - satellite_populate.base - INFO - 1 entities already existing in the system
2017-08-15 15:14:03 - satellite_populate.base - INFO - 0 entities were created in the system
2017-08-15 15:14:03 - satellite_populate.base - ERROR - populate: 422 Client Error: Unprocessable Entity for url: https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/domains/1 {'action': 'delete', 'search_query': {'name': '{{ name }}'}, 'model': 'Domain', 'log_message': u'executing...'}{
  "error": {"id":1,"errors":{"base":["http://www.test_domain.com is used by hp-xl420gen9-01.khw.lab.eng.bos.redhat.com"]},"full_messages":["http://www.test_domain.com is used by hp-xl420gen9-01.khw.lab.eng.bos.redhat.com"]}
}

2017-08-15 15:14:03 - satellite_populate.base - ERROR - {'data': {'name': u'domain_name'}, 'options': {}, 'searchable': True}
chbrown13 commented 7 years ago

Same issue deleting Environment entities:

populate: 422 Client Error: Unprocessable Entity for url: https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/environments/1 {'action': 'delete', 'search_query': {'name': '{{ new_name }}'}, 'model': 'Environment', 'log_message': u'executing...'}{ "error": {"id":1,"errors":{"base":["testenvironment is used by hp-xl420gen9-01.khw.lab.eng.bos.redhat.com"]},"full_messages":["testenvironment is used by hp-xl420gen9-01.khw.lab.eng.bos.redhat.com"]}

chbrown13 commented 7 years ago

Also deleting HostGroups:

2017-08-15 15:51:26 - satellite_populate.base - ERROR - populate: 422 Client Error: Unprocessable Entity for url: https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/hostgroups/1 {'action': 'delete', 'search_query': {'name': '{{ name }}'}, 'model': 'HostGroup', 'log_message': u'executing...'}{ "error": {"id":1,"errors":{"base":["Update Group is used by hostname.l1pmlxnddx"]},"full_messages":["Update Group is used by hostname.l1pmlxnddx"]} }

chbrown13 commented 7 years ago

Deleting SmartProxy entities:

2017-08-17 10:34:16 - satellite_populate.base - ERROR - populate: 422 Client Error: Unprocessable Entity for url: https://hp-xl420gen9-01.khw.lab.eng.bos.redhat.com/api/v2/smart_proxies/1 {'action': 'delete', 'search_query': {'name': '{{ name }}'}, 'model': 'SmartProxy', 'log_message': u'executing...'}{ "error": {"id":1,"errors":{"base":["fakeurl2.com is used by hp-xl420gen9-01.khw.lab.eng.bos.redhat.com","fakeurl2.com is used by hp-xl420gen9-01.khw.lab.eng.bos.redhat.com"]},"full_messages":["fakeurl2.com is used by hp-xl420gen9-01.khw.lab.eng.bos.redhat.com","fakeurl2.com is used by hp-xl420gen9-01.khw.lab.eng.bos.redhat.com"]} }