-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Refactor mech driver #500
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timeouts were recently added to prevent the undersync workflow from hanging indefinitely. It might be a good idea to do that here, too.
if method == "delete": | ||
resp_data = {"status_code": resp.status_code} | ||
else: | ||
resp_data = resp.json() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's special about DELETE?
if method == "delete": | |
resp_data = {"status_code": resp.status_code} | |
else: | |
resp_data = resp.json() | |
if resp.content: | |
resp_data = resp.json() | |
else: | |
resp_data = {"status_code": resp.status_code} |
def make_api_request(self, url: str, method: str, payload: dict) -> dict: | ||
endpoint_url = urljoin(self.base_url, url) | ||
caller_function = inspect.stack()[self.CALLER_FRAME].function | ||
api_call = getattr(self.s, method) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider just using self.s.request(method, url, ...)
although I think that requires method to be upper case.
https://requests.readthedocs.io/en/latest/api/#requests.Session.request
args = {"url": endpoint_url, "timeout": 10} | ||
|
||
if method != "get": | ||
args["payload"] = payload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requests library calls this param data
. How is this working?
if network_id == cfg.CONF.ml2_type_understack.provisioning_network: | ||
network_name = "provisioning" | ||
port_status = "Provisioning-Interface" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this sets the port status to Provisioning, doesn't it have to set it back again afterwards?
"Sleeps 5 seconds between attempts.", | ||
), | ||
cfg.BoolOpt("argo_dry_run", default=True, help="Call Undersync with dry-run mode"), | ||
cfg.BoolOpt("argo_force", default=False, help="Call Undersync with force mode"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added these options to the undersync API because they might be useful for troubleshooting, etc., but I don't think they need to be exposed here unless we have a specific need for them. I can maybe see a reason to have dry_run but certainly "force" would not be a good thing to have permanently switched on.
1c54661
to
e31fbc9
Compare
After this is tested and merged, I'm aware we can do a better cleanup in workflows as we won't need undersync_device workflow anymore.
This PR needs another change in Nautobot prep_switch_interface job as from now on we can use connected_interface_uuid instead of mac_address, so please leave merging to me.