├── .gitignore ├── BuildNum.txt ├── CONTRIBUTING.md ├── Docs ├── Ops Server Config Preparation.docx ├── Ops Server Config Preparation.pdf ├── Ops Server Installation Guide.docx └── Ops Server Installation Guide.pdf ├── Install ├── ArcGISDataStore │ ├── InstallAGSDataStore.bat │ └── SupportFiles │ │ └── CreateAGSDataStore.bat ├── ArcGISServer │ ├── CreateArcGISServerSite.bat │ ├── InstallArcGISServer.bat │ └── SupportFiles │ │ ├── ChangeAGSSecurityConfig.bat │ │ ├── CreateLocalDataStores.py │ │ ├── CreateOpsServer.py │ │ ├── CreateSite.py │ │ ├── FederateAGS.bat │ │ ├── ListPostgresDatabases.sql │ │ └── PreConfigurationChecks.py ├── EsriMapsForOffice │ └── WebContent │ │ └── InstallEM4OWebContent.bat ├── GeoEvent │ ├── InstallGeoEvent.bat │ └── InstallGeoEventPatches.bat ├── InstallIIS.bat ├── InstallOpsServer.bat ├── InstallSettings.bat ├── MessageSimulator │ ├── InstallMessageSimulator.bat │ ├── MessageSimulator.bat │ └── SupportFiles │ │ └── MessageSimulatorTask.xml ├── OpsDashboardUtility │ └── CreateOneClickInstaller.bat ├── Portal │ ├── InstallPortal.bat │ └── Portal │ │ └── CreatePortalAdminAccount.bat ├── PostgreSQL │ ├── InstallPostgreSQL.bat │ └── SupportFiles │ │ └── postgresql.conf ├── PredictiveAnalysis │ └── InstallPredictiveAnalysis.bat └── WebAdaptorIIS │ ├── CreateCertificate.bat │ ├── InstallWebAdaptor.bat │ ├── InstallWebAdaptorPrerequisites.bat │ ├── RegisterAGSwithWebAdaptorHTTPS.bat │ ├── RegisterPortalwithWebAdaptor.bat │ └── SupportFiles │ ├── AddIISMimeTypes.bat │ ├── InstallRolesAndFeatures.bat │ └── SetIISDefaultDocument.bat ├── LICENSE-ThirdParty.txt ├── Publish ├── Portal │ ├── FindOrphanedHostedServices.py │ ├── PortalContentDestroyer.py │ ├── PortalContentExtract.py │ ├── PortalContentPost.py │ ├── PrepItemsForExtract.py │ ├── PublishHostedSceneServices.py │ ├── PublishHostedServices.py │ ├── RemapIDsOnServices.py │ ├── UpdateHostedServiceDefinitions.py │ ├── UpdatePortalGUIDs.py │ └── portalpy │ │ ├── README.md │ │ ├── __init__.py │ │ ├── config.py │ │ ├── provision.py │ │ └── stats.py └── Server │ ├── CopyData.py │ ├── CopyFiles.py │ ├── CopyGDB.py │ ├── CopyGDBs.py │ ├── PublishToOpsServer.py │ ├── RepairMosaicDatasets.py │ └── StartStopServices.py ├── README.md ├── ScreenShot.png ├── SupportFiles ├── AGSRestFunctions.py ├── BatchFiles │ ├── CheckErrorLevel.bat │ ├── CheckExistence.bat │ ├── Checks │ │ ├── CheckServerName.bat │ │ ├── IsInstalled_IIS.bat │ │ ├── IsInstalled_NETFramework3_5.bat │ │ └── IsInstalled_NETFramework4_5.bat │ └── SetOverallErrorLevel.bat ├── CreateFileGDBs.py ├── DataStore.py ├── GetSDFiles.py ├── OpsServerConfig.py ├── PostWebAppDeployment.bat ├── RegisterDataStores.py ├── RepairMosaicDatasets.py ├── SetServicesDirectoryProps.py ├── UpdateWebApps.py ├── UrlChecker.py ├── UrlCheckerWithErrorCodeReturn.bat ├── Utilities.py ├── UtilitiesArcPy.py └── walkingDirTrees.py ├── Utilities ├── BuildSceneCache.py ├── CopyItemToEachAccount.py ├── CreateBatchFileToRunCreateServiceList.py ├── CreateOpsServerReleaseFolderStructure.bat ├── CreateServiceList.py ├── GenerateCreateUserFiles.py ├── ListServiceWorkspaces.py ├── ListServices.py ├── ListServicesInSDFiles.py ├── ManageServiceProperties.py ├── ValidateHostedServiceSources.py ├── WriteHostedSceneServiceDefinitions.py └── WriteHostedServiceDefinitions.py └── license.txt /.gitignore: -------------------------------------------------------------------------------- 1 | *_previous 2 | *_old 3 | *.previous 4 | *.old 5 | Test*.py 6 | *.ags 7 | 8 | *.py[cod] 9 | 10 | # C extensions 11 | *.so 12 | 13 | # Packages 14 | *.egg 15 | *.egg-info 16 | dist 17 | build 18 | eggs 19 | parts 20 | bin 21 | var 22 | sdist 23 | develop-eggs 24 | .installed.cfg 25 | lib 26 | lib64 27 | 28 | # Installer logs 29 | pip-log.txt 30 | 31 | # Unit test / coverage reports 32 | .coverage 33 | .tox 34 | nosetests.xml 35 | 36 | # Translations 37 | *.mo 38 | 39 | # Mr Developer 40 | .mr.developer.cfg 41 | .project 42 | .pydevproject 43 | 44 | 45 | *.komodoproject 46 | -------------------------------------------------------------------------------- /BuildNum.txt: -------------------------------------------------------------------------------- 1 | OpsServer 10.3.1.1 -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](https://github.com/esri/contributing). 2 | -------------------------------------------------------------------------------- /Docs/Ops Server Config Preparation.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Esri/ops-server-config/5768cf45eb9e9aeba0f68c15cdd452287b8af746/Docs/Ops Server Config Preparation.docx -------------------------------------------------------------------------------- /Docs/Ops Server Config Preparation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Esri/ops-server-config/5768cf45eb9e9aeba0f68c15cdd452287b8af746/Docs/Ops Server Config Preparation.pdf -------------------------------------------------------------------------------- /Docs/Ops Server Installation Guide.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Esri/ops-server-config/5768cf45eb9e9aeba0f68c15cdd452287b8af746/Docs/Ops Server Installation Guide.docx -------------------------------------------------------------------------------- /Docs/Ops Server Installation Guide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Esri/ops-server-config/5768cf45eb9e9aeba0f68c15cdd452287b8af746/Docs/Ops Server Installation Guide.pdf -------------------------------------------------------------------------------- /Install/ArcGISDataStore/InstallAGSDataStore.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: InstallAGSDataStore.bat 16 | rem # 17 | rem # Purpose: Installs ArcGIS Data Store software 18 | rem # 19 | rem #============================================================================== 20 | set ops_ChkErrLevelFile=%~dp0..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 21 | 22 | REM --------------------------------------------------------------------- 23 | REM Install ArcGIS Data Store 24 | REM --------------------------------------------------------------------- 25 | echo. 26 | echo %sectionBreak% 27 | echo Install ArcGIS Data Store 28 | echo. 29 | echo --Installing ArcGIS Data Store... 30 | echo. 31 | REM Issue with Data Store, running windows service by any other account 32 | REM except for LOCALSYSTEM is not supported yet. 33 | set execute=%ops_softwareRoot%\ArcGISDataStore\setup.exe /qb ^ 34 | USER_NAME=%ops_dsServiceAccount% PASSWORD=%ops_dsServiceAccountPassword% 35 | 36 | echo %execute% 37 | echo. 38 | %execute% 39 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 40 | 41 | set AGSDATASTORE=C:\Program Files\ArcGIS\DataStore\ 42 | 43 | echo Waiting 3 minutes before continuing... 44 | PING 127.0.0.1 -n 180 > nul 45 | 46 | 47 | -------------------------------------------------------------------------------- /Install/ArcGISDataStore/SupportFiles/CreateAGSDataStore.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: CreateAGSDataStore.bat 16 | rem # 17 | rem # Purpose: Creates the ArcGIS Data Store and registers the Data Store 18 | rem # with the ArcGIS Server site as the managed database. 19 | rem # 20 | rem # Prerequisites: ArcGIS Data Store must be installed (see InstallAGSDataStore.bat) 21 | rem # 22 | rem #============================================================================== 23 | set ops_ChkErrLevelFile=%~dp0..\..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 24 | 25 | REM --------------------------------------------------------------------- 26 | REM Create ArcGIS Data Store 27 | REM --------------------------------------------------------------------- 28 | echo. 29 | echo %sectionBreak% 30 | echo Create ArcGIS Data Store 31 | echo. 32 | echo --Create ArcGIS Data Store... 33 | echo. 34 | set execute="%AGSDATASTORE%tools\configuredatastore.bat" https://%ops_FQDN%:6443/arcgis/admin %ops_userName% %ops_passWord% %ops_agsDataStoreDIR% 35 | 36 | echo %execute% 37 | echo. 38 | %execute% 39 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 40 | 41 | echo Waiting 3 minutes before continuing... 42 | PING 127.0.0.1 -n 180 > nul 43 | 44 | 45 | -------------------------------------------------------------------------------- /Install/ArcGISServer/CreateArcGISServerSite.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: CreateArcGISServerSite.bat 16 | rem # 17 | rem # Purpose: Creates the ArcGIS Server site, Ops Server folders, 18 | rem # local/enterprise geodatabase data stores and registers 19 | rem # the data stores; also starts specific ArcGIS Server services 20 | rem # required by Ops Server. 21 | rem # 22 | rem # Prerequisites: ArcGIS Server must be installed (see InstallArcGISServer.bat) 23 | rem # 24 | rem #============================================================================== 25 | set ops_ChkErrLevelFile=%~dp0..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 26 | 27 | REM --------------------------------------------------------------------- 28 | REM Create ArcGIS Server site, create data stores, register data stores 29 | REM --------------------------------------------------------------------- 30 | echo. 31 | echo %sectionBreak% 32 | echo Create ArcGIS Server site, create data stores, and register data stores... 33 | echo. 34 | Call "%~dp0SupportFiles\CreateOpsServer.py" %ops_agsServiceAccount% ^ 35 | %ops_userName% %ops_passWord% %ops_dataDrive% %ops_cacheDrive% 36 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 37 | PING 127.0.0.1 -n 6 > nul 38 | 39 | REM --------------------------------------------------------------------- 40 | REM Start geometry service 41 | REM --------------------------------------------------------------------- 42 | set ops_servicesList=Utilities//Geometry.GeometryServer,Utilities//PrintingTools.GPServer 43 | echo. 44 | echo %sectionBreak% 45 | echo Start the following services^: 46 | echo %ops_servicesList% 47 | echo. 48 | Call "%~dp0..\..\Publish\Server\StartStopServices.py" %FQDN% ^ 49 | 6080 %ops_userName% %ops_passWord% no Start %ops_servicesList% 50 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 51 | PING 127.0.0.1 -n 3 > nul -------------------------------------------------------------------------------- /Install/ArcGISServer/InstallArcGISServer.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: InstallArcGISServer.bat 16 | rem # 17 | rem # Purpose: Installs and authorizes ArcGIS Server 18 | rem # 19 | rem #============================================================================== 20 | set ops_ChkErrLevelFile=%~dp0..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 21 | SET FQDN=%ops_FQDN% 22 | 23 | echo. 24 | echo %sectionBreak% 25 | echo Install ArcGIS Server 26 | 27 | REM --------------------------------------------------------------------- 28 | REM Install ArcGIS Server 29 | REM --------------------------------------------------------------------- 30 | echo. 31 | echo --Installing ArcGIS Server... 32 | echo. 33 | set execute=%ops_softwareRoot%\ArcGISServer\setup.exe /qb ^ 34 | USER_NAME=%ops_agsServiceAccount% PASSWORD=%ops_agsServiceAccountPassword% ^ 35 | INSTALLDIR1=C:\Python27 36 | 37 | echo %execute% 38 | echo. 39 | %execute% 40 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 41 | 42 | REM --------------------------------------------------------------------- 43 | REM "Install" geometry library to PostgreSQL lib folder 44 | REM --------------------------------------------------------------------- 45 | echo. 46 | echo --Copying geometry library to PostgreSQL lib folder... 47 | echo. 48 | set execute=START /WAIT robocopy "C:\Program Files\ArcGIS\Server\DatabaseSupport\PostgreSQL\9.3\Windows64" ^ 49 | %ops_postgresqlInstallDIR%\lib" 50 | 51 | echo %execute% 52 | echo. 53 | %execute% 54 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% ROBOCOPY 55 | 56 | REM --------------------------------------------------------------------- 57 | REM Authorize ArcGIS Server Software 58 | REM --------------------------------------------------------------------- 59 | echo. 60 | echo --Authorizing ArcGIS Server... 61 | echo. 62 | echo Will use the following file to authorize. If no file found, 63 | echo Software Authorization wizard will walk user through process: 64 | echo %ops_AGSAuthFile% 65 | echo. 66 | set execute=%ops_softwareAuthExePath% -S Ver %ops_AGSVersion% 67 | if exist %ops_AGSAuthFile% ( 68 | set execute=%execute% -LIF %ops_AGSAuthFile% 69 | ) else ( 70 | echo Prompting user for authorizing information... 71 | ) 72 | echo. 73 | echo %execute% 74 | echo. 75 | %execute% 76 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 77 | PING 127.0.0.1 -n 15 > nul -------------------------------------------------------------------------------- /Install/ArcGISServer/SupportFiles/ChangeAGSSecurityConfig.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: ChangeAGSSecurityConfig.bat 16 | rem # 17 | rem # Purpose: Change the ArcGIS Server Security Configuration 18 | rem # 19 | rem # Prerequisites: ArcGIS Server must be installed and the ArcGIS Server site 20 | rem # must exist. 21 | rem # 22 | rem #============================================================================== 23 | set ops_ChkErrLevelFile=%~dp0..\..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 24 | echo. 25 | echo. 26 | echo %sectionBreak% 27 | echo Change the ArcGIS Server security configuration to "HTTPS Only"... 28 | echo. 29 | echo ^- When the web browser opens ^(a 2 minute delay has been added^)... 30 | echo. 31 | echo 1. Sign in to the "ArcGIS Server Administrator Directory" 32 | echo site as the ArcGIS Server site administrator. 33 | echo. 34 | echo Username: %ops_userName% 35 | echo Password: %ops_passWord% 36 | echo. 37 | echo NOTE: You will be redirected to the "Security/Config" page. 38 | echo. 39 | echo. 40 | echo 2. On the "Security/Config" page, click the "update" link. 41 | echo. 42 | echo. 43 | echo 4. In the "Protocol" dropdown, select "HTTPS Only". 44 | echo. 45 | echo. 46 | echo 5. Click "Update". 47 | echo. 48 | echo NOTE: this may take a minute or two to complete 49 | echo because the web server has to be restarted. 50 | echo. 51 | echo. 52 | echo 6. Sign out from the "ArcGIS Server Administrator Directory". 53 | echo. 54 | echo. NOTE: if the sign out results in an error or does not sign out, 55 | echo just close the web browser. 56 | echo. 57 | echo. 58 | echo 7. Close the web browser. 59 | echo. 60 | echo. 61 | set execute=%ops_webBrowserExePath% http://%ops_FQDN%:6080/arcgis/admin/security/config 62 | echo %execute% 63 | echo. 64 | %execute% 65 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 66 | 67 | PING 127.0.0.1 -n 120 > nul 68 | -------------------------------------------------------------------------------- /Install/ArcGISServer/SupportFiles/CreateOpsServer.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # Copyright 2014 Esri 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | #============================================================================== 15 | #Name: CreateOpsServer.py 16 | # 17 | #Purpose: Creates ArcGIS Server site, creates and registers data stores, 18 | # and configures Java Script API. 19 | # 20 | #Prerequisites: ArcGIS Server must be installed and authorized before executing 21 | # this script. 22 | # 23 | #============================================================================== 24 | import sys, os, time, traceback, platform 25 | 26 | # Add "Root folder"\SupportFiles to sys path inorder to import 27 | # modules in subfolder 28 | supportFilesPath = os.path.join( 29 | os.path.dirname(os.path.dirname( 30 | os.path.dirname(os.path.dirname(sys.argv[0])))), "SupportFiles") 31 | 32 | sys.path.append(supportFilesPath) 33 | 34 | import OpsServerConfig 35 | import PreConfigurationChecks 36 | import CreateLocalDataStores 37 | import CreateSite 38 | import RegisterDataStores 39 | 40 | preConfigChecks = True 41 | createSite = True 42 | createDataStores = True 43 | registerDataStores = True 44 | 45 | serverName = OpsServerConfig.serverName 46 | sharedDSConfig = OpsServerConfig.sharedDataStoreConfig 47 | 48 | scriptName = sys.argv[0] 49 | 50 | # --------------------------------------------------------------------- 51 | # Check arguments 52 | # --------------------------------------------------------------------- 53 | if len(sys.argv) <> 6: 54 | print "\n" + scriptName + " " + \ 55 | " " 56 | print "\nWhere:" 57 | print "\n\t (required parameter): ArcGIS Server service account" 58 | print "\n\t (required parameter): ArcGIS Server site administrator user name" 59 | print "\n\t (required parameter): Password used for AGS site admin, and sde user" 60 | print "\n\t (required parameter): the drive letter where Ops Server data will be stored" 61 | print "\n\t (required parameter): the drive letter where Ops Server cache files will be stored" 62 | print 63 | sys.exit(1) 64 | 65 | 66 | agsServerAccount = sys.argv[1] 67 | userName = sys.argv[2] 68 | passWord = sys.argv[3] 69 | dataDrive = sys.argv[4] 70 | cacheDrive = sys.argv[5] 71 | 72 | 73 | try: 74 | success = True 75 | 76 | # Perform pre-configuration checks 77 | if preConfigChecks: 78 | success = PreConfigurationChecks.PreConfigChecks(userName, passWord) 79 | 80 | if not success: 81 | 82 | print 83 | print "\t**************************" 84 | print "\tERROR:" 85 | print "\tPre-Configuration checks FAILED." 86 | print "\tExiting configuration process." 87 | print "\t**************************" 88 | print 89 | 90 | else: 91 | print 92 | print "\t**************************" 93 | print "\tPre-Configuration checks PASSED." 94 | print "\tContinuing with configuration..." 95 | print "\t**************************" 96 | print 97 | 98 | # Create ArcGIS Server Site 99 | if createSite: 100 | if success: 101 | success = CreateSite.createSite(userName, passWord, 102 | dataDrive, cacheDrive) 103 | 104 | if success: 105 | success = CreateSite.createAGSConnFile(userName, passWord) 106 | 107 | # Create local data stores 108 | if createDataStores: 109 | if success: 110 | success = CreateLocalDataStores.createDataStores( 111 | agsServerAccount, passWord, dataDrive) 112 | 113 | # Register local data stores 114 | if registerDataStores: 115 | sleepTime = 60 116 | if success: 117 | print 'Delaying data store registration {} seconds to allow any previous processes to complete...'.format(sleepTime) 118 | time.sleep(sleepTime) 119 | success = RegisterDataStores.registerDataStores( 120 | sharedDSConfig, False, 121 | userName, passWord, dataDrive) 122 | 123 | 124 | except: 125 | success = False 126 | 127 | # Get the traceback object 128 | tb = sys.exc_info()[2] 129 | tbinfo = traceback.format_tb(tb)[0] 130 | 131 | # Concatenate information together concerning the error into a message string 132 | pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) 133 | 134 | # Print Python error messages for use in Python / Python Window 135 | print 136 | print "***** ERROR ENCOUNTERED *****" 137 | print pymsg + "\n" 138 | 139 | finally: 140 | print 141 | print 142 | if success: 143 | print "Configuration of Ops Server ArcGIS Server/Site completed successfully." 144 | sys.exit(0) 145 | else: 146 | print "ERROR: Configuration of Ops Server ArcGIS Server/Site was _NOT_ completed successfully." 147 | sys.exit(1) 148 | -------------------------------------------------------------------------------- /Install/ArcGISServer/SupportFiles/FederateAGS.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: FederateAGS.bat 16 | rem # 17 | rem # Purpose: Federate ArcGIS Server with portal, set the hosted server, 18 | rem # edit portal's SSL configuration and edit the Utility Services 19 | rem # URLs. 20 | rem # 21 | rem # Prerequisites: 22 | rem # - ArcGIS Server must be installed/authorized and the ArcGIS 23 | rem # Server site must exist. 24 | rem # - Portal for ArcGIS must be installed/authorized. 25 | rem # - ArcGIS Data Store must be installed and created. 26 | rem # - The print and geometry ArcGIS Server services must be started. 27 | rem # 28 | rem #============================================================================== 29 | set ops_ChkErrLevelFile=%~dp0..\..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 30 | echo. 31 | echo. 32 | echo %sectionBreak% 33 | echo Federate ArcGIS Server site with Portal and set the hosted server... 34 | echo (also set some othe properties: SSL properties, Geometry service) 35 | echo. 36 | echo. 37 | echo ^- When the web browser opens the "Sign In" page... 38 | echo ^(the page will be displayed in about minute^) 39 | echo. 40 | echo ^-^-^-^-^-^- Federated/Hosted Server ^-^-^-^-^-^- 41 | echo. 42 | echo 1. Sign in with the primary portal admin user. 43 | echo. 44 | echo. 45 | echo 2. Click on "My Organization" link ^(if not 46 | echo already on the page^). 47 | echo. 48 | echo. 49 | echo 3. Click "Edit Settings". 50 | echo. 51 | echo. 52 | echo 4. Click "Servers" tab on side panel. 53 | echo. 54 | echo. 55 | echo 5. Click "Add Server". 56 | echo. 57 | echo. 58 | echo 6. For "Server URL" property specify^: 59 | echo. 60 | echo https^://%ops_FQDN%/%ops_WebAdaptor_AGS% 61 | echo. 62 | echo. 63 | echo 7. For "Administration URL" property specify^: 64 | echo. 65 | echo https^://%ops_FQDN%^:6443/arcgis 66 | echo. 67 | echo. 68 | echo 8. For "Username/Password" properties specify the 69 | echo name and password of the primary site administrator 70 | echo account that was used to initially log in to Manager 71 | echo and administer ArcGIS Server, see values below^: 72 | echo. 73 | echo For "Username" specify^: %ops_userName% 74 | echo For "Password" specify^: %ops_passWord% 75 | echo. 76 | echo. 77 | echo 9. Click "Add". 78 | echo. 79 | echo. 80 | echo 10. In the "Hosting Server" dropdown select^: 81 | echo. 82 | echo %ops_FQDN%^:6443 83 | echo. 84 | echo. 85 | echo ^-^-^-^-^-^- SSL Property ^-^-^-^-^-^- 86 | echo. 87 | echo 1. Click "Security" tab on side panel. 88 | echo. 89 | echo. 90 | echo 2. Make sure the "Allow access to the portal through SSL only" option is CHECKED. 91 | echo. 92 | echo. 93 | echo ^-^-^-^-^-^- Utility Services ^-^-^-^-^-^- 94 | echo. 95 | echo NOTE: you need to set these URLs; the "Printing" service is used to create 96 | echo thumbnails when you save a web map; and the "Geometry" service is used 97 | echo by various web applications. 98 | echo. 99 | echo 1. Click "Utility Services" tab on side panel. 100 | echo. 101 | echo. 102 | echo 2. Change the "Printing" service URL to: 103 | echo. 104 | echo NOTE: make sure to include the %%20 characters within the URL to represent the spaces 105 | echo in the service URL. 106 | echo. 107 | echo https^://%ops_FQDN%/%ops_WebAdaptor_AGS%/rest/services/Utilities/PrintingTools/GPServer/Export%%20Web%%20Map%%20Task 108 | echo. 109 | echo. 110 | echo. 3. Change the "Geometry" service URL to: 111 | echo. 112 | echo https^://%ops_FQDN%/%ops_WebAdaptor_AGS%/rest/services/Utilities/Geometry/GeometryServer 113 | echo. 114 | echo. 115 | echo ^-^-^-^-^-^- Save Changes to Portal Configuration ^-^-^-^-^-^- 116 | echo. 117 | echo 1. Click "Save" to save all the settings you have modified. 118 | echo. 119 | echo. 120 | echo 2. Sign out of portal. 121 | echo. 122 | echo. 123 | echo 3. Close web browser. 124 | echo. 125 | echo. 126 | PING 127.0.0.1 -n 60 > nul 127 | set execute=%ops_webBrowserExePath% https://%ops_FQDN%/%ops_WebAdaptor_Portal%/home/signin.html? 128 | echo %execute% 129 | echo. 130 | %execute% 131 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 132 | PING 127.0.0.1 -n 3 > nul 133 | -------------------------------------------------------------------------------- /Install/ArcGISServer/SupportFiles/ListPostgresDatabases.sql: -------------------------------------------------------------------------------- 1 | select datname from pg_database; -------------------------------------------------------------------------------- /Install/EsriMapsForOffice/WebContent/InstallEM4OWebContent.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2015 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: InstallEM4OWebContent.bat 16 | rem # 17 | rem # Purpose: Installs Esri Maps for Office Web Content 18 | rem # 19 | rem #============================================================================== 20 | set ops_ChkErrLevelFile=%~dp0..\..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 21 | 22 | echo. 23 | echo %sectionBreak% 24 | echo Install Esri Maps for Office Web Content 25 | 26 | REM --------------------------------------------------------------------- 27 | REM Install Esri Maps for Office Web Content 28 | REM --------------------------------------------------------------------- 29 | echo. 30 | echo --Installing Esri Maps for Office Web Content... 31 | echo. 32 | set execute=%ops_softwareRoot%\EsriMapsForOffice\WebContent\Portal_Resources_for_AM4O_4.1_Beta_en.exe /passive 33 | 34 | echo %execute% 35 | echo. 36 | %execute% 37 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 38 | 39 | PING 127.0.0.1 -n 15 > nul -------------------------------------------------------------------------------- /Install/GeoEvent/InstallGeoEvent.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: InstallGeoEvent.bat 16 | rem # 17 | rem # Purpose: Installs ArcGIS GeoEvent Processor Extension for ArcGIS Server 18 | rem # 19 | rem # Prerequisites: ArcGIS Server must be installed, authorized and ArcGIS Server 20 | rem # site must exist. 21 | rem # 22 | rem #============================================================================== 23 | set ops_ChkErrLevelFile=%~dp0..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 24 | 25 | echo. 26 | echo %sectionBreak% 27 | echo Install ArcGIS GeoEvent Extension for ArcGIS Server 28 | 29 | REM --------------------------------------------------------------------- 30 | REM Install GeoEvent Processor Extension 31 | REM --------------------------------------------------------------------- 32 | echo. 33 | echo. 34 | echo --Installing GeoEvent Processor Extension... 35 | echo. 36 | echo Waiting 8 minutes before installing Geoevent... 37 | PING 127.0.0.1 -n 480 > nul 38 | 39 | set execute=%ops_softwareRoot%\ArcGISGeoEvent\setup.exe /qb ^ 40 | PASSWORD=%ops_agsServiceAccountPassword% 41 | echo %execute% 42 | echo. 43 | %execute% 44 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 45 | echo. 46 | echo Giving GeoEvent 8 minutes to finish setting up all it's web services before 47 | echo continuing with the Ops Server configuration... 48 | PING 127.0.0.1 -n 480 > nul 49 | 50 | REM --------------------------------------------------------------------- 51 | REM Unset variables 52 | REM --------------------------------------------------------------------- 53 | set ops_ChkErrLevelFile= 54 | set execute= 55 | 56 | echo. 57 | echo. 58 | echo Finished installing GeoEvent Extension for ArcGIS Server. 59 | echo. 60 | echo. 61 | -------------------------------------------------------------------------------- /Install/GeoEvent/InstallGeoEventPatches.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2015 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: InstallGeoEventPatches.bat 16 | rem # 17 | rem # Purpose: Installs any ArcGIS GeoEvent Processor Extension for 18 | rem # ArcGIS Server patches 19 | rem # 20 | rem # Prerequisites: ArcGIS GeoEvent Processor Extension for ArcGIS Server 21 | rem # must be installed, authorized and ArcGIS Server 22 | rem # 23 | rem #============================================================================== 24 | set ops_ChkErrLevelFile=%~dp0..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 25 | 26 | set winServicename=ArcGISGeoEvent 27 | 28 | REM --------------------------------------------------------------------- 29 | REM Stop Geoevent Windows Service 30 | REM --------------------------------------------------------------------- 31 | echo. 32 | echo %sectionBreak% 33 | echo Install ArcGIS GeoEvent Extension for ArcGIS Server Group Layer Patch 34 | echo. 35 | echo --Stopping the windows service %winServicename%... 36 | net stop %winServicename% 37 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 38 | PING 127.0.0.1 -n 3 > nul 39 | 40 | REM --------------------------------------------------------------------- 41 | REM Install GeoEvent Processor Extension Group Layer Patch 42 | REM --------------------------------------------------------------------- 43 | set replacement_file=webapp-10.3.1.war 44 | set geoevent_install_root=C:\Program Files\ArcGIS\Server\GeoEvent 45 | echo. 46 | echo --Replacing originally installed Geoevent %replacement_file% file. 47 | echo. 48 | set execute=move "%geoevent_install_root%\system\com\esri\geoevent\manager\webapp\10.3.1\%replacement_file%" "%geoevent_install_root%\%replacement_file%_backup" 49 | echo %execute% 50 | echo. 51 | %execute% 52 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 53 | PING 127.0.0.1 -n 3 > nul 54 | 55 | set execute=copy /Y "%ops_softwareRoot%\ArcGISGeoEventPatches\GroupLayerPatch\%replacement_file%" "%geoevent_install_root%\system\com\esri\geoevent\manager\webapp\10.3.1\%replacement_file%" 56 | echo. 57 | echo %execute% 58 | echo. 59 | %execute% 60 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 61 | PING 127.0.0.1 -n 3 > nul 62 | 63 | 64 | REM --------------------------------------------------------------------- 65 | REM Start Geoevent Windows Service 66 | REM --------------------------------------------------------------------- 67 | echo. 68 | echo --Starting the windows service %winServicename%... 69 | net start %winServicename% 70 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 71 | 72 | echo. 73 | echo Waiting 2 minutes before continuing with the Ops Server configuration... 74 | PING 127.0.0.1 -n 120 > nul 75 | 76 | 77 | REM --------------------------------------------------------------------- 78 | REM Unset variables 79 | REM --------------------------------------------------------------------- 80 | set ops_ChkErrLevelFile= 81 | set execute= 82 | set winServicename= 83 | set replacement_file= 84 | set geoevent_install_root= 85 | 86 | echo. 87 | echo. 88 | echo Finished installing ArcGIS GeoEvent Extension for ArcGIS Server Group Layer Patch 89 | echo. 90 | echo. 91 | -------------------------------------------------------------------------------- /Install/InstallIIS.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem #------------------------------------------------------------------------------ 3 | rem # Copyright 2014 Esri 4 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 5 | rem # you may not use this file except in compliance with the License. 6 | rem # You may obtain a copy of the License at 7 | rem # 8 | rem # http://www.apache.org/licenses/LICENSE-2.0 9 | rem # 10 | rem # Unless required by applicable law or agreed to in writing, software 11 | rem # distributed under the License is distributed on an "AS IS" BASIS, 12 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | rem # See the License for the specific language governing permissions and 14 | rem # limitations under the License. 15 | rem #============================================================================== 16 | rem # Name: InstallIIS.bat 17 | rem # 18 | rem # Purpose: Installs IIS, .NET framework 3.5 and configures certain 19 | rem # aspects of the IIS configuration. 20 | rem # 21 | rem #============================================================================== 22 | title Internet Information Server ^(IIS^) Installer 23 | 24 | set ops_scriptName=%0 25 | 26 | REM --------------------------------------------------------------------- 27 | REM Set user specified variables 28 | REM --------------------------------------------------------------------- 29 | Call InstallSettings.bat 30 | set sectionBreak========================================================================= 31 | 32 | REM --------------------------------------------------------------------- 33 | REM Check if command prompt is running in elevated permissions mode 34 | REM (i.e. "run as administrator) 35 | REM --------------------------------------------------------------------- 36 | echo. 37 | echo --Checking if Windows Command window is running as administrator 38 | echo by querying LOCAL SERVICE user registry entries... 39 | echo. 40 | reg query HKU\S-1-5-19 41 | if "%ERRORLEVEL%"=="1" ( 42 | echo. 43 | echo ********************************************************** 44 | echo ** ERROR: 45 | echo ** You are _NOT_ running Windows Command window 46 | echo ** in elevated administrator mode ^(i.e., the CMD.exe 47 | echo ** must be "Run as administrator"^). 48 | echo ** Exiting %ops_scriptName% 49 | echo ********************************************************** 50 | echo. 51 | goto end 52 | ) 53 | cls 54 | 55 | REM --------------------------------------------------------------------- 56 | REM Check if user "installed" configuration script in correct location 57 | REM --------------------------------------------------------------------- 58 | echo. 59 | echo --Checking if installation scripts are installed in the correct location... 60 | 61 | set ops_ScriptRootName=ops-server-config 62 | set ops_ScriptRoot=C:\%ops_ScriptRootName%\ 63 | 64 | echo %~dp0 | find /I "%ops_ScriptRoot%" 65 | 66 | if "%ERRORLEVEL%"=="1" ( 67 | echo. 68 | echo ********************************************************** 69 | echo ** ERROR: 70 | echo ** The '%ops_ScriptRootName%' folder is not installed in 71 | echo ** the correct location. It should be located at: 72 | echo ** %ops_ScriptRoot% 73 | echo ** Exiting %ops_scriptName%. 74 | echo ********************************************************** 75 | echo. 76 | goto end 77 | ) 78 | cls 79 | 80 | :start 81 | REM --------------------------------------------------------------------- 82 | REM Start Block 83 | REM --------------------------------------------------------------------- 84 | echo ************************************************************************* 85 | echo * Internet Information Server ^(IIS^) Installer * 86 | echo ************************************************************************* 87 | echo. This script: 88 | echo. - Installs IIS. 89 | echo. - Installs .Net Framework 3.5 90 | echo. - Sets the IIS default document 91 | echo. - Adds additional IIS MIME types required by Ops Server components. 92 | echo. 93 | echo 1. Install 94 | echo. 95 | echo 0. Quit 96 | echo. 97 | 98 | set /p choice="Enter the number of your choice: " 99 | 100 | if "%choice%"=="1" ( 101 | goto Install 102 | ) 103 | if "%choice%"=="0" exit 104 | echo Invalid choice: %choice% 105 | echo. 106 | pause 107 | cls 108 | goto start 109 | 110 | :Install 111 | REM --------------------------------------------------------------------- 112 | REM Install Software 113 | REM --------------------------------------------------------------------- 114 | echo. 115 | echo Start at: 116 | date /T 117 | time /T 118 | echo. 119 | echo %sectionBreak% 120 | echo Install IIS and other prerequisites for ArcGIS Web Adaptor for IIS 121 | echo. 122 | Call %~dp0WebAdaptorIIS\InstallWebAdaptorPrerequisites.bat 123 | PING 127.0.0.1 -n 3 > nul 124 | 125 | 126 | REM --------------------------------------------------------------------- 127 | REM Open Server Manager so users who have a domain certicate server 128 | REM can create a domain certificate and bind to https 129 | REM --------------------------------------------------------------------- 130 | echo. 131 | echo %sectionBreak% 132 | echo Create domain certificate (applies only to those users who 133 | echo have a domain certificate server and want to use a domain 134 | echo certificate with Portal for ArcGIS/ArcGIS Server) and bind to https 135 | echo. 136 | Call %~dp0WebAdaptorIIS\CreateCertificate.bat 137 | goto end 138 | 139 | :end 140 | echo. 141 | echo Execution of %ops_scriptName% script completed. 142 | date /T 143 | time /T 144 | echo. 145 | pause 146 | REM exit -------------------------------------------------------------------------------- /Install/MessageSimulator/InstallMessageSimulator.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: InstallMessageSimulator.bat 16 | rem # 17 | rem # Purpose: Install Message Simulator 18 | rem # 19 | rem #============================================================================== 20 | set ops_ChkErrLevelFile=%~dp0..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 21 | 22 | echo. 23 | echo %sectionBreak% 24 | echo Install Message Simulator 25 | 26 | REM --------------------------------------------------------------------- 27 | REM Copy Message Simulator files 28 | REM --------------------------------------------------------------------- 29 | set ops_destPath="C:\MessageSimulator" 30 | echo. 31 | echo. 32 | echo --Copying Message Simulator folders/files... 33 | echo. 34 | set execute=START /WAIT robocopy %ops_softwareRoot%\MessageSimulator\ %ops_destPath% *.* /S 35 | echo %execute% 36 | echo. 37 | %execute% 38 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% ROBOCOPY 39 | PING 127.0.0.1 -n 3 > nul 40 | 41 | REM --------------------------------------------------------------------- 42 | REM Create Windows Scheduled Task 43 | REM --------------------------------------------------------------------- 44 | set ops_taskName=MessageSimulator 45 | echo. 46 | echo. 47 | echo --Create Windows Scheduled Task for Message Simulator... 48 | echo. 49 | REM /F switch will create the task even if it already exists. 50 | REM 51 | set execute=SCHTASKS /Create /XML %~dp0SupportFiles\MessageSimulatorTask.xml /TN %ops_taskName% /F 52 | echo %execute% 53 | echo. 54 | %execute% 55 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 56 | PING 127.0.0.1 -n 3 > nul 57 | 58 | echo. 59 | echo. 60 | echo --Disable the Message Simulator task... 61 | echo. 62 | set execute=SCHTASKS /Change /TN %ops_taskName% /DISABLE 63 | echo %execute% 64 | echo. 65 | %execute% 66 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 67 | PING 127.0.0.1 -n 3 > nul -------------------------------------------------------------------------------- /Install/MessageSimulator/MessageSimulator.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem #------------------------------------------------------------------------------ 3 | rem # Copyright 2015 Esri 4 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 5 | rem # you may not use this file except in compliance with the License. 6 | rem # You may obtain a copy of the License at 7 | rem # 8 | rem # http://www.apache.org/licenses/LICENSE-2.0 9 | rem # 10 | rem # Unless required by applicable law or agreed to in writing, software 11 | rem # distributed under the License is distributed on an "AS IS" BASIS, 12 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | rem # See the License for the specific language governing permissions and 14 | rem # limitations under the License. 15 | rem #============================================================================== 16 | rem # Name: MessageSimulator.bat 17 | rem # 18 | rem # Purpose: Enables and run the OS Schechuled Task "MessageSimulator" 19 | rem # 20 | rem #============================================================================== 21 | set ops_scriptName=MessageSimulator.bat 22 | set ops_ChkErrLevelFile=%~dp0..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 23 | 24 | set ops_taskName=MessageSimulator 25 | 26 | set sectionBreak=================================================================================== 27 | 28 | REM --------------------------------------------------------------------- 29 | REM Check if command prompt is running in elevated permissions mode 30 | REM (i.e. "run as administrator) 31 | REM --------------------------------------------------------------------- 32 | echo. 33 | echo --Checking if Windows Command window is running as administrator 34 | echo by querying LOCAL SERVICE user registry entries... 35 | echo. 36 | reg query HKU\S-1-5-19 37 | if "%ERRORLEVEL%"=="1" ( 38 | echo. 39 | echo ********************************************************** 40 | echo ** ERROR: 41 | echo ** You are _NOT_ running Windows Command window 42 | echo ** in elevated administrator mode ^(i.e., the CMD.exe 43 | echo ** must be "Run as administrator"^). 44 | echo ** Exiting %ops_scriptName%. 45 | echo ********************************************************** 46 | echo. 47 | goto end 48 | ) 49 | cls 50 | 51 | echo. 52 | echo %sectionBreak% 53 | echo Run %ops_taskName% scheduled task 54 | 55 | REM --------------------------------------------------------------------- 56 | REM Enable Windows Scheduled Task 57 | REM --------------------------------------------------------------------- 58 | echo. 59 | echo. 60 | echo --Enable Windows Scheduled Task for %ops_taskName%... 61 | echo. 62 | set execute=SCHTASKS /Change /TN %ops_taskName% /ENABLE 63 | echo %execute% 64 | echo. 65 | %execute% 66 | set error=%ERRORLEVEL% 67 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 68 | PING 127.0.0.1 -n 3 > nul 69 | 70 | REM If enable failed end script 71 | if "%error%"=="1" ( 72 | goto end 73 | ) 74 | 75 | 76 | REM --------------------------------------------------------------------- 77 | REM Run Windows Scheduled Task 78 | REM --------------------------------------------------------------------- 79 | echo. 80 | echo. 81 | echo --Run the %ops_taskName% task... 82 | echo. 83 | set execute=SCHTASKS /Run /TN %ops_taskName% 84 | echo %execute% 85 | echo. 86 | %execute% 87 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 88 | PING 127.0.0.1 -n 3 > nul 89 | 90 | :end 91 | REM --------------------------------------------------------------------- 92 | REM End Block 93 | REM --------------------------------------------------------------------- 94 | @echo on -------------------------------------------------------------------------------- /Install/MessageSimulator/SupportFiles/MessageSimulatorTask.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Esri/ops-server-config/5768cf45eb9e9aeba0f68c15cdd452287b8af746/Install/MessageSimulator/SupportFiles/MessageSimulatorTask.xml -------------------------------------------------------------------------------- /Install/OpsDashboardUtility/CreateOneClickInstaller.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: CreateOneClickInstaller.bat 16 | rem # 17 | rem # Purpose: Creates the Operations Dashboard One-click Installer and copies 18 | rem # the Operations Dashboard installer and the help files to the 19 | rem # appropriate portal deployment folder. 20 | rem # 21 | rem # Prerequisites: 22 | rem # - .NET framework 4.5 must be installed. 23 | rem # - Portal for ArcGIS must be installed. 24 | rem # 25 | rem #============================================================================== 26 | set ops_ChkErrLevelFile=%~dp0..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 27 | 28 | echo. 29 | echo. 30 | echo %sectionBreak% 31 | echo Create the Operations Dashboard One-click Installer... 32 | echo. 33 | echo. 34 | 35 | REM --------------------------------------------------------------------- 36 | REM Create the folder to store the deployment files created by the 37 | REM Ops Dashboard Deployment Utility 38 | REM --------------------------------------------------------------------- 39 | set ops_outputFolder=%ops_tempInstallDir%\OpsDashboardUtilityOutput 40 | 41 | echo --Creating the output folder %ops_outputFolder%... 42 | echo. 43 | 44 | set execute=mkdir %ops_outputFolder% 45 | 46 | if not exist %ops_outputFolder% ( 47 | echo %execute% 48 | echo. 49 | %execute% 50 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 51 | ) 52 | 53 | 54 | REM --------------------------------------------------------------------- 55 | REM Run the Operations Dashboard Deployment Utility 56 | REM --------------------------------------------------------------------- 57 | echo. 58 | echo. 59 | echo --Running the Operations Dashboard Deployment Utility... 60 | echo. 61 | echo. 62 | echo NOTE: When the "Importing a new private signature key" dialog is 63 | echo displayed, click "OK". 64 | echo. 65 | echo. 66 | set execute=START /WAIT %ops_softwareRoot%\OpsDashboardUtility\OperationsDashboardUtility.exe ^ 67 | /outPut %ops_outputFolder% /url https://%ops_FQDN%/%ops_WebAdaptor_Portal% ^ 68 | /certpath %ops_softwareRoot%\OpsDashboardUtility\Certificate\TODO_CHANGE_CERT_FILENAME.pfx ^ 69 | /password TODO_CHANGE_CERT_PASSWORD 70 | echo %execute% 71 | echo. 72 | echo It will take a couple of minutes for the OperationsDashboardUtility.exe to complete. 73 | echo. 74 | %execute% 75 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 76 | PING 127.0.0.1 -n 20 > nul 77 | 78 | 79 | REM ----------------------------------- 80 | REM Copy One-click installer 81 | REM ----------------------------------- 82 | set ops_destPath="C:\Program Files\ArcGIS\Portal\apps\dashboard-win" 83 | echo. 84 | echo. 85 | echo --Copying Ops Dashboard One-click installer files to %ops_destPath%... 86 | echo. 87 | set execute=START /WAIT robocopy %ops_outputFolder%\dashboard-win %ops_destPath% *.* /S 88 | echo %execute% 89 | echo. 90 | %execute% 91 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% ROBOCOPY 92 | 93 | 94 | REM ----------------------------------- 95 | REM Copy help files 96 | REM ----------------------------------- 97 | set ops_destPath="C:\Program Files\ArcGIS\Portal\apps\dashboard-win" 98 | echo. 99 | echo. 100 | echo --Copying Ops Dashboard help files to %ops_destPath%... 101 | echo. 102 | set execute=START /WAIT robocopy %ops_outputFolder%\operations-dashboard %ops_destPath% *.* /S 103 | echo %execute% 104 | echo. 105 | %execute% 106 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% ROBOCOPY 107 | -------------------------------------------------------------------------------- /Install/Portal/InstallPortal.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: InstallPortal.bat 16 | rem # 17 | rem # Purpose: Installs/authorizes Portal for ArcGIS; Configure ArcGIS Server 18 | rem # Services Directory properties to point to locally hosted ArcGIS 19 | rem # for JavaScript API 20 | rem # 21 | rem # Prerequisites: ArcGIS Server must be installed. 22 | rem # 23 | rem #============================================================================== 24 | set ops_ChkErrLevelFile=%~dp0..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 25 | SET FQDN=%ops_FQDN% 26 | 27 | REM --------------------------------------------------------------------- 28 | REM Install Portal for ArcGIS 29 | REM --------------------------------------------------------------------- 30 | echo. 31 | echo %sectionBreak% 32 | echo Install Portal for ArcGIS 33 | echo. 34 | echo --Installing Portal for ArcGIS... 35 | echo. 36 | set execute=%ops_softwareRoot%\PortalForArcGIS\setup.exe /qb CONTENTDIR=C:\arcgisportal ^ 37 | USER_NAME=%ops_portalServiceAccount% PASSWORD=%ops_portalServiceAccountPassword% 38 | 39 | echo %execute% 40 | echo. 41 | %execute% 42 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 43 | echo Adding a 2 minute delay before moving on to authorize portal... 44 | PING 127.0.0.1 -n 120 > nul 45 | 46 | REM --------------------------------------------------------------------- 47 | REM Authorize Portal for ArcGIS 48 | REM --------------------------------------------------------------------- 49 | echo. 50 | echo --Authorizing Portal for ArcGIS... 51 | echo. 52 | echo Will use the following file to authorize. If no file found, 53 | echo Software Authorization wizard will walk user through process: 54 | echo %ops_PortalAuthFile% 55 | echo. 56 | set execute=%ops_softwareAuthExePath% -S Ver %ops_PortalVersion% 57 | if exist %ops_PortalAuthFile% ( 58 | set execute=%execute% -LIF %ops_PortalAuthFile% 59 | ) else ( 60 | echo Prompting user for authorizing information... 61 | ) 62 | echo. 63 | echo %execute% 64 | echo. 65 | %execute% 66 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 67 | PING 127.0.0.1 -n 25 > nul 68 | 69 | REM --------------------------------------------------------------------- 70 | REM Configure ArcGIS Server Services Directory properties to point to 71 | REM locally hosted ArcGIS for JavaScript API 72 | REM --------------------------------------------------------------------- 73 | echo. 74 | echo %sectionBreak% 75 | echo Configure ArcGIS Server Services Directory to point to 76 | echo locally hosted ArcGIS for JavaScript API... 77 | echo. 78 | Call "%~dp0..\..\SupportFiles\SetServicesDirectoryProps.py" ^ 79 | %FQDN% 6443 %ops_userName% %ops_passWord% Yes 80 | echo. 81 | -------------------------------------------------------------------------------- /Install/Portal/Portal/CreatePortalAdminAccount.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: CreatePortalAdminAccount.bat 16 | rem # 17 | rem # Purpose: Creates the Portal for ArcGIS Admin Account. 18 | rem # 19 | rem # Prerequisites: Portal for ArcGIS must be installed. 20 | rem # 21 | rem #============================================================================== 22 | set ops_ChkErrLevelFile=%~dp0..\..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 23 | echo. 24 | echo. 25 | echo %sectionBreak% 26 | echo Create the Portal for ArcGIS initial administrator account... 27 | echo. 28 | echo ^- When the web browser opens the "Initial Administrator Account Required" page... 29 | echo ^(about a 2.5 minute delay has been added) 30 | echo. 31 | echo NOTEs: 32 | echo - The web browser will open in about two minutes; a delay has been 33 | echo added to give the portal service time to restart. 34 | echo. 35 | echo - If the web browser opens, but the page does not display, refresh 36 | echo the web page. 37 | echo. 38 | echo. 39 | echo 1. Enter the required information to create the admin user. 40 | echo. 41 | echo *************** WARNING *************** 42 | echo *** User/password for portal administrator account must be the 43 | echo *** same as that used for the ArcGIS Server site. 44 | echo *** 45 | echo *** User must be set as: %ops_userName% 46 | echo *** Password must be set as: %ops_passWord% 47 | echo *** 48 | echo ******************************************************** 49 | echo. 50 | echo. 51 | echo 2. Click "Create". 52 | echo. 53 | echo. 54 | echo 3. If creation of the admin account is successful, 55 | echo the "Account Created" dialog will be displayed. 56 | echo Click "OK" on this dialog. 57 | echo. 58 | echo. 59 | echo 4. When the "Web Adaptor Required" web page is displayed, 60 | echo you can ignore the instructions on this web page instructing 61 | echo you to install and config the web adaptor. The web adaptor has 62 | echo already been installed and it will be configured for portal 63 | echo automatically in subsequent steps. 64 | echo. 65 | echo. 66 | echo 5. Test if you can sign in by clicking on the "Sign In" link located 67 | echo in the upper-right of the web page. 68 | echo. 69 | echo. 70 | echo 6. Sign Out of the portal. 71 | echo. 72 | echo. 73 | echo 7. Close the web browser. 74 | echo. 75 | echo. 76 | PING 127.0.0.1 -n 160 > nul 77 | set execute=%ops_webBrowserExePath% https://%ops_FQDN%:7443/arcgis/home/signin.html? 78 | echo %execute% 79 | echo. 80 | %execute% 81 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 82 | -------------------------------------------------------------------------------- /Install/PostgreSQL/InstallPostgreSQL.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: InstallPostgreSQL.bat 16 | rem # 17 | rem # Purpose: Installs PostgreSQL Database Server 18 | rem # 19 | rem #============================================================================== 20 | set ops_ChkErrLevelFile=%~dp0..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 21 | 22 | echo. 23 | echo %sectionBreak% 24 | echo Install PostrgreSQL Database Server 25 | 26 | REM --------------------------------------------------------------------- 27 | REM Install PostgreSQL server 28 | REM --------------------------------------------------------------------- 29 | echo. 30 | echo --Installing PostgreSQL... 31 | echo. 32 | 33 | set execute=%ops_softwareRoot%\Database\PostgreSQL_9.3.5\Postgres_Installation\postgresql-9.3.5-1-windows-x64.exe ^ 34 | --unattendedmodeui minimal --mode unattended --superaccount postgres ^ 35 | --servicename postgreSQL --serviceaccount %ops_rdbmsServiceAccount% ^ 36 | --servicepassword %ops_rdbmsServiceAccountPassword% ^ 37 | --superpassword %ops_passWord% --serverport 5432 ^ 38 | --prefix %ops_postgresqlInstallDIR% --datadir %ops_postgresqlDataDIR% 39 | 40 | echo %execute% 41 | echo. 42 | %execute% 43 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 44 | 45 | REM --------------------------------------------------------------------- 46 | REM Replace postgreSQL configuration file 47 | REM --------------------------------------------------------------------- 48 | echo. 49 | echo --Replacing originally installed PostgreSQL configuration file (postgresql.conf) 50 | echo with custom file modified to disable database logging and with 51 | echo increased number of allowed connections. 52 | echo. 53 | set execute=move %ops_postgresqlDataDIR%\postgresql.conf %ops_postgresqlDataDIR%\postgresql.conf_bak 54 | echo %execute% 55 | echo. 56 | %execute% 57 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 58 | 59 | set execute=copy /Y %~dp0SupportFiles\postgresql.conf %ops_postgresqlDataDIR%\postgresql.conf 60 | echo. 61 | echo %execute% 62 | echo. 63 | %execute% 64 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 65 | 66 | 67 | REM --------------------------------------------------------------------- 68 | REM Restart the PostgreSQL service because we switched out the config file 69 | REM --------------------------------------------------------------------- 70 | set winServicename=postgreSQL 71 | echo. 72 | echo --Restarting %winServicename% service... 73 | echo. 74 | 75 | net stop %winServicename% 76 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 77 | 78 | net start %winServicename% 79 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 80 | 81 | PING 127.0.0.1 -n 3 > nul 82 | -------------------------------------------------------------------------------- /Install/PredictiveAnalysis/InstallPredictiveAnalysis.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2015 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: InstallPredictiveAnalysis.bat 16 | rem # 17 | rem # Purpose: Installs the Predictive Analysis Web Services 18 | rem # 19 | rem # Prerequisites: ArcGIS Server must be installed, authorized and ArcGIS Server 20 | rem # site must exist. 21 | rem # 22 | rem #============================================================================== 23 | set ops_ChkErrLevelFile=%~dp0..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 24 | 25 | echo. 26 | echo %sectionBreak% 27 | echo Install Predictive Analysis Web Services 28 | echo. 29 | echo. 30 | echo --Installing Predictive Analysis Web Services... 31 | echo. 32 | 33 | set execute=%ops_softwareRoot%\PredictiveAnalysis\setup.exe /qb 34 | echo %execute% 35 | echo. 36 | %execute% 37 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 38 | echo. 39 | PING 127.0.0.1 -n 3 > nul 40 | 41 | REM --------------------------------------------------------------------- 42 | REM Unset variables 43 | REM --------------------------------------------------------------------- 44 | set ops_ChkErrLevelFile= 45 | set execute= 46 | 47 | echo. 48 | echo Finished installing Predictive Analysis Web Services. 49 | echo. 50 | echo. 51 | -------------------------------------------------------------------------------- /Install/WebAdaptorIIS/CreateCertificate.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: CreateCertificate.bat 16 | rem # 17 | rem # Purpose: Enable SSL and bind the SSL certificate to web site that hosts 18 | rem # the web adaptor 19 | rem # 20 | rem # Prerequisites: IIS must be installed. 21 | rem # 22 | rem #============================================================================== 23 | echo. 24 | echo. 25 | echo %sectionBreak% 26 | echo Enable SSL on your web server... 27 | echo. 28 | echo To enable SSL on your web server you will need to: 29 | echo ^- Obtain a SSL certificate from a Certificate Authority or create a domain certificate. 30 | echo ^- Bind the certificate to the website that will host the ArcGIS Web Adaptor for IIS. 31 | echo See the instructions below. 32 | echo. 33 | echo. 34 | echo When the "Internet Information Services ^(IIS^) Manager" interface opens, perform the following: 35 | echo. 36 | echo. 37 | echo 1. From the Connections panel, click on the server node and then 38 | echo double-click on "Server Certificates" ^(in IIS group^). 39 | echo. 40 | echo. 41 | echo ^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^- 42 | echo 2. Create Certificate Authority certificate __OR__ domain certificate. 43 | echo. 44 | echo. 45 | echo ^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^- 46 | echo. To create Certificate Authority certificate: 47 | echo ^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^- 48 | echo. 49 | echo For more detailed information see the following web page: 50 | echo. 51 | echo http://www.sslshopper.com/article-installing-an-ssl-certificate-in-windows-server-2008-iis-7.0.html 52 | echo. 53 | echo. 54 | echo 2a. From the "Actions" panel, click "Create Certificate Request". 55 | echo. 56 | echo. 57 | echo 2b. On the "Distinguished Name Properties" dialog... 58 | echo. 59 | echo ^- Enter... 60 | echo. 61 | echo Common name: %ops_FQDN% 62 | echo Organization: "Specify your organization" 63 | echo Organization unit: "Specify organization unit" 64 | echo City^/locality: "Specify your city/locality" ^(no abbreviations^) 65 | echo State^/province: "Specify your state/provice" ^(no abbreviations^) 66 | echo Country^/region: "Specify your country/region" 67 | echo. 68 | echo ^- Click "Next". 69 | echo. 70 | echo. 71 | echo 2c. On the "Cryptographic Service Provider Properties" dialog... 72 | echo. 73 | echo ^- Use the default "Cryptographic service provider" 74 | echo ^(i.e. Microsoft RSA SChannel Cryptographic Provider^) 75 | echo. 76 | echo ^- Select a minimum bit length of at least 2048 or higher. 77 | echo. 78 | echo ^- Click "Next" button. 79 | echo. 80 | echo. 81 | echo 2d. On the "File Name" dialog... 82 | echo. 83 | echo ^- Specify a file name for the certificate request (CSR file). 84 | echo. 85 | echo ^- Click "Finish". 86 | echo. 87 | echo. 88 | echo 2e. Use the contents of the CSR file to obtain a certificate 89 | echo from a Certficate Authority. 90 | echo. 91 | echo. 92 | echo 2f. When you have obtained the certificate from a Certficate 93 | echo Authority, install the certificate by clicking on 94 | echo "Complete Certficate Request". 95 | echo. 96 | echo. 97 | echo. 2g. On the "Specify Certificate Authority Response" dialog... 98 | echo. 99 | echo ^- Browse to the certificate file. 100 | echo. 101 | echo ^- Within the "Friendly name" textbox enter a friendly name 102 | echo such as "%ops_FQDN%". 103 | echo. 104 | echo. 105 | echo 2h. Proceed to step #3. 106 | echo. 107 | echo. 108 | echo ^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^- 109 | echo. To create domain certificate: 110 | echo ^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^- 111 | echo. 112 | echo 2a. From the "Actions" panel, click "Create Domain Certificate". 113 | echo. 114 | echo. 115 | echo 2b. On the "Distinguished Name Properties" dialog enter... 116 | echo. 117 | echo. 118 | echo Common name: %ops_FQDN% 119 | echo Organization: "Specify your organization" 120 | echo Organization unit: "Specify organization unit" 121 | echo City^/locality: "Specify your city/locality" ^(no abbreviations^) 122 | echo State^/province: "Specify your state/provice" ^(no abbreviations^) 123 | echo Country^/region: "Specify your country/region" 124 | echo. 125 | echo Then click "Next" button. 126 | echo. 127 | echo. 128 | echo 2c. On the "Online Certificaion Authority" dialog... 129 | echo. 130 | echo ^- Click "Select", click the certificate authority and click "OK". 131 | echo. 132 | echo ^- Within the "Friendly name" textbox enter a friendly name 133 | echo such as "%ops_FQDN%". 134 | echo. 135 | echo ^- Click "Finish". 136 | echo. 137 | echo. 138 | echo 2d. Proceed to step #3. 139 | echo. 140 | echo. 141 | echo ^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^- 142 | echo. 143 | echo 3. Bind the certificate to the web site that will host the web adaptor. 144 | echo. 145 | echo. 146 | echo 3a. From the "Connections" panel, navigate to Sites ^> Default Web Site 147 | echo. 148 | echo. 149 | echo 3b. From the "Actions" panel, click "Bindings". 150 | echo. 151 | echo. 152 | echo 3c. On the "Site Bindings" dialog, click "Add"... 153 | echo. 154 | echo ^- Select "https" in "Type" dropdown. 155 | echo. 156 | echo ^- Select the SSL certificate in the "SSL certificate" dropdown. 157 | echo. 158 | echo ^- Click "OK". 159 | echo. 160 | echo ^- On the "Site Bindings" dialog, click "Close". 161 | echo. 162 | echo. 163 | echo 4. Close the "Server Manager" interface; click File ^> Exit. 164 | echo. 165 | echo. 166 | 167 | %windir%\system32\inetsrv\InetMgr.exe 168 | PING 127.0.0.1 -n 3 > nul 169 | -------------------------------------------------------------------------------- /Install/WebAdaptorIIS/InstallWebAdaptor.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: InstallWebAdaptor.bat 16 | rem # 17 | rem # Purpose: Install ArcGIS Web Adpator for IIS (installs one web adaptor 18 | rem # for ArcGIS Server and one for Portal for ArcGIS) 19 | rem # 20 | rem # Prerequisites: Web Adaptor prerequisites and ArcGIS Server must be installed. 21 | rem # 22 | rem #============================================================================== 23 | set ops_ChkErrLevelFile=%~dp0..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 24 | 25 | echo. 26 | echo %sectionBreak% 27 | echo Install ArcGIS Web Adaptor for IIS 28 | echo. 29 | echo --Installing Web Adaptor for ArcGIS Server ^(%ops_WebAdaptor_AGS%^)... 30 | echo. 31 | set execute=%ops_softwareRoot%\WebAdaptorIIS\setup.exe /qb ADDLOCAL=ALL VDIRNAME=%ops_WebAdaptor_AGS% WEBSITE_ID=1 PORT=80 32 | echo %execute% 33 | echo. 34 | %execute% 35 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 36 | PING 127.0.0.1 -n 6 > nul 37 | echo. 38 | echo. 39 | echo --Installing Web Adaptor for Portal for ArcGIS ^(%ops_WebAdaptor_Portal%^)... 40 | echo. 41 | set execute=%ops_softwareRoot%\WebAdaptorIIS\setup.exe /qb ADDLOCAL=ALL VDIRNAME=%ops_WebAdaptor_Portal% WEBSITE_ID=1 PORT=80 42 | echo %execute% 43 | echo. 44 | %execute% 45 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 46 | PING 127.0.0.1 -n 6 > nul -------------------------------------------------------------------------------- /Install/WebAdaptorIIS/InstallWebAdaptorPrerequisites.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: InstallWebAdaptorPrerequisites.bat 16 | rem # 17 | rem # Purpose: Install Web Adpator Prerequisites: 18 | rem # - IIS Roles and IIS features 19 | rem # - .Net framework 3.5 20 | rem # Also sets the IIS default document and adds additional MIME 21 | rem # types needed for Ops Server applications to IIS. 22 | rem # 23 | rem #============================================================================== 24 | 25 | REM --------------------------------------------------------------------- 26 | REM Install IIS Role and .Net Framework Feature 27 | REM --------------------------------------------------------------------- 28 | Call %~dp0SupportFiles\InstallRolesAndFeatures.bat 29 | 30 | REM --------------------------------------------------------------------- 31 | REM Set the IIS default document 32 | REM --------------------------------------------------------------------- 33 | Call %~dp0SupportFiles\SetIISDefaultDocument.bat 34 | 35 | REM --------------------------------------------------------------------- 36 | REM Modify IIS as needed for Ops Server 37 | REM --------------------------------------------------------------------- 38 | REM Add additional MIME types 39 | Call %~dp0SupportFiles\AddIISMimeTypes.bat 40 | PING 127.0.0.1 -n 3 > nul -------------------------------------------------------------------------------- /Install/WebAdaptorIIS/RegisterAGSwithWebAdaptorHTTPS.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: RegisterAGSwithWebAdaptorHTTPS.bat 16 | rem # 17 | rem # Purpose: Register ArcGIS Server with the Web Adpator for IIS through SSL 18 | rem # 19 | rem # Prerequisites: ArcGIS for Server and Web Adaptor for IIS must be installed. 20 | rem # 21 | rem #============================================================================== 22 | set ops_ChkErrLevelFile=%~dp0..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 23 | 24 | echo. 25 | echo. 26 | echo %sectionBreak% 27 | echo Register ArcGIS Server with the Web Adaptor for IIS ^(HTTPS^)... 28 | echo. 29 | 30 | set execute=%ops_ConfWebAdaptorExePath% /m server /w https://%ops_FQDN%/%ops_WebAdaptor_AGS%/webadaptor /g https://%ops_FQDN%:6443 ^ 31 | /u %ops_userName% /p %ops_passWord% /a true 32 | 33 | if exist %ops_ConfWebAdaptorExePath% ( 34 | echo %execute% 35 | %execute% 36 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 37 | PING 127.0.0.1 -n 3 > nul 38 | 39 | ) else ( 40 | echo ********************************************************** 41 | echo ** ERROR: 42 | echo ** Could not register ArcGIS Server with the WebAdaptor. 43 | echo ** The executable '%ops_ConfWebAdaptorExePath%' 44 | echo ** does not exist. 45 | echo ** Exiting RegisteringAGSwithWebAdaptor.bat. 46 | echo ********************************************************** 47 | echo. 48 | Call %ops_ChkErrLevelFile% 1 49 | ) -------------------------------------------------------------------------------- /Install/WebAdaptorIIS/RegisterPortalwithWebAdaptor.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: RegisterPortalwithWebAdaptor.bat 16 | rem # 17 | rem # Purpose: Register Portal for ArcGIS with the Web Adpator for IIS 18 | rem # 19 | rem # Prerequisites: Portal for ArcGIS and Web Adaptor for IIS must be installed. 20 | rem # 21 | rem #============================================================================== 22 | set ops_ChkErrLevelFile=%~dp0..\..\SupportFiles\BatchFiles\CheckErrorLevel.bat 23 | 24 | echo. 25 | echo %sectionBreak% 26 | echo Register Portal for ArcGIS with the Web Adpator for IIS... 27 | echo. 28 | echo NOTE: a 4 minute delay has been added to give the portal service time to restart. 29 | echo. 30 | PING 127.0.0.1 -n 240 > nul 31 | set execute=%ops_ConfWebAdaptorExePath% /m portal /w https://%ops_FQDN%/%ops_WebAdaptor_Portal%/webadaptor /g http://%ops_FQDN%:7080 ^ 32 | /u %ops_userName% /p %ops_passWord% 33 | 34 | if exist %ops_ConfWebAdaptorExePath% ( 35 | echo %execute% 36 | %execute% 37 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 38 | PING 127.0.0.1 -n 10 > nul 39 | ) else ( 40 | echo ********************************************************** 41 | echo ** ERROR: 42 | echo ** Could not register Portal for ArcGIS with the WebAdaptor. 43 | echo ** The executable '%ops_ConfWebAdaptorExePath%' 44 | echo ** does not exist. 45 | echo ** Exiting RegisteringAGSwithWebAdaptor.bat. 46 | echo ********************************************************** 47 | echo. 48 | Call %ops_ChkErrLevelFile% 1 49 | ) -------------------------------------------------------------------------------- /Install/WebAdaptorIIS/SupportFiles/AddIISMimeTypes.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: AddIISMineTypes.bat 16 | rem # 17 | rem # Purpose: Adds MIME types to IIS 18 | rem # 19 | rem #============================================================================== 20 | echo. 21 | echo --Adding new MIME types... 22 | echo. 23 | echo JSON - .json, application/json 24 | echo. 25 | %windir%\system32\inetsrv\appcmd set config /section:staticContent /+"[fileExtension='.json',mimeType='application/json']" 26 | %windir%\system32\inetsrv\appcmd set config /section:staticContent /+"[fileExtension='.mp4',mimeType='video/mp4']" 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Install/WebAdaptorIIS/SupportFiles/InstallRolesAndFeatures.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: InstallRolesAndFeatures.bat 16 | rem # 17 | rem # Purpose: Enable IIS roles/features and .NET framework 3.5 18 | rem # 19 | rem #============================================================================== 20 | echo. 21 | echo --Installing IIS and .Net Framework 3.5... 22 | echo. 23 | START /WAIT DISM /Online /Enable-Feature /FeatureName:IIS-WebServerRole /FeatureName:IIS-WebServer ^ 24 | /FeatureName:IIS-CommonHttpFeatures /FeatureName:IIS-StaticContent /FeatureName:IIS-DefaultDocument ^ 25 | /FeatureName:IIS-DirectoryBrowsing /FeatureName:IIS-HttpErrors /FeatureName:IIS-ApplicationDevelopment ^ 26 | /FeatureName:IIS-ASPNET /FeatureName:IIS-NetFxExtensibility /FeatureName:IIS-ISAPIExtensions /FeatureName:IIS-ISAPIFilter ^ 27 | /FeatureName:IIS-HealthAndDiagnostics /FeatureName:IIS-HttpLogging /FeatureName:IIS-RequestMonitor ^ 28 | /FeatureName:IIS-Security /FeatureName:IIS-BasicAuthentication /FeatureName:IIS-WindowsAuthentication ^ 29 | /FeatureName:IIS-ClientCertificateMappingAuthentication /FeatureName:IIS-RequestFiltering ^ 30 | /FeatureName:IIS-Performance /FeatureName:IIS-HttpCompressionStatic /FeatureName:IIS-WebServerManagementTools ^ 31 | /FeatureName:IIS-ManagementConsole /FeatureName:IIS-ManagementScriptingTools /FeatureName:IIS-ManagementService ^ 32 | /FeatureName:IIS-IIS6ManagementCompatibility /FeatureName:IIS-Metabase /FeatureName:NetFx3 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Install/WebAdaptorIIS/SupportFiles/SetIISDefaultDocument.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: SetIISDefaultDocument.bat 16 | rem # 17 | rem # Purpose: Sets the IIS default document 18 | rem # 19 | rem #============================================================================== 20 | echo. 21 | echo --Setting IIS default document... 22 | echo. 23 | %windir%\system32\inetsrv\appcmd set config /section:defaultDocument ^ 24 | /+files.[value='default.ashx'] 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /LICENSE-ThirdParty.txt: -------------------------------------------------------------------------------- 1 | The code in the module https://github.com/Esri/ops-server-config/blob/master/SupportFiles/walkingDirTrees.py 2 | is from section 4.18 "Walking Directory Trees" in the publication "Python Cookbook (TM)", edited by 3 | Alex Martelli and David Ascher, published by O'Reilly Media, Inc. 2002. 4 | 5 | Code credit: Robin Parmar, and Alex Martelli 6 | 7 | The following is the modified Berkeley license which applies to this code: 8 | 9 | Copyright (c) 2001, Robin Parmar, and Alex Martelli 10 | All rights reserved. 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions 13 | are met: 14 | * Redistributions of source code must retain the above copyright 15 | notice, this list of conditions and the following disclaimer. 16 | * Redistributions in binary form must reproduce the above 17 | copyright notice, this list of conditions and the following 18 | disclaimer in the documentation and/or other materials provided 19 | with the distribution. 20 | * Neither the name of the nor the names of its 21 | contributors may be used to endorse or promote products derived 22 | from this software without specific prior written premission. 23 | THIS SOFWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS 27 | OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES); LOSS OF USE, DATA, OR PROFITS; 30 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 31 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 32 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 33 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /Publish/Portal/PortalContentDestroyer.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # Copyright 2014 Esri 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | #============================================================================== 15 | #Name: PortalContentDestroyer.py 16 | # 17 | #Purpose: Deletes all items, groups and users from portal except for 18 | # specified admin account 19 | # 20 | #============================================================================== 21 | 22 | import portalpy 23 | import os 24 | import json 25 | import shutil 26 | from datetime import datetime, timedelta 27 | from portalpy import Portal, parse_hostname, portal_time 28 | import sys 29 | import logging 30 | 31 | logging.basicConfig() 32 | 33 | # Do not delete the content for the following users 34 | exclude_users = ['system_publisher'] 35 | 36 | sectionBreak = '================================================' 37 | 38 | 39 | DEBUG = False 40 | 41 | def val_user_response(value): 42 | do_continue = False 43 | valid_values = ['y', 'yes'] # specified values in lowercase 44 | if not value: 45 | value = '' 46 | value = value.lower().strip().replace(" ","") 47 | if value in valid_values: 48 | do_continue = True 49 | return do_continue 50 | 51 | def printResponse(response): 52 | if response == True: 53 | print "\t\tSuccessful." 54 | else: 55 | print "\t\t*** Error deleting." 56 | 57 | def val_arg_users(portal, specified_users): 58 | values_to_use = [] 59 | exclude_users_list = [] # Contains users that should be excluded 60 | include_users_list = [] # Contains users that should be included 61 | 62 | if specified_users: 63 | specified_users = specified_users.strip() 64 | 65 | # get a list of all portal users 66 | all_users = portal.users() 67 | 68 | # don't delete any of the esri_ users 69 | all_users_modified = [] 70 | for user in all_users: 71 | if not user['username'].startswith('esri_'): 72 | all_users_modified.append(user) 73 | all_users = all_users_modified 74 | 75 | # if there are no specified users then return all users 76 | if specified_users is None: 77 | return all_users 78 | 79 | elif specified_users == "#": 80 | return all_users 81 | 82 | elif specified_users.find("-") == 0: 83 | # Return all the users that _aren't_ in the specified users list. 84 | values_to_use = list(all_users) 85 | exclude_users = specified_users.replace("-","",1) 86 | exclude_users_list = [element.lower().strip() for element in exclude_users.split(",")] 87 | 88 | for exclude_user in exclude_users_list: 89 | for user in all_users: 90 | if exclude_user.lower() == user['username'].lower(): 91 | values_to_use.remove(user) 92 | 93 | return values_to_use 94 | 95 | else: 96 | # Return all the users that _are_ in the specified users list 97 | include_users_list = [element.lower().strip() for element in specified_users.split(",")] 98 | 99 | for include_user in include_users_list: 100 | for user in all_users: 101 | if include_user.lower() == user['username'].lower(): 102 | if user not in values_to_use: 103 | values_to_use.append(user) 104 | 105 | return values_to_use 106 | 107 | def main(): 108 | 109 | scriptName = sys.argv[0] 110 | specified_users = None 111 | 112 | # --------------------------------------------------------------------- 113 | # Check arguments 114 | # --------------------------------------------------------------------- 115 | if len(sys.argv) < 4: 116 | print '\n' + scriptName + ' {UsersToDelete}' 117 | 118 | print '\nWhere:' 119 | print '\n\t (required parameter): URL of Portal to delete content (i.e. https://fully_qualified_domain_name/arcgis)' 120 | print '\n\t (required parameter): Portal user that has administrator role.' 121 | print '\n\t (required parameter): Password for AdminUser.' 122 | print '\n\t{UsersToDelete} (optional):' 123 | print '\t\t-By default, all users are deleted.' 124 | print '\t\t-To delete only specific users, specify comma delimited list of users, i.e. user1,user2,...' 125 | print '\t\t-To delete ALL except specific users, specify comma delimited ' 126 | print '\t\t list of users not to delete using "-" prefix, i.e. -user1,user2,...' 127 | sys.exit(1) 128 | 129 | # Set variables from script parameters 130 | portal_address = sys.argv[1] 131 | adminuser = sys.argv[2] 132 | adminpassword = sys.argv[3] 133 | if len(sys.argv) > 4: 134 | specified_users = sys.argv[4] 135 | 136 | # Add specified user parameter value to exclude list. 137 | if adminuser not in exclude_users: 138 | exclude_users.append(adminuser) 139 | 140 | # Create portal object based on specified connection information 141 | portaladmin = Portal(portal_address, adminuser, adminpassword) 142 | portalProps = portaladmin.properties 143 | 144 | print sectionBreak 145 | print "Deleting Portal Content" 146 | print sectionBreak 147 | print "Portal: " + portaladmin.hostname 148 | print "Hardcoded users to exclude from delete: " + str(exclude_users) 149 | print "User specified users to include/exclude(-) from delete: " + str(specified_users) 150 | print 151 | 152 | print "WARNING: this script will delete all user content in the specified portal: " 153 | print portaladmin.url + "\n" 154 | user_response = raw_input("Do you want to continue? Enter 'y' to continue: ") 155 | 156 | if not val_user_response(user_response): 157 | print "Exiting script..." 158 | sys.exit(1) 159 | 160 | # get a list of users 161 | portal_users_to_del = val_arg_users(portaladmin, specified_users) 162 | 163 | # Remove excluded users from list of users to delete 164 | for user_to_del in portal_users_to_del: 165 | if user_to_del['username'].lower() in exclude_users: 166 | portal_users_to_del.remove(user_to_del) 167 | 168 | if len(portal_users_to_del) == 0: 169 | print "\nWARNING: there are no users to delete. Exiting script." 170 | sys.exit(1) 171 | 172 | # remove their groups and items 173 | for user_dict in portal_users_to_del: 174 | current_user = user_dict['username'] 175 | 176 | print sectionBreak 177 | print "User: \t" + current_user 178 | 179 | # Delete the user and all owned groups and content 180 | resp = portaladmin.delete_user(current_user, cascade=True) 181 | printResponse(resp) 182 | 183 | print "\nDONE: Finished deleting content from portal." 184 | 185 | if __name__ == "__main__": 186 | main() 187 | -------------------------------------------------------------------------------- /Publish/Portal/PrepItemsForExtract.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #------------------------------------------------------------------------------ 3 | # Copyright 2015 Esri 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | #Name: PrepItemsForExtract.py 17 | # 18 | #Purpose: Prepare portal items for extract: 19 | # - Add "Hosted Service" tag to hosted service items 20 | # 21 | #============================================================================== 22 | import sys 23 | import os 24 | import traceback 25 | import logging 26 | 27 | from portalpy import Portal 28 | from FindOrphanedHostedServices import get_hosted_service_items 29 | 30 | logging.basicConfig() 31 | 32 | def format_hosted_item_info(item): 33 | itemID = item.get('id') 34 | itemTitle = item.get('title') 35 | itemOwner = item.get('owner') 36 | itemType = item.get('type') 37 | itemURL = item.get('url') 38 | service = itemURL.split('/Hosted/')[1] 39 | 40 | return "Id: {:<34}Owner: {:<22}Type: {:<17}URL: {:<50}Title: {:<30}".format( 41 | itemID, itemOwner, itemType, service, itemTitle) 42 | 43 | def format_item_info(item): 44 | itemID = item.get('id') 45 | itemTitle = item.get('title') 46 | itemOwner = item.get('owner') 47 | itemType = item.get('type') 48 | 49 | return "Id: {:<34}Owner: {:<25}Type: {:25}Title: {:<40}".format( 50 | itemID, itemOwner, itemType, itemTitle) 51 | 52 | def print_args(): 53 | """ Print script arguments """ 54 | 55 | if len(sys.argv) < 4: 56 | print '\n' + os.path.basename(sys.argv[0]) + \ 57 | ' ' \ 58 | ' ' \ 59 | ' ' 60 | print '\nWhere:' 61 | print '\n\t (required): URL of Portal ' \ 62 | '(i.e. https://fully_qualified_domain_name/arcgis)' 63 | print '\n\t (required): Primary portal administrator user.' 64 | print '\n\t (required): Password for AdminUser.' 65 | return None 66 | else: 67 | # Set variables from parameter values 68 | portal_address = sys.argv[1] 69 | adminuser = sys.argv[2] 70 | password = sys.argv[3] 71 | 72 | return portal_address, adminuser, password 73 | 74 | def main(): 75 | exit_err_code = 1 76 | 77 | # Print/get script arguments 78 | results = print_args() 79 | if not results: 80 | sys.exit(exit_err_code) 81 | portal_address, adminuser, password = results 82 | 83 | total_success = True 84 | title_break_count = 100 85 | section_break_count = 75 86 | search_query = None 87 | 88 | print '=' * title_break_count 89 | print 'Prepare Items for Extract' 90 | print '=' * title_break_count 91 | 92 | try: 93 | 94 | portal = Portal(portal_address, adminuser, password) 95 | 96 | items = portal.search(q=search_query, sort_field='owner') 97 | 98 | # --------------------------------------------------------------------- 99 | # Prepare hosted service items 100 | # --------------------------------------------------------------------- 101 | # Add new tag to hosted service so we can identify the original 102 | # hosted service after the portal items are published to a new portal 103 | 104 | new_tags = ['Hosted Service'] 105 | 106 | print '\n{}'.format('-' * section_break_count) 107 | print '- Prepare Hosted Service Items (Add tags: {})...'.format(', '.join(new_tags)) 108 | 109 | items_to_prep = get_hosted_service_items(portal, items) 110 | 111 | for item_to_prep in items_to_prep: 112 | print '\n {}'.format(format_hosted_item_info(item_to_prep)) 113 | tags = item_to_prep.get('tags') 114 | for new_tag in new_tags: 115 | if new_tag not in tags: 116 | tags.append(new_tag) 117 | # NOTE: have to pass new tags as string and not as a list 118 | resp = portal.update_item(item_to_prep['id'], {'tags':', '.join(tags)}) 119 | if not resp: 120 | print '***ERROR encountered during "update_item".' 121 | total_success = False 122 | 123 | except: 124 | total_success = False 125 | 126 | # Get the traceback object 127 | tb = sys.exc_info()[2] 128 | tbinfo = traceback.format_tb(tb)[0] 129 | 130 | # Concatenate information together concerning the error 131 | # into a message string 132 | pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + \ 133 | "\nError Info:\n" + str(sys.exc_info()[1]) 134 | 135 | # Print Python error messages for use in Python / Python Window 136 | print 137 | print "***** ERROR ENCOUNTERED *****" 138 | print pymsg + "\n" 139 | 140 | finally: 141 | print '\nDone.' 142 | if total_success: 143 | sys.exit(0) 144 | else: 145 | sys.exit(exit_err_code) 146 | 147 | if __name__ == "__main__": 148 | main() 149 | 150 | 151 | -------------------------------------------------------------------------------- /Publish/Portal/UpdateHostedServiceDefinitions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #------------------------------------------------------------------------------ 3 | # Copyright 2015 Esri 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | #Name: UpdateHostedServiceDefinitions.py 17 | # 18 | #Purpose: Update hosted feature service definitions (i.e. service Sync, 19 | # Tracking, Export and edting properties) using JSON file 20 | # created by WriteHostedServiceDefinitions.py. 21 | # 22 | #============================================================================== 23 | import sys 24 | import os 25 | import time 26 | import traceback 27 | import json 28 | from datetime import datetime 29 | totalSuccess = True 30 | 31 | # Add "Root folder"\SupportFiles to sys path inorder to import 32 | # modules in subfolder 33 | sys.path.append(os.path.join(os.path.dirname( 34 | os.path.dirname(os.path.dirname(sys.argv[0]))), "SupportFiles")) 35 | 36 | from AGSRestFunctions import updateHostedFeatureServiceDefinition 37 | 38 | scriptName = os.path.basename(sys.argv[0]) 39 | exitErrCode = 1 40 | 41 | def check_args(): 42 | # --------------------------------------------------------------------- 43 | # Check arguments 44 | # --------------------------------------------------------------------- 45 | 46 | if len(sys.argv) < 7: 47 | 48 | print '\n' + scriptName + ' ' 49 | 50 | print '\nWhere:' 51 | print '\n\t (required): the fully qualified domain name of the ArcGIS Server machine.' 52 | print '\n\t (required): the port number of the ArcGIS Server (specify # if no port).' 53 | print '\n\t (required): ArcGIS Server for ArcGIS site administrator.' 54 | print '\n\t (required): Password for ArcGIS Server for ArcGIS site administrator user.' 55 | print '\n\t (required): Flag indicating if ArcGIS Server requires HTTPS.' 56 | print '\n\t (required) the json file containing the hosted service definitions (created by WriteHostedServiceDefintions.py).' 57 | return None 58 | 59 | else: 60 | 61 | # Set variables from parameter values 62 | server = sys.argv[1] 63 | port = sys.argv[2] 64 | adminuser = sys.argv[3] 65 | password = sys.argv[4] 66 | use_ssl = sys.argv[5] 67 | input_file = sys.argv[6] 68 | 69 | if port.strip() == '#': 70 | port = None 71 | 72 | if use_ssl.strip().lower() in ['yes', 'ye', 'y']: 73 | use_ssl = True 74 | else: 75 | use_ssl = False 76 | 77 | if not os.path.isfile(input_file): 78 | print '\nERROR: The path {} does not exist or is not a file. Exiting script.\n'.format(input_file) 79 | return None 80 | 81 | return server, port, adminuser, password, use_ssl, input_file 82 | 83 | def main(): 84 | 85 | totalSuccess = True 86 | 87 | # ------------------------------------------------- 88 | # Check arguments 89 | # ------------------------------------------------- 90 | results = check_args() 91 | if not results: 92 | sys.exit(exitErrCode) 93 | server, port, adminuser, password, use_ssl, input_file = results 94 | 95 | if use_ssl: 96 | protocol = 'https' 97 | else: 98 | protocol = 'http' 99 | 100 | try: 101 | 102 | os.chdir(os.path.dirname(input_file)) 103 | definitions = json.load(open(os.path.basename(input_file))) 104 | 105 | print '\n{}'.format('=' * 80) 106 | print 'Updating service definition information for hosted feature services' 107 | print '(i.e. editing, sync, export, tracking properties)' 108 | print '{}\n'.format('=' * 80) 109 | 110 | total_num = len(definitions.keys()) 111 | n = 0 112 | for service in definitions.keys(): 113 | n = n + 1 114 | print '-' * 80 115 | print 'Service: {} ({} out of {})'.format(service, n, total_num) 116 | 117 | definition = definitions[service]['updateDefinition'] 118 | 119 | success, status = updateHostedFeatureServiceDefinition(server, port, adminuser, password, service, definition, use_ssl) 120 | print 'Update successful: {}'.format(success) 121 | if not success: 122 | totalSuccess = False 123 | print 'ERROR: {}'.format(status) 124 | 125 | print '\n\nDone executing {}.\n'.format(scriptName) 126 | 127 | except: 128 | totalSuccess = False 129 | 130 | # Get the traceback object 131 | tb = sys.exc_info()[2] 132 | tbinfo = traceback.format_tb(tb)[0] 133 | 134 | # Concatenate information together concerning the error into a message string 135 | pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) 136 | 137 | # Print Python error messages for use in Python / Python Window 138 | print 139 | print "***** ERROR ENCOUNTERED *****" 140 | print pymsg + "\n" 141 | 142 | finally: 143 | if totalSuccess: 144 | sys.exit(0) 145 | else: 146 | sys.exit(exitErrCode) 147 | 148 | 149 | if __name__ == "__main__": 150 | main() 151 | -------------------------------------------------------------------------------- /Publish/Portal/portalpy/README.md: -------------------------------------------------------------------------------- 1 | This is not the official Esri release of the PortalPy module. Please see [Esri/portalpy](https://github.com/Esri/portalpy). 2 | -------------------------------------------------------------------------------- /Publish/Portal/portalpy/config.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # Copyright 2014 Esri 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import logging 16 | 17 | from portalpy import unpack, PortalError 18 | 19 | _log = logging.getLogger(__name__) 20 | 21 | def configure_portal(portal, name=None, desc=None): 22 | props = dict() 23 | if name: 24 | props['name'] = name 25 | if desc: 26 | props['description'] = desc 27 | if props: 28 | portal.update_properties(props) 29 | 30 | def create_basemap_gallery_group(portal, title, desc=None, snippet=None, 31 | tags='Basemap', phone=None, access='org', 32 | invitation_only=True, thumbnail=None, 33 | copy=True, copy_filter=None): 34 | 35 | # If it's a single tenant portal change 'org' access to 'public' access 36 | if not portal.is_multitenant() and access == 'org': 37 | access = 'public' 38 | 39 | # Prepare the group object 40 | group = { 'title': title, 'tags': tags, 'access': access, 41 | 'isinvitationonly': invitation_only } 42 | if desc: 43 | group['description'] = desc 44 | if snippet: 45 | group['snippet'] = snippet 46 | if phone: 47 | group['phone'] = phone 48 | 49 | # Create the group 50 | group_id = portal.create_group(group, thumbnail) 51 | if not group_id: 52 | raise PortalError('Unable to create basemap group: ' + title) 53 | 54 | # Share the contents of the current basemap group, if directed to do so 55 | if copy: 56 | old_group_id = _prop_to_group_id(portal, 'basemapGalleryGroupQuery') 57 | if old_group_id: 58 | item_query = 'group:' + old_group_id 59 | if copy_filter: 60 | item_query += ' ' + copy_filter 61 | item_ids = unpack(portal.search(['id'], item_query, scope='public')) 62 | for item_id in item_ids: 63 | portal.share_item(item_id, [group_id]) 64 | 65 | # Update the portal to use the new basemap gallery group 66 | portal.update_property('basemapGalleryGroupQuery', 'id:' + group_id) 67 | return group_id 68 | 69 | def feature_groups(portal, group_ids, clear_existing=False): 70 | featured_groups = [] 71 | group_ids = unpack(group_ids, 'id') 72 | 73 | # If we're not clearing all existing groups, get the current set of featured 74 | # groups and check to see which groups are already featured. If a group is 75 | # already featured, remove it from the list. 76 | if not clear_existing: 77 | featured_groups = portal.properties().get('featuredGroups') 78 | already_featured_ids = [] 79 | if featured_groups: 80 | for featured_group in featured_groups: 81 | if featured_group['id'] in group_ids: 82 | _log.info('Group ' + featured_group['id'] + ' is already featured') 83 | already_featured_ids.append(featured_group['id']) 84 | group_ids = [id for id in group_ids if id not in already_featured_ids] 85 | 86 | # Add the featured group entries to the array of featured groups (requires 87 | # fetching owner and title from the portal) 88 | for id in group_ids: 89 | group = portal.group(id) 90 | featured_groups.append({'owner': group['owner'], 'id': id, 91 | 'title': group['title']}) 92 | 93 | # Update the featured groups property 94 | if featured_groups: 95 | portal.update_property('featuredGroups', featured_groups) 96 | 97 | def feature_groups_query(portal, q, clear_existing=False): 98 | 99 | # Query for the groups we want to feature 100 | groups = portal.groups(['owner', 'id', 'title'], q) 101 | 102 | # If we're not clearing all existing groups, get the current set of featured 103 | # groups and add them to this list of groups to featyre. 104 | if not clear_existing: 105 | featured_groups = portal.properties().get('featuredGroups') 106 | if featured_groups: 107 | group_ids = [group['id'] for group in groups] 108 | for featured_group in featured_groups: 109 | if featured_group['id'] not in group_ids: 110 | groups.append(featured_group) 111 | 112 | # Update the featured groups property 113 | if groups: 114 | portal.update_property('featuredGroups', groups) 115 | 116 | def clear_featured_groups(portal): 117 | portal.update_property('featuredGroups', []) 118 | 119 | def feature_items(portal, item_ids, gallery=True, home_page=True, 120 | clear_existing=False): 121 | item_ids = unpack(item_ids, 'id') 122 | 123 | # Clear existing featured items (if directed to) 124 | if clear_existing: 125 | clear_featured_items(portal, gallery, home_page) 126 | 127 | # Retrieve the IDs of the gallery groups to share with 128 | group_ids = _get_featured_group_ids(portal, gallery, home_page) 129 | 130 | # If there are gallery groups to share with, share each item with the 131 | # gallery group(s) 132 | if group_ids: 133 | for item_id in item_ids: 134 | portal.share_item(item_id, group_ids) 135 | 136 | def feature_items_query(portal, q, gallery=True, home_page=True, 137 | clear_existing=False): 138 | 139 | # Query for the items to feature 140 | items = portal.search(['id'], q) 141 | item_ids = unpack(items) 142 | 143 | # Call the feature_items function using with the query results 144 | return feature_items(portal, item_ids, gallery, home_page, clear_existing) 145 | 146 | def clear_featured_items(portal, gallery=True, home_page=True): 147 | 148 | # Retrieve the IDs of the gallery groups to unshare with 149 | group_ids = _get_featured_group_ids(portal, gallery, home_page) 150 | 151 | # If there are gallery group(s) to unshare with, get the list of items in 152 | # those group(s) and then unshare each item from the gallery group(s) 153 | if group_ids: 154 | item_query = ' OR '.join('group:"%s"' % id for id in group_ids) 155 | items = portal.search(['id'], item_query) 156 | item_ids = unpack(items) 157 | for item_id in item_ids: 158 | portal.share_item(item_id, group_ids) 159 | 160 | def _get_featured_group_ids(portal, gallery, home_page): 161 | prop_names = [] 162 | if gallery: 163 | prop_names.append('featuredItemsGroupQuery') 164 | if home_page: 165 | prop_names.append('homePageFeaturedContent') 166 | return _props_to_group_ids(portal, prop_names) 167 | 168 | def _props_to_group_ids(portal, prop_names): 169 | group_ids = [] 170 | for prop_name in prop_names: 171 | group_id = _prop_to_group_id(portal, prop_name) 172 | if group_id: 173 | group_ids.append(group_id) 174 | return group_ids 175 | 176 | def _prop_to_group_id(portal, prop_name): 177 | group_query = portal.properties().get(prop_name) 178 | if group_query: 179 | groups = portal.groups(['id'], group_query, scope='public') 180 | if groups: 181 | return groups[0]['id'] 182 | 183 | -------------------------------------------------------------------------------- /Publish/Portal/portalpy/stats.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # Copyright 2014 Esri 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import random 16 | 17 | from math import sqrt 18 | from portalpy import unpack 19 | 20 | def group_item_stats(portal, sample_size=100): 21 | results = portal.groups(['id']) 22 | group_ids = unpack(results) 23 | group_ids_sample = random.sample(group_ids, min(sample_size, len(group_ids))) 24 | 25 | # Find the item counts (max of sample_size groups) 26 | item_counts = [] 27 | for index, group_id in enumerate(group_ids_sample): 28 | if index > sample_size: 29 | break 30 | item_count = len(portal.search(['id'], 'group:' + group_id)) 31 | item_counts.append(item_count) 32 | 33 | # Calculate and return statistics 34 | if len(item_counts): 35 | mean = sum(item_counts) / len(item_counts) 36 | stdv = _stdv(item_counts, mean) 37 | return min(item_counts), mean, max(item_counts), stdv 38 | return 0, 0, 0, 0 39 | 40 | def group_member_stats(portal, sample_size=100): 41 | results = portal.groups(['id']) 42 | group_ids = unpack(results) 43 | group_ids_sample = random.sample(group_ids, min(sample_size, len(group_ids))) 44 | 45 | # Find the member counts (max of sample_size groups) 46 | member_counts = [] 47 | for index, group_id in enumerate(group_ids_sample): 48 | if index > sample_size: 49 | break 50 | group_members = portal.group_members(group_id) 51 | member_count = len(group_members['admins']) + len(group_members['users']) 52 | member_counts.append(member_count) 53 | 54 | # Calculate and return statistics 55 | if len(member_counts): 56 | mean = sum(member_counts) / len(member_counts) 57 | stdv = _stdv(member_counts, mean) 58 | return min(member_counts), mean, max(member_counts), stdv 59 | return 0, 0, 0, 0 60 | 61 | def _stdv(values, mean): 62 | stdv = 0 63 | for value in values: 64 | stdv += (value - mean)**2 65 | stdv = sqrt(stdv / float(len(values) - 1)) 66 | stdv = round(stdv, 2) 67 | return stdv 68 | 69 | -------------------------------------------------------------------------------- /Publish/Server/CopyFiles.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #------------------------------------------------------------------------------ 3 | # Copyright 2015 Esri 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | #Name: CopyFiles.py 17 | # 18 | #Purpose: Copy folders/files from source folder to desintation folder 19 | # 20 | #============================================================================== 21 | import arcpy 22 | import sys 23 | import traceback 24 | import time 25 | import os 26 | 27 | # Add "Root folder"\SupportFiles to sys path inorder to import 28 | # modules in subfolder 29 | supportFilePath = os.path.join(os.path.dirname( 30 | os.path.dirname(os.path.dirname(sys.argv[0]))), "SupportFiles") 31 | sys.path.append(supportFilePath) 32 | 33 | from datetime import datetime 34 | from Utilities import changeOwnership 35 | from Utilities import getFreeSpace 36 | from Utilities import getDirSize 37 | from UtilitiesArcPy import checkResults 38 | from UtilitiesArcPy import copyData 39 | from walkingDirTrees import listFiles 40 | 41 | scriptName = sys.argv[0] 42 | 43 | if len(sys.argv) < 3: 44 | print "\n" + scriptName + " " 45 | print "\nWhere:" 46 | print "\n\t (required): path of source folder to copy." 47 | print "\n\t (required): path of folder where source folder will be copied." 48 | print 49 | sys.exit(1) 50 | 51 | 52 | # script parameter: 53 | src_folder = sys.argv[1] 54 | dest_folder = sys.argv[2] 55 | owner_account = None 56 | # if len(sys.argv) > 3: 57 | # owner_account = sys.argv[3] 58 | 59 | # --------------------------------------------------------------------- 60 | # Check parameters 61 | # --------------------------------------------------------------------- 62 | goodParameters = True 63 | 64 | # Check path parameter to make sure they exist 65 | 66 | if not os.path.exists(src_folder): 67 | print "\nThe path specified for parameter " + \ 68 | " (" + src_folder + ") does not exist." 69 | goodParameters = False 70 | 71 | if not os.path.exists(dest_folder): 72 | print "\nThe path specified for parameter " + \ 73 | " (" + dest_folder + ") does not exist." 74 | goodParameters = False 75 | 76 | # Exit script if parameters are not valid. 77 | if not goodParameters: 78 | print "\nInvalid script parameters. Exiting " + scriptName + "." 79 | sys.exit(1) 80 | 81 | printMsg = True 82 | totalCopySuccess = True 83 | 84 | 85 | def copyDataFolders(srcRootPath, destRootPath, ownerAccount=None): 86 | copySuccess = True 87 | 88 | # Check if there is available space on destination drive 89 | # to copy folders. 90 | freeSpace = getFreeSpace(destRootPath, "GB") 91 | 92 | # Get total size of source folders 93 | srcSize = getDirSize(srcRootPath, "GB") 94 | 95 | print '{:<34}{:>10.4f}{:>3}'.format("Available space to copy folders:", freeSpace, " GB") 96 | print '{:<34}{:>10.4f}{:>3}'.format("Size of folders to copy:", srcSize, " GB") 97 | print 98 | 99 | if srcSize >= freeSpace: 100 | totalCopySuccess = False 101 | print 102 | print "ERROR: Not enough available space to copy folders/files." 103 | print 104 | else: 105 | 106 | # Get list of top-level directories and files 107 | returnFolders = 1 #Yes 108 | recursive = 0 #No 109 | dirList = listFiles(srcRootPath, "*", recursive, returnFolders) 110 | 111 | x = 0 112 | for srcPath in dirList: 113 | # List may have files so test for directory 114 | if os.path.isdir(srcPath): 115 | pathType = "Folder" 116 | elif os.path.isfile(srcPath): 117 | pathType = "File" 118 | else: 119 | pathType = "" 120 | 121 | # "Create" destination path 122 | destPath = os.path.join(destRootPath, os.path.basename(srcPath)) 123 | 124 | print 125 | print "- Copying " + pathType.lower() + "..." 126 | print '{:<16}{:<100}'.format("\tSource:", srcPath) 127 | print '{:<16}{:<100}'.format("\tDestination:", destPath) 128 | 129 | # Copy data and check results 130 | results = copyData(srcPath, destPath) 131 | success = checkResults(results, printMsg) 132 | if not success: 133 | copySuccess = success 134 | 135 | # Change ownership function doesn't seem to be working 136 | # so for time being lets comment out this function call. 137 | # if not success: 138 | # copySuccess = success 139 | # else: 140 | # if ownerAccount: 141 | # changeOwnership(destPath, ownerAccount) 142 | 143 | return copySuccess 144 | 145 | try: 146 | 147 | startTime = datetime.now() 148 | print "\n==============================================================" 149 | print "Copying files..." 150 | print "==============================================================\n" 151 | print '{:<25}{}'.format("Source folder:", src_folder) 152 | print '{:<25}{}\n'.format("Destination folder:", dest_folder) 153 | success = copyDataFolders(src_folder, dest_folder, owner_account) 154 | if not success: 155 | totalCopySuccess = success 156 | 157 | except: 158 | 159 | # Get the traceback object 160 | tb = sys.exc_info()[2] 161 | tbinfo = traceback.format_tb(tb)[0] 162 | 163 | # Concatenate information together concerning the error into a message string 164 | pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) 165 | 166 | # Print Python error messages for use in Python / Python Window 167 | print 168 | print "***** ERROR ENCOUNTERED *****" 169 | print pymsg + "\n" 170 | 171 | finally: 172 | 173 | if totalCopySuccess: 174 | print "\n\nFile copy was successful.\n" 175 | else: 176 | print "\n\nERROR occurred during file copy.\n" 177 | 178 | print '{:<14}{:%Y-%m-%d %H:%M:%S}'.format("Start time:", startTime) 179 | endTime = datetime.now() 180 | print '{:<14}{:%Y-%m-%d %H:%M:%S}'.format("End time:", endTime) 181 | print '\nDone.' 182 | 183 | if totalCopySuccess: 184 | sys.exit(0) 185 | else: 186 | sys.exit(1) 187 | -------------------------------------------------------------------------------- /Publish/Server/CopyGDB.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #------------------------------------------------------------------------------ 3 | # Copyright 2015 Esri 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | #Name: CopyGDB.py 17 | # 18 | #Purpose: Copy contents from one geodatabase to another 19 | # 20 | #============================================================================== 21 | import arcpy 22 | import sys, traceback, time, os 23 | 24 | # Add "Root folder"\SupportFiles to sys path inorder to import 25 | # modules in subfolder 26 | supportFilePath = os.path.join(os.path.dirname( 27 | os.path.dirname(os.path.dirname(sys.argv[0]))), "SupportFiles") 28 | sys.path.append(supportFilePath) 29 | 30 | from datetime import datetime 31 | from UtilitiesArcPy import checkResults, copyGDBData 32 | 33 | scriptName = sys.argv[0] 34 | 35 | if len(sys.argv) <> 3: 36 | print "\n" + scriptName + " " 37 | print "\nWhere:" 38 | print "\n\t (required): path to the source geodatabase." 39 | print "\n\t (required): path to the destination geodatabase." 40 | print 41 | sys.exit(1) 42 | 43 | srcPath = sys.argv[1] 44 | destPath = sys.argv[2] 45 | 46 | # --------------------------------------------------------------------- 47 | # Check parameters 48 | # --------------------------------------------------------------------- 49 | goodParameters = True 50 | 51 | # Check path parameter to make sure they exist 52 | 53 | if not os.path.exists(srcPath): 54 | print "\nThe path specified for parameter " + \ 55 | " (" + srcPath + ") does not exist." 56 | goodParameters = False 57 | 58 | if not os.path.exists(destPath): 59 | print "\nThe path specified for parameter " + \ 60 | " (" + destPath + ") does not exist." 61 | goodParameters = False 62 | 63 | # Exit script if parameters are not valid. 64 | if not goodParameters: 65 | print "\nInvalid script parameters. Exiting " + scriptName + "." 66 | sys.exit(1) 67 | 68 | printMsg = True 69 | totalCopySuccess = True 70 | 71 | 72 | try: 73 | 74 | # startTime = datetime.now() 75 | # print 76 | # print '{:<14}{:<100}'.format("Source:", srcPath) 77 | # print '{:<14}{:<100}'.format("Destination:", destPath) 78 | 79 | results = copyGDBData(srcPath, destPath) 80 | success = checkResults(results, printMsg) 81 | if not success: 82 | totalCopySuccess = success 83 | 84 | except: 85 | 86 | # Get the traceback object 87 | tb = sys.exc_info()[2] 88 | tbinfo = traceback.format_tb(tb)[0] 89 | 90 | # Concatenate information together concerning the error into a message string 91 | pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) 92 | 93 | # Print Python error messages for use in Python / Python Window 94 | print 95 | print "***** ERROR ENCOUNTERED *****" 96 | print pymsg + "\n" 97 | 98 | finally: 99 | if totalCopySuccess: 100 | print "\nData copy was successful." 101 | else: 102 | print "\nERROR occurred during data copy." 103 | 104 | # print '{:<14}{:%Y-%m-%d %H:%M:%S}'.format("Start time:", startTime) 105 | # print '{:<14}{:%Y-%m-%d %H:%M:%S}'.format("End time:", datetime.now()) 106 | 107 | if totalCopySuccess: 108 | sys.exit(0) 109 | else: 110 | sys.exit(1) 111 | 112 | -------------------------------------------------------------------------------- /Publish/Server/CopyGDBs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #------------------------------------------------------------------------------ 3 | # Copyright 2015 Esri 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | #Name: CopyGDBs.py 17 | # 18 | #Purpose: Copy contents of multiple geodatabases given folder path of source 19 | # and destination SDE connection files/file geodatabases. 20 | # 21 | #============================================================================== 22 | import arcpy 23 | import sys, traceback, time, os 24 | 25 | # Add "Root folder"\SupportFiles to sys path inorder to import 26 | # modules in subfolder 27 | supportFilePath = os.path.join(os.path.dirname( 28 | os.path.dirname(os.path.dirname(sys.argv[0]))), "SupportFiles") 29 | sys.path.append(supportFilePath) 30 | 31 | from datetime import datetime 32 | from UtilitiesArcPy import checkResults, copyGDBData 33 | from Utilities import intersect, findFilePath, findFolderPath 34 | 35 | scriptName = sys.argv[0] 36 | 37 | if len(sys.argv) <> 3: 38 | print "\n" + scriptName + " " 39 | print "\nWhere:" 40 | print "\n\t (required): folder path of SDE connection files/file geodatabases." 41 | print "\n\t (required): folder path of SDE connection files/file geodatabases." 42 | print 43 | sys.exit(1) 44 | 45 | srcPath = sys.argv[1] 46 | destPath = sys.argv[2] 47 | 48 | # --------------------------------------------------------------------- 49 | # Check parameters 50 | # --------------------------------------------------------------------- 51 | goodParameters = True 52 | 53 | # Check path parameter to make sure they exist 54 | 55 | if not os.path.exists(srcPath): 56 | print "\nThe path specified for parameter " + \ 57 | " (" + srcPath + ") does not exist." 58 | goodParameters = False 59 | 60 | if not os.path.exists(destPath): 61 | print "\nThe path specified for parameter " + \ 62 | " (" + destPath + ") does not exist." 63 | goodParameters = False 64 | 65 | # Exit script if parameters are not valid. 66 | if not goodParameters: 67 | print "\nInvalid script parameters. Exiting " + scriptName + "." 68 | sys.exit(1) 69 | 70 | printMsg = True 71 | totalCopySuccess = True 72 | 73 | 74 | try: 75 | 76 | #startTime = datetime.now() 77 | 78 | # ---------------------------------------- 79 | # Determine which databases to copy 80 | # ---------------------------------------- 81 | print "- Determining which databases to copy..." 82 | 83 | # Get list of all workspaces in destination folder 84 | # (these could be file or enterprise geodatabases) 85 | destDBPathsSDE = findFilePath(destPath, "*.sde", returnFirst=False) 86 | destDBPathsFGDB = findFolderPath(destPath, "*.gdb", returnFirst=False) 87 | destDBPaths = destDBPathsSDE + destDBPathsFGDB 88 | 89 | # Create dictionary where destination db name is key and 90 | # path to workspace is value. 91 | destDBs = {} 92 | for dbPath in destDBPaths: 93 | destDBs[os.path.basename(dbPath).split(".")[0].lower()] = dbPath 94 | 95 | # Get list of all workspaces in source folder 96 | # (these could be file or enterprise geodatabases) 97 | srcDBPathsSDE = findFilePath(srcPath, "*.sde", returnFirst=False) 98 | srcDBPathsFGDB = findFolderPath(srcPath, "*.gdb", returnFirst=False) 99 | srcDBPaths = srcDBPathsSDE + srcDBPathsFGDB 100 | 101 | # Create dictionary where source db name is key and 102 | # path to workspace is value. 103 | srcDBs = {} 104 | for dbPath in srcDBPaths: 105 | srcDBs[os.path.basename(dbPath).split(".")[0].lower()] = dbPath 106 | 107 | # Create list of db names that exist as keys in both source and 108 | # destination dictionaries 109 | dbsToCopy = intersect(srcDBs, destDBs) 110 | 111 | if len(dbsToCopy) == 0: 112 | continueCopy = False 113 | totalCopySuccess = False 114 | print 115 | print "\tERROR: There are no databases to copy!" 116 | print 117 | else: 118 | continueCopy = True 119 | 120 | if continueCopy: 121 | for db in dbsToCopy: 122 | print "-" * 80 123 | print "- Copying " + db.upper() + " database data..." 124 | srcPath = srcDBs[db] 125 | destPath = destDBs[db] 126 | results = copyGDBData(srcPath, destPath) 127 | success = checkResults(results, printMsg) 128 | if not success: 129 | totalCopySuccess = success 130 | 131 | 132 | except: 133 | 134 | # Get the traceback object 135 | tb = sys.exc_info()[2] 136 | tbinfo = traceback.format_tb(tb)[0] 137 | 138 | # Concatenate information together concerning the error into a message string 139 | pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) 140 | 141 | # Print Python error messages for use in Python / Python Window 142 | print 143 | print "***** ERROR ENCOUNTERED *****" 144 | print pymsg + "\n" 145 | 146 | finally: 147 | if totalCopySuccess: 148 | print "\nData copy was successful." 149 | else: 150 | print "\nERROR occurred during data copy." 151 | 152 | # print '{:<14}{:%Y-%m-%d %H:%M:%S}'.format("Start time:", startTime) 153 | # print '{:<14}{:%Y-%m-%d %H:%M:%S}'.format("End time:", datetime.now()) 154 | 155 | if totalCopySuccess: 156 | sys.exit(0) 157 | else: 158 | sys.exit(1) 159 | 160 | -------------------------------------------------------------------------------- /Publish/Server/RepairMosaicDatasets.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #------------------------------------------------------------------------------ 3 | # Copyright 2015 Esri 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | #Name: RepairMosaicDatasets.py 17 | # 18 | #Purpose: Updates paths referenced in non-reference mosaic datasets stored 19 | # in file geodatabases to point to the Ops Server being setup. 20 | # 21 | #============================================================================== 22 | import os 23 | import sys 24 | import traceback 25 | import arcpy 26 | 27 | # Add "Root folder"\SupportFiles to sys path inorder to import 28 | # modules in subfolder 29 | sys.path.append(os.path.join(os.path.dirname( 30 | os.path.dirname(os.path.dirname(sys.argv[0]))), "SupportFiles")) 31 | 32 | from Utilities import findFolderPath 33 | 34 | print_msg = True 35 | total_success = True 36 | script_name = os.path.basename(sys.argv[0]) 37 | 38 | def getFileGeodatabases(root_path): 39 | # Get list of all folders ending in ".gdb" 40 | gdbs = findFolderPath(root_path, "*.gdb", False) 41 | 42 | # Ensure that list only contains entries that are local geodatabase 43 | # (file geodatabase); just in case there happens to be a folder with ".gdb" 44 | # that is not a geodatabase 45 | gdbs[:] = [gdb for gdb in gdbs if 46 | arcpy.Describe(gdb).workspaceType.upper() == "LOCALDATABASE"] 47 | 48 | return gdbs 49 | 50 | def check_args(): 51 | # --------------------------------------------------------------------- 52 | # Check arguments 53 | # --------------------------------------------------------------------- 54 | 55 | if len(sys.argv) <> 3: 56 | 57 | print '\n{} '.format(script_name) 58 | 59 | print '\nWhere:' 60 | print '\n\t (required): the root folder path to search for mosaic datasets.' 61 | print '\n\t (required): a list of the paths to remap. Include the current path stored ' 62 | print '\t\tin the mosaic dataset and the path to which it will be changed. You can enter an' 63 | print '\t\tasterisk (*) as the original path if you wish to change all your paths.' 64 | print '\n\t\tPattern (surround in double-qoutes): [[original_path new_path];...]' 65 | print '\n\t\tExamples:' 66 | print '\t\t\t"C:\OriginalSource\Data D:\NewSource\Data"' 67 | print '\t\t\t"C:\OriginalSource1\Data D:\NewSource1\Data; C:\OriginalSource2\Data D:\NewSource2\Data"' 68 | print '\t\t\t"\\\\FileServer\OriginalSource\Data \\\\FileServer\NewSource\Data"' 69 | print '\n\tNOTE: script only repairs paths in file geodatabase non-reference mosaic datasets.' 70 | return None 71 | 72 | else: 73 | 74 | # Set variables from parameter values 75 | root_path = sys.argv[1] 76 | remap_paths = sys.argv[2] 77 | 78 | return root_path, remap_paths 79 | 80 | def main(): 81 | 82 | total_success = True 83 | 84 | # Check arguments 85 | results = check_args() 86 | if not results: 87 | sys.exit(0) 88 | root_path, remap_paths = results 89 | 90 | try: 91 | print '\n{}'.format('=' * 80) 92 | print 'Repair Mosaic Datasets' 93 | print '{}\n'.format('=' * 80) 94 | print '{:<15}{}'.format('Root folder:', root_path) 95 | print '{:<15}{}\n'.format('Remap paths:', remap_paths) 96 | 97 | print 'Searching {} looking for file geodatabases...'.format(root_path) 98 | gdbs = getFileGeodatabases(root_path) 99 | 100 | for gdb in gdbs: 101 | 102 | print '\n\n{}'.format('=' * 80) 103 | print 'Found file geodatabase: {}'.format(gdb) 104 | print '\tChecking for existence of non-referenced mosaic datasets...' 105 | 106 | # Get any mosaic datasets in geodatabase 107 | arcpy.env.workspace = gdb 108 | mosaic_datasets = arcpy.ListDatasets('*', 'Mosaic') 109 | 110 | # Modify list to contain only non-reference mosaic datasets 111 | mosaic_datasets[:] = [mosaic_dataset for mosaic_dataset in mosaic_datasets if not arcpy.Describe(mosaic_dataset).referenced] 112 | 113 | if len(mosaic_datasets) == 0: 114 | print '\tNone found.' 115 | else: 116 | print '\tFound {} non-referenced mosaic dataset(s)...'.format(len(mosaic_datasets)) 117 | 118 | for mosaic_dataset in mosaic_datasets: 119 | print '\n\t{}'.format('-' * 70) 120 | print '\tRepairing paths in mosaic dataset {}...'.format(mosaic_dataset) 121 | results = arcpy.RepairMosaicDatasetPaths_management(mosaic_dataset, remap_paths) 122 | if results.maxSeverity == 2: 123 | total_success = False 124 | print '\n{}'.format(results.getMessages()) 125 | 126 | except: 127 | total_success = False 128 | 129 | # Get the traceback object 130 | tb = sys.exc_info()[2] 131 | tbinfo = traceback.format_tb(tb)[0] 132 | 133 | # Concatenate information together concerning the error into a message string 134 | pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) 135 | 136 | # Print Python error messages for use in Python / Python Window 137 | print 138 | print "***** ERROR ENCOUNTERED *****" 139 | print pymsg + "\n" 140 | 141 | finally: 142 | if total_success: 143 | print "\n\nDone. Review output for errors.\n" 144 | sys.exit(0) 145 | else: 146 | print "\n\nDone. ERROR(s) occurred during mosaic dataset repair.\n" 147 | sys.exit(1) 148 | 149 | 150 | if __name__ == "__main__": 151 | main() -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ops-server-config 2 | 3 | The **Operations Server Configuration** is a collection of Python scripts and batch files that automate the installation of 4 | the ArcGIS platform on Windows machines and the publication of Portal for ArcGIS content and ArcGIS for Server services. 5 | While developed for an implementation of the ArcGIS Platform with a specific software configuration and content (i.e. _Operations Server_), 6 | the scripts can be modified to meet your requirements. 7 | 8 | The goals of the scripts are to: 9 | 10 | * Automate the software installation and configuration process as much as possible. 11 | * Ensure a consistent and repeatable process. 12 | * Reduce the time necessary to install software and deploy content. 13 | * Simplify the complete portal deployment of Esri’s Military and Intelligence solution. 14 | 15 | ![Image of Ops Server](ScreenShot.png "ops-server-config") 16 | 17 | ## Features 18 | 19 | * Automates the installation of the following software: 20 | * ArcGIS for Server (Windows) 10.4 21 | * Portal for ArcGIS (Windows) 10.4 22 | * ArcGIS Web Adaptor (IIS) 10.4 23 | * ArcGIS Data Store (Windows) 10.4 24 | * ArcGIS GeoEvent Extension for Server (Windows) 10.4 25 | * Portal Resources for Esri Maps for Office 3.1 26 | * Deployment of Operations Dashboard configured for Portal for ArcGIS 27 | * PostgreSQL 9.3.5 28 | * IIS and .NET Framework 3.5 29 | * Automates Enterprise Geodatabase creation and registration of these data stores with ArcGIS for Server. 30 | * Automates the publishing of ArcGIS for Server services from service definition files (.sd). 31 | * Automates the publishing of Portal for ArcGIS content to/from disk files. 32 | * Automates the publishing of hosted services from service definition file items uploaded to Portal for ArcGIS. 33 | * Python module for working with the ArcGIS for Server REST API. 34 | 35 | ## Sections 36 | 37 | * [Requirements](#requirements) 38 | * [Instructions](#instructions) 39 | * [Resources](#resources) 40 | * [Issues](#issues) 41 | * [Contributing](#contributing) 42 | * [Licensing](#licensing) 43 | 44 | ## Requirements 45 | 46 | For requirements, please refer to: 47 | * The **_Install Software Preparation_** section of the [Ops Server Configuration Preparation](./Docs/Ops%20Server%20Config%20Preparation.pdf) document. 48 | * The **_Ops Server System Requirements_** and **_Installation Prerequisites_** sections of the [Ops Server Installation Guide](./Docs/Ops%20Server%20Installation%20Guide.pdf). 49 | 50 | ## Instructions 51 | 52 | 1. Follow the instructions in the [Ops Server Configuration Preparation](./Docs/Ops%20Server%20Config%20Preparation.pdf) document. 53 | 2. Follow the instructions in the [Ops Server Installation Guide](./Docs/Ops%20Server%20Installation%20Guide.pdf). 54 | 55 | ## Resources 56 | 57 | * [Ops Server Installation Guide](./Docs/Ops%20Server%20Installation%20Guide.pdf) 58 | * While the following guides are not necessary to use the scripts contained in this repo, they are useful for understanding the procedures executed by the scripts: 59 | * [ArcGIS for Server (Windows) installation guide](http://server.arcgis.com/en/server/latest/install/windows/welcome-to-the-arcgis-for-server-install-guide.htm) 60 | * [Portal for ArcGIS (Windows) installation guide](http://server.arcgis.com/en/portal/latest/install/windows/welcome-to-the-portal-for-arcgis-installation-guide.htm) 61 | * [ArcGIS Web Adaptor (IIS) installation guide](http://server.arcgis.com/en/web-adaptor/latest/install/iis/welcome-to-the-arcgis-web-adaptor-installation-guide.htm) 62 | * [ArcGIS Data Store (Windows) installation guide](http://server.arcgis.com/en/data-store/latest/install/windows/welcome-to-arcgis-data-store-installation-guide.htm) 63 | * [ArcGIS GeoEvent Extension for Server (Windows) installation steps](http://server.arcgis.com/en/geoevent-extension/latest/install/windows/installation-steps.htm) 64 | 65 | ## Issues 66 | 67 | Find a bug or want to request a new feature? Please let us know by submitting an issue. 68 | 69 | ## Contributing 70 | 71 | Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](https://github.com/esri/contributing). 72 | 73 | ## Licensing 74 | Copyright 2014 Esri 75 | 76 | Licensed under the Apache License, Version 2.0 (the "License"); 77 | you may not use this file except in compliance with the License. 78 | You may obtain a copy of the License at 79 | 80 | http://www.apache.org/licenses/LICENSE-2.0 81 | 82 | Unless required by applicable law or agreed to in writing, software 83 | distributed under the License is distributed on an "AS IS" BASIS, 84 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 85 | See the License for the specific language governing permissions and 86 | limitations under the License. 87 | 88 | A copy of the license is available in the repository's [license.txt](./license.txt) file. 89 | 90 | A portion of this code uses a third-party library: 91 | 92 | * Use of the [walkingDirTrees.py](./SupportFiles/walkingDirTrees.py) module is governed by the modified Berkeley license available in the repository's [LICENSE-ThirdParty.txt](https://github.com/ArcGIS/ops-server-config/blob/master/LICENSE-ThirdParty.txt) file. 93 | 94 | [](Esri Tags: ArcGIS Defense Intelligence Military ArcGISSolutions) 95 | [](Esri Language: Python) 96 | -------------------------------------------------------------------------------- /ScreenShot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Esri/ops-server-config/5768cf45eb9e9aeba0f68c15cdd452287b8af746/ScreenShot.png -------------------------------------------------------------------------------- /SupportFiles/BatchFiles/CheckErrorLevel.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: CheckErrorLevel.bat 16 | rem # 17 | rem # Purpose: Checks specified DOS ErrorLevel code. Pauses code execution 18 | rem # if ErrorLevel value represents an error. 19 | rem # 20 | rem #============================================================================== 21 | set ops_ErrLvl=%1 22 | set ops_ProcessType=%2 23 | 24 | REM Batch file compare operations from IF /? 25 | rem EQU - equal 26 | rem NEQ - not equal 27 | rem LSS - less than 28 | rem LEQ - less than or equal 29 | rem GTR - greater than 30 | rem GEQ - greater than or equal 31 | 32 | if "%ops_ProcessType%"=="ROBOCOPY" ( 33 | REM See http://support.microsoft.com/kb/954404 for robocopy exit codes 34 | if %ops_ErrLvl% GEQ 8 goto ERROR 35 | ) else ( 36 | if %ops_ErrLvl% NEQ 0 goto ERROR 37 | ) 38 | goto EOF 39 | 40 | :ERROR 41 | echo. 42 | echo ********************************************************** 43 | echo ** ERROR: error encountered. ErrorLevel code: %ops_ErrLvl% 44 | echo ** Pausing script execution. 45 | echo ** 46 | echo ** Close command prompt to stop script execution. 47 | echo ** Press any key to continue with script execution. 48 | echo ********************************************************** 49 | echo. 50 | pause 51 | 52 | :EOF -------------------------------------------------------------------------------- /SupportFiles/BatchFiles/CheckExistence.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: CheckExistence.bat 16 | rem # 17 | rem # Purpose: Checks for file/folder existence 18 | rem # 19 | rem #============================================================================== 20 | set ops_ChkErrLevelFile=%~dp0CheckErrorLevel.bat 21 | set ops_ErrCode=0 22 | set filelist=%* 23 | echo. 24 | for %%d in (%filelist%) do ( 25 | if not exist %%d ( 26 | set ops_ErrCode=1 27 | echo *** ERROR: The following file\folder does not exist: %%d 28 | ) 29 | ) 30 | Call %ops_ChkErrLevelFile% %ops_ErrCode% -------------------------------------------------------------------------------- /SupportFiles/BatchFiles/Checks/CheckServerName.bat: -------------------------------------------------------------------------------- 1 | @setlocal enableextensions enabledelayedexpansion 2 | @echo off 3 | rem #------------------------------------------------------------------------------ 4 | rem # Copyright 2014 Esri 5 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 6 | rem # you may not use this file except in compliance with the License. 7 | rem # You may obtain a copy of the License at 8 | rem # 9 | rem # http://www.apache.org/licenses/LICENSE-2.0 10 | rem # 11 | rem # Unless required by applicable law or agreed to in writing, software 12 | rem # distributed under the License is distributed on an "AS IS" BASIS, 13 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | rem # See the License for the specific language governing permissions and 15 | rem # limitations under the License. 16 | rem #============================================================================== 17 | rem # Name: CheckServerName.bat 18 | rem # 19 | rem # Purpose: Check Server Name value for underscore "_" 20 | rem # 21 | rem # Comments: ArcGIS Server and ArcGIS Data Store are not supported on machines 22 | rem # which have an underscore in the machine name. 23 | rem # 24 | rem # Learned how to find str within a str in batch file from following 25 | rem # web post (25 Sept 2014) 26 | rem # http://stackoverflow.com/questions/7005951/batch-file-find-if-substring-is-in-string-not-in-a-file 27 | rem # user "paxdiablo" who answered the question Aug 10 '11 at 4:47 28 | rem #============================================================================== 29 | set ops_ChkErrLevelFile=%~dp0..\CheckErrorLevel.bat 30 | 31 | set input_str=%1 32 | set ops_ErrCode=0 33 | if not x%input_str:_=%==x%input_str% ( 34 | set ops_ErrCode=1 35 | echo. 36 | echo ********************************************************** 37 | echo ** ERROR: Server name contains an underscore ^("_"^). 38 | echo ** 39 | echo ** ArcGIS Server and ArcGIS Data Store are not supported 40 | echo ** on machines with underscores in the machine name. 41 | echo ********************************************************** 42 | echo. 43 | ) 44 | Call %ops_ChkErrLevelFile% %ops_ErrCode% 45 | endlocal 46 | -------------------------------------------------------------------------------- /SupportFiles/BatchFiles/Checks/IsInstalled_IIS.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: IsInstalled_IIS.bat 16 | rem # 17 | rem # Purpose: Check if IIS is installed 18 | rem # 19 | rem # Comments: See the following web page for more information: 20 | rem # http://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx 21 | rem #============================================================================== 22 | 23 | set serviceName=W3SVC 24 | sc query %serviceName% | find "RUNNING" 25 | set ops_CheckErrLvl=%ERRORLEVEL% 26 | 27 | if "%ops_CheckErrLvl%"=="1" ( 28 | echo. 29 | echo ********************************************************** 30 | echo ** ERROR: Installation dependency has not been met. 31 | echo ** IIS is not enabled or the IIS service 32 | echo ** "World Wide Web Publishing Service" ^(%serviceName%^) 33 | echo ** is not running. 34 | echo ** 35 | echo ** Solution: 36 | echo ** - If IIS is not installed run the InstallIIS.bat 37 | echo ** which will "enable" this OS "role". 38 | echo ** - If IIS is installed, but the windows service is 39 | echo ** not running, start the windows service. 40 | echo ********************************************************** 41 | echo. 42 | ) 43 | 44 | -------------------------------------------------------------------------------- /SupportFiles/BatchFiles/Checks/IsInstalled_NETFramework3_5.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: IsInstalled_NETFramework3_5.bat 16 | rem # 17 | rem # Purpose: Check if .NET Framework 3.5 is installed 18 | rem # 19 | rem # Comments: See the following web page for more information: 20 | rem # http://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx 21 | rem #============================================================================== 22 | 23 | reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5" /v Version 24 | set ops_CheckErrLvl=%ERRORLEVEL% 25 | 26 | if "%ops_CheckErrLvl%"=="1" ( 27 | echo. 28 | echo ********************************************************** 29 | echo ** ERROR: Installation dependency has not been met. 30 | echo ** .NET Framework 3.5 is not installed. 31 | echo ** 32 | echo ** Solution: Run the InstallIIS.bat which will "enable" this 33 | echo ** OS "feature". 34 | echo ********************************************************** 35 | echo. 36 | ) 37 | 38 | -------------------------------------------------------------------------------- /SupportFiles/BatchFiles/Checks/IsInstalled_NETFramework4_5.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: IsInstalled_NETFramework4_5.bat 16 | rem # 17 | rem # Purpose: Check if .NET Framework 4.5 is installed 18 | rem # 19 | rem # Comments: See the following web page for more information: 20 | rem # http://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx 21 | rem # 22 | rem # If the registery DWORD "Release" exists then .NET Framework 4.5 or 23 | REM # newer has been installed. 24 | rem #============================================================================== 25 | 26 | reg query "HKLM\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" /v Release 27 | set ops_CheckErrLvl=%ERRORLEVEL% 28 | 29 | if "%ops_CheckErrLvl%"=="1" ( 30 | echo. 31 | echo ********************************************************** 32 | echo ** ERROR: Installation dependency has not been met. 33 | echo ** .NET Framework 4.5 is not installed. 34 | echo ** 35 | echo ** Solution: Install .NET Framework 4.5; the installer can 36 | echo ** downloaded from http://microsoft.com 37 | echo ********************************************************** 38 | echo. 39 | ) 40 | 41 | -------------------------------------------------------------------------------- /SupportFiles/BatchFiles/SetOverallErrorLevel.bat: -------------------------------------------------------------------------------- 1 | rem #------------------------------------------------------------------------------ 2 | rem # Copyright 2014 Esri 3 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 4 | rem # you may not use this file except in compliance with the License. 5 | rem # You may obtain a copy of the License at 6 | rem # 7 | rem # http://www.apache.org/licenses/LICENSE-2.0 8 | rem # 9 | rem # Unless required by applicable law or agreed to in writing, software 10 | rem # distributed under the License is distributed on an "AS IS" BASIS, 11 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | rem # See the License for the specific language governing permissions and 13 | rem # limitations under the License. 14 | rem #============================================================================== 15 | rem # Name: SetOverallErrorLevel.bat 16 | rem # 17 | rem # Purpose: Sets overall Error Level variable 18 | rem # 19 | rem # Comments: Used to set "Global" variable ops_OverallErrLvl storing error level. 20 | rem # Batch file should be called after running any of the batch files 21 | rem # in the SupportFiles\BatchFiles\Checks directory. If error code is 22 | rem # passed to batch file, set the "Global" variable = 1 indicating that 23 | rem # an error has occurred. 24 | rem #============================================================================== 25 | set ErrLvl=%1 26 | 27 | REM Batch file compare operations from IF /? 28 | rem EQU - equal 29 | rem NEQ - not equal 30 | rem LSS - less than 31 | rem LEQ - less than or equal 32 | rem GTR - greater than 33 | rem GEQ - greater than or equal 34 | 35 | if %ErrLvl% GTR 0 ( 36 | set ops_OverallErrLvl=1 37 | ) -------------------------------------------------------------------------------- /SupportFiles/CreateFileGDBs.py: -------------------------------------------------------------------------------- 1 | #!/bin/env python2 2 | # ------------------------------------------------------------------------------ 3 | # Copyright 2014-2015 Esri 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # ------------------------------------------------------------------------------ 16 | # Name: creategdbs.py 17 | # Usage: creategdbs.py 18 | # Requirements/Constraints: Must be run with ArcGIS Desktop/Server (arcpy requirement) 19 | # ------------------------------------------------------------------------------- 20 | # Description: This script will create file geodatabases after from the associated 21 | # .sde connection files 22 | # 1. This script will check the source folder for *.sde files 23 | # 2. If files are found, it will create a file geodatabase using the same name as the 24 | # sde connection file in the destination directory. 25 | # ------------------------------------------------------------------------------- 26 | 27 | import arcpy 28 | import sys 29 | import os 30 | 31 | 32 | def usage(): 33 | print("creategdbs.py ") 34 | 35 | 36 | def getfolders(path, patterns): 37 | matching_file_list = [os.path.join(dp, f) for dp, dn, filenames in \ 38 | os.walk(path) for f in filenames if os.path.splitext(f)[1] in patterns] 39 | return matching_file_list 40 | 41 | if len(sys.argv) < 3: 42 | usage() 43 | sys.exit(1) 44 | 45 | source_folder = sys.argv[1] 46 | destination_folder = sys.argv[2] 47 | 48 | print("Source Folder is " + source_folder) 49 | print("Creating databases in " + destination_folder) 50 | 51 | destination_dblist =[] 52 | 53 | source_dblist = getfolders(source_folder, [".sde"]) 54 | print("Source databases found: " + str(source_dblist)) 55 | 56 | print("Stripping extension and path from source database list") 57 | for sourcedb in source_dblist: 58 | filename = os.path.split(sourcedb)[1] 59 | filename_noext = os.path.splitext(filename)[0] 60 | print(filename_noext) 61 | destination_dblist.append(filename_noext) 62 | 63 | print("Destination databases to create: " + str(destination_dblist)) 64 | 65 | for database in destination_dblist: 66 | try: 67 | tempdb = database + ".gdb" 68 | print("Creating " + tempdb) 69 | arcpy.CreateFileGDB_management(destination_folder, tempdb) 70 | 71 | except arcpy.ExecuteError as arcpy_error: 72 | print(arcpy.GetMessages()) -------------------------------------------------------------------------------- /SupportFiles/PostWebAppDeployment.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem #------------------------------------------------------------------------------ 3 | rem # Copyright 2014 Esri 4 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 5 | rem # you may not use this file except in compliance with the License. 6 | rem # You may obtain a copy of the License at 7 | rem # 8 | rem # http://www.apache.org/licenses/LICENSE-2.0 9 | rem # 10 | rem # Unless required by applicable law or agreed to in writing, software 11 | rem # distributed under the License is distributed on an "AS IS" BASIS, 12 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | rem # See the License for the specific language governing permissions and 14 | rem # limitations under the License. 15 | rem #============================================================================== 16 | rem # Name: PostWebAppDeployment.bat 17 | rem # 18 | rem # Purpose: Perform Post Web App Deployment operations 19 | rem # 20 | rem # Prerequisites: Ops Server wwwroot files/folder must already exist in the 21 | rem # C:\inetpub\wwwroot folder 22 | rem # 23 | rem #============================================================================== 24 | set ops_ChkErrLevelFile=%~dp0\BatchFiles\CheckErrorLevel.bat 25 | set ops_solutionsweb_path=C:\inetpub\wwwroot\SolutionsWeb 26 | 27 | REM Check if SolutionsWeb folder exists 28 | set ops_test_path=%ops_solutionsweb_path% 29 | if not exist %ops_test_path% (goto NO_FOLDER) 30 | 31 | set sectionBreak=================================================================================== 32 | set sectionBreak1=------------------------------------------------------- 33 | echo. 34 | echo. 35 | echo %sectionBreak% 36 | echo Execute Post Web Application Deployment Operations 37 | echo %sectionBreak% 38 | echo. 39 | echo. 40 | REM --------------------------------------------------------------------- 41 | REM Convert certain web folders to IIS web applications 42 | REM --------------------------------------------------------------------- 43 | echo %sectionBreak1% 44 | echo Convert web folders in IIS to web application 45 | echo %sectionBreak1% 46 | echo. 47 | echo --Converting SolutionsWeb/Apps/Templates/ImageDiscovery to application... 48 | echo. 49 | set ops_test_path=%ops_solutionsweb_path%\Apps\Templates\ImageDiscovery 50 | if not exist %ops_test_path% (goto NO_FOLDER) 51 | set execute=%windir%\system32\inetsrv\appcmd add app /site.name:"Default Web Site" /path:/SolutionsWeb/Apps/Templates/ImageDiscovery /physicalPath:"%ops_test_path%" 52 | echo %execute% 53 | echo. 54 | %execute% 55 | Call %ops_ChkErrLevelFile% %ERRORLEVEL% 56 | 57 | goto END 58 | 59 | :NO_FOLDER 60 | @echo. 61 | @echo Error: Folder %ops_test_path% does not exist. 62 | @echo. 63 | @goto END 64 | 65 | :END 66 | @echo on -------------------------------------------------------------------------------- /SupportFiles/RegisterDataStores.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------ 2 | # Copyright 2014 Esri 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | #============================================================================== 15 | #Name: RegisterDataStores.py 16 | #Purpose: Registers the servers data stores with the ArcGIS Server site. 17 | # 18 | #Prerequisites: The variables in the "Shared / Replicated Database Configuration" 19 | # section of the OpsServerConfig.py script must be set before 20 | # executing this script. 21 | # 22 | #============================================================================== 23 | import sys, os, traceback 24 | 25 | # For Http calls 26 | import httplib, urllib, json 27 | 28 | import OpsServerConfig 29 | from Utilities import makePath 30 | from DataStore import create_shared_folder_item 31 | from DataStore import create_replicated_folder_item 32 | from DataStore import register 33 | from DataStore import create_managed_entdb_item 34 | from DataStore import create_shared_entdb_item 35 | from DataStore import create_replicated_entdb_item 36 | from DataStore import create_postgresql_db_connection_str 37 | 38 | serverName = OpsServerConfig.serverName 39 | serverPort = OpsServerConfig.serverPort 40 | 41 | regFolders = True 42 | regDatabases = True 43 | 44 | def registerDataStores(sharedDataStoreConfig, forInstallPurposeOnly, username, password, dataDrive): 45 | 46 | successRegister = True 47 | 48 | sharedDBConfig = sharedDataStoreConfig 49 | sharedFolderConfig = sharedDataStoreConfig 50 | 51 | try: 52 | opsServer = OpsServerConfig.getOpsServerRootPath(dataDrive) 53 | environmentData = OpsServerConfig.getEnvDataRootPath(dataDrive) 54 | clientServerName = OpsServerConfig.publishingDBServer 55 | clientFolderPath = OpsServerConfig.publishingFolder 56 | clientFolderDSName = OpsServerConfig.dataFolderDStoreName 57 | installOnlyClientFolders = OpsServerConfig.installOnlyPublishingFolders 58 | dbsToRegister = OpsServerConfig.databasesToCreate 59 | 60 | print "\n\t-Register Data Stores with Site...\n" 61 | 62 | # --------------------------------------------------------------------- 63 | # Register Folders by just using paths 64 | # --------------------------------------------------------------------- 65 | if regFolders: 66 | 67 | if forInstallPurposeOnly: 68 | clientFolderPaths = installOnlyClientFolders 69 | else: 70 | clientFolderPaths = {clientFolderDSName: clientFolderPath} 71 | 72 | for registrationName, clientFolderPath in clientFolderPaths.items(): 73 | 74 | # Create folder data store item 75 | if sharedFolderConfig: 76 | sharedStr = "shared" 77 | dsPath, dsItem = create_shared_folder_item(registrationName, environmentData, serverName) 78 | 79 | else: 80 | sharedStr = "replicated" 81 | dsPath, dsItem = create_replicated_folder_item(registrationName, clientFolderPath, environmentData) 82 | 83 | # Register the data store item 84 | print "\t\t-Registering folder " + environmentData + " with site as " + registrationName + " (" + sharedStr + ")..." 85 | success, response = register(serverName, serverPort, username, password, dsItem, useSSL=False) 86 | if success: 87 | print "\t\tDone.\n" 88 | else: 89 | successRegister = False 90 | print "ERROR:" + str(response) 91 | 92 | ## --------------------------------------------------------------------- 93 | ## Register databases 94 | ## (NOTE: Assumes database password is the same as that used to install 95 | ## arcgis server) 96 | ## --------------------------------------------------------------------- 97 | if regDatabases: 98 | 99 | for db in dbsToRegister: 100 | 101 | isManaged = dbsToRegister[db][0] 102 | registrationName = dbsToRegister[db][1] 103 | 104 | # Do not register managed database if it is for 105 | # install purposes only 106 | if isManaged and forInstallPurposeOnly: 107 | continueRegister = False 108 | else: 109 | continueRegister = True 110 | 111 | if continueRegister: 112 | 113 | success, server_db_conn = create_postgresql_db_connection_str( 114 | serverName, serverPort, username, password, 115 | serverName, db, 'sde', password, useSSL=False, token=None, encrypt_dbpassword=False) 116 | if not success: 117 | successRegister = False 118 | print "ERROR: error encountered while creating server database connection string -" 119 | print str(server_db_conn) 120 | 121 | if forInstallPurposeOnly: 122 | registrationName = registrationName + "_InstallOnly" 123 | 124 | managedStr = "" 125 | if isManaged: 126 | managedStr = "Managed" 127 | dsPath, dsItem = create_managed_entdb_item(registrationName, server_db_conn) 128 | 129 | else: 130 | managedStr = "Non-managed" 131 | if sharedDBConfig: 132 | managedStr = managedStr + " - shared" 133 | dsPath, dsItem = create_shared_entdb_item(registrationName, server_db_conn) 134 | 135 | else: 136 | managedStr = managedStr + " - replicated" 137 | 138 | success, publisher_db_conn = create_postgresql_db_connection_str( 139 | serverName, serverPort, username, password, 140 | clientServerName, db, 'sde', password, useSSL=False, token=None, encrypt_dbpassword=False) 141 | if not success: 142 | successRegister = False 143 | print "ERROR: error encountered while creating publisher database connection string -" 144 | print str(publisher_db_conn) 145 | 146 | dsPath, dsItem = create_replicated_entdb_item(registrationName, publisher_db_conn, server_db_conn) 147 | 148 | print "\t\t-Registering " + db + " database with site as " + registrationName + " (" + managedStr + ")..." 149 | success, response = register(serverName, serverPort, username, password, dsItem, useSSL=False) 150 | if success: 151 | print "\t\tDone.\n" 152 | else: 153 | successRegister = False 154 | print "ERROR:" + str(response) 155 | 156 | 157 | except: 158 | successRegister = False 159 | 160 | # Get the traceback object 161 | tb = sys.exc_info()[2] 162 | tbinfo = traceback.format_tb(tb)[0] 163 | 164 | # Concatenate information together concerning the error into a message string 165 | pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) 166 | 167 | # Print Python error messages for use in Python / Python Window 168 | print 169 | print "***** ERROR ENCOUNTERED *****" 170 | print pymsg + "\n" 171 | 172 | finally: 173 | # Return success flag 174 | return successRegister 175 | 176 | # Script start 177 | if __name__ == "__main__": 178 | sys.exit(main(sys.argv[1:])) 179 | -------------------------------------------------------------------------------- /SupportFiles/RepairMosaicDatasets.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #------------------------------------------------------------------------------ 3 | # Copyright 2014 Esri 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | #Name: RepairMosaicDatasets.py 17 | # 18 | #Purpose: Updates paths referenced in non-reference mosaic datasets stored 19 | # in file geodatabases to point to the Ops Server being setup. 20 | # 21 | #============================================================================== 22 | import os, arcpy, sys, traceback 23 | 24 | import OpsServerConfig 25 | from UtilitiesArcPy import repairMosaicDatasetPaths 26 | from UtilitiesArcPy import checkResults 27 | from Utilities import findFolderPath 28 | 29 | installOnlyPublishingFolders = OpsServerConfig.installOnlyPublishingFolders 30 | printMsg = True 31 | 32 | def repairMosaicDatasets(dataDrive): 33 | 34 | try: 35 | 36 | totalSuccess = True 37 | 38 | newPath = OpsServerConfig.getEnvDataRootPath(dataDrive) 39 | 40 | # "Create" RepairMosaicDatasetPaths GP tool Original Path/New Path 41 | # parameter string 42 | repairOrigNewPath = "" 43 | for regName in installOnlyPublishingFolders.keys(): 44 | repairOrigNewPath = repairOrigNewPath + "; " + \ 45 | installOnlyPublishingFolders[regName] + " " + newPath 46 | # Remove leading semicolon 47 | repairOrigNewPath = repairOrigNewPath.replace("; ", "", 1) 48 | 49 | rootSearchPath = newPath 50 | 51 | # Get list of all folders ending in ".gdb" 52 | print 53 | print "Searching " + rootSearchPath + " looking for file geodatabases..." 54 | gdbList = findFolderPath(rootSearchPath, "*.gdb", False) 55 | 56 | # Ensure that list only contains entries that are local geodatabase 57 | # (file geodatabase); just in case there happens to be a folder with ".gdb" 58 | # that is not a geodatabase 59 | gdbList[:] = [gdb for gdb in gdbList if 60 | arcpy.Describe(gdb).workspaceType.upper() == "LOCALDATABASE"] 61 | 62 | # Loop through all file geodatabases and repair paths for any non-referenced 63 | # mosaic datasets 64 | for gdb in gdbList: 65 | print 66 | print "Found file geodatabase: " + gdb 67 | print "\tChecking for existence of non-referenced mosaic datasets..." 68 | 69 | # Get any mosaic datasets in geodatabase 70 | arcpy.env.workspace = gdb 71 | mdList = arcpy.ListDatasets("*", "Mosaic") 72 | 73 | # Modify list to contain only non-reference mosaic datasets 74 | mdList[:] = [md for md in mdList if not arcpy.Describe(md).referenced] 75 | 76 | if len(mdList) == 0: 77 | print "\tNone found." 78 | else: 79 | print "\tFound " + str(len(mdList)) + " non-referenced mosaic dataset(s)." 80 | 81 | for md in mdList: 82 | print 83 | print "\tRepairing paths in mosaic dataset '" + md + "'..." 84 | results = repairMosaicDatasetPaths(md, repairOrigNewPath) 85 | success = checkResults(results, printMsg) 86 | if not success: 87 | totalSuccess = success 88 | 89 | except: 90 | 91 | # Get the traceback object 92 | tb = sys.exc_info()[2] 93 | tbinfo = traceback.format_tb(tb)[0] 94 | 95 | # Concatenate information together concerning the error into a message string 96 | pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) 97 | 98 | # Print Python error messages for use in Python / Python Window 99 | print 100 | print "***** ERROR ENCOUNTERED *****" 101 | print pymsg + "\n" 102 | 103 | finally: 104 | print 105 | print 106 | if totalSuccess: 107 | print "Done repairing mosaic dataset paths." 108 | else: 109 | print "ERROR occurred during mosaic dataset path repair." 110 | print 111 | 112 | return totalSuccess 113 | 114 | -------------------------------------------------------------------------------- /SupportFiles/UpdateWebApps.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #------------------------------------------------------------------------------ 3 | # Copyright 2014 Esri 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | #Name: UpdateWebApps.py 17 | # 18 | #Purpose: Performs search/replace of server names and portal item ids 19 | # in files deployed to IIS. 20 | # 21 | #Prerequisites: Portal content must have already been published and web apps 22 | # deployed to IIS. 23 | # 24 | #============================================================================== 25 | import os, sys, traceback, fnmatch, fileinput 26 | import httplib, urllib, json 27 | from Utilities import makePath 28 | from Utilities import editFiles 29 | from walkingDirTrees import listFiles 30 | from Utilities import findFolderPath, findFilePath, findInFile 31 | import json 32 | 33 | is_debug = False 34 | is_edit = True 35 | 36 | scriptName = sys.argv[0] 37 | 38 | # --------------------------------------------------------------------- 39 | # Check arguments 40 | # --------------------------------------------------------------------- 41 | if len(sys.argv) <> 5: 42 | print '\n' + scriptName + ' ' 43 | print '\nWhere:' 44 | print '\n\t (required): the path of the root folder to search for web files to edit.' 45 | print '\n\t (required): the old server name' 46 | print '\n\t (required): the new server name where web apps will running on' 47 | print '\n\t (required): the file path to the .json file containing the old and new portal item ids.' 48 | print '\t\t\t(i.e. the file named "oldID_newID.json" that is created by the PublishContentPost.py script within' 49 | print '\t\t\t the source portal content folder)' 50 | print '\n\tNOTE: script only edits index.html, briefingbook_config.js, Config.js, and *.csv files;' 51 | print '\t\tSearch functionality is case-sensitive.' 52 | sys.exit(1) 53 | 54 | 55 | # Set variables from script parameters 56 | root_path = sys.argv[1] 57 | old_hostname = sys.argv[2] 58 | new_hostname = sys.argv[3] 59 | id_map_file = sys.argv[4] 60 | 61 | # ------------------------------------------------------------------------------------ 62 | # Check if root folder and json file exist. 63 | # ------------------------------------------------------------------------------------ 64 | if not os.path.exists(root_path): 65 | print '\nERROR: folder ' + root_path + ' does not exist. Exiting script.' 66 | sys.exit(1) 67 | 68 | if not os.path.isfile(id_map_file): 69 | print '\nERROR: file ' + id_map_file + ' does not exist. Exiting script.' 70 | sys.exit(1) 71 | 72 | # ------------------------------------------------------------------------------------ 73 | # Create list of files to update 74 | # ------------------------------------------------------------------------------------ 75 | files_to_update = [] 76 | 77 | files_to_update.extend(findFilePath(root_path, '*.js', returnFirst=False)) 78 | files_to_update.extend(findFilePath(root_path, '*.html', returnFirst=False)) 79 | files_to_update.extend(findFilePath(root_path, '*.json', returnFirst=False)) 80 | files_to_update.extend(findFilePath(root_path, '*.csv', returnFirst=False)) 81 | files_to_update.extend(findFilePath(root_path, '*.erb', returnFirst=False)) 82 | files_to_update.extend(findFilePath(root_path, '*.config', returnFirst=False)) 83 | 84 | total_files = len(files_to_update) 85 | 86 | # ------------------------------------------------------------------------------------ 87 | # Create dictionary of search/replace values 88 | # ------------------------------------------------------------------------------------ 89 | search_replace_map = {} 90 | 91 | # Add old/new hostnames 92 | search_replace_map[old_hostname] = new_hostname 93 | 94 | # Load json file containing old/new ids 95 | if id_map_file: 96 | os.chdir(os.path.dirname(id_map_file)) 97 | id_map = json.load(open(os.path.basename(id_map_file))) 98 | 99 | if is_debug: 100 | print str(id_map) 101 | 102 | for i in id_map: 103 | try: 104 | # Read in search/replace values from hosted service 105 | # item mapping file 106 | search = i['search'] 107 | replace = i['replace'] 108 | except Exception as err: 109 | # Read in search/replace values from portal post script 110 | # item mapping file 111 | search = i 112 | replace = id_map[search]['id'] 113 | 114 | search_replace_map[search] = replace 115 | 116 | if is_debug: 117 | print '\n\n' + str(search_replace_map) 118 | 119 | # ------------------------------------------------------------------------------------ 120 | # Replace values in each file 121 | # ------------------------------------------------------------------------------------ 122 | section_break = '-' * 120 123 | 124 | if is_edit: 125 | n = 1 126 | for myfile in files_to_update: 127 | print section_break 128 | print 'Editing file: {} ({} of {})'.format(myfile, n, total_files) 129 | for line in fileinput.FileInput(myfile,inplace=1): 130 | # Also remove the newline character from end of line, otherwise 131 | # when "line" is printed below an extra newline character 132 | # will be embedded. 133 | for find_string, replace_string in search_replace_map.iteritems(): 134 | find_str_list = [find_string, find_string.lower(), find_string.upper()] 135 | for find_str in find_str_list: 136 | line = line.replace(find_str.encode('ascii'), replace_string.encode('ascii')).rstrip('\n') 137 | #!!! NOTE: you must print line to screen for "inplace" option to work 138 | print line 139 | print '\tDone.' 140 | n = n + 1 141 | print '\n\nDone updating values in files.' 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /SupportFiles/UrlCheckerWithErrorCodeReturn.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | :: **IMPORTANT** 4 | :: You may need to edit Python Path Below to change to the Python 2.X Path on your machine (requires Python 2.X) 5 | :: 6 | :: Instructions: 7 | :: To use this script/batch to check the arcgis-solutions-website pages 8 | :: 9 | :: 1. Copy the following files to arcgis-solutions-website\source 10 | :: a. UrlChecker.py 11 | :: b. UrlCheckerWithErrorCodeReturn.bat 12 | :: 2. Edit the python below path if necessary 13 | :: 3. Run UrlCheckerWithErrorCodeReturn.bat 14 | :: a. Open a command prompt 15 | :: b. Change directory to arcgis-solutions-website\source 16 | :: > cd {local location}\arcgis-solutions-website\source folder 17 | :: c. Run UrlCheckerWithErrorCodeReturn.bat 18 | 19 | :: This script calls a link checker and exits with an error code if a failure (error code) returned from script 20 | 21 | :: TODO: Edit this if necessary to point to the local install of python 22 | SET MY_PYTHON_PATH="C:\Python27\ArcGIS10.3" 23 | 24 | if not exist %MY_PYTHON_PATH%\python.exe goto no_python 25 | 26 | %MY_PYTHON_PATH%\python UrlChecker.py Results-military.csv military 27 | if %errorlevel% NEQ 0 goto failure 28 | 29 | %MY_PYTHON_PATH%\python UrlChecker.py Results-intel.csv intelligence 30 | if %errorlevel% NEQ 0 goto failure 31 | 32 | :: Custom example if you just want to check a single subfolder, edit & uncomment 33 | ::%MY_PYTHON_PATH%\python UrlChecker.py Results-Example.csv military\land-operations\operational-environment 34 | ::if %errorlevel% NEQ 0 goto failure 35 | 36 | 37 | echo No Bad Links Detected 38 | exit /b 0 39 | 40 | :failure 41 | echo ********** BAD LINKS DETECTED ********** 42 | exit /b 1 43 | 44 | :no_python 45 | echo ********** PYTHON NOT FOUND ********** 46 | echo Python not found at: %MY_PYTHON_PATH% 47 | exit /b 1 48 | -------------------------------------------------------------------------------- /SupportFiles/walkingDirTrees.py: -------------------------------------------------------------------------------- 1 | # The code in this module is from the publication "Python Cookbook (TM)", 2 | # edited by Alex Martelli and David Ascher, published by O'Reilly Media, Inc. 2002 3 | # 4 | # This code can be found in section 4.18 "Walking Directory Trees" of the above 5 | # listed publication. Credit: Robin Parmar, and Alex Martelli 6 | # 7 | # The following is the modified Berkeley license which applies to the code 8 | # in this module: 9 | # 10 | # Copyright (c) 2001, Robin Parmar, and Alex Martelli 11 | # All rights reserved. 12 | # Redistribution and use in source and binary forms, with or without 13 | # modification, are permitted provided that the following conditions 14 | # are met: 15 | # * Redistributions of source code must retain the above copyright 16 | # notice, this list of conditions and the following disclaimer. 17 | # * Redistributions in binary form must reproduce the above 18 | # copyright notice, this list of conditions and the following 19 | # disclaimer in the documentation and/or other materials provided 20 | # with the distribution. 21 | # * Neither the name of the nor the names of its 22 | # contributors may be used to endorse or promote products derived 23 | # from this software without specific prior written premission. 24 | # THIS SOFWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 25 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 26 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 27 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS 28 | # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 29 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 30 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES); LOSS OF USE, DATA, OR PROFITS; 31 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 32 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 33 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 34 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | #============================================================================== 36 | #Name: walkingDirTrees.py 37 | # 38 | #Purpose: Searches folder structure for specified file/folder. 39 | # 40 | #============================================================================== 41 | import os.path, fnmatch 42 | 43 | def listFiles(root, patterns='*', recurse=1, return_folders=0): 44 | 45 | # Expand patterns from semicolon-separated string to list 46 | pattern_list = patterns.split(';') 47 | # Collect input and output arguments into one bunch 48 | class Bunch: 49 | def __init__(self, **kwds): self.__dict__.update(kwds) 50 | arg = Bunch(recurse=recurse, pattern_list=pattern_list, 51 | return_folders=return_folders, results=[]) 52 | 53 | def visit(arg, dirname, files): 54 | # Append to arg.results all relevant files (and perhaps folders) 55 | for name in files: 56 | fullname = os.path.normpath(os.path.join(dirname, name)) 57 | if arg.return_folders or os.path.isfile(fullname): 58 | for pattern in arg.pattern_list: 59 | if fnmatch.fnmatch(name, pattern): 60 | arg.results.append(fullname) 61 | break 62 | # Block recursion if recursion was disallowed 63 | if not arg.recurse: files[:]=[] 64 | 65 | os.path.walk(root, visit, arg) 66 | 67 | return arg.results 68 | 69 | -------------------------------------------------------------------------------- /Utilities/CreateBatchFileToRunCreateServiceList.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #------------------------------------------------------------------------------ 3 | # Copyright 2014 Esri 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | #Name: CreateBatchFileToRunCreateServiceList.py 17 | # 18 | #Purpose: Creates a batch file containing the syntax to execute the CreateServiceList.py 19 | # for each portal user in the specified portal. 20 | # 21 | #============================================================================== 22 | import sys 23 | import os 24 | 25 | append_to_sys_path = os.path.join(os.path.join((os.path.dirname(os.path.dirname(sys.argv[0]))), 'Publish'), 'Portal') 26 | sys.path.append(append_to_sys_path) 27 | 28 | #import portalpy 29 | import json 30 | from portalpy import Portal 31 | 32 | script_name = sys.argv[0] 33 | script_path = os.path.dirname(sys.argv[0]) 34 | exitErrCode = 1 35 | username_exclude = ['system_publisher'] 36 | 37 | def main(): 38 | 39 | totalSuccess = True 40 | out_file = None 41 | 42 | # Check arguments 43 | results = check_args() 44 | if not results: 45 | sys.exit(exitErrCode) 46 | 47 | # Get parameter values 48 | portal_url, user, password, output_file, output_per_user = results 49 | 50 | try: 51 | access_mode = 'w' 52 | 53 | # Create portal object 54 | portal = Portal(portal_url, user, password) 55 | 56 | if not portal: 57 | raise Exception('ERROR: Could not create "portal" object.') 58 | 59 | if not portal.logged_in_user(): 60 | raise Exception('\nERROR: Could not sign in with specified credentials.') 61 | 62 | # Get portal users 63 | portal_users = portal.org_users() 64 | 65 | out_file = open(output_file, access_mode) 66 | out_file_dir = os.path.dirname(output_file) 67 | 68 | for portal_user in portal_users: 69 | 70 | user_name = portal_user['username'] 71 | 72 | if user_name in username_exclude: 73 | continue 74 | 75 | if output_per_user: 76 | service_list_outfile = os.path.join(out_file_dir, '{}_ServiceList.txt'.format(user_name)) 77 | service_list_qc_outfile = os.path.join(out_file_dir, '{}_CreateServiceList_output.txt'.format(user_name)) 78 | access_mode = 'OVERWRITE' 79 | redirect = '>' 80 | else: 81 | service_list_outfile = os.path.join(out_file_dir, 'ServiceList.txt') 82 | service_list_qc_outfile = os.path.join(out_file_dir, 'CreateServiceList_output.txt') 83 | access_mode = 'APPEND' 84 | redirect = '>>' 85 | 86 | script_parameters = '{} {} {} {} {} {} {} {} {}'.format( 87 | os.path.join(script_path, 'CreateServiceList.py'), 88 | portal_url, user, password, service_list_outfile, 89 | access_mode, user_name, redirect, service_list_qc_outfile) 90 | 91 | out_file.write(script_parameters + '\n') 92 | 93 | print '\nCreated output batch file: {}\n'.format(output_file) 94 | print 'Done.' 95 | 96 | except: 97 | totalSuccess = False 98 | 99 | # Get the traceback object 100 | tb = sys.exc_info()[2] 101 | tbinfo = traceback.format_tb(tb)[0] 102 | 103 | # Concatenate information together concerning the error into a message string 104 | pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) 105 | 106 | # Print Python error messages for use in Python / Python Window 107 | print 108 | print "***** ERROR ENCOUNTERED *****" 109 | print pymsg + "\n" 110 | 111 | finally: 112 | if hasattr(out_file, 'close'): 113 | out_file.close() 114 | if totalSuccess: 115 | sys.exit(0) 116 | else: 117 | sys.exit(1) 118 | 119 | def check_args(): 120 | # --------------------------------------------------------------------- 121 | # Check arguments 122 | # --------------------------------------------------------------------- 123 | 124 | if len(sys.argv) < 5: 125 | 126 | print '\n' + script_name + ' {FilePerUser: YES|NO}' 127 | 128 | print '\nWhere:' 129 | print '\n\t{:<20}: {}'.format('', 'URL of Portal (i.e. https://fully_qualified_domain_name/arcgis).') 130 | print '\n\t{:<20}: {}'.format('', 'Portal admin user.') 131 | print '\n\t{:<20}: {}'.format('', 'Password for portal admin user.') 132 | print '\n\t{:<20}: {}'.format('', 'Path and name of batch file to write call to CreateServiceList.py script.') 133 | print '\n\t{:<20}: {}'.format('{FilePerUser: YES|NO}', 'CreateServiceList.py script will create a file per user.\n') 134 | return None 135 | 136 | else: 137 | 138 | # Set variables from parameter values 139 | portal_url = sys.argv[1] 140 | user = sys.argv[2] 141 | password = sys.argv[3] 142 | output_file = sys.argv[4] 143 | output_per_user = 'YES' 144 | 145 | if len(sys.argv) == 6: 146 | output_per_user = sys.argv[5] 147 | 148 | if len(sys.argv) > 6: 149 | print '\nError: too many parameters.\n' 150 | return None 151 | 152 | valid_file_per_user = ['YES', 'NO'] 153 | if not output_per_user.upper() in valid_file_per_user: 154 | print '\nError: incorrect {{FilePerUser}} value "{}". Valid choices are: {}\n'.format( 155 | output_per_user, ', '.join(valid_file_per_user)) 156 | return None 157 | 158 | if output_per_user.upper() == 'YES': 159 | output_per_user = True 160 | else: 161 | output_per_user = False 162 | 163 | return portal_url, user, password, output_file, output_per_user 164 | 165 | if __name__ == "__main__": 166 | main() 167 | -------------------------------------------------------------------------------- /Utilities/CreateOpsServerReleaseFolderStructure.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem #------------------------------------------------------------------------------ 3 | rem # Copyright 2014 Esri 4 | rem # Licensed under the Apache License, Version 2.0 (the "License"); 5 | rem # you may not use this file except in compliance with the License. 6 | rem # You may obtain a copy of the License at 7 | rem # 8 | rem # http://www.apache.org/licenses/LICENSE-2.0 9 | rem # 10 | rem # Unless required by applicable law or agreed to in writing, software 11 | rem # distributed under the License is distributed on an "AS IS" BASIS, 12 | rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | rem # See the License for the specific language governing permissions and 14 | rem # limitations under the License. 15 | rem #======================================================================== 16 | rem # 17 | rem # Purpose: Create Ops Server distribution folder structure. 18 | rem # 19 | rem # Usage: CreateOpsServerReleaseFolderStructure 20 | rem # 21 | rem #======================================================================== 22 | 23 | set argc=0 24 | for %%x in (%*) do Set /A argc+=1 25 | if %argc% LSS 1 (goto PRINTUSAGE) 26 | 27 | set ops_rootPath=%1 28 | set ops_rootInstallPath=%ops_rootPath%\OPSServerInstall 29 | 30 | set ops_OpsTypes=DomOps Intel LandOps MaritimeOps EmergencyManagement 31 | 32 | REM --------------------------------------- 33 | REM Create Demo and Scripts folder 34 | REM --------------------------------------- 35 | set ops_demoScriptsRootPath=%ops_rootPath%\DemoAndScripts 36 | 37 | mkdir %ops_demoScriptsRootPath% 38 | 39 | REM --------------------------------------- 40 | REM Create Resources folder 41 | REM --------------------------------------- 42 | set ops_resourcesRootPath=%ops_rootPath%\Resources 43 | set ops_ResourcesSubFolders=Videos 44 | 45 | mkdir %ops_resourcesRootPath% 46 | 47 | for %%d in (%ops_ResourcesSubFolders%) do ( 48 | mkdir %ops_resourcesRootPath%\%%d 49 | ) 50 | 51 | REM --------------------------------------- 52 | REM Create Geoevent related "support" folders 53 | REM --------------------------------------- 54 | set ops_geoeventRootPath=%ops_rootInstallPath%\Geoevent 55 | set ops_geoeventSubFolders=Data jar_files MessageSimulator MessageSimulator\Messages MessageSimulator\Messages\GeoEventSimulator 56 | mkdir %ops_geoeventRootPath% 57 | for %%d in (%ops_geoeventSubFolders%) do ( 58 | mkdir %ops_geoeventRootPath%\%%d 59 | ) 60 | 61 | REM --------------------------------------- 62 | REM Create portal related folders 63 | REM --------------------------------------- 64 | set ops_portalRootPath=%ops_rootInstallPath%\Portal 65 | 66 | mkdir %ops_portalRootPath%\PortalContent 67 | for %%d in (%ops_OpsTypes%) do ( 68 | mkdir %ops_portalRootPath%\PortalResources\%%d 69 | ) 70 | 71 | REM --------------------------------------- 72 | REM Create server related folders 73 | REM --------------------------------------- 74 | set ops_serverRootPath=%ops_rootInstallPath%\Server 75 | 76 | set ops_ServerFolders=DistributionEntGDBs ServiceDefinitions Staging\Caches Staging\Data SupportFiles\Republishing 77 | for %%d in (%ops_ServerFolders%) do ( 78 | mkdir %ops_serverRootPath%\%%d 79 | ) 80 | 81 | REM --------------------------------------- 82 | REM Create software related folders 83 | REM --------------------------------------- 84 | set ops_softwareRootPath=%ops_rootInstallPath%\Software 85 | 86 | set ops_SoftwareFolders=ArcGISDataStore ArcGISGeoEvent ArcGISServer Authorization_Files ChatServer\Openfire Database\PostgreSQL_9.3.5 Desktop ArcGISPro ^ 87 | MessageSimulator\MessageSimulator OpsDashboardUtility\Certificate ops-server-config PortalForArcGIS WebAdaptorIIS EsriMapsForOffice PredictiveAnalysis 88 | for %%d in (%ops_SoftwareFolders%) do ( 89 | mkdir %ops_softwareRootPath%\%%d 90 | ) 91 | 92 | REM --------------------------------------- 93 | REM Created web apps related folders 94 | REM --------------------------------------- 95 | set ops_webappsRootPath=%ops_rootInstallPath% 96 | 97 | mkdir %ops_webappsRootPath%\WebApps\wwwroot\Downloads 98 | 99 | @echo Done. 100 | 101 | goto END 102 | 103 | :PRINTUSAGE 104 | @echo Usage: CreateOpsServerReleaseFolderStructure ^ 105 | @goto END 106 | 107 | :END 108 | -------------------------------------------------------------------------------- /Utilities/GenerateCreateUserFiles.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #------------------------------------------------------------------------------ 3 | # Copyright 2014 Esri 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | #Name: GenerateCreateUserFiles.py 17 | # 18 | #Purpose: Creates the input files used by the CreateUsers.bat file from 19 | # the portal content extracted by the PortalContentExtract.py 20 | # script. 21 | # 22 | #Prerequisites: Portal items must have been extracted to disk. 23 | # 24 | #============================================================================== 25 | import sys, os, traceback, json 26 | 27 | sys.path.append(os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'SupportFiles')) 28 | 29 | from Utilities import findFilePath 30 | 31 | scriptName = sys.argv[0] 32 | exitErrCode = 1 33 | sectionBreak = '=' * 175 34 | sectionBreak1 = '-' * 175 35 | 36 | userinfo_file = 'userinfo.json' 37 | account_password = 'MyPassword!' # Built-in account password 38 | email_suffix = '@no_email_in_user_profile.org' 39 | ent_filename = 'enterprise_users.txt' 40 | builtin_filename = 'builtin_users.txt' 41 | out_ent_f = None # Enterprise account file object 42 | out_builtin_f = None # Built-in account file object 43 | file_objects = [out_ent_f, out_builtin_f] 44 | 45 | def check_args(): 46 | # --------------------------------------------------------------------- 47 | # Check arguments 48 | # --------------------------------------------------------------------- 49 | 50 | if len(sys.argv) <> 3: 51 | 52 | print '\n' + scriptName + ' ' 53 | 54 | print '\nWhere:' 55 | print '\n\t (required): path to the folder containing the extracted portal content.' 56 | print '\n\t (required): path to the folder where the output user files ({}, {}) will be created.\n'.format(ent_filename, builtin_filename) 57 | return None 58 | 59 | else: 60 | 61 | # Set variables from parameter values 62 | content_folder = sys.argv[1] 63 | output_folder = sys.argv[2] 64 | 65 | # Verify that paths exist 66 | if not os.path.exists(content_folder): 67 | print '\nERROR: path {} does not exist.\n'.format(content_folder) 68 | sys.exit(exitErrCode) 69 | if not os.path.exists(output_folder): 70 | print '\nERROR: path {} does not exist.\n'.format(output_folder) 71 | sys.exit(exitErrCode) 72 | 73 | return content_folder, output_folder 74 | 75 | def get_userinfo_files(portal_content_folder): 76 | userinfo_files = findFilePath(portal_content_folder, userinfo_file, returnFirst=False) 77 | return userinfo_files 78 | 79 | def is_enterprise_account(userinfo): 80 | ''' Returns boolean indicating if account is an enterprise account ''' 81 | return userinfo['username'].find('@') > -1 82 | 83 | def create_account_recs(portal_content_folder): 84 | ent_accounts = [] 85 | builtin_accounts = [] 86 | 87 | userinfo_files = get_userinfo_files(portal_content_folder) 88 | 89 | for userinfo_file in userinfo_files: 90 | os.chdir(os.path.dirname(userinfo_file)) 91 | userinfo = json.load(open(userinfo_file)) 92 | 93 | login = userinfo['username'] 94 | email = userinfo['email'] 95 | name = userinfo['fullName'] 96 | role = userinfo['role'] 97 | description = str(userinfo['description']) # Optional 98 | idpusername = str(userinfo['idpUsername']) # Optional 99 | 100 | # Perform some extra processing 101 | if not email: 102 | email = login.split('@')[0] + email_suffix 103 | if description == 'None': 104 | description = '' 105 | if idpusername == 'null': 106 | idpusername = '' 107 | 108 | if is_enterprise_account(userinfo): 109 | account = [login, email, name, role, description, idpusername] 110 | ent_accounts.append('|'.join(account)) 111 | else: 112 | account = [login, account_password, email, name, role, description] 113 | builtin_accounts.append('|'.join(account)) 114 | 115 | return ent_accounts, builtin_accounts 116 | 117 | def write_files(output_folder, ent_accounts, builtin_accounts): 118 | 119 | out_ent_file = output_folder + os.path.sep + ent_filename 120 | out_builtin_file = output_folder + os.path.sep + builtin_filename 121 | 122 | # Delete existing files 123 | if os.path.exists(out_ent_file): 124 | os.remove(out_ent_file) 125 | if os.path.exists(out_builtin_file): 126 | os.remove(out_builtin_file) 127 | 128 | # Write files 129 | if len(ent_accounts) > 0: 130 | out_ent_f = open(out_ent_file, 'w') 131 | for account in ent_accounts: 132 | out_ent_f.write('{}\n'.format(account)) 133 | out_ent_f.close() 134 | 135 | if len(builtin_accounts) > 0: 136 | out_builtin_f = open(out_builtin_file, 'w') 137 | for account in builtin_accounts: 138 | out_builtin_f.write('{}\n'.format(account)) 139 | out_builtin_f.close() 140 | 141 | def main(): 142 | 143 | totalSuccess = True 144 | out_ent_file = None 145 | out_builtin_file = None 146 | 147 | # ------------------------------------------------- 148 | # Check arguments 149 | # ------------------------------------------------- 150 | results = check_args() 151 | if not results: 152 | sys.exit(exitErrCode) 153 | 154 | # Get parameter values 155 | content_folder, output_folder = results 156 | 157 | try: 158 | print '\n- Assembling user account info from extracted portal content...' 159 | ent_accounts, builtin_accounts = create_account_recs(content_folder) 160 | 161 | print '\n- Writing user account info to output files...' 162 | write_files(output_folder, ent_accounts, builtin_accounts) 163 | 164 | print '\nDone.\n' 165 | 166 | except: 167 | totalSuccess = False 168 | 169 | # Get the traceback object 170 | tb = sys.exc_info()[2] 171 | tbinfo = traceback.format_tb(tb)[0] 172 | 173 | # Concatenate information together concerning the error into a message string 174 | pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) 175 | 176 | # Print Python error messages for use in Python / Python Window 177 | print 178 | print "***** ERROR ENCOUNTERED *****" 179 | print pymsg + "\n" 180 | 181 | finally: 182 | for file_object in file_objects: 183 | if hasattr(file_object, 'close'): 184 | file_object.close() 185 | 186 | if totalSuccess: 187 | sys.exit(0) 188 | else: 189 | sys.exit(exitErrCode) 190 | 191 | if __name__ == "__main__": 192 | main() 193 | -------------------------------------------------------------------------------- /Utilities/ListServiceWorkspaces.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #------------------------------------------------------------------------------ 3 | # Copyright 2014 Esri 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | #Name: ListServiceWorkspaces.py 17 | # 18 | #Purpose: Output service workspace information for each service in 19 | # specified ArcGIS Server site. 20 | # 21 | #============================================================================== 22 | import sys, os, traceback, datetime, ast, copy, json 23 | 24 | sys.path.append(os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'SupportFiles')) 25 | 26 | from AGSRestFunctions import getServiceList 27 | from AGSRestFunctions import getServiceManifest 28 | 29 | scriptName = os.path.basename(sys.argv[0]) 30 | exitErrCode = 1 31 | debug = False 32 | sectionBreak = '=' * 175 33 | sectionBreak1 = '-' * 175 34 | 35 | 36 | def check_args(): 37 | # --------------------------------------------------------------------- 38 | # Check arguments 39 | # --------------------------------------------------------------------- 40 | 41 | if len(sys.argv) <> 6: 42 | 43 | print '\n' + scriptName + ' ' 44 | 45 | print '\nWhere:' 46 | print '\n\t (required): the fully qualified domain name of the ArcGIS Server machine.' 47 | print '\n\t (required): the port number of the ArcGIS Server (specify # if no port).' 48 | print '\n\t (required): ArcGIS Server for ArcGIS site administrator.' 49 | print '\n\t (required): Password for ArcGIS Server for ArcGIS site administrator user.' 50 | print '\n\t (required) Flag indicating if ArcGIS Server requires HTTPS.\n' 51 | return None 52 | 53 | else: 54 | 55 | # Set variables from parameter values 56 | server = sys.argv[1] 57 | port = sys.argv[2] 58 | adminuser = sys.argv[3] 59 | password = sys.argv[4] 60 | useSSL = sys.argv[5] 61 | 62 | if port.strip() == '#': 63 | port = None 64 | 65 | if useSSL.strip().lower() in ['yes', 'ye', 'y']: 66 | useSSL = True 67 | else: 68 | useSSL = False 69 | 70 | return server, port, adminuser, password, useSSL 71 | 72 | def parseService(service): 73 | # Parse folder and service nameType 74 | folder = None 75 | serviceNameType = None 76 | 77 | parsedService = service.split('//') 78 | 79 | if len(parsedService) == 1: 80 | serviceNameType = parsedService[0] 81 | else: 82 | folder = parsedService[0] 83 | serviceNameType = parsedService[1] 84 | 85 | return folder, serviceNameType 86 | 87 | def main(): 88 | 89 | totalSuccess = True 90 | 91 | # ------------------------------------------------- 92 | # Check arguments 93 | # ------------------------------------------------- 94 | results = check_args() 95 | if not results: 96 | sys.exit(exitErrCode) 97 | server, port, adminuser, password, useSSL = results 98 | 99 | if debug: 100 | print server, port, adminuser, password, useSSL 101 | 102 | try: 103 | # ------------------------------------------------- 104 | # Get all services that exist on server 105 | # ------------------------------------------------- 106 | if useSSL: 107 | protocol = 'https' 108 | else: 109 | protocol = 'http' 110 | 111 | allServices = getServiceList(server, port, adminuser, password) 112 | 113 | # Remove certain services from collection 114 | excludeServices = ['SampleWorldCities.MapServer'] 115 | services = [service for service in allServices if service not in excludeServices] 116 | if len(services) == 0: 117 | raise Exception('ERROR: There are no user published ArcGIS Server services. Have you published the ArcGIS Server services?') 118 | 119 | # ------------------------------------------------- 120 | # List service workspaces 121 | # ------------------------------------------------- 122 | numServices = len(services) 123 | i = 0 124 | 125 | # Print header 126 | print 'ArcGIS Server|Service|On Server Connection String/or Path' 127 | 128 | for service in services: 129 | onServerStr = '' 130 | 131 | folder, serviceNameType = parseService(service) 132 | 133 | serviceManifest = getServiceManifest(server, port, adminuser, password, folder, serviceNameType) 134 | 135 | databases = serviceManifest.get('databases') 136 | if databases: 137 | onServerConnStr = databases[0].get('onServerConnectionString') 138 | if onServerConnStr: 139 | if onServerConnStr.find('DB_CONNECTION_PROPERTIES') > 0: 140 | # It's an enterprise geodatabase 141 | onServerStr = onServerConnStr.split('DB_CONNECTION_PROPERTIES=')[1] 142 | else: 143 | onServerStr = onServerConnStr.replace('DATABASE=','') 144 | else: 145 | if serviceNameType.find('.GeocodeServer') > 0 or serviceNameType.find('.GPServer') > 0: 146 | onServerStr = serviceManifest.get('resources')[0].get('serverPath') 147 | 148 | if len(onServerStr) == 0: 149 | onServerStr = str(serviceManifest) 150 | 151 | print '{}|{}|{}'.format(server, service, onServerStr) 152 | 153 | 154 | except: 155 | totalSuccess = False 156 | 157 | # Get the traceback object 158 | tb = sys.exc_info()[2] 159 | tbinfo = traceback.format_tb(tb)[0] 160 | 161 | # Concatenate information together concerning the error into a message string 162 | pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) 163 | 164 | # Print Python error messages for use in Python / Python Window 165 | print 166 | print "***** ERROR ENCOUNTERED *****" 167 | print pymsg + "\n" 168 | 169 | finally: 170 | if totalSuccess: 171 | sys.exit(0) 172 | else: 173 | sys.exit(1) 174 | 175 | 176 | if __name__ == "__main__": 177 | main() 178 | -------------------------------------------------------------------------------- /Utilities/ListServices.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #------------------------------------------------------------------------------ 3 | # Copyright 2015 Esri 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | #Name: ListServices.py 17 | # 18 | #Purpose: Output list of services in specified ArcGIS Server site. 19 | # 20 | #============================================================================== 21 | import sys, os, traceback, datetime, ast, copy, json 22 | 23 | sys.path.append(os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'SupportFiles')) 24 | 25 | from AGSRestFunctions import getServiceList 26 | #from AGSRestFunctions import getServiceManifest 27 | 28 | scriptName = os.path.basename(sys.argv[0]) 29 | exitErrCode = 1 30 | debug = False 31 | sectionBreak = '=' * 175 32 | sectionBreak1 = '-' * 175 33 | 34 | 35 | def check_args(): 36 | # --------------------------------------------------------------------- 37 | # Check arguments 38 | # --------------------------------------------------------------------- 39 | 40 | if len(sys.argv) <> 6: 41 | 42 | print '\n' + scriptName + ' ' 43 | 44 | print '\nWhere:' 45 | print '\n\t (required): the fully qualified domain name of the ArcGIS Server machine.' 46 | print '\n\t (required): the port number of the ArcGIS Server (specify # if no port).' 47 | print '\n\t (required): ArcGIS Server for ArcGIS site administrator.' 48 | print '\n\t (required): Password for ArcGIS Server for ArcGIS site administrator user.' 49 | print '\n\t (required) Flag indicating if ArcGIS Server requires HTTPS.\n' 50 | return None 51 | 52 | else: 53 | 54 | # Set variables from parameter values 55 | server = sys.argv[1] 56 | port = sys.argv[2] 57 | adminuser = sys.argv[3] 58 | password = sys.argv[4] 59 | useSSL = sys.argv[5] 60 | 61 | if port.strip() == '#': 62 | port = None 63 | 64 | if useSSL.strip().lower() in ['yes', 'ye', 'y']: 65 | useSSL = True 66 | else: 67 | useSSL = False 68 | 69 | return server, port, adminuser, password, useSSL 70 | 71 | def main(): 72 | 73 | totalSuccess = True 74 | 75 | # ------------------------------------------------- 76 | # Check arguments 77 | # ------------------------------------------------- 78 | results = check_args() 79 | if not results: 80 | sys.exit(exitErrCode) 81 | server, port, adminuser, password, useSSL = results 82 | 83 | if debug: 84 | print server, port, adminuser, password, useSSL 85 | 86 | try: 87 | # ------------------------------------------------- 88 | # Get all services that exist on server 89 | # ------------------------------------------------- 90 | if useSSL: 91 | protocol = 'https' 92 | else: 93 | protocol = 'http' 94 | 95 | allServices = getServiceList(server, port, adminuser, password) 96 | 97 | # Remove certain services from collection 98 | #excludeServices = ['SampleWorldCities.MapServer'] 99 | excludeServices = [] 100 | services = [service for service in allServices if service not in excludeServices] 101 | services = [service.replace('//', '/') for service in allServices] 102 | 103 | if len(services) == 0: 104 | raise Exception('ERROR: There are no user published ArcGIS Server services. Have you published the ArcGIS Server services?') 105 | 106 | # ------------------------------------------------- 107 | # List service workspaces 108 | # ------------------------------------------------- 109 | numServices = len(services) 110 | i = 0 111 | 112 | for service in services: 113 | i += 1 114 | print service 115 | #print 'Total: {}'.format(i) 116 | 117 | except: 118 | totalSuccess = False 119 | 120 | # Get the traceback object 121 | tb = sys.exc_info()[2] 122 | tbinfo = traceback.format_tb(tb)[0] 123 | 124 | # Concatenate information together concerning the error into a message string 125 | pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) 126 | 127 | # Print Python error messages for use in Python / Python Window 128 | print 129 | print "***** ERROR ENCOUNTERED *****" 130 | print pymsg + "\n" 131 | 132 | finally: 133 | if totalSuccess: 134 | sys.exit(0) 135 | else: 136 | sys.exit(1) 137 | 138 | 139 | if __name__ == "__main__": 140 | main() 141 | -------------------------------------------------------------------------------- /Utilities/ListServicesInSDFiles.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #------------------------------------------------------------------------------ 3 | # Copyright 2015 Esri 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | #============================================================================== 16 | #Name: ListServicesInSDFiles.py 17 | # 18 | #Purpose: Write service names referenced in SD files to file. 19 | # 20 | #============================================================================== 21 | import sys 22 | import os 23 | import traceback 24 | import datetime 25 | import ast 26 | import copy 27 | import json 28 | import subprocess 29 | import tempfile 30 | 31 | sys.path.append(os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'SupportFiles')) 32 | 33 | from walkingDirTrees import listFiles 34 | from GetSDFiles import extractFromSDFile 35 | 36 | scriptName = os.path.basename(sys.argv[0]) 37 | exitErrCode = 1 38 | sectionBreak = '=' * 175 39 | sectionBreak1 = '-' * 175 40 | sevenZipExePath = r'C:\Program Files\7-Zip\7z.exe' 41 | out_f = None 42 | 43 | # Create temporary extract folder 44 | extract_folder = tempfile.mkdtemp() 45 | 46 | def check_args(): 47 | # --------------------------------------------------------------------- 48 | # Check arguments 49 | # --------------------------------------------------------------------- 50 | 51 | if len(sys.argv) <> 3: 52 | 53 | print '\n' + scriptName + ' ' 54 | 55 | print '\nWhere:' 56 | print '\n\t (required): folder containing the SD files.' 57 | print '\n\t (required): path and name of file where service names will be written.' 58 | return None 59 | 60 | else: 61 | 62 | # Set variables from parameter values 63 | sd_root_folder = sys.argv[1] 64 | output_file = sys.argv[2] 65 | 66 | if not os.path.isdir(sd_root_folder): 67 | print '\nERROR: Specified path {} does not exist' \ 68 | ' or is not a directory. Exiting script.\n'.format(sd_root_folder) 69 | return None 70 | 71 | if os.path.exists(output_file): 72 | print '\nERROR: Specified file {} already exists. ' \ 73 | 'Exiting script.\n'.format(output_file) 74 | return None 75 | 76 | return sd_root_folder, output_file 77 | 78 | def _format_servicename(folder_name, service_name, service_type): 79 | 80 | full_service_name = '{}.{}'.format(service_name, service_type) 81 | if len(folder_name) > 0: 82 | full_service_name = '{}/{}'.format(folder_name, full_service_name) 83 | 84 | return full_service_name 85 | 86 | def get_servicename_from_sdfile(sd_file): 87 | ''' Return folder/servicename.servicetype from service defintion file''' 88 | 89 | # Extract service configuration json file from compressed .sd file 90 | extract_file = 'serviceconfiguration.json' 91 | json_file = os.path.join(extract_folder, extract_file) 92 | extractFromSDFile(sd_file, extract_folder, extract_file) 93 | 94 | # Extract service information from the service config json file 95 | os.chdir(extract_folder) 96 | service_config = json.load(open(extract_file)) 97 | folder_name = service_config['folderName'] 98 | service_name = service_config['service']['serviceName'] 99 | service_type = service_config['service']['type'] 100 | 101 | return _format_servicename(folder_name, service_name, service_type) 102 | 103 | def main(): 104 | 105 | total_success = True 106 | 107 | # Before executing rest of script, lets check if 7-zip exe exists 108 | if not os.path.exists(sevenZipExePath): 109 | print 'ERROR: File path set by "sevenZipExePath" variable (' + \ 110 | sevenZipExePath + ') does not exist. Exiting script.' 111 | sys.exit(exitErrCode) 112 | 113 | # Get script parameters 114 | results = check_args() 115 | if not results: 116 | sys.exit(exitErrCode) 117 | sd_root_folder, output_file = results 118 | 119 | try: 120 | write_list = [] 121 | 122 | sd_files = listFiles(sd_root_folder, '*.sd') 123 | 124 | for sd_file in sd_files: 125 | full_service_name = get_servicename_from_sdfile(sd_file) 126 | write_list.append(full_service_name) 127 | 128 | write_list.sort() 129 | 130 | if len(write_list) > 0: 131 | out_f = open(output_file, 'w') 132 | for write_str in write_list: 133 | out_f.write('{}\n'.format(write_str)) 134 | 135 | print '\n\nDone. Output written to file: {}\n'.format(output_file) 136 | 137 | except: 138 | total_success = False 139 | 140 | # Get the traceback object 141 | tb = sys.exc_info()[2] 142 | tbinfo = traceback.format_tb(tb)[0] 143 | 144 | # Concatenate information together concerning the error into a message string 145 | pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1]) 146 | 147 | # Print Python error messages for use in Python / Python Window 148 | print 149 | print "***** ERROR ENCOUNTERED *****" 150 | print pymsg + "\n" 151 | 152 | finally: 153 | if out_f: 154 | out_f.close() 155 | 156 | if total_success: 157 | sys.exit(0) 158 | else: 159 | sys.exit(exitErrCode) 160 | 161 | 162 | if __name__ == "__main__": 163 | main() 164 | --------------------------------------------------------------------------------