예제 #1
0
 def __init__(self, s, auth):
     rcCloud.Cloud.__init__(self, s, auth)
     if 'key' not in auth:
         raise ex.excInitError("option 'key' is mandatory in gandi section")
     gandi = get_driver(Provider.GANDI)
     try:
         self.driver = gandi(auth['key'])
     except Exception as e:
         raise ex.excInitError("error login to gandi cloud %s: %s" %
                               (s, str(e)))
예제 #2
0
    def __init__(self, rid, path, opts, **kwargs):
        Resource.__init__(self, rid, type="share.nfs", **kwargs)

        if not which("share"):
            raise ex.excInitError("share is not installed")
        self.label = "nfs:" + path
        self.path = path
        try:
            self.opts = self.parse_opts(opts)
        except ex.excError as e:
            raise ex.excInitError(str(e))
예제 #3
0
 def __init__(self, rid, path, opts, **kwargs):
     Resource.__init__(self, rid, type="share.nfs", **kwargs)
     if not which("exportfs"):
         raise ex.excInitError("exportfs is not installed")
     self.label = "nfs:" + path
     self.path = path
     l = opts.replace('\\', '').split()
     self.opts = {}
     for e in l:
         try:
             client, opts = self.parse_entry(e)
         except ex.excError as e:
             raise ex.excInitError(str(e))
         self.opts[client] = opts
예제 #4
0
 def __init__(self, s, auth):
     rcCloud.Cloud.__init__(self, s, auth)
     if 'access_key_id' not in auth:
         raise ex.excInitError(
             "option 'access_key_id' is mandatory in amazon section")
     if 'provider' not in auth:
         raise ex.excInitError(
             "option 'provider' is mandatory in amazon section")
     if 'secret_key' not in auth:
         raise ex.excInitError(
             "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'])
예제 #5
0
 def dockerd_exe(self):
     if self.dockerd_exe_init and which(self.dockerd_exe_init):
         return self.dockerd_exe_init
     elif which("dockerd"):
         return "dockerd"
     else:
         raise ex.excInitError("dockerd executable not found")
예제 #6
0
 def __init__(self, s, auth):
     rcCloud.Cloud.__init__(self, s, auth)
     if 'username' not in auth:
         raise ex.excInitError(
             "option 'username' is mandatory in vcloud section")
     if 'password' not in auth:
         raise ex.excInitError(
             "option 'password' is mandatory in vcloud section")
     if 'manager' not in auth:
         raise ex.excInitError(
             "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'])
예제 #7
0
 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.excInitError("%s: malformed devs" % self.rid)
         if sv in self.sv:
             raise ex.excInitError("%s: duplicate sv %s in devs" %
                                   (self.rid, sv))
         if ld in self.ld:
             raise ex.excInitError("%s: duplicate ld %s in devs" %
                                   (self.rid, ld))
         self.sv[sv] = sv
         self.ld[ld] = ld
         self.svld.append((sv, ld))
예제 #8
0
 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 self.docker_exe_init and which(self.docker_exe_init):
         return self.docker_exe_init
     elif which("docker.io"):
         return "docker.io"
     elif which("docker"):
         return "docker"
     else:
         raise ex.excInitError("docker executable not found")
예제 #9
0
    def __init__(self, s, auth):
        rcCloud.Cloud.__init__(self, s, auth)
        kwargs = {}

        if 'username' not in auth:
            raise ex.excInitError(
                "option 'username' is mandatory in %s section" % self.mode)

        if 'password' not in auth:
            raise ex.excInitError(
                "option 'password' is mandatory in %s section" % self.mode)

        if 'url' not in auth:
            raise ex.excInitError("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)
예제 #10
0
    def __init__(self,
                 rid=None,
                 target=None,
                 src=None,
                 dst=None,
                 sender=None,
                 recursive=False,
                 snap_size=0,
                 **kwargs):
        resSync.Sync.__init__(self,
                              rid=rid,
                              type="sync.btrfs",
                              **kwargs)

        self.label = "btrfs of %s to %s"%(src, ", ".join(target))
        self.src = src
        self.target = target
        self.sender = sender
        self.recursive = recursive

        if ":" not in src or src.index(":") == len(src) - 1:
            raise ex.excInitError("malformed src value")
        if ":" not in dst or dst.index(":") == len(dst) - 1:
            raise ex.excInitError("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
예제 #11
0
    def on_add(self):
        try:
            arrays = rc.Hp3pars(objects=[self.array],
                                log=self.log,
                                node=self.svc.node)
        except Exception as e:
            raise ex.excInitError(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
예제 #12
0
    def __init__(self,
                 rid=None,
                 type="sync.symclone",
                 symid=None,
                 pairs=[],
                 precopy=True,
                 consistent=True,
                 restore_timeout=None,
                 recreate_timeout=None,
                 **kwargs):
        resSync.Sync.__init__(self, rid=rid, type=type, **kwargs)

        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.excInitError("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
예제 #13
0
import rcCloud
import rcExceptions 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.excInitError("apache-libcloud module must be installed")


class Cloud(rcCloud.Cloud):
    mode = 'gandi'

    def __init__(self, s, auth):
        rcCloud.Cloud.__init__(self, s, auth)
        if 'key' not in auth:
            raise ex.excInitError("option 'key' is mandatory in gandi section")
        gandi = get_driver(Provider.GANDI)
        try:
            self.driver = gandi(auth['key'])
        except Exception as e:
            raise ex.excInitError("error login to gandi cloud %s: %s" %
                                  (s, str(e)))

    def app_id(self):
        return ''

    def cloud_id(self):
        return self.mode
예제 #14
0
import os
import json
from optparse import Option

import rcExceptions as ex
from rcGlobalEnv import rcEnv
from storage import Storage
from rcUtilities import bdecode, factory, split_path
from converters import convert_size
from rcOptParser import OptParser
from node import Node

try:
    import requests
except ImportError:
    raise ex.excInitError("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", default=None, action="store_true", dest="parm_help",
        help="show this help message and exit"),
    "array": Option(
        "-a", "--array", default=None, action="store", dest="array_name",