Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions conf/params.distrib.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<itop_password>admin</itop_password>
<itop_token/>
<itop_login_mode/>
<itop_env>production</itop_env>

<!-- console_log_level: level of logging to console (std output)
-1 : none, nothing will be logged to the console
Expand Down
6 changes: 4 additions & 2 deletions core/collector.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,8 @@ public function Synchronize($iMaxChunkSize = 0)
);

$sLoginform = Utils::GetLoginMode();
$sResult = self::CallItopViaHttp("/synchro/synchro_import.php?login_mode=$sLoginform",
$sEnv = Utils::GetSwitchEnv();
$sResult = self::CallItopViaHttp("/synchro/synchro_import.php?login_mode=$sLoginform&switch_env=$sEnv",
$aData);

$sTrimmedOutput = trim(strip_tags($sResult));
Expand All @@ -739,7 +740,8 @@ public function Synchronize($iMaxChunkSize = 0)
}

$sLoginform = Utils::GetLoginMode();
$sResult = self::CallItopViaHttp("/synchro/synchro_exec.php?login_mode=$sLoginform",
$sEnv = Utils::GetSwitchEnv();
$sResult = self::CallItopViaHttp("/synchro/synchro_exec.php?login_mode=$sLoginform&switch_env=$sEnv",
$aData);

$iErrorsCount = $this->ParseSynchroExecOutput($sResult);
Expand Down
6 changes: 4 additions & 2 deletions core/restclient.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ protected static function ExecOperation($aOperation, $sVersion = '1.0')
$aData = Utils::GetCredentials();
$aData['json_data'] = json_encode($aOperation);
$sLoginform = Utils::GetLoginMode();
$sUrl = sprintf('%s/webservices/rest.php?login_mode=%s&version=%s',
$sEnv = Utils::GetSwitchEnv();
$sUrl = sprintf('%s/webservices/rest.php?login_mode=%s&version=%s&switch_env=%s',
Utils::GetConfigurationValue('itop_url', ''),
$sLoginform,
$sVersion
$sVersion,
$sEnv
);
$aHeaders = array();
$aCurlOptions = Utils::GetCurlOptions();
Expand Down
12 changes: 12 additions & 0 deletions core/utils.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,18 @@ static public function GetLoginMode() : string {
return 'form';
}


/**
* Returns the iTop environment to use when connecting to the iTop API.
*
* @return string
*/
static public function GetSwitchEnv() : string {

return Utils::GetConfigurationValue('itop_env', 'production');

}

/**
* Dump information about the configuration (value of the parameters)
*
Expand Down
1 change: 1 addition & 0 deletions test/utils/params.test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<itop_password>admin</itop_password>
<itop_token></itop_token>
<itop_login_mode></itop_login_mode>
<itop_env>production</itop_env>
<console_log_level>6</console_log_level>
<eventissue_log_level>-1</eventissue_log_level>
<console_log_dateformat>[Y-m-d H:i:s]</console_log_dateformat>
Expand Down