We are having the issue to use the orionsdk-python to reserve IP.
Here are some details
1. The solarwinds IP address Manager version is 4.5.2.
2. We are using the python docker container as the run-time environment to run the script. Here is the dockerfile we used for this image:
FROM python:2.7
ARG user=jenkins
ARG group=jenkins
ARG uid=1000
ARG gid=1000
# Install any needed packages specified in requirements.txt
RUN pip install --upgrade pip
RUN pip install orionsdk
ENV HOME /home/jenkins
RUN groupadd -g ${gid} ${group}
RUN useradd -d "/home/jenkins" -u "${uid}" -g "${gid}" -m -s /bin/bash "${user}"
3. Here is the scripts we are used in this test:
import requests, os
from orionsdk import SwisClient
npm_server = 'server1'
username = os.environ['USERNAME']
password = os.environ['PASSWORD']
verify = False
if not verify:
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
verify = False
if not verify:
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
def main():
swis = SwisClient(npm_server, username, password)
query = """
SELECT TOP 1 I.uri, I.Status, I.DisplayName
FROM IPAM.IPNode I
WHERE Status=2 AND I.Subnet.DisplayName = @id
"""
results = swis.query(query, id='DEV')
for row in results['results']:
print("{Status} [{Status}] : {DisplayName} [{DisplayName}]".format(**row))
ipAddr=results['results'][0]['DisplayName']
print(ipAddr)
ipStatus=results['results'][0]['Status']
print(ipStatus)
ipUri=results['results'][0]['uri']
print(ipUri)
swis.update(ipUri, Status='Used')
if __name__ == '__main__':
main()
4. Here is the error message we got:
Traceback (most recent call last):
File "getIp.py", line 49, in <module>
main()
File "getIp.py", line 46, in main
swis.update('swis://pasnorion1.wam.westernasset.local/Orion/IPAM.IPNode/IpNodeId=1094', Status='Used')
File "/usr/local/lib/python2.7/site-packages/orionsdk/swisclient.py", line 40, in update
self._req("POST", uri, properties)
File "/usr/local/lib/python2.7/site-packages/orionsdk/swisclient.py", line 59, in _req
resp.raise_for_status()
File "/usr/local/lib/python2.7/site-packages/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Access to IPAM.IPNode denied. for url: https://pasnorion1.wam.westernasset.local:17778/SolarWinds/InformationService/v3/Json/swis://pasnorion1.wam.westernasset.local/Orion/IPAM.IPNode/IpNodeId=1094
Please help.
Thanks
Louie Liu