Commit cb411335 authored by Kristian Feldsam's avatar Kristian Feldsam

Basic project setup

Signed-off-by: Kristian Feldsam's avatarKristián Feldsam <>
parent c5e40361
#!/usr/bin/env python
import argparse
import urllib3
import config
import pyone
import functions
# ----------------------------
# Define parser
# ----------------------------
parser = argparse.ArgumentParser(description='OpenNebula Backup Tool')
parser.add_argument('-i', '--image', help='Image id or comma separated list of image ids to backup.'
'Omit for backup all images', type=functions.list_of_int_arg)
parser.add_argument('-S', '--startImage', help='Image id to start backup from. Backups all following images'
'including defined one', type=int)
parser.add_argument('-a', '--datastore', help='Datastore id or comma separated list of datastore ids to backup'
'from. Omit to backup from all datastores to backup',
parser.add_argument('-l', '--label', help='Label or comma separated list of labels of tagged images or datastores',
parser.add_argument('-e', '--exclude', help='Skip (exclude) by label or comma separated list of labels of tagged'
'images or datastores', type=functions.list_arg)
parser.add_argument('-D', '--deployments', help='Backup also deployments files from system datastores')
parser.add_argument('-d', '--dryRun', help='Dry run - not execute any commands, all cmds will be just printed')
parser.add_argument('-v', '--verbose', help='Verbose mode')
# -------------------------------------
# Parse args and proceed with execution
# -------------------------------------
args = parser.parse_args()
# -----------------------
# Connect to OpenNebula
# -----------------------
one = pyone.OneServer(config.ONE['address'], session='%s:%s' % (config.ONE['username'], config.ONE['password']))
imagepool =, -1, -1)
for image in imagepool.IMAGE:
print image.PERSISTENT
# OpenNebula XML-RPC API connection details
ONE = {
'address': 'https://opennebula:2633/RPC2',
'username': 'user',
'password': 'pass'
# Path where to save backups on backup server
BACKUP_DIR = '/var/data/backups/'
# Lock Image and VM during backup
# OpenNebula 5.6+ required
# 3PAR connection details
_3PAR = {
'api': 'https://3par:8080/api/v1',
'ip': '3par_ip',
'username': '3paradm',
'password': '3pardata',
'secure': True
from hpe3parclient import client, exceptions
import config
# ------------------
# Login to 3PAR
# ------------------
cl = client.HPE3ParClient(config._3PAR['api'], config._3PAR['secure'])
cl.setSSHOptions(config._3PAR['ip'], config._3PAR['username'], config._3PAR['password'])
cl.login(config._3PAR['username'], config._3PAR['password'])
except exceptions.HTTPUnauthorized as ex:
print "Login failed."
\ No newline at end of file
def bool_arg(string):
if string != True and string != '1' and string != 'YES':
return False
return True
def list_of_int_arg(string):
return map(int, string.split(','))
def list_arg(string):
return string.split(',')
\ No newline at end of file
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