Sysadmin tools which works with OVH API, written in bash and python.
There's multiple scripts. The main code is cloud.sh
.
cloud.sh
- manipulate OVH public cloud instances and snapshotmk_cred.py
- intiate credential for python OVH APIovh_reverse.py
- set a reverse DNS entry on OVHovh_snapshot.py
- take a snapshot of an instance
Documentation is still lacking a lot of details and programming skill is strongly requiered.
pickup what is needed for your environment: (Tested on Debian 8 Jessie and ubuntu 16.10)
I assume ~/
as base dir.
apt install -y git
git clone https://github.com/opensource-expert/ovh-tools.git
apt install -y jq python-pip python-dev
cd ~/ovh-tools
pip install -r requirements.txt
git clone https://github.com/yadutaf/ovh-cli.git
cd ovh-cli/
pip install -r requirements.txt
# downloads json for API
./ovh-eu
.
├── ovh-cli
│ ├── ovhcli
│ │ └── formater
│ └── schemas
└── ovh-tools
├── templates
└── test
Credential are stored in ovh.conf
in the local folder.
This is the python OVH API way of storing the credential. See
pyhton API.
make your credential with: (currently fixed credential for ovh-eu
in mk_cred.py
)
cd ~/ovh-tools
./mk_cred.py new
# or if you need to update your credential
./mk_cred.py update
Paste it! Select on screen info and paste it as is + hit ctrl-D. You will need to authenticate twice on OVH URL.
Sharing credential with ovh-cli
copy credential file: (here we symlink in both dir ovh-tools/
ovh-cli/
)
mv ovh_conf.tmp ovh.conf
cd ../ovh-cli
ln -s ../ovh-tools/ovh.conf .
See Python OVH API doc for more details.
Test credential:
./ovh-eu auth current-credential
During cloud.sh
usage if you get a similar error message.
jq
is reporting a parse error, credential are probaly invalid, check with:
./cloud.sh call ovh_cli auth current-credential
./cloud.sh call ovh_cli me
list your cloud environment
./cloud.sh
Store your working PROJECT_ID
in cloud.conf
for easier command:
./cloud.sh set_project PROJECT_ID
After all command are run against this PROJECT_ID
. You can also
force it on command line.
list runing instances:
./cloud.sh list
etc… read the code, some param are fixed or globals.
Many working command line usage are listed in usage_examples.sh.
help
only grep functions and case entries.
./cloud.sh help
Not exhaustive.
$proj
is a PROJECT_ID
can be saved in cloud.conf via set_project
.
list_snap
$proj
: list available snapshotcreate
$proj
$snap_id
$hostname
(sshkey
fixed)name
get_ssh
$proj
[$name
] : list available sshkeys idlist_instance
$proj
: list available runing instancerename
$proj
$instance
$new_name
: renamestatus
$proj
[$instance
] : display json info abouts instancesmake_snap
$proj
$instance
[$name
] : take a snapshotdelete
$proj
$instance
... : delete a runing instance- all function are callable directly too, read the code