ArcPy.AddDataStoreItem Bug

1173
2
02-18-2013 06:26 PM
JoseSousa
Esri Contributor
Hi,

I have an SDE connection that points to version SDE.DEFAULT. If I register that sde connection with ArcGIS for Server using ArcPy it works.

If I create another connection file with exact same values except the version (e.g. DBO.WHATEVER) and try to register with ArcGIS for Server the AddDataStoreItem method fails saying Client database entry is already registered. This is wrong because when I analyse the connections it says that the Data Source is not registered with ArcGIS for Server which is true since the version is different ...

If I register that connection using both ArcGIS for Server or ArcGIS Desktop built-in functions using the import button it works as expected. If instead of passing as arguments the sde connection I use the string (e.g. ENCRYPTED_PASSWORD=00022e6858746e5734667063704b444a556f32623865634c4372634e2f645563514f5361423062367731617a36496b3d2a00;SERVER=MYHOST;INSTANCE=sde:sqlserver:MYHOST;DBCLIENT=sqlserver;DB_CONNECTION_PROPERTIES=MYHOST;DATABASE=sde;USER=sa;VERSION=DBO.WHATEVER;AUTHENTICATION_MODE=DBMS) it works.

I need this method to work properly as users generates versions through Workflow Manager and need that services are available on ArcGIS for Server on-the-fly. Please fix this issue.

Thanks,
Jose
Tags (2)
0 Kudos
2 Replies
JoseSousa
Esri Contributor
With the connection string it doesn't work either ...

I have monitored the requests made by ArcPy and ArcGIS for Server

ArcPy - FAILS
It doesn't call for the registeritem REST service ... it says that Client database entry is already registered
It calls for the finditems which only finds the SDE.DEFAULT connection already there ...

This is the only request that it makes ....
http://localhost/arcgis/admin/data/findItems/?f=json&parentPath=%2fenterpriseDatabases&types=egdb&to...

POST values
{"items":[{"path":"/enterpriseDatabases/MYSTORENAME","type":"egdb","id":null,"clientPath":null,"totalRefCount":0,"info":{"connectionString":"ENCRYPTED_PASSWORD=00022e6858746e5734667063704b444a556f32623865634c4372634e2f645563514f5361423062367731617a36496b3d2a00;SERVER=MYHOST;INSTANCE=sde:sqlserver:MYHOST;DBCLIENT=sqlserver;DB_CONNECTION_PROPERTIES=MYHOST;DATABASE=sde;USER=sa;VERSION=SDE.DEFAULT;AUTHENTICATION_MODE=DBMS","isManaged":false,"dataStoreConnectionType":"shared"}}]}

The request above was made by executing the arcpy line:
arcpy.AddDataStoreItem("ArcGIS_Server_Admin.ags", "DATABASE", "xpto", "PASSWORD=MyPass;SERVER=MYHOST;INSTANCE=sde:sqlserver:MYHOST;DBCLIENT=sqlserver;DB_CONNECTION_PROPERTIES=MYHOST;DATABASE=sde;USER=sa;VERSION=DBO.WHATEVER;AUTHENTICATION_MODE=DBMS") ... note that it fails same way if using an existing SDE connection that I know that works well.

ArcGIS for Server Manager built-in functions - WORKS
Before calling the http://localhost/arcgis/admin/data/findItems it calls for http://localhost/arcgis/admin/data/registerItem?f=json&token=YmVUvZ6RPlhd9ENB7U1JMO7tnS8SobJheauMHk6... which returns success

Then it calls the http://localhost/arcgis/admin/data/findItems which shows the new item and the previous one already there (the SDE.DEFAULT)

Hope this helps,
Jose
0 Kudos
JoseSousa
Esri Contributor
Issue: It seems like ArcPy validates some connection properties to see if the connection was already published or not but is not including the version in that client-side comparison.

Workaround:
Replace a property that is not required for our RDBMS (in my case SQL Server) so that that comparison fails. Note that this comparison is done client-side so requests for server-side validation (which works just fine) don't even happen. That is why the ArcPy.AddDataStoreItem method does not request for validation or to register the items in AGS for Server. The request was immediately denied after ArcPy determined that the client database was already registered.

I am changing the server name of the connection properties to be always different. That is not actually used for the connection (ArcGIS Desktop don't even show that property when opens the Connection Property Window for SQL Server) but is used for the client-side validation of ArcPy. It then succeeds and allows me to register successfully the data source.

Because I am validating whether the Store Name already exists before adding the data store this works just fine. Note that this validation uses the store name and not the sde connection file as parameter...

The AGS server validation (server-side) is smart enough to ignore the server name when making the comparison and validates the version. So this happens to work as I wanted.

Jose
0 Kudos