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
2ed1f5eb
Commit
2ed1f5eb
authored
Dec 18, 2015
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgraded to rest api instead of soapi
parent
0ff0580a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
104 additions
and
58 deletions
+104
-58
README.md
README.md
+2
-0
common.sh
common.sh
+1
-1
migration
scripts/migration
+1
-0
ovh_cmd
scripts/ovh_cmd
+36
-53
ovh_cmd.old_soapi
scripts/ovh_cmd.old_soapi
+58
-0
start
scripts/start
+4
-4
stop
scripts/stop
+2
-0
No files found.
README.md
View file @
2ed1f5eb
...
@@ -12,6 +12,8 @@ for example:
...
@@ -12,6 +12,8 @@ for example:
gnt-instance add-tags instance01 route:81.82.83.84/32:br0
gnt-instance add-tags instance01 route:81.82.83.84/32:br0
*
install python-ovh from https://github.com/ovh/python-ovh
*
put all the directory and files of the tarball in /etc/ganeti
*
put all the directory and files of the tarball in /etc/ganeti
*
edit /etc/ganeti/scripts/ovh_cmd and change both $hostmap, $username and $passwd according to your use case
*
edit /etc/ganeti/scripts/ovh_cmd and change both $hostmap, $username and $passwd according to your use case
*
put a crontab that touch /tmp/ganeti.checkroute one time every $(choose_your_time, i use 1 hour)
*
put a crontab that touch /tmp/ganeti.checkroute one time every $(choose_your_time, i use 1 hour)
...
...
common.sh
View file @
2ed1f5eb
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
export
PATH
=
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin
export
PATH
=
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin
SSHCMD
=
"ssh -o ConnectTimeout=3 -o ServerAliveInterval=5 -o ServerAliveCountMax=3"
SSHCMD
=
"ssh -o ConnectTimeout=3 -o ServerAliveInterval=5 -o ServerAliveCountMax=3
-o BatchMode=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
"
getmaster
()
getmaster
()
{
{
...
...
scripts/migration
View file @
2ed1f5eb
...
@@ -16,6 +16,7 @@ do
...
@@ -16,6 +16,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}'
`
#
if
[
$primary
]
;
then
if
[
$primary
]
;
then
add_route
$addr
$iface
add_route
$addr
$iface
else
else
...
...
scripts/ovh_cmd
View file @
2ed1f5eb
#!/usr/bin/env php
#!/usr/bin/env python
<?php
import
sys
,
os
import
ovh
$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
);
hostmap
=
{
'node1.example.net'
:
{
'ip'
:
'94.93.92.91'
,
'name'
:
'ns999999.ovh.net'
},
'node3.example.net'
:
{
'ip'
:
'91.92.93.94'
,
'name'
:
'ns888888.ovh.net'
},
}
}
//logout
client
=
ovh
.
Client
(
$soap
->
logout
(
$session
);
endpoint
=
'ovh-eu'
,
application_key
=
'<application key>'
,
}
catch
(
SoapFault
$fault
)
{
application_secret
=
'<application secret>'
,
exit
(
1
);
consumer_key
=
'<consumer key>'
,
}
)
?>
def
main
(
cmd
,
host
,
dest
,
addr
):
if
cmd
==
"list"
:
if
host
in
hostmap
.
keys
():
opts
=
{
'routedTo.serviceName'
:
hostmap
[
host
][
'name'
],
'type'
:
"failover"
}
for
ip
in
client
.
get
(
'/ip'
,
**
opts
):
if
len
(
ip
.
split
(
"/"
)[
0
])
>=
7
:
print
ip
.
split
(
"/"
)[
0
]
elif
cmd
==
"move"
:
opts
=
{
'to'
:
dest
,
'ip'
:
addr
+
"/32"
}
client
.
post
(
'/ip/move'
,
**
opts
)
if
__name__
==
'__main__'
:
cmd
=
None
host
=
None
dest
=
None
addr
=
None
if
len
(
sys
.
argv
)
>
1
:
cmd
=
sys
.
argv
[
1
]
if
len
(
sys
.
argv
)
>
2
:
host
=
sys
.
argv
[
2
]
if
len
(
sys
.
argv
)
>
3
:
dest
=
sys
.
argv
[
3
]
if
len
(
sys
.
argv
)
>
4
:
addr
=
sys
.
argv
[
4
]
if
cmd
:
main
(
cmd
,
host
,
dest
,
addr
)
scripts/ovh_cmd.old_soapi
0 → 100755
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 @
2ed1f5eb
...
@@ -15,10 +15,10 @@ do
...
@@ -15,10 +15,10 @@ do
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
add_route
$addr
$iface
||
true
echo
"add_route
$addr
$iface
"
echo
"add_route
$addr
$iface
"
else
else
del_route
$addr
loc
del_route
$addr
loc
||
true
fi
fi
done
done
...
@@ -32,9 +32,9 @@ do
...
@@ -32,9 +32,9 @@ 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
/128
$iface
||
true
else
else
del_v6route
$addr
/128
$iface
del_v6route
$addr
/128
$iface
||
true
fi
fi
echo
$route
echo
$route
fi
fi
...
...
scripts/stop
View file @
2ed1f5eb
...
@@ -27,4 +27,6 @@ do
...
@@ -27,4 +27,6 @@ do
del_v6route
$addr
/128
$iface
del_v6route
$addr
/128
$iface
fi
fi
done
done
unset
IFS
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