Create Enterprise Geodatabase with arcpy - Invalid license file provided!

09-10-2012 04:59 AM
New Contributor
Hi. I'm trying to create geodatabase in ArcGIS for Server enterprise with arcpy script. But it's falling with exception Invalid license file provided. Please provide an ArcGIS for Server enterprise keycodes file!
But i've got licenced ArcGis for Server enterprise!!! I can't understand why this script is not working!?

Description: Provide connection information to a DBMS instance and create an enterprise geodatabase.
Type -h or --help for usage
Author: Esri

# Import system modules
import arcpy, os, optparse, sys

# Define usage and version
parser = optparse.OptionParser(usage = "usage: %prog [Options]", version="%prog 1.0 for 10.1 release")

#Define help and options
parser.add_option ("--DBMS", dest="Database_type", type="choice", choices=['SQLSERVER', 'ORACLE', 'POSTGRESQL', ''], default="", help="Type of enterprise DBMS:  SQLSERVER, ORACLE, or POSTGRESQL.")                  
parser.add_option ("-i", dest="Instance", type="string", default="", help="DBMS instance name")
parser.add_option ("-D", dest="Database", type="string", default="none", help="Database name:  Not required for Oracle")
parser.add_option ("--auth", dest="Account_authentication", type ="choice", choices=['DATABASE_AUTH', 'OPERATING_SYSTEM_AUTH'], default='DATABASE_AUTH', help="Authentication type options (case-sensitive):  DATABASE_AUTH, OPERATING_SYSTEM_AUTH.  Default=DATABASE_AUTH")
parser.add_option ("-U", dest="Dbms_admin", type="string", default="", help="DBMS administrator user")
parser.add_option ("-P", dest="Dbms_admin_pwd", type="string", default="", help="DBMS administrator password")
parser.add_option ("--schema", dest="Schema_type", type="choice", choices=['SDE_SCHEMA', 'DBO_SCHEMA'], default="SDE_SCHEMA", help="Schema Type for SQL Server geodatabase, SDE or DBO. Default=SDE_SCHEMA")
parser.add_option ("-u", dest="Gdb_admin", type="string", default="", help="Geodatabase administrator user name")
parser.add_option ("-p", dest="Gdb_admin_pwd", type="string", default="", help="Geodatabase administrator password")
parser.add_option ("-t", dest="Tablespace", type="string", default="", help="Tablespace name")
parser.add_option ("-l", dest="Authorization_file", type="string", default="", help="Full path and name of authorization file")
# Check if value entered for option
(options, args) = parser.parse_args()

#Check if no system arguments (options) entered
if len(sys.argv) == 1:
  print "%s: error: %s\n" % (sys.argv[0], "No command options given")

#Usage parameters for spatial database connection
database_type = options.Database_type.upper()
instance = options.Instance
database = options.Database.lower()
account_authentication = options.Account_authentication.upper()
dbms_admin = options.Dbms_admin
dbms_admin_pwd = options.Dbms_admin_pwd
schema_type = options.Schema_type.upper()
gdb_admin = options.Gdb_admin
gdb_admin_pwd = options.Gdb_admin_pwd
tablespace = options.Tablespace
license = options.Authorization_file

if (database_type == "SQLSERVER"):
  database_type = "SQL_SERVER"

if( database_type ==""):
  print " \n%s: error: \n%s\n" % (sys.argv[0], "DBMS type (--DBMS) must be specified.")
if (license == ""):
  print " \n%s: error: \n%s\n" % (sys.argv[0], "Authorization file (-l) must be specified.")

if(database_type == "SQL_SERVER"):
  if(schema_type == "SDE_SCHEMA" and gdb_admin.lower() != "sde"):
   print "\n%s: error: %s\n" % (sys.argv[0], "To create SDE schema on SQL Server, geodatabase administrator must be SDE.")
  if (schema_type == "DBO_SCHEMA" and gdb_admin != ""):
   print "\nWarning: %s\n" % ("Ignoring geodatabase administrator specified when creating DBO schema...")
  if( account_authentication == "DATABASE_AUTH" and dbms_admin == ""):
   print "\n%s: error: %s\n" % (sys.argv[0], "DBMS administrator must be specified with database authentication")
  if( account_authentication == "OPERATING_SYSTEM_AUTH" and dbms_admin != ""):
   print "\nWarning: %s\n" % ("Ignoring DBMS administrator specified when using operating system authentication...")
  if (schema_type == "DBO_SCHEMA"):
   print "\nWarning: %s %s, %s\n" % ("Only SDE schema is supported on", database_type, "switching to SDE schema..." )
  if( gdb_admin.lower() == ""):
   print "\n%s: error: %s\n" % (sys.argv[0], "Geodatabase administrator must be specified.")

  if( gdb_admin.lower() != "sde"):
   if (database_type == "ORACLE"):
    print "\nGeodatabase admin user is not SDE, creating user schema geodatabase on Oracle...\n"
    print "\n%s: error: %s for %s.\n" % (sys.argv[0], "Geodatabase administrator must be SDE", database_type)
  if( dbms_admin == ""):
   print "\n%s: error: %s\n" % (sys.argv[0], "DBMS administrator must be specified!")

  if (account_authentication == "OPERATING_SYSTEM_AUTH"):
   print "Warning: %s %s, %s\n" % ("Only database authentication is supported on", database_type, "switching to database authentication..." )

# Get the current product license

# Checks required license level
if product_license.upper() == "ARCVIEW" or product_license.upper() == 'ENGINE':
  print "\n" + product_license + " license found!" + " Creating an enterprise geodatabase requires an ArcGIS for Desktop Standard or Advanced, ArcGIS Engine with the Geodatabase Update extension, or ArcGIS for Server license."
  sys.exit("Re-authorize ArcGIS before creating enterprise geodatabase.")
  print "\n" + product_license + " license available!  Continuing to create..."

  print "Creating enterprise geodatabase...\n"
  arcpy.CreateEnterpriseGeodatabase_management(database_platform=database_type,instance_name=instance, database_name=database, account_authentication=account_authentication, database_admin=dbms_admin, database_admin_password=dbms_admin_pwd, sde_schema=schema_type, gdb_admin_name=gdb_admin, gdb_admin_password=gdb_admin_pwd, tablespace_name=tablespace, authorization_file=license)
  for i in range(arcpy.GetMessageCount()):
  for i in range(arcpy.GetMessageCount()):
#Check if no value entered for option
except SystemExit as e:
if e.code == 2:
  parser.usage = ""
  print "\n"

This is output of the execution of above python script:

C:\Python27\ArcGISx6410.1>python --DBMS=SQLSERVER -i ARC
GISSQLSERVER -D kostroma -U sa -P 112 -u sde -l C:\Program Files\ESRI\License10.

ArcServer license available!  Continuing to create...
Creating enterprise geodatabase...

Executing: CreateEnterpriseGeodatabase SQL_Server ARCGISSQLSERVER kostroma DATAB
ASE_AUTH sa ***** SDE_SCHEMA sde # # C:\Program
Start Time: Mon Sep 10 16:36:42 2012
ERROR: Failed to execute. Parameters are not valid.
ERROR: Invalid license file provided. Please provide an ArcGIS for Server enterp
rise keycodes file.
ERROR: Failed to execute (CreateEnterpriseGeodatabase).
Failed at Mon Sep 10 16:36:42 2012 (Elapsed Time: 0,00 seconds)

I will appreciate any help=)
0 Kudos
3 Replies
Esri Esteemed Contributor
Does the same license file work through the Toolbox utility?

This is really something best taken to Tech Support and/or Customer Service,
since no one here can (or should) verify your license file.

- V
0 Kudos
New Contributor III
Hi Vselivanov,

You will need to provide the path and the filename of the keycodes file for this 'Create Enterprise Geodatabase' to pick up the license.

As described on the webhelp link of the "Create Enterprise Geodatabase" tool:

"Provide the path and file name of the keycodes file that was created when you authorized ArcGIS for Server Enterprise. This file is in the \\Program Files\ESRI\License<release#>\sysgen folder on Windows and /arcgis/server/framework/runtime/.wine/drive_c/Program Files/ESRI/License<release#>/sysgen directory on Linux."

You can also use a .ecp file by downloading it from ArcSDE 10 and ArcIMS 10 Authorization Form.

- Mandar
0 Kudos
New Contributor
Thanks a lot for fast response. But I found out that problem was in the provided parameters for python script.
Then I passed the path to license key like C:\Program Files\ESRI\License10.1\sysgen\keycodes inside python script in licence variable
was only C:\Program, so that is why it's falling with not appropriate license! All problem was in a gap between Program and Files=)
Nevertheless, thanks=)
0 Kudos