https://github.com/softlayer/softlayer-python
A set of Python libraries that assist in calling the SoftLayer API.
https://github.com/softlayer/softlayer-python
python softlayer
Last synced: 10 months ago
JSON representation
A set of Python libraries that assist in calling the SoftLayer API.
- Host: GitHub
- URL: https://github.com/softlayer/softlayer-python
- Owner: softlayer
- License: mit
- Created: 2010-04-21T20:36:31.000Z (almost 16 years ago)
- Default Branch: master
- Last Pushed: 2025-03-31T21:39:18.000Z (11 months ago)
- Last Synced: 2025-04-11T23:16:50.134Z (10 months ago)
- Topics: python, softlayer
- Language: Python
- Homepage: http://softlayer.github.io/softlayer-python/
- Size: 10 MB
- Stars: 150
- Watchers: 35
- Forks: 192
- Open Issues: 22
-
Metadata Files:
- Readme: README-internal.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
This document is for internal users wanting to use this library to interact with the internal API. It will not work for `api.softlayer.com`.
## SSL: CERTIFICATE_VERIFY_FAILED fix
You need to specify the server certificate to verify the connection to the internal API since its a self signed certificate. Python's request module doesn't use the system SSL cert for some reason, so even if you can use `curl` without SSL errors becuase you installed the certificate on your system, you still need to tell python about it. Further reading:
- https://hackernoon.com/solving-the-dreadful-certificate-issues-in-python-requests-module
- https://levelup.gitconnected.com/using-custom-ca-in-python-here-is-the-how-to-for-k8s-implementations-c450451b6019
On Mac, after installing the softlayer.local certificate, the following worked for me:
```bash
security export -t certs -f pemseq -k /System/Library/Keychains/SystemRootCertificates.keychain -o bundleCA.pem
sudo cp bundleCA.pem /etc/ssl/certs/bundleCA.pem
```
Then in the `~/.softlayer` config, set `verify = /etc/ssl/certs/bundleCA.pem` and that should work.
You may also need to set `REQUESTS_CA_BUNDLE` -> `export REQUESTS_CA_BUNDLE=/etc/ssl/certs/bundleCA.pem` to force python to load your CA bundle
## Certificate Example
For use with a utility certificate. In your config file (usually `~/.softlayer`), you need to set the following:
```
[softlayer]
endpoint_url = https:///v3/internal/rest/
timeout = 0
theme = dark
auth_cert = /etc/ssl/certs/my_utility_cert-dev.pem
verify = /etc/ssl/certs/allCAbundle.pem
```
`auth_cert`: is your utility user certificate
`server_cert`: is the CA certificate bundle to validate the internal API ssl chain. Otherwise you get self-signed ssl errors without this.
```python
import SoftLayer
import logging
import click
@click.command()
def testAuthentication():
client = SoftLayer.CertificateClient()
result = client.call('SoftLayer_Account', 'getObject', id=12345, mask="mask[id,companyName]")
print(result)
if __name__ == "__main__":
logger = logging.getLogger()
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.DEBUG)
testAuthentication()
```
## Employee Example
To login with your employee username, have your config look something like this
*NOTE*: Currently logging in with the rest endpoint doesn't quite work, so use xmlrpc until I fix [this issue](https://github.ibm.com/SoftLayer/internal-softlayer-cli/issues/10)
```
[softlayer]
username =
endpoint_url = https:///v3/internal/xmlrpc/
verify = /etc/ssl/certs/allCAbundle.pem
```
You can login and use the `slcli` with. Use the `-i` flag to make internal API calls, otherwise it will make SLDN api calls.
```bash
slcli -i emplogin
```
If you want to use any of the built in commands, you may need to use the `-a ` flag.