Register Data Store with Python Failing

3303
3
06-26-2015 10:02 AM
JosephBuckles
New Contributor II

ESRI has pointed me to using a python script and a pipe deliminited text file for scripting the registration of data stores with our ArcGIS Server/Portal implementation.

http://server.arcgis.com/en/server/latest/administer/windows/example-register-folders-and-databases-...


The problem is it just won't work.  I can log into the manager and use the same .sde files and create the data store manually. I can also do the same with making a connection via ArcCatalog and adding the datastore manually but the python script simply will not work.  I've tested all the .ags files the script generates and they connect just fine to ArcGIS Server.  I have checked that we have the correct SQL Server Client installed.

When I run the script that is found above from my desktop it errors with the following:

Adding the datastore: winauth@write_stage Adding of the datastore: winauth@write_stage failed. Cannot open server connection to database. Adding the datastore: winauth@vector_stage Adding of the datastore: winauth@vector_stage failed. Cannot open server connection to database.

When I try to run python from the server itself I get this:

Adding the datastore: winauth@write_stage Adding of the datastore: winauth@write_stage failed. Cannot open AGS server connection. Adding the datastore: winauth@vector_stage Adding of the datastore: winauth@vector_stage failed. Cannot open AGS server connection.

Sometimes on the server it throws up an exception to the certificate I add it to the trusted store but that doesn't provide any relief

I made sure to use HTTPS and Port 6443 and I've I've tried it with HTTP and 6080 and I've tried it wout any port it is always the same result.

I get the following error in the AGS Log: Token is not a valid Admin token. Trying portal token next. Token = ., referrer = https://.domain.com/arcgis/manager/log.html#lgf=type%2Ctime%2Cmessage%2Csource&lqlf=DEBUG&lqa=last%2... not decrypt token. Token may not be valid.

But I can see just above it this error that a token was requested and granted

Thank you in advance for troubleshooting help

3 Replies
KenHansen1
New Contributor

Did you ever get an answer to this question?

AprilSummers
New Contributor II

Did you ever get an answer to this question. How was it resolved?

DarylHochhalter
Occasional Contributor II

I can tell you this, you'll need to use the arcgis API for Python, the link they pointed the initial poster to was for older python functions from Arcmap.

you'll need to get to this hosting_servers=gis.admin.servers.get(role="HOSTING_SERVER") to get a 

DataStoreManager = hosting_servers[0].datastoresDataStoreManager   

I used this with a csv containing the parameters 

dstores = hosting_servers[0].datastores

inputFile = r"\\mypathto\The.csv"

try:
with open(inputFile, 'r') as newDSFile:
DSdict_csv = csv.DictReader(newDSFile)
for dstore in DSdict_csv:

print("Adding the " + dstore['dsType'] + " datastore: " + dstore['dsName'])
if dstore['dsType'] == 'FOLDER':
item = dstores.add_folder(dstore['dsName'],dstore['dsServerPath'])
if item:
print(str(item.properties) + '\n')
elif dstore['dsType'] == 'DATABASE':
con = dstores.generate_connection_string(dstore['dsServerPath'])
item = dstores.add_database(dstore['dsName'],con)
if item:
print(str(item.properties) + '\n')

except Exception as Ex:
print(str(Ex))

0 Kudos