ArcREST icon indicating copy to clipboard operation
ArcREST copied to clipboard

attribute not implemented manageags.AGSAdministration

Open ckel490 opened this issue 8 years ago • 9 comments

ArcRest or ArcRestHelper

ArcRest

Version or date of download

8/20/2016

Bug or Enhancement

More question than either

Repo Steps or Enhancement details

I am succesfully accessing the services on our Dev ArcGIS Server through manageags, but when I try to access our Production server, I get the following when I type ags.resources:

status - attribute not implemented manageags.AGSAdministration. code - attribute not implemented manageags.AGSAdministration. messages - attribute not implemented manageags.AGSAdministration.

Is there a setting on the Server that I need to change?

Here's the code below:

Ask for admin/publisher user name and password

env = raw_input("Enter Envrionemnt, dev or prod: ") ##username = raw_input("Enter user name: ") username = "siteadmin" password = getpass.getpass("Enter password: ")

if env == 'dev': admin_url = r"http://[servername]:6080/arcgis/admin" elif env == 'prod': admin_url = r"http://[servername]:6080/arcgis/admin/"

Create Security Handler

sh= arcrest.AGSTokenSecurityHandler(username = username,password = password,org_url = admin_url) #Create ArcGIS Server REST API Wrapper ags = arcrest.manageags.AGSAdministration(admin_url,sh)

ckel490 avatar Aug 29 '16 16:08 ckel490

Those attributes are returned when there is an error connecting to the server. Are the user name and password correct?

MikeMillerGIS avatar Aug 29 '16 16:08 MikeMillerGIS

I am able to connect using the same user name and password directly to the URL… That’s why it is confusing to me. [cid:[email protected]]

ckel490 avatar Aug 29 '16 16:08 ckel490

Do you use a web adapter on prod? Maybe a firewall is blocking 6080? Can you try port 80?

MikeMillerGIS avatar Aug 29 '16 16:08 MikeMillerGIS

No, it’s configured to use port 6080. The username and password are identical if I use script or on the web….

I am having the same issue on our test server. I can access with siteadmin username and password via URlLbut not through the script using arcrest. It’s interesting that it is acquiring the security handler, so it’s accessing the server.

I am working with our server guys to see if there is something configured differently between our dev and prod boxes.

ckel490 avatar Aug 29 '16 17:08 ckel490

It's unclear to me why I am able to run the script from http://server.arcgis.com/en/server/10.3/administer/linux/example-stop-or-start-all-services-in-a-folder.htm to stop services in a folder. But I am unable to obtain a token from arcrest using the same username, password, servername and port...

ckel490 avatar Aug 29 '16 19:08 ckel490

@ckel490: Try removing the slash from the end of your admin_url for production, so that it looks like:

admin_url = r"http://[servername]:6080/arcgis/admin"

Your admin_url is used in the call ags = arcrest.manageags.AGSAdministration(admin_url,sh). However, the first part of src.arcrest.manageags.administration.AGSAdministration.__init__() makes this comparison:

        if url.lower().endswith('/admin') == False:
            url = "%s/admin" % url

Which means your URL that ends with an extra slash will become http://[servername]:6080/arcgis/admin/admin.

This is a bug in arcrest.manageags.administration.AGSAdministration. It should use a standard URL handling library to determine whether another element needs to be added to the path. I'd recommend using https://pypi.python.org/pypi/urlnorm. (I also recommend that ArcREST should use https://pypi.python.org/pypi/requests instead of urllib.) arcrest.AGSTokenSecurityHandler also makes some assumptions about URLs that may not be safe.

In the perfect world, it shouldn't matter whether your URL ends with a slash. Technically, having the slash is the correct format according to the standards documents, but without the slash should work as well, as they do in most web browsers. Those work because they use standardized URL handling code.

sloanlance avatar Aug 30 '16 08:08 sloanlance

@sloanlance I understand the idea of using requests vs urllib, but some people do not want to use anything but the standard library.

Also, I think urlnorm is very interesting, but the github repo does not have a license posted, so that could cause some trouble.

achapkowski avatar Sep 01 '16 10:09 achapkowski

@achapkowski, the PyPI entry for urlnorm says it uses an MIT license. Its setup.py and main class file on GitHub also mention it, although they don't have a LICENSE file. I don't know whether that license is compatible with ArcREST's, though. If urlnorm can't be used, at least it could be inspiration for improved URL handling in this project. I learned a few good solutions for URL handling before I found urlnorm and started using it instead.

WRT urllib vs. requests, does this project intend to not force other dependencies on its users? It only requires six (bundled) and numpy (external; BSD license) now. I think requests offers so many improvements over requests, it would improve the robustness of this project. It may be a bit of a leap to switch to the other module, for sure. An alternative is to use requests if it's installed, but work with urllib if that's all that's available. Making ArcREST work with either could make the code a little more complex, though.

sloanlance avatar Sep 01 '16 13:09 sloanlance

I figured out the problem. I was using your example in the Wiki for administering ArcGIS Server, which uses the admin_url for the AGSTokenSecurityHandler. This worked on our Dev server. When I checked the sh.token_url, it was http://server:6080/arcgis/tokens/

In order to create a token for our test and prod servers, I need to use the token_url parameter = http://server:6080/arcgis/admin/generateToken as http://server:6080/arcgis/tokens/ does not work.

It might be helpful to modify the examples to explicitly use the token_url for the security handler. Thanks, Christina

ckel490 avatar Sep 07 '16 18:09 ckel490