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

Sample for Adding Agent using the python SDK #48

Open
gssajith opened this issue Mar 21, 2020 · 3 comments
Open

Sample for Adding Agent using the python SDK #48

gssajith opened this issue Mar 21, 2020 · 3 comments

Comments

@gssajith
Copy link

What is the best way to install agent (add agent) to a newly created VM in the network?
Tried Orion.AgentManagement.Agent.Deploy but not fruitful. Is there any example somewhere?

Method1:

props = {
        "Name": "<AGENTNAME>",
        "Hostname": "<HOSTNAME>",
        "DNSName": "<DNSNAME>",
        "IP": "<IP>",
        "OSVersion": "<OS Version>",
        "PollingEngineId": 9,
        "ConnectionStatus": 0,
        "ConnectionStatusMessage": "Initial API insertion - connection pending",
        "AgentStatus": 0,
        "AgentStatusMessage": "Unknown",
        "Mode": 0,
        "AutoUpdateEnabled": True
    }
    
response = swis.invoke('Orion.AgentManagement.Agent', 'Deploy', **props)


Failed with:
Traceback (most recent call last):
File "./add_agent.py", line 52, in
main()
File "./add_agent.py", line 45, in main
response = swis.invoke('Orion.AgentManagement.Agent', 'Deploy', **props)
TypeError: invoke() got an unexpected keyword argument 'Name'

Method2:

response = swis.invoke('Orion.AgentManagement.Agent', 'Deploy', 9, "<AGENT_NAME>", "<HOST_NAME>", "<DNSName>",
                        "<IP>","<OSVersion>", "<PolingEngineID>","<AgentStatus>0")

Failed with:
_Traceback (most recent call last):
File "./add_agent.py", line 53, in
main()
File "./add_agent.py", line 46, in main
"10.201.16.11","7.7", "9","0")
File "/usr/lib/python2.7/site-packages/orionsdk/swisclient.py", line 31, in invoke
"Invoke/{}/{}".format(entity, verb), args).json()
File "/usr/lib/python2.7/site-packages/orionsdk/swisclient.py", line 63, in req
resp.raise_for_status()
File "/usr/lib/python2.7/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Agent '"<AGENT_NAME>' must be assigned to existing polling engine for url: https://solarwindsEndpint:17778/SolarWinds/InformationService/v3/Json/Invoke/Orion.AgentManagement.Agent/Deploy

@Mesverrum
Copy link

The argument is not called name, it is called agentname

The majority of the good full examples are under the powershell section as that is what the majority of Orion admins are using. See this one:

https://github.com/solarwinds/OrionSDK/blob/master/Samples/PowerShell/DeployAgentViaVerb.ps1

@Mesverrum
Copy link

In fact looking at your code it appears you are just trying to populate all the default fields of an agent row in the db. That is not the way the SWIS verbs work at all. They all have pre-defined arguments. You will have a MUCH easier time if you install the Orion SDK on a Windows box to learn to navigate the table relationships verbs, otherwise it is a lot of work to constantly be looking up the syntax for everything in the schema and from the swagger.

http://solarwinds.github.io/OrionSDK/2019.4/schema/index.html
http://solarwinds.github.io/OrionSDK/swagger-ui/

@gssajith
Copy link
Author

Thanks for the guidelines

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

No branches or pull requests

2 participants