Skip to content
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

create_ssh_key returns 404 #78

Closed
mattdavis0351 opened this issue Mar 31, 2020 · 4 comments
Closed

create_ssh_key returns 404 #78

mattdavis0351 opened this issue Mar 31, 2020 · 4 comments
Labels

Comments

@mattdavis0351
Copy link

Problem

Using this method returns 404 even though the resource gets created as expected in the Packet Project.

Method:

key = manager.create_ssh_key(label="matt-desktop,
                             public_key="some key")

Error:

packet\baseapi.py", line 92, in call_api
raise Error("Error {0}: {1}".format(resp.status_code, msg))
packet.baseapi.Error: Error 404: Not found

Resource actually created:
image

The key that is set for this label is the correct public key from my key file. Therefore returning 404 makes no sense.

This error also stops the rest of the execution for this script... as expected.

@mattdavis0351
Copy link
Author

mattdavis0351 commented Mar 31, 2020

Update

When using a Project Level API key the above error exists,

When using a Personal API key the above code works as expected.

@vielmetti
Copy link
Member

Referenced in #80

@vielmetti vielmetti added the bug label Apr 21, 2020
@displague
Copy link
Member

displague commented Jul 8, 2020

I was able to reproduce this problem (gist) in the latest master branch by using a project API key instead of a user API key.

$ for APIKEY in USER_APIKEY PROJECT_APIKEY; do \
  echo "## $APIKEY"; \
  APIKEY=${!APIKEY} python3 test-sshkey-create.py; \
done
## USER_APIKEY
## PROJECT_APIKEY
Traceback (most recent call last):
  File "test-sshkey-create.py", line 16, in <module>
    public_key=Path("/Users/marques/.ssh/id_rsa.pub").read_text(),
  File "/usr/local/lib/python3.7/site-packages/packet_python-1.42.0-py3.7.egg/packet/Manager.py", line 199, in create_ssh_key
  File "/usr/local/lib/python3.7/site-packages/packet_python-1.42.0-py3.7.egg/packet/Manager.py", line 31, in call_api
  File "/usr/local/lib/python3.7/site-packages/packet_python-1.42.0-py3.7.egg/packet/baseapi.py", line 115, in call_api
packet.baseapi.ResponseError: Error 404: Not found

I created this branch to attempt to prevent the redirect from happening after the 201 response is received, but I still received a 404.

https://github.com/packethost/packet-python/compare/master...displague:disable-allow-redirects.patch

@displague
Copy link
Member

This problem should now be resolved thanks to changes in the Equinix Metal (Packet) API.

We should be able to revert the work-around created here:
https://github.com/packethost/packet-python/pull/80/files#diff-4b7536d3531098c5ab1cf269f404aa499c4effb6b3595203f88e6e16b218e9b5R201-R240

Feel free to re-open this, @mattdavis0351 if the problem persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants