Skip to content

Commit

Permalink
[PLINT-246] Add pagination support for baremetal conductors (#17026)
Browse files Browse the repository at this point in the history
* enabled capability and added unit tests for conductors pagination for rest api

* fixing metrics and file names

* enabled capability and added unit tests for conductors pagination for sdk api

* fixed linting

* indexing by hostname instead of uuid, and adjusting test cases to match

* additional fixes to test files
  • Loading branch information
rahulkaukuntla authored Mar 5, 2024
1 parent 30e2b3f commit 3437025
Show file tree
Hide file tree
Showing 14 changed files with 351 additions and 23 deletions.
1 change: 1 addition & 0 deletions openstack_controller/changelog.d/17026.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[PLINT-246] Add pagination support for baremetal conductors
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,12 @@ def use_legacy_nodes_resource(microversion):
return self.make_paginated_request(url, 'nodes', 'uuid', params=params)

def get_baremetal_conductors(self):
response = self.http.get(
'{}/v1/conductors'.format(self._catalog.get_endpoint_by_type(Component.Types.BAREMETAL.value))
)
response.raise_for_status()
return response.json().get('conductors', [])

ironic_endpoint = self._catalog.get_endpoint_by_type(Component.Types.BAREMETAL.value)

url = '{}/v1/conductors'.format(ironic_endpoint)

return self.make_paginated_request(url, 'conductors', 'hostname', params={})

def get_load_balancer_loadbalancers(self, project_id):
params = {'project_id': project_id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,12 @@ def get_baremetal_nodes(self):
]

def get_baremetal_conductors(self):
return [conductor.to_dict(original_names=True) for conductor in self.connection.baremetal.conductors()]
return [
conductor.to_dict(original_names=True)
for conductor in self.call_paginated_api(
self.connection.baremetal.conductors, limit=self.config.paginated_limit
)
]

def get_auth_projects(self):
response = self.http.get('{}/v3/auth/projects'.format(self.cloud_config.get_auth_args().get('auth_url')))
Expand Down
2 changes: 1 addition & 1 deletion openstack_controller/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def nodes(details, limit=None):
for node in mock_responses('GET', '/baremetal/v1/nodes/detail')['nodes']
]

def conductors():
def conductors(limit=None):
if http_error and 'conductors' in http_error:
raise requests.exceptions.HTTPError(response=http_error['conductors'])
return [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"conductors": [
{
"hostname": "agent-integrations-openstack-ironic",
"conductor_group": "",
"links": [
{
"href": "http://127.0.0.1/baremetal/v1/conductors/agent-integrations-openstack-ironic?limit=1",
"rel": "self"
},
{
"href": "http://127.0.0.1/baremetal/conductors/agent-integrations-openstack-ironic?limit=1",
"rel": "bookmark"
}
],
"alive": true
}
],
"previous": "http://127.0.0.1/baremetal/conductors/agent-integrations-openstack-ironic-to-next?limit=1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"conductors": [
{
"hostname": "agent-integrations-openstack-ironic",
"conductor_group": "",
"links": [
{
"href": "http://127.0.0.1/baremetal/v1/conductors/agent-integrations-openstack-ironic?limit=1",
"rel": "self"
},
{
"href": "http://127.0.0.1/baremetal/conductors/agent-integrations-openstack-ironic?limit=1",
"rel": "bookmark"
}
],
"alive": true
}
],
"previous": "http://127.0.0.1/baremetal/conductors/agent-integrations-openstack-ironic-to-next?limit=1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"conductors": [
{
"hostname": "agent-integrations-openstack-ironic-to-next",
"conductor_group": "",
"links": [
{
"href": "http://127.0.0.1/baremetal/v1/conductors/agent-integrations-openstack-ironic-to-next?limit=1",
"rel": "self"
},
{
"href": "http://127.0.0.1/baremetal/conductors/agent-integrations-openstack-ironic-to-next?limit=1",
"rel": "bookmark"
}
],
"alive": true
}
],
"next": "http://127.0.0.1/baremetal/v1/conductors?limit=1&marker=agent-integrations-openstack-ironic"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"conductors": [
{
"hostname": "agent-integrations-openstack-ironic-to-next",
"conductor_group": "",
"links": [
{
"href": "http://127.0.0.1/baremetal/v1/conductors/agent-integrations-openstack-ironic-to-next?limit=1",
"rel": "self"
},
{
"href": "http://127.0.0.1/baremetal/conductors/agent-integrations-openstack-ironic-to-next?limit=1",
"rel": "bookmark"
}
],
"alive": true
}
],
"next": "http://127.0.0.1/baremetal/v1/conductors?limit=1&marker=agent-integrations-openstack-ironic"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"conductors": [
{
"hostname": "agent-integrations-openstack-ironic-to-next",
"conductor_group": "",
"links": [
{
"href": "http://127.0.0.1/baremetal/v1/conductors/agent-integrations-openstack-ironic-to-next?limit=1",
"rel": "self"
},
{
"href": "http://127.0.0.1/baremetal/conductors/agent-integrations-openstack-ironic-to-next?limit=1",
"rel": "bookmark"
}
],
"alive": true
},
{
"hostname": "agent-integrations-openstack-ironic",
"conductor_group": "",
"links": [
{
"href": "http://127.0.0.1/baremetal/v1/conductors/agent-integrations-openstack-ironic?limit=1000",
"rel": "self"
},
{
"href": "http://127.0.0.1/baremetal/conductors/agent-integrations-openstack-ironic?limit=1000",
"rel": "bookmark"
}
],
"alive": true
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"conductors": [
{
"hostname": "agent-integrations-openstack-ironic-to-next",
"conductor_group": "",
"links": [
{
"href": "http://127.0.0.1/baremetal/v1/conductors/agent-integrations-openstack-ironic-to-next",
"rel": "self"
},
{
"href": "http://127.0.0.1/baremetal/conductors/agent-integrations-openstack-ironic-to-next",
"rel": "bookmark"
}
],
"alive": true
},
{
"hostname": "agent-integrations-openstack-ironic",
"conductor_group": "",
"links": [
{
"href": "http://127.0.0.1/baremetal/v1/conductors/agent-integrations-openstack-ironic",
"rel": "self"
},
{
"href": "http://127.0.0.1/baremetal/conductors/agent-integrations-openstack-ironic",
"rel": "bookmark"
}
],
"alive": true
}
]
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
{
"conductors": [
"conductors": [
{
"hostname": "agent-integrations-openstack-ironic",
"conductor_group": "",
"links": [
{
"href": "http://34.141.226.224/baremetal/v1/conductors/agent-integrations-openstack-ironic",
"rel": "self"
},
{
"href": "http://34.141.226.224/baremetal/conductors/agent-integrations-openstack-ironic",
"rel": "bookmark"
}
],
"alive": true
"hostname": "agent-integrations-openstack-ironic-to-next",
"conductor_group": "",
"links": [
{
"href": "http://127.0.0.1/baremetal/v1/conductors/agent-integrations-openstack-ironic-to-next",
"rel": "self"
},
{
"href": "http://127.0.0.1/baremetal/conductors/agent-integrations-openstack-ironic-to-next",
"rel": "bookmark"
}
],
"alive": true
},
{
"hostname": "agent-integrations-openstack-ironic",
"conductor_group": "",
"links": [
{
"href": "http://127.0.0.1/baremetal/v1/conductors/agent-integrations-openstack-ironic",
"rel": "self"
},
{
"href": "http://127.0.0.1/baremetal/conductors/agent-integrations-openstack-ironic",
"rel": "bookmark"
}
],
"alive": true
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"conductors": [
{
"hostname": "agent-integrations-openstack-ironic-to-next",
"conductor_group": "",
"links": [
{
"href": "http://127.0.0.1/baremetal/v1/conductors/agent-integrations-openstack-ironic-to-next",
"rel": "self"
},
{
"href": "http://127.0.0.1/baremetal/conductors/agent-integrations-openstack-ironic-to-next",
"rel": "bookmark"
}
],
"alive": true
},
{
"hostname": "agent-integrations-openstack-ironic",
"conductor_group": "",
"links": [
{
"href": "http://127.0.0.1/baremetal/v1/conductors/agent-integrations-openstack-ironic",
"rel": "self"
},
{
"href": "http://127.0.0.1/baremetal/conductors/agent-integrations-openstack-ironic",
"rel": "bookmark"
}
],
"alive": true
}
]
}
10 changes: 10 additions & 0 deletions openstack_controller/tests/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4524,6 +4524,16 @@
CONDUCTORS_METRICS_IRONIC_MICROVERSION_DEFAULT = []

CONDUCTORS_METRICS_IRONIC_MICROVERSION_1_80 = [
{
'name': 'openstack.ironic.conductor.count',
'count': 1,
'value': 1,
'tags': [
'conductor_group:',
'conductor_hostname:agent-integrations-openstack-ironic-to-next',
'keystone_server:http://127.0.0.1:8080/identity',
],
},
{
'name': 'openstack.ironic.conductor.count',
'count': 1,
Expand Down
Loading

0 comments on commit 3437025

Please sign in to comment.