Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

attribute not implemented manageags.AGSAdministration #290

Open
ckel490 opened this issue Aug 29, 2016 · 9 comments
Open

attribute not implemented manageags.AGSAdministration #290

ckel490 opened this issue Aug 29, 2016 · 9 comments

Comments

@ckel490
Copy link

ckel490 commented Aug 29, 2016

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)

@MikeMillerGIS
Copy link
Member

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

@ckel490
Copy link
Author

ckel490 commented Aug 29, 2016

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:image001.png@01D201D9.1789E610]

@MikeMillerGIS
Copy link
Member

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

@ckel490
Copy link
Author

ckel490 commented Aug 29, 2016

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
Copy link
Author

ckel490 commented Aug 29, 2016

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...

@sloanlance
Copy link
Contributor

sloanlance commented Aug 30, 2016

@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.

@achapkowski
Copy link
Collaborator

@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.

@sloanlance
Copy link
Contributor

@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.

@ckel490
Copy link
Author

ckel490 commented Sep 7, 2016

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

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

No branches or pull requests

4 participants