Commit 88a6fbba authored by nextime's avatar nextime

Update with latest changes in ganeti and OVH

parent 2ed1f5eb
......@@ -65,14 +65,14 @@ get_instances_running_list ()
gettags ()
{
local cmd=$(mastercmd)
local res=$(${cmd} gnt-instance list -otags --no-headers $1 | grep "^route")
local res=$(${cmd} gnt-instance list -otags --no-headers $1 | sed 's/,/\n/g' | grep "^route")
echo $res
}
getv6tags ()
{
local cmd=$(mastercmd)
local res=$(${cmd} gnt-instance list -otags --no-headers $1 | grep "^v6")
local res=$(${cmd} gnt-instance list -otags --no-headers $1 | sed 's/,/\n/g' | grep "^v6")
echo $res
}
......@@ -146,7 +146,7 @@ del_v6route ()
# We need to avoid returning != 0
setsid ip -6 neigh del proxy $1 dev eth0 > /dev/null 2>&1
if [ $(route6_exists $1 $2) ] ; then
ip -6 route del $1 dev $2
ip -6 route del $1/128 dev $2
fi
}
......@@ -155,9 +155,9 @@ add_v6route ()
{
ip -6 neigh add proxy $1 dev eth0
if [ $(route6_exists $1) ] ; then
del_route $1
del_v6route $1
fi
ip -6 route add $1 dev $2
ip -6 route add $1/128 dev $2
}
......
#!/bin/bash
#!/bin/bash -x
env > /tmp/antani.env
if [ -f /etc/ganeti/common.sh ] ; then
......@@ -8,7 +8,7 @@ else
fi
routes=$(gettags $GANETI_INSTANCE_NAME)
primary=$(i_am_primary)
IFS=','
#IFS=','
for tag in $routes
do
rtype=`echo $tag | awk -F ':' '{print $1}'`
......@@ -35,13 +35,13 @@ do
iface=`echo $route | awk -F '_' '{print $2}'`
#
if [ $primary ] ; then
add_v6route $addr/128 $iface
add_v6route $addr $iface
else
del_v6route $addr/128 $iface
del_v6route $addr $iface
fi
echo $route
fi
done
unset IFS
#unset IFS
......@@ -16,6 +16,13 @@ client = ovh.Client(
consumer_key='<consumer key>',
)
client = ovh.Client(
endpoint='ovh-eu',
application_key='',
application_secret='',
consumer_key='',
)
def main(cmd, host, dest, addr):
if cmd=="list":
......@@ -26,7 +33,7 @@ def main(cmd, host, dest, addr):
print ip.split("/")[0]
elif cmd=="move":
opts={'to':dest, 'ip': addr+"/32"}
client.post('/ip/move', **opts)
client.post('/ip/'+addr+'/move', to=hostmap[dest]['name'])
if __name__ == '__main__':
cmd=None
......
#!/usr/bin/env php
<?php
$hostmap=array(
'node1.example.net' => array('ip' => '94.93.92.91', 'name' => 'ns999999.ovh.net'),
'node2.example.net' => array('ip' => '91.92.93.94', 'name' => 'ns888888.ovh.net'),
);
$username="ab12345-ovh";
$passwd="password";
$cmd=$argv[1];
if(count($argv) > 2) $host=$argv[2];
if(count($argv) > 3) $dest=$argv[3];
if(count($argv) > 4) $addr=$argv[4];
try {
$soap = new SoapClient("https://www.ovh.com/soapi/soapi-re-1.24.wsdl");
//login
$session = $soap->login($username, $passwd,"it", false);
switch($cmd)
{
case "list":
//dedicatedFailoverList
$result = $soap->dedicatedFailoverList($session, $hostmap[$host]['name']);
//print_r($result); // your code here ...
foreach($result as $fip)
{
if(strlen($fip->ip) >= 7) {
print_r("$fip->ip\n");
}
}
break;
case "move":
$soap->dedicatedFailoverUpdate($session, $hostmap[$host]['name'], "$addr", $hostmap[$dest]['ip']);
break;
case "rev6":
$soap->dedicatedReverseAdd($session, $hostmap[$host]['name'], $dest, $addr );
}
//logout
$soap->logout($session);
} catch(SoapFault $fault) {
exit(1);
}
?>
#!/bin/bash
#!/bin/bash -x
env > /tmp/antani.env
if [ -f /etc/ganeti/common.sh ] ; then
......@@ -8,17 +8,18 @@ else
fi
routes=$(gettags $GANETI_INSTANCE_NAME)
primary=$(i_am_primary)
IFS=','
#IFS=','
for tag in $routes
do
route=`echo $tag | awk -F ':' '{print $2":"$3}'`
addr=`echo $route | awk -F ':' '{print $1}'`
iface=`echo $route | awk -F ':' '{print $2}'`
if [ $primary ] ; then
add_route $addr $iface || true
echo "add_route $addr $iface"
echo "add_route $addr $iface" >> /tmp/antani.env 2>&1
add_route $addr $iface || true >> /tmp/antani.env 2>&1
else
del_route $addr loc || true
echo "del route $addr $iface" >> /tmp/antani.env 2>&1
del_route $addr loc || true >> /tmp/antani.env 2>&1
fi
done
......@@ -32,13 +33,13 @@ do
iface=`echo $route | awk -F '_' '{print $2}'`
#
if [ $primary ] ; then
add_v6route $addr/128 $iface || true
add_v6route $addr $iface || true
else
del_v6route $addr/128 $iface || true
del_v6route $addr $iface || true
fi
echo $route
fi
done
unset IFS
#unset IFS
......@@ -7,7 +7,6 @@ else
exit 0
fi
routes=$(gettags $GANETI_INSTANCE_NAME)
IFS=','
for tag in $routes
do
route=`echo $tag | awk -F ':' '{print $2":"$3}'`
......@@ -24,9 +23,7 @@ do
route=`echo $tag | awk -F '_' '{print $2":"$3}'`
addr=`echo $route | awk -F '_' '{print $1}'`
iface=`echo $route | awk -F '_' '{print $2}'`
del_v6route $addr/128 $iface
del_v6route $addr $iface
fi
done
unset IFS
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment