commons

package
v0.0.0-...-a834cfb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2024 License: UPL-1.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const AlterApexUsers string = "\nALTER SESSION SET CONTAINER=%[2]s;" +
	"\n ALTER USER APEX_PUBLIC_USER IDENTIFIED BY \\\"%[1]s\\\" ACCOUNT UNLOCK; " +
	"\n ALTER USER APEX_REST_PUBLIC_USER IDENTIFIED BY \\\"%[1]s\\\" ACCOUNT UNLOCK;" +
	"\n ALTER USER APEX_LISTENER IDENTIFIED BY \\\"%[1]s\\\" ACCOUNT UNLOCK;" +
	"\nexec APEX_UTIL.set_workspace(p_workspace => 'INTERNAL');" +
	"\nexec APEX_UTIL.EDIT_USER(p_user_id => APEX_UTIL.GET_USER_ID('ADMIN'), p_user_name  => 'ADMIN', p_web_password => '%[1]s', p_new_password => '%[1]s');\n"
View Source
const AlterCpuCountCMD string = "echo -e \"alter system set cpu_count=%d; \" | %s"
View Source
const AlterProcessesCMD string = "echo -e  \"alter system set processes=%d scope=spfile; \" | %s && " + CreateChkFileCMD + " && " +
	"echo -e  \"SHUTDOWN IMMEDIATE; \n STARTUP MOUNT; \n ALTER DATABASE OPEN; \n ALTER PLUGGABLE DATABASE ALL OPEN; \n ALTER SYSTEM REGISTER;\" | %s && " +
	RemoveChkFileCMD
View Source
const AlterSgaPgaCMD string = "echo -e  \"alter system set sga_target=%dM scope=both; \n alter system set pga_aggregate_target=%dM scope=both; \" | %s "
View Source
const ApexAdmin string = "BEGIN" +
	"\napex_util.set_security_group_id(p_security_group_id => 10); APEX_UTIL.REMOVE_USER(p_user_name => 'ADMIN');" +
	"\nCOMMIT;" +
	"\nEND;" +
	"\n/" +
	"\nBEGIN" +
	"\nAPEX_UTIL.create_user(p_user_name => 'ADMIN',p_email_address   => 'admin@oracle.com',p_web_password => '%[1]s',p_developer_privs => 'ADMIN',p_failed_access_attempts => '5' ," +
	" p_allow_app_building_yn => 'Y' ,p_allow_sql_workshop_yn => 'Y' ,p_allow_websheet_dev_yn => 'Y' , p_allow_team_development_yn => 'Y' , p_change_password_on_first_use  => 'N' );" +
	"apex_util.unlock_account(p_user_name => 'ADMIN'); APEX_UTIL.set_security_group_id( null );" +
	"\nCOMMIT;" +
	"\nEND;" +
	"\n/" +
	"\nALTER SESSION SET CONTAINER=%[2]s;" +
	"\nBEGIN" +
	"\napex_util.set_security_group_id(p_security_group_id => 10); APEX_UTIL.REMOVE_USER(p_user_name => 'ADMIN');" +
	"\nCOMMIT;" +
	"\nEND;" +
	"\n/" +
	"\nBEGIN" +
	"\nAPEX_UTIL.create_user(p_user_name => 'ADMIN',p_email_address   => 'admin@oracle.com',p_web_password => '%[1]s',p_developer_privs => 'ADMIN',p_failed_access_attempts => '5' ," +
	" p_allow_app_building_yn => 'Y' ,p_allow_sql_workshop_yn => 'Y' ,p_allow_websheet_dev_yn => 'Y' , p_allow_team_development_yn => 'Y' , p_change_password_on_first_use  => 'N' );" +
	"apex_util.unlock_account(p_user_name => 'ADMIN'); APEX_UTIL.set_security_group_id( null );" +
	"\nCOMMIT;" +
	"\nEND;" +
	"\n/"
View Source
const ArchiveLogFalseCMD string = CreateChkFileCMD + " && " +
	"echo -e  \"SHUTDOWN IMMEDIATE; \n STARTUP MOUNT; \n ALTER DATABASE NOARCHIVELOG; \n SELECT log_mode FROM v\\$database; \n ALTER DATABASE OPEN;" +
	" \n ALTER PLUGGABLE DATABASE ALL OPEN; \n ALTER SYSTEM REGISTER;\" | %s && " + RemoveChkFileCMD
View Source
const ArchiveLogTrueCMD string = CreateChkFileCMD + " && " +
	"echo -e  \"SHUTDOWN IMMEDIATE; \n STARTUP MOUNT; \n ALTER DATABASE ARCHIVELOG; \n SELECT log_mode FROM v\\$database; \n ALTER DATABASE OPEN;" +
	" \n ALTER PLUGGABLE DATABASE ALL OPEN; \n ALTER SYSTEM REGISTER;\" | %s && " + RemoveChkFileCMD
View Source
const CONTAINER_LISTENER_PORT int32 = 1521
View Source
const CONTAINER_TCPS_PORT int32 = 2484
View Source
const CheckModesSQL string = "" /* 162-byte string literal not displayed */
View Source
const ChownApex string = " chown oracle:oinstall /opt/oracle/oradata/${ORACLE_SID^^}/apex;"
View Source
const ClientWalletLocation string = "/opt/oracle/oradata/clientWallet/%s"

TCPS clientWallet location

View Source
const ClientWalletUpdate string = "sed -i -e 's/HOST.*$/HOST=%s)/g' -e 's/PORT.*$/PORT=%d)/g' ${ORACLE_BASE}/oradata/clientWallet/${ORACLE_SID}/tnsnames.ora"

TCPS clientWallet update command

View Source
const ConfigureApexRest string = "if [ -f ${ORDS_HOME}/config/apex/apex_rest_config.sql ]; then  cd ${ORDS_HOME}/config/apex && " +
	"echo -e \"%[1]s\n%[1]s\" | %[2]s ; else echo \"Apex Folder doesn't exist\" ; fi ;"
View Source
const CopyApexImages string = " ( while true; do  sleep 60; echo \"Copying Apex Images...\" ; done ) & mkdir -p /opt/oracle/oradata/${ORACLE_SID^^}_ORDS/apex/images && " +
	" cp -R /opt/oracle/oradata/${ORACLE_SID^^}/apex/images/* /opt/oracle/oradata/${ORACLE_SID^^}_ORDS/apex/images; chown -R oracle:oinstall /opt/oracle/oradata/${ORACLE_SID^^}_ORDS/apex; kill -9 $!;"
View Source
const CreateAdminPasswordFile string = "umask 177\n cat > admin.pwd <<EOF\n%s\nEOF\n umask 022"
View Source
const CreateChkFileCMD string = "touch \"${ORACLE_BASE}/oradata/.${ORACLE_SID}.nochk\" && sync"
View Source
const CreateDBRecoveryDestCMD string = "mkdir -p ${ORACLE_BASE}/oradata/fast_recovery_area"
View Source
const CreateDGMGRLScriptFile string = "umask 177\n echo -e \"%s\" > dgmgrl.cmd\n umask 022"
View Source
const CreateORDSSchemaSQL = "\nALTER SESSION SET CONTAINER=%[3]s;" +
	"\nCREATE USER %[1]s IDENTIFIED BY \\\"%[2]s\\\";" +
	"\nGRANT CONNECT, RESOURCE, DBA, PDB_DBA TO %[1]s;"
View Source
const CreateSIDlinkCMD string = "cd ${ORACLE_BASE}/oradata && test ! -e $ORACLE_SID && ln -s $(basename $PRIMARY_DB_CONN_STR)/$ORACLE_SID"
View Source
const DBA_GUID int64 = 54322
View Source
const DBShowConfigCMD string = "SHOW CONFIGURATION;"
View Source
const DataguardBrokerAddDBMaxAvailabilityCMD string = "ADD DATABASE ${ORACLE_SID} AS CONNECT IDENTIFIER IS ${SVC_HOST}:1521/${ORACLE_SID} MAINTAINED AS PHYSICAL;" +
	"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY LogXptMode='SYNC';" +
	"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY STATICCONNECTIDENTIFIER='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=${SVC_HOST})(PORT=1521))" +
	"(CONNECT_DATA=(SERVICE_NAME=${ORACLE_SID}_DGMGRL)(INSTANCE_NAME=${ORACLE_SID})(SERVER=DEDICATED)))';" +
	"\nENABLE CONFIGURATION;"
View Source
const DataguardBrokerAddDBMaxPerformanceCMD string = "ADD DATABASE ${ORACLE_SID} AS CONNECT IDENTIFIER IS ${SVC_HOST}:1521/${ORACLE_SID} MAINTAINED AS PHYSICAL;" +
	"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY LogXptMode='ASYNC';" +
	"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY STATICCONNECTIDENTIFIER='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=${SVC_HOST})(PORT=1521))" +
	"(CONNECT_DATA=(SERVICE_NAME=${ORACLE_SID}_DGMGRL)(INSTANCE_NAME=${ORACLE_SID})(SERVER=DEDICATED)))';" +
	"\nENABLE CONFIGURATION;"
View Source
const DataguardBrokerGetDatabaseCMD string = "SELECT DATABASE || ':' || DATAGUARD_ROLE AS DATABASE FROM V\\$DG_BROKER_CONFIG;"
View Source
const DataguardBrokerMaxAvailabilityCMD string = "CREATE CONFIGURATION dg_config AS PRIMARY DATABASE IS ${PRIMARY_SID} CONNECT IDENTIFIER IS ${PRIMARY_DB_CONN_STR};" +
	"\nADD DATABASE ${ORACLE_SID} AS CONNECT IDENTIFIER IS ${SVC_HOST}:1521/${ORACLE_SID} MAINTAINED AS PHYSICAL;" +
	"\nEDIT DATABASE ${PRIMARY_SID} SET PROPERTY LogXptMode='SYNC';" +
	"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY LogXptMode='SYNC';" +
	"\nEDIT DATABASE ${PRIMARY_SID} SET PROPERTY STATICCONNECTIDENTIFIER='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=${PRIMARY_IP})(PORT=1521))" +
	"(CONNECT_DATA=(SERVICE_NAME=${PRIMARY_SID}_DGMGRL)(INSTANCE_NAME=${PRIMARY_SID})(SERVER=DEDICATED)))';" +
	"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY STATICCONNECTIDENTIFIER='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=${SVC_HOST})(PORT=1521))" +
	"(CONNECT_DATA=(SERVICE_NAME=${ORACLE_SID}_DGMGRL)(INSTANCE_NAME=${ORACLE_SID})(SERVER=DEDICATED)))';" +
	"\nEDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;" +
	"\nENABLE CONFIGURATION;"
View Source
const DataguardBrokerMaxPerformanceCMD string = "CREATE CONFIGURATION dg_config AS PRIMARY DATABASE IS ${PRIMARY_SID} CONNECT IDENTIFIER IS ${PRIMARY_DB_CONN_STR};" +
	"\nADD DATABASE ${ORACLE_SID} AS CONNECT IDENTIFIER IS ${SVC_HOST}:1521/${ORACLE_SID} MAINTAINED AS PHYSICAL;" +
	"\nEDIT DATABASE ${PRIMARY_SID} SET PROPERTY LogXptMode='ASYNC';" +
	"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY LogXptMode='ASYNC';" +
	"\nEDIT DATABASE ${PRIMARY_SID} SET PROPERTY STATICCONNECTIDENTIFIER='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=${PRIMARY_IP})(PORT=1521))" +
	"(CONNECT_DATA=(SERVICE_NAME=${PRIMARY_SID}_DGMGRL)(INSTANCE_NAME=${PRIMARY_SID})(SERVER=DEDICATED)))';" +
	"\nEDIT DATABASE ${ORACLE_SID} SET PROPERTY STATICCONNECTIDENTIFIER='(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=${SVC_HOST})(PORT=1521))" +
	"(CONNECT_DATA=(SERVICE_NAME=${ORACLE_SID}_DGMGRL)(INSTANCE_NAME=${ORACLE_SID})(SERVER=DEDICATED)))';" +
	"\nEDIT CONFIGURATION SET PROTECTION MODE AS MAXPERFORMANCE;" +
	"\nENABLE CONFIGURATION;"
View Source
const DisableTcpsCMD string = "$ORACLE_BASE/$CONFIG_TCPS_FILE disable"

Command to disable TCPS

View Source
const DropAdminUsersSQL string = "drop user C##DBAPI_CDB_ADMIN cascade;" +
	"\ndrop user C##_DBAPI_PDB_ADMIN cascade;"
View Source
const EnableFSFOCMD string = "ENABLE FAST_START FAILOVER;"
View Source
const EnableORDSSchemaSQL string = "\nALTER SESSION SET CONTAINER=%[4]s;" +
	"\nGRANT INHERIT PRIVILEGES ON USER SYS TO ORDS_METADATA;" +
	"\nexec ORDS.enable_schema(p_enabled => %[2]s ,p_schema => '%[1]s',p_url_mapping_type => 'BASE_PATH',p_url_mapping_pattern => '%[3]s',p_auto_rest_auth => FALSE);"
View Source
const EnableTcpsCMD string = "$ORACLE_BASE/$CONFIG_TCPS_FILE"

Command to enable TCPS as a formatted string. The parameter would be the port at which TCPS is enabled.

View Source
const FlashBackFalseSQL string = "SELECT flashback_on FROM v\\$database;" +
	"\nALTER DATABASE FLASHBACK OFF;" +
	"\nSELECT flashback_on FROM v\\$database;"
View Source
const FlashBackTrueSQL string = "SELECT flashback_on FROM v\\$database;" +
	"\nALTER DATABASE FLASHBACK ON;" +
	"\nSELECT flashback_on FROM v\\$database;"
View Source
const ForceLoggingFalseSQL string = "SELECT force_logging FROM v\\$database;" +
	"\nALTER DATABASE NO FORCE LOGGING;" +
	"\nSELECT force_logging FROM v\\$database;"
View Source
const ForceLoggingTrueSQL string = "SELECT force_logging FROM v\\$database;" +
	"\nALTER DATABASE FORCE LOGGING;" +
	"\nALTER SYSTEM SWITCH LOGFILE;" +
	"\nSELECT force_logging FROM v\\$database;"
View Source
const GetCheckpointFileCMD string = "find ${ORACLE_BASE}/oradata -maxdepth 1 -name .${ORACLE_SID}${CHECKPOINT_FILE_EXTN}"
View Source
const GetDBOpenMode string = "select open_mode from v\\$database;"
View Source
const GetDatabaseRoleCMD string = "SELECT DATABASE_ROLE FROM V\\$DATABASE; "
View Source
const GetEnterpriseEditionFileCMD string = "" /* 149-byte string literal not displayed */
View Source
const GetInitParamsSQL string = "column name format a20;" +
	"\ncolumn display_value format a20;" +
	"\nset linesize 100 pagesize 50;" +
	"\nselect name,display_value from v\\$parameter where name in  ('sga_target','pga_aggregate_target','cpu_count','processes') order by name asc;"
View Source
const GetORDSStatus string = "curl -sSkv -k -X GET https://localhost:8443/ords/_/db-api/stable/metadata-catalog/"
View Source
const GetPdbsSQL string = "select name from v\\$pdbs where name not like 'PDB\\$SEED' and open_mode like 'READ WRITE';"
View Source
const GetSessionInfoSQL string = "select s.sid || ',' || s.serial# as Info FROM v\\$session s, v\\$process p " +
	"WHERE (s.username = 'ORDS_PUBLIC_USER' or " +
	"s.username = 'APEX_PUBLIC_USER' or " +
	"s.username = 'APEX_REST_PUBLIC_USER' or " +
	"s.username = 'APEX_LISTENER' or " +
	"s.username = 'C##_DBAPI_CDB_ADMIN' or " +
	"s.username = 'C##_DBAPI_PDB_ADMIN' ) AND p.addr(+) = s.paddr;"
View Source
const GetSidPdbEditionCMD string = "echo $ORACLE_SID,$ORACLE_PDB,$ORACLE_EDITION;"

Get Sid, Pdbname, Edition for prebuilt db

View Source
const GetSqlpatchDescriptionSQL string = "" /* 135-byte string literal not displayed */
View Source
const GetSqlpatchStatusSQL string = "select status from dba_registry_sqlpatch order by action_time desc;"
View Source
const GetSqlpatchVersionSQL string = "select SOURCE_VERSION || ':' || TARGET_VERSION as versions from dba_registry_sqlpatch order by action_time desc;"
View Source
const GetStandardEditionFileCMD string = "" /* 145-byte string literal not displayed */
View Source
const GetUserORDSSchemaStatusSQL string = "alter session set container=%[2]s;" +
	"\nselect 'STATUS:'||status as status from ords_metadata.ords_schemas where upper(parsing_schema) = upper('%[1]s');"
View Source
const GetVersionSQL string = "SELECT VERSION_FULL FROM V\\$INSTANCE;"
View Source
const InitORDSCMD string = "if [ -f $ORDS_HOME/config/ords/defaults.xml ]; then exit ;fi;" +
	"\nexport APEXI=$ORDS_HOME/config/apex/images" +
	"\n$ORDS_HOME/runOrds.sh --setuponly" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property database.api.enabled true" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.auth.enabled true" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property database.api.management.services.disabled false" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property database.api.admin.enabled true" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property dbc.auth.enabled true" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property restEnabledSql.active true" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property db.serviceNameSuffix \"\" " +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.InitialLimit 5" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.MaxLimit 20" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.InactivityTimeout 300" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property feature.sdw true" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property security.verifySSL false" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.maxRows 1000" +
	"\nmkdir -p $ORDS_HOME/config/ords/conf" +
	"\numask 177" +
	"\necho db.cdb.adminUser=C##DBAPI_CDB_ADMIN AS SYSDBA > cdbAdmin.properties" +
	"\necho db.cdb.adminUser.password=\"${ORACLE_PWD}\" >> cdbAdmin.properties" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_pu cdbAdmin.properties" +
	"\nrm -f cdbAdmin.properties" +
	"\necho db.adminUser=C##_DBAPI_PDB_ADMIN > pdbAdmin.properties" +
	"\necho db.adminUser.password=\"${ORACLE_PWD}\">> pdbAdmin.properties" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_pu pdbAdmin.properties" +
	"\nrm -f pdbAdmin.properties" +
	"\necho -e \"${ORDS_PWD}\n${ORDS_PWD}\" > sqladmin.passwd" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war user ${ORDS_USER} \"SQL Administrator , System Administrator , SQL Developer , oracle.dbtools.autorest.any.schema \" < sqladmin.passwd" +
	"\nrm -f sqladmin.passwd" +
	"\numask 022"
View Source
const InitPrebuiltDbCMD string = "if [ ! -d /mnt/oradata/${ORACLE_SID} -a -d $ORACLE_BASE/oradata/${ORACLE_SID} ]; then cp -v $ORACLE_BASE/oradata/.${ORACLE_SID}$CHECKPOINT_FILE_EXTN /mnt/oradata && " +
	" cp -vr $ORACLE_BASE/oradata/${ORACLE_SID} /mnt/oradata && cp -vr $ORACLE_BASE/oradata/dbconfig /mnt/oradata; fi "
View Source
const InitWalletCMD string = "if [ ! -f $ORACLE_BASE/oradata/.${ORACLE_SID}${CHECKPOINT_FILE_EXTN} ] || [ ! -f ${ORACLE_BASE}/oradata/dbconfig/$ORACLE_SID/.docker_%s ];" +
	" then while [ ! -f ${WALLET_DIR}/ewallet.p12 ] || pgrep -f $WALLET_CLI > /dev/null; do sleep 0.5; done; fi "
View Source
const InstallApex string = "if [ -f /opt/oracle/oradata/${ORACLE_SID^^}/apex/apexins.sql ]; then  ( while true; do  sleep 60; echo \"Installing Apex...\" ; done ) & " +
	" cd /opt/oracle/oradata/${ORACLE_SID^^}/apex && echo -e \"@apexins.sql SYSAUX SYSAUX TEMP /i/\" | %[1]s && kill -9 $!; else echo \"Apex Folder doesn't exist\" ; fi ;"
View Source
const InstallApexInContainer string = "cd ${ORDS_HOME}/config/apex/ && echo -e \"@apxsilentins.sql SYSAUX SYSAUX TEMP /i/ %[1]s %[1]s %[1]s %[1]s;\n" +
	"@apex_rest_config_core.sql;\n" +
	"exec APEX_UTIL.set_workspace(p_workspace => 'INTERNAL');\n" +
	"exec APEX_UTIL.EDIT_USER(p_user_id => APEX_UTIL.GET_USER_ID('ADMIN'), p_user_name  => 'ADMIN', p_change_password_on_first_use => 'Y');\n" +
	"\" | sqlplus -s sys/%[2]s@${ORACLE_HOST}:${ORACLE_PORT}/%[3]s as sysdba;"
View Source
const IsApexInstalled string = "echo -e \"select 'APEXVERSION:'||version as version FROM DBA_REGISTRY WHERE COMP_ID='APEX';\"" +
	" | sqlplus -s sys/%[1]s@${ORACLE_HOST}:${ORACLE_PORT}/%[2]s as sysdba;"
View Source
const KillSessionSQL string = "alter system kill session '%[1]s';"
View Source
const ListPdbSQL string = "SELECT NAME FROM V\\$PDBS;"
View Source
const ListenerEntry string = `` /* 705-byte string literal not displayed */
View Source
const LsnrNodePort string = "\"name\": \"listener\", \"protocol\": \"TCP\", \"port\": 1521, \"nodePort\": %d"

Payload section for listener node port

View Source
const LsnrPort string = "\"name\": \"listener\", \"protocol\": \"TCP\", \"port\": %d, \"targetPort\": 1521"

Payload section for listener port

View Source
const ModifyStdbyDBOpenMode string = "alter database recover managed standby database disconnect;"
View Source
const NoExternalIp string = "Node ExternalIP unavailable"
View Source
const ORACLE_GUID int64 = 54321
View Source
const ORACLE_UID int64 = 54321
View Source
const OpenPDBSeed = "alter pluggable database pdb\\$seed close;" +
	"\nalter pluggable database pdb\\$seed open read only;"
View Source
const PDBTnsnamesEntry string = `` /* 169-byte string literal not displayed */
View Source
const PodMountsCmd string = "awk '$2 == \"%s\" {print}' /proc/mounts"

Check Mount in pods

View Source
const PrimaryTnsnamesEntry string = `` /* 193-byte string literal not displayed */
View Source
const ReconcileBlocked string = "ReconcileBlocked"
View Source
const ReconcileBlockedReason string = "LastReconcileCycleBlocked"
View Source
const ReconcileCompelete string = "ReconcileComplete"
View Source
const ReconcileCompleteReason string = "LastReconcileCycleCompleted"
View Source
const ReconcileError string = "ReconcileError"
View Source
const ReconcileErrorReason string = "LastReconcileCycleFailed"
View Source
const ReconcileQueued string = "ReconcileQueued"
View Source
const ReconcileQueuedReason string = "LastReconcileCycleQueued"
View Source
const RemoveAdminPasswordFile string = "rm -rf admin.pwd"
View Source
const RemoveChkFileCMD string = "rm -f \"${ORACLE_BASE}/oradata/.${ORACLE_SID}.nochk\""
View Source
const RemoveDGMGRLScriptFile string = "rm -rf dgmgrl.cmd"
View Source
const RemoveDataguardConfiguration string = "DISABLE FAST_START FAILOVER;" +
	"\nEDIT CONFIGURATION SET PROTECTION MODE AS MAXPERFORMANCE;" +
	"\nREMOVE CONFIGURATION;"
View Source
const RemoveStandbyDBFromDGConfgCMD string = "DISABLE DATABASE ${ORACLE_SID};" +
	"\nREMOVE DATABASE ${ORACLE_SID};"
View Source
const RenewCertsCMD string = EnableTcpsCMD

Command for TCPS certs renewal to prevent their expiry. It is same as the EnableTcpsCMD

View Source
const RunDatapatchCMD string = " ( while true; do  sleep 60; echo \"Installing patches...\" ; done ) & if ! $ORACLE_HOME/OPatch/datapatch -skip_upgrade_check;" +
	" then echo \"Datapatch execution has failed.\" ; else echo \"DONE: Datapatch execution.\" ; fi ; kill -9 $!;"
View Source
const SQLPlusCLI string = "sqlplus -s / as sysdba"
View Source
const SetAdminUsersSQL string = "CREATE USER C##DBAPI_CDB_ADMIN IDENTIFIED BY \\\"%[1]s\\\" ACCOUNT UNLOCK CONTAINER=ALL;" +
	"\nalter user C##DBAPI_CDB_ADMIN identified by \\\"%[1]s\\\" account unlock;" +
	"\nGRANT DBA TO C##DBAPI_CDB_ADMIN CONTAINER = ALL;" +
	"\nGRANT PDB_DBA  TO C##DBAPI_CDB_ADMIN CONTAINER = ALL;" +
	"\nCREATE USER C##_DBAPI_PDB_ADMIN IDENTIFIED BY \\\"%[1]s\\\" CONTAINER=ALL ACCOUNT UNLOCK;" +
	"\nalter user C##_DBAPI_PDB_ADMIN identified by \\\"%[1]s\\\" account unlock;" +
	"\nGRANT DBA TO C##_DBAPI_PDB_ADMIN CONTAINER = ALL;" +
	"\nalter pluggable database pdb\\$seed close;" +
	"\nalter pluggable database pdb\\$seed open read write force;"
View Source
const SetApexUsers string = "\numask 177" +
	"\necho db.username=APEX_LISTENER > apexlistener" +
	"\necho db.password=\"%[1]s\" >> apexlistener" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_al apexlistener" +
	"\nrm -f apexlistener" +
	"\necho db.username=APEX_REST_PUBLIC_USER > apexRestPublicUser" +
	"\necho db.password=\"%[1]s\" >> apexRestPublicUser" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_rt apexRestPublicUser" +
	"\nrm -f apexRestPublicUser" +
	"\necho db.username=APEX_PUBLIC_USER > apexPublicUser" +
	"\necho db.password=\"%[1]s\" >> apexPublicUser" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex apexPublicUser" +
	"\nrm -f apexPublicUser" +
	"\numask 022"

SetApexUsers is used to set Apex Users, pod that runs SetApexUsers is deleted and new ones is created.

View Source
const SetDBRecoveryDestSQL string = "SHOW PARAMETER db_recovery_file_dest;" +
	"\nALTER SYSTEM SET db_recovery_file_dest_size=50G scope=both sid='*';" +
	"\nALTER SYSTEM SET db_recovery_file_dest='${ORACLE_BASE}/oradata/fast_recovery_area' scope=both sid='*';" +
	"\nSHOW PARAMETER db_recovery_file_dest;"
View Source
const SetupORDSCMD string = "$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property database.api.enabled true" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.auth.enabled true" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property database.api.management.services.disabled false" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property database.api.admin.enabled true" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property dbc.auth.enabled true" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property restEnabledSql.active true" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property db.serviceNameSuffix \"\" " +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.InitialLimit 5" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.MaxLimit 20" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.InactivityTimeout 300" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property feature.sdw true" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property security.verifySSL false" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property jdbc.maxRows 1000" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-property pdb.open.asneeded true" +
	"\numask 177" +
	"\necho db.cdb.adminUser=C##DBAPI_CDB_ADMIN AS SYSDBA > cdbAdmin.properties" +
	"\necho db.cdb.adminUser.password=\"%[4]s\" >> cdbAdmin.properties" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_pu cdbAdmin.properties" +
	"\nrm -f cdbAdmin.properties" +
	"\necho db.username=APEX_LISTENER > apexlistener" +
	"\necho db.password=\"%[2]s\" >> apexlistener" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_al apexlistener" +
	"\nrm -f apexlistener" +
	"\necho db.username=APEX_REST_PUBLIC_USER > apexRestPublicUser" +
	"\necho db.password=\"%[2]s\" >> apexRestPublicUser" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_rt apexRestPublicUser" +
	"\nrm -f apexRestPublicUser" +
	"\necho db.username=APEX_PUBLIC_USER > apexPublicUser" +
	"\necho db.password=\"%[2]s\" >> apexPublicUser" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex apexPublicUser" +
	"\nrm -f apexPublicUser" +
	"\necho db.adminUser=C##_DBAPI_PDB_ADMIN > pdbAdmin.properties" +
	"\necho db.adminUser.password=\"%[4]s\">> pdbAdmin.properties" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war set-properties --conf apex_pu pdbAdmin.properties" +
	"\nrm -f pdbAdmin.properties" +
	"\necho -e \"%[1]s\n%[1]s\" > sqladmin.passwd" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war user ${ORDS_USER} \"SQL Administrator , System Administrator , SQL Developer , oracle.dbtools.autorest.any.schema \" < sqladmin.passwd" +
	"\nrm -f sqladmin.passwd" +
	"\numask 022" +
	"\nsed -i 's,jetty.port=8888,jetty.secure.port=8443\\nssl.cert=\\nssl.cert.key=\\nssl.host=%[3]s,g' /opt/oracle/ords/config/ords/standalone/standalone.properties " +
	"\nsed -i 's,standalone.static.path=/opt/oracle/ords/doc_root/i,standalone.static.path=/opt/oracle/ords/config/apex/images,g' /opt/oracle/ords/config/ords/standalone/standalone.properties"

SetupORDSCMD is run only for the FIRST TIME, ORDS is installed. Once ORDS is installed, we delete the pod that ran SetupORDSCMD and create new ones. Newly created pod doesn't run this SetupORDSCMD.

View Source
const StandbyDatabasePrerequisitesSQL string = "ALTER SYSTEM SET db_create_file_dest='/opt/oracle/oradata/';" +
	"\nALTER SYSTEM SET db_create_online_log_dest_1='/opt/oracle/oradata/';" +
	"\nALTER SYSTEM SWITCH LOGFILE;" +
	"\nALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 200M;" +
	"\nALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 200M;" +
	"\nALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 200M;" +
	"\nALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 200M;" +
	"\nALTER SYSTEM SET STANDBY_FILE_MANAGEMENT=AUTO;" +
	"\nALTER SYSTEM SET dg_broker_config_file1='/opt/oracle/oradata/dbconfig/dr1${ORACLE_SID}.dat' scope=both;" +
	"\nALTER SYSTEM SET dg_broker_config_file2='/opt/oracle/oradata/dbconfig/dr2${ORACLE_SID}.dat';" +
	"\nALTER SYSTEM SET dg_broker_start=TRUE;"
View Source
const StandbyTnsnamesEntry string = `` /* 219-byte string literal not displayed */
View Source
const StatusCreating string = "Creating"
View Source
const StatusError string = "Error"
View Source
const StatusNotReady string = "Unhealthy"
View Source
const StatusPatching string = "Patching"
View Source
const StatusPending string = "Pending"
View Source
const StatusReady string = "Healthy"
View Source
const StatusUpdating string = "Updating"
View Source
const TcpsNodePort string = "\"name\": \"listener-tcps\", \"protocol\": \"TCP\", \"port\": 2484, \"nodePort\": %d"

Payload section for TCPS node port

View Source
const TcpsPort string = "\"name\": \"listener-tcps\", \"protocol\": \"TCP\", \"port\": %d, \"targetPort\": 2484"

Payload section for TCPS port

View Source
const ThreePortPayload string = "{\"spec\": { \"type\": \"%s\", \"ports\": [{\"name\": \"xmldb\", \"port\": 5500, \"protocol\": \"TCP\"},{%s},{%s}]}}"

Service Patch Payloads Three port payload: one OEM express, one TCP and one TCPS port

View Source
const TlsCertsLocation string = "/run/secrets/tls_secret"

Location of tls certs

View Source
const TwoPortPayload string = "{\"spec\": { \"type\": \"%s\", \"ports\": [{\"name\": \"xmldb\", \"port\": 5500, \"protocol\": \"TCP\"},{%s}]}}"

Two port payload: one OEM express, one TCP/TCPS port

View Source
const UninstallApex string = "" /* 129-byte string literal not displayed */
View Source
const UninstallORDSCMD string = "\numask 177" +
	"\necho -e \"1\n${ORACLE_HOST}\n${ORACLE_PORT}\n1\n${ORACLE_SERVICE}\nsys\n%[1]s\n%[1]s\n1\" > ords.cred" +
	"\n$JAVA_HOME/bin/java -jar $ORDS_HOME/ords.war uninstall advanced < ords.cred" +
	"\nrm -f ords.cred" +
	"\numask 022" +
	"\nrm -f /opt/oracle/ords/config/ords/defaults.xml" +
	"\nrm -f /opt/oracle/ords/config/ords/credentials" +
	"\nrm -rf /opt/oracle/ords/config/ords/conf" +
	"\nrm -rf /opt/oracle/ords/config/ords/standalone" +
	"\nrm -rf /opt/oracle/ords/config/ords/apex"
View Source
const UnzipApexOnORDSPod string = "" /* 194-byte string literal not displayed */
View Source
const UnzipApexOnSIDBPod string = "" /* 181-byte string literal not displayed */
View Source
const ValidateAdminPassword string = "conn sys/\\\"%s\\\"@${ORACLE_SID} as sysdba\nshow user"
View Source
const ValueUnavailable string = "Unavailable"
View Source
const WalletCreateCMD string = "" /* 241-byte string literal not displayed */
View Source
const WalletDeleteCMD string = "rm -rf ${WALLET_DIR}"
View Source
const WalletEntriesCMD string = "umask 177\ncat > wallet.passwd <<EOF\n${WALLET_PWD}\nEOF\n mkstore -wrl ${WALLET_DIR} -createEntry oracle.dbsecurity.sysPassword %[1]s -createEntry oracle.dbsecurity.systemPassword %[1]s " +
	"-createEntry oracle.dbsecurity.pdbAdminPassword %[1]s -createEntry oracle.dbsecurity.dbsnmpPassword %[1]s < wallet.passwd\nrm -f wallet.passwd\numask 022;"
View Source
const WalletPwdCMD string = "export WALLET_PWD=\"`openssl rand -base64 8`1\""

Variables

View Source
var ErrNoReadyPod = errors.New("SingleInstanceDatabase has no ready pod currently")

Functions

func ApexPasswordValidator

func ApexPasswordValidator(pwd string) bool

Apex password validation function

func CheckDBConfig

func CheckDBConfig(readyPod corev1.Pod, r client.Reader, config *rest.Config,
	ctx context.Context, req ctrl.Request, edition string) (bool, bool, bool, ctrl.Result)

returns flashBackStatus,archiveLogStatus,forceLoggingStatus of Primary Pod

func CheckDBInitParams

func CheckDBInitParams(sidbReadyPod corev1.Pod, r client.Reader, config *rest.Config,
	ctx context.Context, req ctrl.Request) (int, int, int, int, error)

func ExecCommand

func ExecCommand(r client.Reader, config *rest.Config, podName string, namespace string, containerName string,
	ctx context.Context, req ctrl.Request, nologCommand bool, command ...string) (string, error)

Execs into podName and executes command

func FindPods

func FindPods(r client.Reader, version string, image string, name string, namespace string, ctx context.Context,
	req ctrl.Request) (corev1.Pod, int, []corev1.Pod, []corev1.Pod, error)

retuns Ready Pod,No of replicas ( Only running and Pending Pods) ,available pods , Total No of Pods of a particular CRD

func GenerateRandomString

func GenerateRandomString(n int) string

returns a randomString

func GetDatabaseOpenMode

func GetDatabaseOpenMode(readyPod corev1.Pod, r client.Reader,
	config *rest.Config, ctx context.Context, req ctrl.Request, edition string) (string, error)

func GetDatabaseRole

func GetDatabaseRole(readyPod corev1.Pod, r client.Reader,
	config *rest.Config, ctx context.Context, req ctrl.Request) (string, error)

Fetch role by quering the DB

func GetDatabaseVersion

func GetDatabaseVersion(readyPod corev1.Pod, r client.Reader,
	config *rest.Config, ctx context.Context, req ctrl.Request) (string, error)

Returns Database version

func GetDatabasesInDgConfig

func GetDatabasesInDgConfig(readyPod corev1.Pod, r client.Reader,
	config *rest.Config, ctx context.Context, req ctrl.Request) ([]string, string, error)

Returns the databases in DG config .

func GetLabelsForController

func GetLabelsForController(version string, name string) map[string]string

getLabelsForController returns the labels for selecting the resources

func GetNodeIp

func GetNodeIp(r client.Reader, ctx context.Context, req ctrl.Request) string

Get Node Ip to display in ConnectionString Returns Node External Ip if exists ; else InternalIP

func GetPodNames

func GetPodNames(pods []corev1.Pod) []string

getPodNames returns the pod names of the array of pods passed in

func GetPrimaryDatabase

func GetPrimaryDatabase(databases []string) string

Returns a Primary Database in "databases" slice

func GetSidPdbEdition

func GetSidPdbEdition(r client.Reader, config *rest.Config, ctx context.Context, req ctrl.Request) (string, string, string, error)

GetSidPdbEdition to display sid, pdbname, edition in ConnectionString

func GetSqlClient

func GetSqlClient(edition string) string

func GetSqlpatchStatus

func GetSqlpatchStatus(r client.Reader, config *rest.Config, readyPod corev1.Pod, ctx context.Context, req ctrl.Request) (string, string, string, error)

Get Datapatch Status

func GetWatchNamespaces

func GetWatchNamespaces() map[string]bool

func IsAnyPodWithStatus

func IsAnyPodWithStatus(pods []corev1.Pod, phase corev1.PodPhase) (bool, corev1.Pod)

Returns true if any of the pod in 'pods' is with pod.Status.Phase == phase

func IsDatabaseFound

func IsDatabaseFound(sid string, databases []string, dgrole string) (bool, bool)

CHECKS IF SID IN DATABASES SLICE , AND ITS DGROLE

func IsSourceDatabaseOnCluster

func IsSourceDatabaseOnCluster(cloneFrom string) bool

Is Source Database On same Cluster

func IsStatusChanged

func IsStatusChanged(r client.Reader, objName string, namespace string,
	ctx context.Context, req ctrl.Request, object string, statusChange string) wait.ConditionFunc

returns a func() that returns true if an object is confirmed to be created or deleted . else false

func PatchService

func PatchService(config *rest.Config, namespace string, ctx context.Context, req ctrl.Request, svcName string, payload string) error

Function for patching the K8s service with the payload. Patch strategy used: Strategic Merge Patch

func ResourceEventHandler

func ResourceEventHandler() predicate.Predicate

Filter events that trigger reconcilation

func StringToLines

func StringToLines(s string) (lines []string, err error)

Convert "sqlplus -s " output to array of lines

func WaitForStatusChange

func WaitForStatusChange(r client.Reader, objName string, namespace string,
	ctx context.Context, req ctrl.Request, timeout time.Duration, object string, statusChange string) error

Poll up to timeout seconds for Object to change state Returns an error if the object never changes the state

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL