Exemplo n.º 1
0
class IntegrationTest(UnitTest):
    """Base class for integration tests.

    Integration tests run with a connected client to the API, which is
    available under the "client" property.
    """

    pubkey = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDi3GUFtZA4WxysevYPPrp3G4' \
             'W3sehLJOyEp4vf5G/rLfoKwz1JXd3gqq8snoSwYefQSAW0PKPff6lxyaraFqq4' \
             '+vzNg4rAHJSdBhAHLWlcNWSh8UZOGD11vgGdOLrDBPZ8/jKJIZgcFiXjzulMzU' \
             'RKLGx0ZFbUZDfHYIqEpCscnlfG6kenrtWAdCrTkl4CP56xcOY91qx4s9Ll0Yvz' \
             'hyF2GiqgCe0eJqNflJkqX+d9e0A3BdIzM//UfYplzmUGimWgGN4vFFa4sspUzq' \
             'gwHV7yZYI7W+Ey5oOOiSpTt1PpkPHIBaUEmg37/7Pq6PuQxfs18QLPK1DuJz6g' \
             'UsCjFRFl testkey'

    def setUp(self):
        url = self.config.get('integration', 'url') or None
        username = self.config.get('integration', 'username')
        password = self.config.get('integration', 'password')
        self.client = RavelloClient()
        self.client.connect(url)
        self.client.login(username, password)

    def tearDown(self):
        self.client.logout()
        self.client.close()
Exemplo n.º 2
0
class IntegrationTest(UnitTest):
    """Base class for integration tests.

    Integration tests run with a connected client to the API, which is
    available under the "client" property.
    """

    pubkey = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDi3GUFtZA4WxysevYPPrp3G4' \
             'W3sehLJOyEp4vf5G/rLfoKwz1JXd3gqq8snoSwYefQSAW0PKPff6lxyaraFqq4' \
             '+vzNg4rAHJSdBhAHLWlcNWSh8UZOGD11vgGdOLrDBPZ8/jKJIZgcFiXjzulMzU' \
             'RKLGx0ZFbUZDfHYIqEpCscnlfG6kenrtWAdCrTkl4CP56xcOY91qx4s9Ll0Yvz' \
             'hyF2GiqgCe0eJqNflJkqX+d9e0A3BdIzM//UfYplzmUGimWgGN4vFFa4sspUzq' \
             'gwHV7yZYI7W+Ey5oOOiSpTt1PpkPHIBaUEmg37/7Pq6PuQxfs18QLPK1DuJz6g' \
             'UsCjFRFl testkey'

    def setUp(self):
        url = self.config.get('integration', 'url') or None
        username = self.config.get('integration', 'username')
        password = self.config.get('integration', 'password')
        self.client = RavelloClient()
        self.client.connect(url)
        self.client.login(username, password)

    def tearDown(self):
        self.client.logout()
        self.client.close()
Exemplo n.º 3
0
def connect_ravello(trial_name):
    """Return a new Ravello connection."""
    client = RavelloClient()
    client.connect()
    kwargs = cfgdict(app.config, '{0}_ravello'.format(trial_name), 'ravello')
    client.login(**kwargs)
    return client
Exemplo n.º 4
0
def create_client(args):
    """Connect to the Ravello API and return a connection."""
    client = RavelloClient()
    if args["password"] is None:
        args["password"] = getpass("Enter password for {0}: ".format(args["username"]))
    client.connect()
    try:
        client.login(args["username"], args["password"])
    except RavelloError:
        raise RavelloError("could not login with provided credentials")
    return client
Exemplo n.º 5
0
def create_client(args):
    """Connect to the Ravello API and return a connection."""
    client = RavelloClient()
    if args['password'] is None:
        args['password'] = getpass('Enter password for {0}: '.format(
            args['username']))
    client.connect()
    try:
        client.login(args['username'], args['password'])
    except RavelloError:
        raise RavelloError('could not login with provided credentials')
    return client
class RavelloPowerAdapter():

    def __init__(self, user, password, application_name, vm_name):
        self.client = RavelloClient()
        self.client.login(user, password)
        self.application_name = application_name
        self.vm_name = vm_name

    def _get_application_id(self):
        for app in self.client.get_applications():
            if app['name'] == self.application_name:
                return app['id']
        return None

    def _get_vm_id(self):
        app_id = self._get_application_id()
        for vm in self.client.get_vms(app_id):
            if vm['name'] == self.vm_name:
                return vm['id']
        return None

    def get_vm_state(self):
        return self.client.get_vm_state(self._get_application_id(),
                                        self._get_vm_id())

    def power_on_vm(self):
        vm_state = self.get_vm_state()
        if vm_state in ['STARTED', 'STARTING']:
            return
        elif vm_state == 'STOPPED':
            self.client.start_vm(self._get_application_id(), self._get_vm_id())
        else:
            raise Exception("Error when powering on the VM. Cannot handle "
                            "VM state: '%s'" % vm_state)

    def power_off_vm(self):
        vm_state = self.get_vm_state()
        if vm_state in ['STOPPED', 'STOPPING']:
            return
        if vm_state == 'STARTED':
            self.client.poweroff_vm(self._get_application_id(),
                                    self._get_vm_id())
        else:
            raise Exception("Error when powering off the VM. Cannot handle "
                            "VM state: '%s'" % vm_state)
Exemplo n.º 7
0
def _validate_config():
    """Validate the configuration options."""
    if not CONF.ravello.username:
        raise exception.InvalidParameterValue(_(
            "RavelloDriver requires 'username' config option."))
    if not CONF.ravello.password:
        raise exception.InvalidParameterValue(_(
            "RavelloDriver requires 'password' config option."))
    conn = RavelloClient()
    try:
        conn.connect(CONF.ravello.endpoint)
    except socket.error as e:
        raise exception.InvalidParameterValue(_(
            "RavelloDriver could not connect to: %s." % CONF.ravello.endpoint))
    try:
        conn.login(CONF.ravello.username, CONF.ravello.password)
    except RavelloError as e:
        raise exception.InvalidParameterValue(_(
            "RavelloDriver could not login with supplied credentials."))
    finally:
        conn.close()
#!/usr/bin/python

#will probably need these later
#import os
#import re
#import sys
#import json

from ravello_sdk import RavelloClient
client = RavelloClient()
client.login('*****@*****.**', 'Redhat1234')
for app in client.get_applications():
   print('Found Application: {0}'.format(app['name']))
Exemplo n.º 9
0
def _get_ravello_client():
    """Return a Ravello API client."""
    client = RavelloClient()
    client.connect(CONF.ravello.endpoint)
    client.login(CONF.ravello.username, CONF.ravello.password)
    return client
Exemplo n.º 10
0
ibm_endpoint = args['ibm_endpoint']
ibm_auth_endpoint = args['ibm_auth_endpoint']
ibm_resource_id = args['ibm_resource_id']

disk_prefix = args['disk_prefix']
image_format = args['image_format']
start_conv_character = args['start_conv_character']
single_vm = args['single_vm']
max_mount_count = 25 - (ord(start_conv_character) - ord('a'))

bpname = args["blueprint"]
client = RavelloClient()

try:
    domain = None if args["domain"] == "None" else args["domain"]
    client.login(args["user"], args["password"], domain)
except Exception as e:
    print("Error connecting to Ravello {0} - User: {1} - Domain {2}".format(
        e, args["user"], args["domain"]))
    sys.exit(-1)
bp = client.get_blueprints(filter={"name": bpname})[0]
config = client.get_blueprint(bp["id"])
env = Environment(loader=file_loader)

network_config = config["design"]["network"]
vms_config = config["design"]["vms"]


def get_root_disk_size(vm):
    for disk in vm["hardDrives"]:
        if disk["boot"] and disk["type"] == "DISK":