60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
|
<?php
|
||
|
|
||
|
/**
|
||
|
* Petit script listant la répartition des IP failover
|
||
|
*
|
||
|
* Le fichier .auth-api-ovh.ini permet de stocker les identifiants de connexion
|
||
|
* et ressemble à :
|
||
|
* login = xxNNNNN-ovh
|
||
|
* password = xxxxxxxxxxxxxxx
|
||
|
*
|
||
|
* FIXME: seul hostnameOvh est nécessaire : faire sauter la conf. et passer
|
||
|
* les noms des serveurs en argument.
|
||
|
*/
|
||
|
|
||
|
/* Config */
|
||
|
$failoverIp = 'ip.fa.il.ov.er';
|
||
|
$listeServeurs = array(
|
||
|
'srv1' => array(
|
||
|
'hostnameOvh' => 'ns111111.ovh.net',
|
||
|
'ip' => '1.1.1.1',
|
||
|
),
|
||
|
'srv2' => array(
|
||
|
'hostnameOvh' => 'ns222222.ovh.net',
|
||
|
'ip' => '2.2.2.2',
|
||
|
),
|
||
|
);
|
||
|
|
||
|
|
||
|
|
||
|
if ( ! ($identifiants = parse_ini_file('.auth-api-ovh.ini'))) {
|
||
|
echo "ERREUR : Impossible de récupérer les identifiants de connexion à l'API OVH.\n";
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
$soap = new SoapClient("https://www.ovh.com/soapi/soapi-re-1.59.wsdl");
|
||
|
|
||
|
//login
|
||
|
$session = $soap->login($identifiants['login'], $identifiants['password'],"fr", false);
|
||
|
echo "login successfull\n";
|
||
|
|
||
|
//dedicatedFailoverRipeList
|
||
|
foreach ($listeServeurs as $key => $server) {
|
||
|
$result = $soap->dedicatedFailoverList($session, $server['hostnameOvh']);
|
||
|
echo "$key : ";
|
||
|
print_r($result);
|
||
|
}
|
||
|
|
||
|
//logout
|
||
|
$soap->logout($session);
|
||
|
echo "logout successfull\n";
|
||
|
|
||
|
} catch(SoapFault $fault) {
|
||
|
echo $fault;
|
||
|
exit(1);
|
||
|
}
|
||
|
|
||
|
// Code de retour Ok
|
||
|
exit(0);
|