Exemplo n.º 1
0
import sys
import time

from openstackclient_base.base import monkey_patch
monkey_patch()

from openstackclient_base.client_set import ClientSet
import argparse

parser = argparse.ArgumentParser(
    description='Spawn selenium instance in just installed cloud.')
parser.add_argument('--master', help='master node ip', default='10.0.0.103')
parser.add_argument('--tenant', help='Tenant name', default='systenant')
parser.add_argument('--login', help='login', default='admin')
parser.add_argument('--password', help='password', default='topsecret')

parser.add_argument('--net',
                    help='Network to use with tenant',
                    default='10.109.0.0/24')
parser.add_argument('--vlan', help='VLAN to use with network', default='3310')
parser.add_argument('--image',
                    help='URL for image to download and register in cloud',
                    default='http://10.100.0.3/images/selenium-server.qcow2')
cloud = parser.parse_args()

conf = {}
conf['auth_uri'] = 'http://%s:5000/v2.0/' % cloud.master
conf['tenant_name'] = cloud.tenant
conf['username'] = cloud.login
conf['password'] = cloud.password
client = ClientSet(**conf)
Exemplo n.º 2
0
Miscellaneous utility functions:

- usage calculations for different VM states;
- datetime manipulations;
- other.
"""


import json
import logging
import sys
import os
from datetime import datetime

from openstackclient_base.base import monkey_patch
monkey_patch()
from openstackclient_base.client_set import ClientSet


LOG = logging.getLogger(__name__)


class ContentType(object):
    JSON = "application/json"


def total_seconds(td):
    """This function is added for portability
    because timedelta.total_seconds()
    was introduced only in python 2.7."""
    return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6