Closed PKehnel closed 3 years ago
Hi @PKehnel , as the dedicatedHostId
parameter is an integer identifier, you just need to pass it, like below:
user_id = 12345
dedicated_host_id = 654321
result = client['SoftLayer_User_Customer'].addDedicatedHostAccess(dedicated_host_id, id=user_id)
print(result)
Also, If you ever find yourself wishing there was an example of how to do something in the SoftLayer API, please make a github issue on the githubio_source repository.
Hey @ATGE,
thanks for the fast response and the link to the other repo. This is one of the users:
When running the suggested code:
dedicated_host_id = 443490
user_id = user["id"]
client["SoftLayer_User_Customer"].addDedicatedHostAccess(
dedicated_host_id,
id=user_id,
)
I get following error:
SoftLayer.exceptions.SoftLayerAPIError: SoftLayerAPIError(SoftLayer_Exception_Public): DedicatedHost 443490 not found.
My assumption was, that the _dedicated_host_id = devices.id from the cloud portal, which matches with the screenshot above.
Above user was generated via (first user):
all_users = client.call(
"SoftLayer_Account",
"getUsers",
mask=objectMask,
iter=False,
limit=2,
offset=35,
)
@PKehnel , looks like the id 443490
is a hardware server identifier, and the SoftLayer_User_Customer::addDedicatedHostAccess, just works with a dedicated host identifier, you can get the valid dedicated hosts with SoftLayer_Account::getDedicatedHosts, so like the id 443490
is a hardware server, try with :
user_id = user["id"]
hardware_id = 443490
result = client['SoftLayer_User_Customer'].addHardwareAccess(hardware_id, id=user_id)
print(result)
Thanks a lot @ATGE.
Works like a charm.
Hey,
currently struggling to use the function:
addDedicatedHostAccess
https://sldn.softlayer.com/reference/services/SoftLayer_User_Customer/addDedicatedHostAccess/Thought maybe I can get a minimum example here or a hint where I can find support / examples for functions like this.
My first guess was somewhere along the lines:
If I follow the documentation strictly, all I need is the
dedicatedHostId
, but I guess I also need a user_id?