def __init__(self, target=None, src=None, dst=None, sender=None, recursive=False, snap_size=0, **kwargs): super(SyncBtrfs, self).__init__(type="sync.btrfs", **kwargs) self.target = target or [] self.label = "btrfs of %s to %s" % (src, ", ".join(self.target)) self.src = src self.sender = sender self.recursive = recursive if ":" not in src or src.index(":") == len(src) - 1: raise ex.InitError("malformed src value") if ":" not in dst or dst.index(":") == len(dst) - 1: raise ex.InitError("malformed dst value") self.src_label = src[:src.index(":")] self.src_subvol = src[src.index(":") + 1:] if dst is None: self.dst_label = self.src_label self.dst_subvol = self.src_subvol else: self.dst_label = dst[:dst.index(":")] self.dst_subvol = dst[dst.index(":") + 1:] self.dst_btrfs = {} self.src_btrfs = None
def __init__(self, s, auth): super(Cloud, self).__init__(s, auth) if 'key' not in auth: raise ex.InitError("option 'key' is mandatory in gandi section") gandi = get_driver(Provider.GANDI) try: self.driver = gandi(auth['key']) except Exception as e: raise ex.InitError("error login to gandi cloud %s: %s"%(s, str(e)))
def __init__(self, path=None, opts=None, **kwargs): Resource.__init__(self, type="share.nfs", **kwargs) if "node.x.share" not in capabilities: raise ex.InitError("share is not installed") self.label = "nfs:%s" % path self.path = path try: self.opts = self.parse_opts(opts) except ex.Error as e: raise ex.InitError(str(e))
def __init__(self, s, auth): super(Cloud, self).__init__(s, auth) if 'access_key_id' not in auth: raise ex.InitError("option 'access_key_id' is mandatory in amazon section") if 'provider' not in auth: raise ex.InitError("option 'provider' is mandatory in amazon section") if 'secret_key' not in auth: raise ex.InitError("option 'secret_key' is mandatory in amazon section") o = get_driver(auth['provider']) self.driver = o(auth['access_key_id'], auth['secret_key']) if 'proxy' in auth: self.driver.connection.set_http_proxy(proxy_url=auth['proxy'])
def __init__(self, s, auth): super(Cloud, self).__init__(s, auth) if 'username' not in auth: raise ex.InitError( "option 'username' is mandatory in vcloud section") if 'password' not in auth: raise ex.InitError( "option 'password' is mandatory in vcloud section") if 'manager' not in auth: raise ex.InitError( "option 'manager' is mandatory in vcloud section") if 'api_version' not in auth: auth['api_version'] = '1.5' vcloud = get_driver(Provider.VCLOUD) self.driver = vcloud(auth['username'], auth['password'], host=auth['manager'], api_version=auth['api_version'])
def parse_devs(self, devs): self.svld = [] self.sv = {} self.ld = {} devs = devs.replace(' ', ',') for e in devs.split(','): try: sv, ld = e.split(':') except: raise ex.InitError("%s: malformed devs" % self.rid) if sv in self.sv: raise ex.InitError("%s: duplicate sv %s in devs" % (self.rid, sv)) if ld in self.ld: raise ex.InitError("%s: duplicate ld %s in devs" % (self.rid, ld)) self.sv[sv] = sv self.ld[ld] = ld self.svld.append((sv, ld))
def docker_exe(self): """ Return the docker executable to use, using the service configuration docker_exe as the first choice, and a docker.io or docker exe found in PATH as a fallback. """ if capabilities.has("node.x.docker.io"): return "docker.io" if capabilities.has("node.x.docker"): return "docker" raise ex.InitError("docker executable not found")
def __init__(self, path=None, opts=None, **kwargs): Resource.__init__(self, type="share.nfs", **kwargs) self.label = "nfs:%s" % path self.path = path l = opts.replace('\\', '').split() self.opts = {} for e in l: try: client, opts = self.parse_entry(e) except ex.Error as e: raise ex.InitError(str(e)) self.opts[client] = opts
def on_add(self): try: arrays = array_driver.Hp3pars(objects=[self.array], log=self.log, node=self.svc.node) except Exception as e: raise ex.InitError(str(e)) if len(arrays.arrays) == 1: self.array_obj = arrays.arrays[0] else: self.array_obj = None if self.array_obj is None: self.log.error("no 3par array object") return self.array_obj.path = self.svc.path
def __init__(self, s, auth): super(Cloud, self).__init__(s, auth) kwargs = {} if 'username' not in auth: raise ex.InitError("option 'username' is mandatory in %s section" % self.mode) if 'password' not in auth: raise ex.InitError("option 'password' is mandatory in %s section" % self.mode) if 'url' not in auth: raise ex.InitError("option 'url' is mandatory in %s section" % self.mode) kwargs['ex_force_auth_url'] = auth['url'] if 'tenant' in auth: self.tenant_name = auth['tenant'] kwargs['ex_tenant_name'] = auth['tenant'] else: self.tenant_name = None if 'version' in auth: kwargs['ex_force_auth_version'] = auth['version'] else: kwargs['ex_force_auth_version'] = '2.0_password' if 'service_name' in auth: kwargs['ex_force_service_name'] = auth['service_name'] if 'verify_ssl_cert' in auth and not auth['verify_ssl_cert']: libcloud.security.VERIFY_SSL_CERT = False openstack = get_driver(Provider.OPENSTACK) self.driver = openstack(auth['username'], auth['password'], **kwargs)
def __init__(self, type="sync.symclone", symid=None, pairs=None, precopy=True, consistent=True, restore_timeout=None, recreate_timeout=None, **kwargs): super(SyncSymclone, self).__init__(type=type, **kwargs) if pairs is None: pairs = [] if self.type == "sync.symclone": self.active_states = ["copied", "copyinprog"] self.activable_states = ["recreated", "precopy"] elif self.type == "sync.symsnap": self.active_states = ["copyonwrite"] self.activable_states = ["recreated", "created"] else: raise ex.InitError("unsupported symclone driver type %s", self.type) self.activate_timeout = 20 self.recreate_timeout = recreate_timeout self.restore_timeout = restore_timeout self.precopy = precopy self.pairs_written = {} self.label = "symclone symid %s pairs %s" % (symid, " ".join(pairs)) if len(self.label) > 80: self.label = self.label[:76] + "..." self.symid = symid self.pairs = pairs self.consistent = consistent self.svcstatus = {} self.default_schedule = "@0" if restore_timeout is None: self.restore_timeout = 300 else: self.restore_timeout = restore_timeout
import core.cloud import core.exceptions as ex import socket try: from libcloud.compute.types import Provider from libcloud.compute.providers import get_driver #import libcloud.security except ImportError: raise ex.InitError("apache-libcloud module must be installed") class Cloud(core.cloud.BaseCloud): mode = 'vcloud' def __init__(self, s, auth): super(Cloud, self).__init__(s, auth) if 'username' not in auth: raise ex.InitError( "option 'username' is mandatory in vcloud section") if 'password' not in auth: raise ex.InitError( "option 'password' is mandatory in vcloud section") if 'manager' not in auth: raise ex.InitError( "option 'manager' is mandatory in vcloud section") if 'api_version' not in auth: auth['api_version'] = '1.5' vcloud = get_driver(Provider.VCLOUD) self.driver = vcloud(auth['username'], auth['password'],
import sys import json import logging import core.exceptions as ex from env import Env from utilities.storage import Storage from utilities.naming import factory, split_path from utilities.converters import convert_size from utilities.optparser import OptParser, Option from core.node import Node try: import requests except ImportError: raise ex.InitError("the requests module must be installed") try: requests.packages.urllib3.disable_warnings() except AttributeError: pass verify = False PROG = "om array" OPT = Storage({ "help": Option( "-h", "--help", action="store_true", dest="parm_help", help="show this help message and exit"), "array": Option( "-a", "--array", action="store", dest="array_name", help="The name of the array, as defined in the node or cluster configuration."),
def dockerd_exe(self): if capabilities.has("node.x.dockerd"): return "dockerd" else: raise ex.InitError("dockerd executable not found")