Exemple #1
0
def set_azurearm_driver():
    """ Convenience method to set the custom driver"""
    driver_module = "drivers.azurearm.driver"
    driver_klass = "CustomAzureNodeDriver"
    driver_provider = "CustomAzureArm"
    try:
        set_driver(driver_provider, driver_module, driver_klass)
    except AttributeError as e:  # usually raised when AzureArm is already registered
        print(str(e))
Exemple #2
0
 def __init__(self, config):
     super(VSphereConnector, self).__init__(config)
     self.type = "vsphere"
     self.logger = logging.getLogger("hyclops.connector." + self.type)
     try:
         self.driver = get_driver("vsphere")
     except AttributeError:
         set_driver("vsphere", 'hyclops.libcloud_driver.vsphere', 'VSphereNodeDriver')
         self.driver = get_driver("vsphere")
Exemple #3
0
def set_spot_drivers():
    """
    Convenience method that sets all drives in this file.

    The provider name will be ec2_spot_AWS_REGION, with all hyphens
    replaced by underscores in the AWS_REGION.
    """
    driver_module = 'drivers.ccglibcloud.ec2spot'
    for region, driver_klass in REGION_TO_DRIVER.items():
        set_driver(_region_to_provider(region), driver_module, driver_klass)
Exemple #4
0
    def run_driver_rancher(self, medriver):
        set_driver('bibindrancher', 'libcloud_bibind.bibindrancher',
                   'BibindRancherContainerDriver')

        Driver = get_driver(Provider.RANCHER)

        driver = Driver(medriver.rancher_accesskey, medriver.rancher_secretkey,
                        medriver.rancher_url, medriver.rancher_port,
                        medrive.rancher_secure)
        rancher_port
        return driver
                       extra={'public_key_type': key_type,
                              'public_key_content': key_content})
                              
    def _parse_ssh_public_key(self, ssh_public_key):
        try:
            key = ssh_public_key.strip('\t\r\n ').split(' ', 2)
            key_type = key[0]
            key_content = key[1]
            key_name = key[2] if len(key) > 2 else ''
        except Exception:
            raise ValueError('Invalid OpenSSH key format for key: {}'
                             .format(ssh_public_key))
        return key_type, key_content, key_name
                              
    def _add_ssh_public_key(self, ssh_public_key):
        user_public_keys = self.ss_api.get_user().ssh_public_keys
        
        user_public_keys.append(ssh_public_key)
        ssh_public_keys = '\n'.join(user_public_keys)
        
        return self.ss_api.update_user(ssh_public_keys=ssh_public_keys)



from libcloud.compute.providers import set_driver
set_driver('slipstream',
           'slipstream.libcloud.compute_driver',
           'SlipStreamNodeDriver')


import ovh
from socket import getaddrinfo
import requests
import sys
sys.path.insert(0, "/mnt/extra-addons/bibind/models/bibind_container")
from libcloud.compute.types import Provider
from libcloud.compute.providers import DRIVERS
from libcloud.compute.providers import get_driver
from libcloud.compute.deployment import MultiStepDeployment
from libcloud.compute.deployment import ScriptDeployment, SSHKeyDeployment
from libcloud.compute.providers import set_driver
from libcloud_bibind.bibindrancher import BibindRancherContainerDriver
import gitlab

set_driver('bibindrancher',
           'libcloud_bibind.bibindrancher',
           'BibindRancherContainerDriver')




_logger = logging.getLogger("bibind_cloudservice")


def generator_password():
    characters = string.ascii_letters + string.punctuation  + string.digits
    password =  "".join(choice(characters) for x in range(randint(8, 16)))
    return password


try:
    import nose
    NOSE_FOUND = True
except ImportError:
    NOSE_FOUND = False

from libcloudvagrant.driver import VAGRANT, VagrantDriver, __name__ as pkg_name


__all__ = [
    "__version__",
    "test",
]


providers.set_driver(VAGRANT, pkg_name, VagrantDriver.__name__)

security.CA_CERTS_PATH.append(os.path.join(os.path.dirname(__file__),
                                           "ca-bundle.crt"))


__version__ = "0.1.0"


def test():
    """Runs the tests for ``libcloud-vagrant``.

    Requires ``nose`` to be installed. The tests take quite a bit of time to
    finish, and use up about 10 GB of disk space and 3 GB of memory, since
    several VMs are created.
Exemple #8
0
Detailed implementation of the StratusLab methods for the StratusLabClient
class.  Uses the Libcloud API to connect to the StratusLab services.
"""

import os
import tempfile
from ConfigParser import SafeConfigParser
from StringIO import StringIO
from contextlib import closing

import stratuslab.libcloud.compute_driver

# ensures that StratusLab Libcloud driver is loaded before use
from libcloud.compute.providers import set_driver

set_driver('STRATUSLAB', 'stratuslab.libcloud.compute_driver',
           'StratusLabNodeDriver')

from libcloud.compute.base import NodeAuthSSHKey
from libcloud.compute.providers import get_driver

try:
    from DIRAC import gLogger, S_OK, S_ERROR
except:
    from stratuslab.dirac.DiracMock import gLogger, S_OK, S_ERROR

from stratuslab.dirac.DiracSshContext import DiracSshContext


class StratusLabClient(object):
    """ Implementation of the StratusLabImage functionality. """
    def __init__(self, endpointConfiguration, imageConfiguration):
import ovh
from socket import getaddrinfo
import requests
import sys
sys.path.insert(0, "/mnt/extra-addons/bibind/models/bibind_api")
from libcloud.compute.types import Provider
from libcloud.compute.providers import DRIVERS
from libcloud.compute.providers import get_driver
from libcloud.compute.deployment import MultiStepDeployment
from libcloud.compute.deployment import ScriptDeployment, SSHKeyDeployment
from libcloud.compute.providers import set_driver
from libcloud_bibind.bibind import BibindNodeDriver
import gitlab

set_driver('bibind',
           'libcloud_bibind.bibind',
           'BibindNodeDriver')




_logger = logging.getLogger("bibind_cloudservice")


def generator_password():
    characters = string.ascii_letters + string.punctuation  + string.digits
    password =  "".join(choice(characters) for x in range(randint(8, 16)))
    return password


class cloud_service_api_fournisseur(models.Model):
class.  Uses the Libcloud API to connect to the StratusLab services.
"""

import os
import tempfile
from ConfigParser import SafeConfigParser
from StringIO import StringIO
from contextlib import closing

import stratuslab.libcloud.compute_driver

# ensures that StratusLab Libcloud driver is loaded before use
from libcloud.compute.providers import set_driver

set_driver('STRATUSLAB',
           'stratuslab.libcloud.compute_driver',
           'StratusLabNodeDriver')

from libcloud.compute.base import NodeAuthSSHKey
from libcloud.compute.providers import get_driver

try:
    from DIRAC import gLogger, S_OK, S_ERROR
except:
    from stratuslab.dirac.DiracMock import gLogger, S_OK, S_ERROR

from stratuslab.dirac.DiracSshContext import DiracSshContext


class StratusLabClient(object):
    """ Implementation of the StratusLabImage functionality. """
Exemple #11
0
from libcloud.compute import providers

KAMATERA_NODE_DRIVER = "kamatera_node_driver"

providers.set_driver(KAMATERA_NODE_DRIVER, "libcloud_driver_kamatera.kamatera",
                     "KamateraNodeDriver")


def get_node_driver():
    return providers.get_driver(KAMATERA_NODE_DRIVER)
from libcloud.compute.providers import get_driver
from libcloud.compute.providers import set_driver

set_driver("stratuslab", "stratuslab.libcloud.stratuslab_driver",
           "StratusLabNodeDriver")

# Your code which uses the driver.
# For example:
driver = get_driver("stratuslab")
Exemple #13
0
#=================================================================
# Copyright(c) Institute of Software, Chinese Academy of Sciences
#=================================================================
# Author : [email protected]
# Date   : 2016/05/25

from libcloud.compute.providers import set_driver

from gemini.compute.types import ProviderExt

DRIVERS_EXT = ({
    ProviderExt.LIBVIRT_EXT:
    ('gemini.compute.driver.libvirt_driver_ext', 'LibvirtNodeDriverExt')
})

set_driver(ProviderExt.LIBVIRT_EXT, DRIVERS_EXT[ProviderExt.LIBVIRT_EXT][0],
           DRIVERS_EXT[ProviderExt.LIBVIRT_EXT][1])
import os.path

from libcloud.compute.base import NodeAuthSSHKey
from libcloud.compute.providers import get_driver

import demo_utils as utils

from libcloud.compute.providers import set_driver

import stratuslab.libcloud.compute_driver

set_driver('stratuslab', 'stratuslab.libcloud.compute_driver',
           'StratusLabNodeDriver')

# Obtain instance of StratusLab driver.
StratusLabDriver = get_driver('stratuslab')
driver = StratusLabDriver('unused-key')

print 'Driver: ', driver

# List sizes, locations, and images.
print

sizes = driver.list_sizes()
utils.print_objs(sizes)

locations = driver.list_locations()
utils.print_objs(locations)

images = driver.list_images()
utils.print_objs(images[-5:])
Exemple #15
0
    # For pyflakes
    netifaces
except ImportError:
    NETIFACES_FOUND = False

from libcloudvagrant.common.types import VAGRANT
from libcloudvagrant.compute import driver as compute_driver

__all__ = [
    "__version__",
    "VAGRANT",
    "test",
]

compute_providers.set_driver(VAGRANT, compute_driver.__name__,
                             compute_driver.VagrantDriver.__name__)

security.CA_CERTS_PATH.append(
    os.path.join(os.path.dirname(__file__), "common", "ca-bundle.crt"))

__version__ = "0.5.0"


def test():  # pragma: no cover
    """Runs the tests for ``libcloud-vagrant``.

    Requires ``nose`` to be installed. The tests take quite a bit of time to
    finish, and use up about 10 GB of disk space and 3 GB of memory, since
    several VMs are created.

    """
Exemple #16
0
except ImportError:
    NETIFACES_FOUND = False

from libcloudvagrant.common.types import VAGRANT
from libcloudvagrant.compute import driver as compute_driver


__all__ = [
    "__version__",
    "VAGRANT",
    "test",
]


compute_providers.set_driver(VAGRANT,
                             compute_driver.__name__,
                             compute_driver.VagrantDriver.__name__)

security.CA_CERTS_PATH.append(os.path.join(os.path.dirname(__file__),
                                           "common",
                                           "ca-bundle.crt"))


__version__ = "0.5.0"


def test():  # pragma: no cover
    """Runs the tests for ``libcloud-vagrant``.

    Requires ``nose`` to be installed. The tests take quite a bit of time to
    finish, and use up about 10 GB of disk space and 3 GB of memory, since
Exemple #17
0
from libcloud.compute.providers import get_driver, set_driver

set_driver('CTyun', 'libcloud_mods.ctyun', 'CTyunNodeDriver')

driver = get_driver('CTyun')
CTyunDriver = driver(access_key, secret_key)
Exemple #18
0
  
"""


import os
import tempfile

from ConfigParser import SafeConfigParser
from StringIO     import StringIO
from contextlib   import closing

# FIXME: Hack, hack, hack...
# ensures that StratusLab Libcloud driver is loaded before use
from libcloud.compute.providers import set_driver
set_driver( 'stratuslab',
            'stratuslab.libcloud.compute_driver',
            'StratusLabNodeDriver' )
from libcloud.compute.base      import NodeAuthSSHKey
from libcloud.compute.providers import get_driver

# DIRAC
from DIRAC import gLogger, S_OK, S_ERROR

# VMDIRAC
from VMDIRAC.WorkloadManagementSystem.Client.SshContextualize import SshContextualize


class StratusLabClient( object ):
  """ Implementation of the StratusLabImage functionality. """

Exemple #19
0
from libcloud.compute.providers import get_driver
from libcloud.compute.providers import set_driver

from libcloud.common.ovh import API_ROOT, OvhConnection
from libcloud.compute.base import (NodeDriver, NodeSize, Node, NodeLocation,
                                   NodeImage, StorageVolume, VolumeSnapshot)
from libcloud.compute.types import (Provider, StorageVolumeState,
                                    VolumeSnapshotState)
from libcloud.compute.drivers.openstack import OpenStackNodeDriver
from libcloud.compute.drivers.openstack import OpenStackKeyPair
from libcloud.compute.drivers.ovh import OvhNodeDriver

import gitlab
from jinja2 import Environment, PackageLoader

set_driver('bibind', 'tests.bibind', 'BibindNodeDriver')

# rancher
# cle acces
# 5B8D466780146E519CA7
# Cle secrete (mot de passe)
# frWiggMWWCb2CeZVvLr5uqzS6KgAYLRWS96kF8sB
# list =driver.list_nodes()
#
# pprint(list)
#
# id = driver.ex_get_node('585e104f-5524-452b-a94f-61292dfe9584')
# print(id.uuid)

BIBINDLOCATIONS = {
    "BHS": {