示例#1
0
    print "\nThe drive specified for parameter <DataDriveLetter>" + \
                " (" + dataDrive + ") is an invalid drive."
    goodParameters = False

if not doesDriveExist(cacheDrive):
    print "\nThe drive specified for parameter <CacheDriveLetter>" + \
                " (" + cacheDrive + ") is an invalid drive."
    goodParameters = False

# Exit script if parameters are not valid.
if not goodParameters:
    print "\nInvalid script parameters. Exiting " + scriptName + "."
    sys.exit(1)

DestinationDBFolder = OpsServerConfig.getDBConnFileRootPath(dataDrive)
DestinationCacheFolder = OpsServerConfig.getCacheRootPath(cacheDrive)
DestinationFolder = OpsServerConfig.getEnvDataRootPath(dataDrive)

modifyOwnershipList = []
printMsg = True
totalCopySuccess = True
totalRepairMDSuccess = True


def copyDataFolders(srcRootPath, destRootPath, ownerAccount):
    copySuccess = True

    # Check if there is available space on destination drive
    # to copy folders.
    freeSpace = getFreeSpace(destRootPath, "GB")
示例#2
0
if not doesDriveExist(dataDrive):
    print "\nThe drive specified for parameter <DataDriveLetter>" + " (" + dataDrive + ") is an invalid drive."
    goodParameters = False

if not doesDriveExist(cacheDrive):
    print "\nThe drive specified for parameter <CacheDriveLetter>" + " (" + cacheDrive + ") is an invalid drive."
    goodParameters = False

# Exit script if parameters are not valid.
if not goodParameters:
    print "\nInvalid script parameters. Exiting " + scriptName + "."
    sys.exit(1)


DestinationDBFolder = OpsServerConfig.getDBConnFileRootPath(dataDrive)
DestinationCacheFolder = OpsServerConfig.getCacheRootPath(cacheDrive)
DestinationFolder = OpsServerConfig.getEnvDataRootPath(dataDrive)

modifyOwnershipList = []
printMsg = True
totalCopySuccess = True
totalRepairMDSuccess = True


def copyDataFolders(srcRootPath, destRootPath, ownerAccount):
    copySuccess = True

    # Check if there is available space on destination drive
    # to copy folders.
    freeSpace = getFreeSpace(destRootPath, "GB")
示例#3
0
def createSite(username, password, dataDrive, cacheDrive):

    success = True
    
    try:
        print
        print "--Create ArcGIS Server Site..."
        print
        
        agsCache = OpsServerConfig.getCacheRootPath(cacheDrive)
        
        pathList = ["arcgisserver", "directories"]
        agsData = makePath(serverDrive, pathList)
        
        pathList = ["arcgisserver", "config-store"]
        agsConfig = makePath(serverDrive, pathList)
    
        # Set up required properties for config store
        print "\t-Setting up required properties for config store..."
        configStoreConnection={"connectionString": agsConfig, "type": "FILESYSTEM"}
        print "\tDone."
        print
     
        # Set up paths for server directories             
        jobsDirPath = os.path.join(agsData, "arcgisjobs")
        outputDirPath = os.path.join(agsData, "arcgisoutput")
        systemDirPath = os.path.join(agsData, "arcgissystem")
       
        # Create Python dictionaries representing server directories
        print "\t-Creating Python dictionaries representing server directories"
        print "\t\t(arcgiscache, arcgisjobs, arcgisoutput, arcgissystem)..."
        cacheDir = dict(name = "arcgiscache",physicalPath = agsCache,directoryType = "CACHE",cleanupMode = "NONE",maxFileAge = 0,description = "Stores tile caches used by map, globe, and image services for rapid performance.", virtualPath = "")    
        jobsDir = dict(name = "arcgisjobs",physicalPath = jobsDirPath, directoryType = "JOBS",cleanupMode = "TIME_ELAPSED_SINCE_LAST_MODIFIED",maxFileAge = 360,description = "Stores results and other information from geoprocessing services.", virtualPath = "")
        outputDir = dict(name = "arcgisoutput",physicalPath = outputDirPath,directoryType = "OUTPUT",cleanupMode = "TIME_ELAPSED_SINCE_LAST_MODIFIED",maxFileAge = 10,description = "Stores various information generated by services, such as map images.", virtualPath = "")
        systemDir = dict(name = "arcgissystem",physicalPath = systemDirPath,directoryType = "SYSTEM",cleanupMode = "NONE",maxFileAge = 0,description = "Stores files that are used internally by the GIS server.", virtualPath = "")
        print "\tDone."
        print
    
        # Serialize directory information to JSON
        print "\t-Serializing server directory information to JSON..."
        directoriesJSON = json.dumps(dict(directories = [cacheDir, jobsDir, outputDir, systemDir]))      
        print "\tDone."
        print
        
        # Construct URL to create a new site
        print "\t-Constructing URL to create a new site..."
        createNewSiteURL = "/arcgis/admin/createNewSite"
        print "\tDone."
        print
        
        # Set up parameters for the request
        print "\t-Setting up parameters for the request to create new site..."
        params = urllib.urlencode({'username': username, 'password': password, 'configStoreConnection': configStoreConnection, 'directories':directoriesJSON, 'f': 'json'})
        
        headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
        print "\tDone."
        print
        
        # Connect to URL and post parameters
        print "\t-Making request to create new site..."
        httpConn = httplib.HTTPConnection(servername, serverPort)
        httpConn.request("POST", createNewSiteURL, params, headers)
        
        # Read response
        response = httpConn.getresponse()
        if (response.status != 200):
            httpConn.close()
            print "\tERROR: Error while creating the site."
            print
            success = False
        else:
            data = response.read()
            httpConn.close()
            
            # Check that data returned is not an error object
            if not assertJsonSuccess(data):          
                print "\tERROR: Error returned by operation. " + str(data)
                print
            else:
                print "\tSite created successfully."
                print "\tDone."
                print
         
    except:
        success = False
        
        # Get the traceback object
        tb = sys.exc_info()[2]
        tbinfo = traceback.format_tb(tb)[0]
     
        # Concatenate information together concerning the error into a message string
        pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
        
        # Print Python error messages for use in Python / Python Window
        print
        print "***** ERROR ENCOUNTERED *****"
        print pymsg + "\n"
        
    finally:
        # Return success flag
        return success