|
1 | 1 | # (C) Copyright 2025 Hewlett Packard Enterprise Development LP. |
2 | 2 | # MIT License |
3 | 3 |
|
4 | | -from ..utils.url_utils import NewCentralURLs, urlJoin |
| 4 | +from ..utils import GLP_URLS, generate_url |
5 | 5 | from .subscriptions import Subscriptions |
6 | 6 | from ..utils.glp_utils import check_progress, rate_limit_check |
7 | 7 | import time |
8 | 8 |
|
9 | | -urls = NewCentralURLs() |
10 | | - |
11 | 9 | DEVICE_GET_LIMIT = 2000 |
12 | 10 | # Input size per request for DEVICE module APIs. |
13 | 11 | INPUT_SIZE = 5 |
@@ -87,7 +85,7 @@ def get_device( |
87 | 85 | """ |
88 | 86 |
|
89 | 87 | conn.logger.info("Getting a device in GLP workspace") |
90 | | - path = urls.GLP_DEVICES["DEFAULT"] |
| 88 | + path = generate_url(GLP_URLS["DEVICE"], category="devices") |
91 | 89 |
|
92 | 90 | params = {"limit": limit, "offset": offset} |
93 | 91 | if filter: |
@@ -142,7 +140,7 @@ def get_status(self, conn, id): |
142 | 140 | :rtype: dict |
143 | 141 | """ |
144 | 142 |
|
145 | | - path = urlJoin(urls.GLP_DEVICES["GET_ASYNC"], id) |
| 143 | + path = generate_url(f"{GLP_URLS['ASYNC']}/{id}", category="devices") |
146 | 144 | resp = conn.command("GET", path, "glp") |
147 | 145 | return resp |
148 | 146 |
|
@@ -181,7 +179,7 @@ def add_devices(self, conn, network=[], compute=[], storage=[]): |
181 | 179 | resp_list.append(self.__add_dev("storage", storage)) |
182 | 180 | return resp_list |
183 | 181 | else: |
184 | | - path = urls.GLP_DEVICES["DEFAULT"] |
| 182 | + path = generate_url(GLP_URLS["DEVICE"], category="devices") |
185 | 183 | data = {"network": network, "compute": compute, "storage": storage} |
186 | 184 | resp = conn.command("POST", path, "glp", api_data=data) |
187 | 185 | resp_list.append(resp) |
@@ -209,7 +207,7 @@ def __add_dev(self, conn, type, inputs): |
209 | 207 | :rtype: list |
210 | 208 | """ |
211 | 209 |
|
212 | | - path = urls.GLP_DEVICES["DEFAULT"] |
| 210 | + path = generate_url(GLP_URLS["DEVICE"], category="devices") |
213 | 211 | data = {"network": [], "compute": [], "storage": []} |
214 | 212 |
|
215 | 213 | if len(inputs) > INPUT_SIZE: |
@@ -300,7 +298,7 @@ def add_sub(self, conn, devices, sub, serial=False, key=False): |
300 | 298 | # Setup variables for iterating commands. |
301 | 299 | queue = [devices] if not split_input else split_input |
302 | 300 | resp_list = [] |
303 | | - path = urls.GLP_DEVICES["DEFAULT"] |
| 301 | + path = generate_url(GLP_URLS["DEVICE"], category="devices") |
304 | 302 | body = {"subscription": [{"id": sub}]} |
305 | 303 |
|
306 | 304 | for inputs in queue: |
@@ -372,7 +370,7 @@ def remove_sub(self, conn, devices, serial=False): |
372 | 370 | # Setup variables for iterating commands. |
373 | 371 | queue = [devices] if not split_input else split_input |
374 | 372 | resp_list = [] |
375 | | - path = urls.GLP_DEVICES["DEFAULT"] |
| 373 | + path = generate_url(GLP_URLS["DEVICE"], category="devices") |
376 | 374 | body = {"subscription": []} |
377 | 375 |
|
378 | 376 | for inputs in queue: |
@@ -421,7 +419,7 @@ def assign_devices( |
421 | 419 | :rtype: dict |
422 | 420 | """ |
423 | 421 | conn.logger.info("Assigning device(s) to an application") |
424 | | - path = urls.GLP_DEVICES["DEFAULT"] |
| 422 | + path = generate_url(GLP_URLS["DEVICE"], category="devices") |
425 | 423 |
|
426 | 424 | if serial: |
427 | 425 | d_list = [] |
@@ -498,7 +496,7 @@ def unassign_devices(self, conn, devices=None, serial=False): |
498 | 496 | :rtype: dict |
499 | 497 | """ |
500 | 498 | conn.logger.info("Unassigning device(s) from an application") |
501 | | - path = urls.GLP_DEVICES["DEFAULT"] |
| 499 | + path = generate_url(GLP_URLS["DEVICE"], category="devices") |
502 | 500 |
|
503 | 501 | if serial: |
504 | 502 | d_list = [] |
|
0 commit comments