Select to view content in your preferred language

AGS admin scripting help

6979
24
Jump to solution
07-28-2016 06:15 AM
JamesCrandall
MVP Frequent Contributor


I'm trying to build some simple service checks (map, feature and gp services) that are published on our ArcGIS Server site(s). Example: Check a folder for stopped services—Documentation (10.3 and 10.3.1) | ArcGIS for Server is what I'm attempting to implement but having difficulty with the request at fetching the token.

I've been provided with the serverName and serverPort parameters (lines 22 and 23 of the sample code) by our AGS admin but I keep tripping the error at line 137.  If I print the response.status it shows a response of 302 and response.reason is "Found".

Any input or success implementing this script?

0 Kudos
1 Solution

Accepted Solutions
JamesCrandall
MVP Frequent Contributor

I ditched using the REST API calls (it's infuriating to navigate and determine all of the correct required server parameters).  Simply opted for simplicity and accomplished this with urllib.open and properly setting up each individual url, taking care in constructing each one correctly.

The REST API is overly complicated for my needs.

View solution in original post

0 Kudos
24 Replies
JamesCrandall
MVP Frequent Contributor

I ditched using the REST API calls (it's infuriating to navigate and determine all of the correct required server parameters).  Simply opted for simplicity and accomplished this with urllib.open and properly setting up each individual url, taking care in constructing each one correctly.

The REST API is overly complicated for my needs.

0 Kudos
JamesCrandall
MVP Frequent Contributor

I may revisit the REST API as there are some other complications to overcome with the approach I took.

The issue with the REST API example is that it doesn't implement the requests library and instead uses urllib.  Normally not an issue, however when dealing with https and TLS & SSL things start to just not work as originally written!  This sends you down an entirely different path --- I may just try to re-write the sample using requests instead.

0 Kudos
JamesCrandall
MVP Frequent Contributor

Thanks!

Have you had a chance to setup the toolkit against HTTPS?  I'd think we'd run into the same issues I'm hitting with the example REST API script.

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

mine runs using the machine name as input and runs again sucure and non-secure services.  I run the tool in the toolbox, then copy the snippet for input into my own script....the only thing I don't like just using this as default is the admin password is part of the snippet (in the results tab too), so be aware of that.

sample of the script...with fake folder names for demonstration....

arcpy.StopStartService(Server_Name="<machinename>",Port="6080",
  Admin_User="<adminUser>",Admin_Password="<adminPsw>",
  Stop__Start__Delete="Stop",
  Service_List="some_gp//ExtractData.GPServer;print//dwcGeoPDF.GPServer;our_public//GMUSubunits.MapServer;our_secure//uculines.MapServer")

If you run it once "manually" with Stop, then you can copy and change to Start to you don't always start up the services you don't want started.

KevinHibma
Esri Regular Contributor

I just came across this post and realize you might have a path forward.

Just a note though - I've been trying to make time to refresh the toolkit. That includes introducing proper HTTPS support. If you're interested in it before its "done", its in a branch here: GitHub - khibma/ArcGISAdministrationToolkit at devupdates

I'm close to being done. I just need to do some more testing. After that I'll update the arcgis.com sample with the newest and greatest.

JamesCrandall
MVP Frequent Contributor

That's great, Kevin!  Thanks!

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

Hi Kevin,

This may not be the place to ask this, but since you mentioned you are working on it., is there a way that the commands can use an .ags administrator (or publisher) connection file, rather than be prompted and/or hardcoding the credentials?  It bothers me that the info ends up in the results.  Maybe that is what you are attempting (or attempting to hide) in the SSL updates??

I haven't done much directly with the ArcGIS Server REST API myself.  Just started looking at it, and the admin tools (the current release, not the gishub version, which I will try out now).  I'm trying to work on the workflow for when I need to update the source FGDB being used....i.e

  1. check for any services that access the FGDB
  2. check for those that are currently STARTED
  3. shut those down
  4. rename/replace FGDB
  5. start ONLY those stopped in step 2

Problems with the current tool is:

  • it lists ALL the services, whether started or stopped already, so if I stop all the ones I need, and duplicate the list, it may start some that I had stopped on purposes already
  • no easy way at this time to tell those I need to shut down (i.e. filter for "services using source"

Let me know if you need me to put this info in GitHub as a comment.  I haven't posted much to github (more of a downloader still)

0 Kudos
KevinHibma
Esri Regular Contributor

Hey Becky - The ability to use the .AGS file would be an excellent enhancement. I actually really like that idea as it hides the password from being inside your scripts. The only problem: from a pure Python code perspective, I have no way to get at the contents of the AGS file, nor is there any arcpy method that could consume the file to give me what I need. Basically we'd have to do something in the core software to assist in using the connection file to help the tools get what they need. I'll have a conversation about that with some team members.

I understand the not knowing if something is stopped or started from the tool UI. Would it simply be enough to show in the UI something like "MyService [STOPPED]"  or  "Service2 [STARTED]" ?  Or are you after an actual filter to only show certain services? I havent wrote any logic to filter, but if I dont consider it now, I probably wont look at making these tools "better" for another 4 years after this go.