Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
OVH_GanetiHooks
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sysadmin
OVH_GanetiHooks
Commits
88a6fbba
Commit
88a6fbba
authored
Oct 25, 2016
by
nextime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update with latest changes in ganeti and OVH
parent
2ed1f5eb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
81 deletions
+28
-81
common.sh
common.sh
+5
-5
migration
scripts/migration
+5
-5
ovh_cmd
scripts/ovh_cmd
+8
-1
ovh_cmd.old_soapi
scripts/ovh_cmd.old_soapi
+0
-58
start
scripts/start
+9
-8
stop
scripts/stop
+1
-4
No files found.
common.sh
View file @
88a6fbba
...
@@ -65,14 +65,14 @@ get_instances_running_list ()
...
@@ -65,14 +65,14 @@ get_instances_running_list ()
gettags
()
gettags
()
{
{
local
cmd
=
$(
mastercmd
)
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
echo
$res
}
}
getv6tags
()
getv6tags
()
{
{
local
cmd
=
$(
mastercmd
)
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
echo
$res
}
}
...
@@ -146,7 +146,7 @@ del_v6route ()
...
@@ -146,7 +146,7 @@ del_v6route ()
# We need to avoid returning != 0
# We need to avoid returning != 0
setsid ip
-6
neigh del proxy
$1
dev eth0
>
/dev/null 2>&1
setsid ip
-6
neigh del proxy
$1
dev eth0
>
/dev/null 2>&1
if
[
$(
route6_exists
$1
$2
)
]
;
then
if
[
$(
route6_exists
$1
$2
)
]
;
then
ip
-6
route del
$1
dev
$2
ip
-6
route del
$1
/128
dev
$2
fi
fi
}
}
...
@@ -155,9 +155,9 @@ add_v6route ()
...
@@ -155,9 +155,9 @@ add_v6route ()
{
{
ip
-6
neigh add proxy
$1
dev eth0
ip
-6
neigh add proxy
$1
dev eth0
if
[
$(
route6_exists
$1
)
]
;
then
if
[
$(
route6_exists
$1
)
]
;
then
del_route
$1
del_
v6
route
$1
fi
fi
ip
-6
route add
$1
dev
$2
ip
-6
route add
$1
/128
dev
$2
}
}
...
...
scripts/migration
View file @
88a6fbba
#!/bin/bash
#!/bin/bash
-x
env
>
/tmp/antani.env
env
>
/tmp/antani.env
if
[
-f
/etc/ganeti/common.sh
]
;
then
if
[
-f
/etc/ganeti/common.sh
]
;
then
...
@@ -8,7 +8,7 @@ else
...
@@ -8,7 +8,7 @@ else
fi
fi
routes
=
$(
gettags
$GANETI_INSTANCE_NAME
)
routes
=
$(
gettags
$GANETI_INSTANCE_NAME
)
primary
=
$(
i_am_primary
)
primary
=
$(
i_am_primary
)
IFS
=
','
#
IFS=','
for
tag
in
$routes
for
tag
in
$routes
do
do
rtype
=
`
echo
$tag
|
awk
-F
':'
'{print $1}'
`
rtype
=
`
echo
$tag
|
awk
-F
':'
'{print $1}'
`
...
@@ -35,13 +35,13 @@ do
...
@@ -35,13 +35,13 @@ do
iface
=
`
echo
$route
|
awk
-F
'_'
'{print $2}'
`
iface
=
`
echo
$route
|
awk
-F
'_'
'{print $2}'
`
#
#
if
[
$primary
]
;
then
if
[
$primary
]
;
then
add_v6route
$addr
/128
$iface
add_v6route
$addr
$iface
else
else
del_v6route
$addr
/128
$iface
del_v6route
$addr
$iface
fi
fi
echo
$route
echo
$route
fi
fi
done
done
unset
IFS
#
unset IFS
scripts/ovh_cmd
View file @
88a6fbba
...
@@ -16,6 +16,13 @@ client = ovh.Client(
...
@@ -16,6 +16,13 @@ client = ovh.Client(
consumer_key
=
'<consumer key>'
,
consumer_key
=
'<consumer key>'
,
)
)
client
=
ovh
.
Client
(
endpoint
=
'ovh-eu'
,
application_key
=
''
,
application_secret
=
''
,
consumer_key
=
''
,
)
def
main
(
cmd
,
host
,
dest
,
addr
):
def
main
(
cmd
,
host
,
dest
,
addr
):
if
cmd
==
"list"
:
if
cmd
==
"list"
:
...
@@ -26,7 +33,7 @@ def main(cmd, host, dest, addr):
...
@@ -26,7 +33,7 @@ def main(cmd, host, dest, addr):
print
ip
.
split
(
"/"
)[
0
]
print
ip
.
split
(
"/"
)[
0
]
elif
cmd
==
"move"
:
elif
cmd
==
"move"
:
opts
=
{
'to'
:
dest
,
'ip'
:
addr
+
"/32"
}
opts
=
{
'to'
:
dest
,
'ip'
:
addr
+
"/32"
}
client
.
post
(
'/ip/
move'
,
**
opts
)
client
.
post
(
'/ip/
'
+
addr
+
'/move'
,
to
=
hostmap
[
dest
][
'name'
]
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
cmd
=
None
cmd
=
None
...
...
scripts/ovh_cmd.old_soapi
deleted
100755 → 0
View file @
2ed1f5eb
#!/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
);
}
?>
scripts/start
View file @
88a6fbba
#!/bin/bash
#!/bin/bash
-x
env
>
/tmp/antani.env
env
>
/tmp/antani.env
if
[
-f
/etc/ganeti/common.sh
]
;
then
if
[
-f
/etc/ganeti/common.sh
]
;
then
...
@@ -8,17 +8,18 @@ else
...
@@ -8,17 +8,18 @@ else
fi
fi
routes
=
$(
gettags
$GANETI_INSTANCE_NAME
)
routes
=
$(
gettags
$GANETI_INSTANCE_NAME
)
primary
=
$(
i_am_primary
)
primary
=
$(
i_am_primary
)
IFS
=
','
#
IFS=','
for
tag
in
$routes
for
tag
in
$routes
do
do
route
=
`
echo
$tag
|
awk
-F
':'
'{print $2":"$3}'
`
route
=
`
echo
$tag
|
awk
-F
':'
'{print $2":"$3}'
`
addr
=
`
echo
$route
|
awk
-F
':'
'{print $1}'
`
addr
=
`
echo
$route
|
awk
-F
':'
'{print $1}'
`
iface
=
`
echo
$route
|
awk
-F
':'
'{print $2}'
`
iface
=
`
echo
$route
|
awk
-F
':'
'{print $2}'
`
if
[
$primary
]
;
then
if
[
$primary
]
;
then
add_route
$addr
$iface
||
true
echo
"add_route
$addr
$iface
"
>>
/tmp/antani.env 2>&1
echo
"add_route
$addr
$iface
"
add_route
$addr
$iface
||
true
>>
/tmp/antani.env 2>&1
else
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
fi
done
done
...
@@ -32,13 +33,13 @@ do
...
@@ -32,13 +33,13 @@ do
iface
=
`
echo
$route
|
awk
-F
'_'
'{print $2}'
`
iface
=
`
echo
$route
|
awk
-F
'_'
'{print $2}'
`
#
#
if
[
$primary
]
;
then
if
[
$primary
]
;
then
add_v6route
$addr
/128
$iface
||
true
add_v6route
$addr
$iface
||
true
else
else
del_v6route
$addr
/128
$iface
||
true
del_v6route
$addr
$iface
||
true
fi
fi
echo
$route
echo
$route
fi
fi
done
done
unset
IFS
#
unset IFS
scripts/stop
View file @
88a6fbba
...
@@ -7,7 +7,6 @@ else
...
@@ -7,7 +7,6 @@ else
exit
0
exit
0
fi
fi
routes
=
$(
gettags
$GANETI_INSTANCE_NAME
)
routes
=
$(
gettags
$GANETI_INSTANCE_NAME
)
IFS
=
','
for
tag
in
$routes
for
tag
in
$routes
do
do
route
=
`
echo
$tag
|
awk
-F
':'
'{print $2":"$3}'
`
route
=
`
echo
$tag
|
awk
-F
':'
'{print $2":"$3}'
`
...
@@ -24,9 +23,7 @@ do
...
@@ -24,9 +23,7 @@ do
route
=
`
echo
$tag
|
awk
-F
'_'
'{print $2":"$3}'
`
route
=
`
echo
$tag
|
awk
-F
'_'
'{print $2":"$3}'
`
addr
=
`
echo
$route
|
awk
-F
'_'
'{print $1}'
`
addr
=
`
echo
$route
|
awk
-F
'_'
'{print $1}'
`
iface
=
`
echo
$route
|
awk
-F
'_'
'{print $2}'
`
iface
=
`
echo
$route
|
awk
-F
'_'
'{print $2}'
`
del_v6route
$addr
/128
$iface
del_v6route
$addr
$iface
fi
fi
done
done
unset
IFS
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment