Пример #1
0
import Cookie
import optparse
import socket
import sys
import time

import wsproxy

from engine import flags
from engine import log as logging
from engine import rpc
from engine import utils

FLAGS = flags.FLAGS
flags.DEFINE_integer('vnc_proxy_idle_timeout', 180,
                     'Seconds before idle connection destroyed')
flags.DEFINE_flag(flags.HelpFlag())
flags.DEFINE_flag(flags.HelpshortFlag())
flags.DEFINE_flag(flags.HelpXMLFlag())


class EngineWebSocketProxy(wsproxy.WebSocketProxy):
    def __init__(self, *args, **kwargs):
        self.register_engine_listeners()
        wsproxy.WebSocketProxy.__init__(self, *args, **kwargs)

    def register_engine_listeners(self):
        self.tokens = {}

        class TopicProxy():
            @staticmethod
Пример #2
0
from engine import exception as excp
from engine import flags
from engine import log as logging
from engine.network import linux_net
from engine.virt.libvirt import netutils
from engine import utils
from engine.virt.vif import VIFDriver
from quantum.client import Client
from quantum.common.wsgi import Serializer

LOG = logging.getLogger('quantum.plugins.cisco.engine.vifdirect')

FLAGS = flags.FLAGS
flags.DEFINE_string('quantum_host', "127.0.0.1",
                     'IP address of the quantum network service.')
flags.DEFINE_integer('quantum_port', 9696,
                     'Listening port for Quantum network service')

HOST = FLAGS.quantum_host
PORT = FLAGS.quantum_port
USE_SSL = False
TENANT_ID = 'engine'
ACTION_PREFIX_EXT = '/v1.0'
ACTION_PREFIX_CSCO = ACTION_PREFIX_EXT + \
        '/extensions/csco/tenants/{tenant_id}'
TENANT_ID = 'engine'
CSCO_EXT_NAME = 'Cisco Engine Tenant'
ASSOCIATE_ACTION = '/associate_port'
DETACH_ACTION = '/detach_port'


class Libvirt802dot1QbhDriver(VIFDriver):
Пример #3
0
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

"""Quotas for instances, volumes, and floating ips."""

from engine import db
from engine import flags


FLAGS = flags.FLAGS
flags.DEFINE_integer('quota_instances', 10,
                     'number of instances allowed per project')
flags.DEFINE_integer('quota_cores', 20,
                     'number of instance cores allowed per project')
flags.DEFINE_integer('quota_ram', 50 * 1024,
                     'megabytes of instance ram allowed per project')
flags.DEFINE_integer('quota_volumes', 10,
                     'number of volumes allowed per project')
flags.DEFINE_integer('quota_gigabytes', 1000,
                     'number of volume gigabytes allowed per project')
flags.DEFINE_integer('quota_floating_ips', 10,
                     'number of floating ips allowed per project')
flags.DEFINE_integer('quota_metadata_items', 128,
                     'number of metadata items allowed per instance')
flags.DEFINE_integer('quota_max_injected_files', 5,
                     'number of injected files allowed')
flags.DEFINE_integer('quota_max_injected_file_content_bytes', 10 * 1024,
Пример #4
0
import datetime
import thread
import traceback
import UserDict

from eventlet import greenpool
from engineclient import v1_1 as engineclient

from engine import db
from engine import flags
from engine import log as logging
from engine import utils

FLAGS = flags.FLAGS
flags.DEFINE_integer('zone_db_check_interval', 60,
                     'Seconds between getting fresh zone info from db.')
flags.DEFINE_integer(
    'zone_failures_to_offline', 3,
    'Number of consecutive errors before marking zone offline')
flags.DEFINE_integer('reserved_host_disk_mb', 0,
                     'Amount of disk in MB to reserve for host/dom0')
flags.DEFINE_integer('reserved_host_memory_mb', 512,
                     'Amount of memory in MB to reserve for host/dom0')


class ZoneState(object):
    """Holds the state of all connected child zones."""
    def __init__(self):
        self.is_active = True
        self.name = None
        self.capabilities = None
Пример #5
0
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
"""
Simple Scheduler
"""

from engine import db
from engine import flags
from engine import exception
from engine.scheduler import driver
from engine.scheduler import chance

FLAGS = flags.FLAGS
flags.DEFINE_integer("max_cores", 16,
                     "maximum number of instance cores to allow per host")
flags.DEFINE_integer("max_gigabytes", 10000,
                     "maximum number of volume gigabytes to allow per host")
flags.DEFINE_integer("max_networks", 1000,
                     "maximum number of networks to allow per host")
flags.DEFINE_string('default_schedule_zone', None,
                    'zone to use when user doesnt specify one')
flags.DEFINE_list('isolated_images', [], 'Images to run on isolated host')
flags.DEFINE_list('isolated_hosts', [], 'Host reserved for specific images')
flags.DEFINE_boolean('skip_isolated_core_check', True,
                     'Allow overcommitting vcpus on isolated hosts')


class SimpleScheduler(chance.ChanceScheduler):
    """Implements Naive Scheduler that tries to find least loaded host."""
    def _schedule_instance(self, context, instance_opts, *_args, **_kwargs):
Пример #6
0
# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

from engine import flags

FLAGS = flags.FLAGS

flags.DEFINE_integer('answer', 42, 'test flag')
Пример #7
0

FLAGS = flags.FLAGS
flags.DEFINE_string('dhcpbridge_flagfile',
                    '/etc/engine/engine-dhcpbridge.conf',
                    'location of flagfile for dhcpbridge')
flags.DEFINE_string('networks_path', '$state_path/networks',
                    'Location to keep network config files')
flags.DEFINE_string('public_interface', 'eth0',
                    'Interface for public IP addresses')
flags.DEFINE_string('network_device_mtu', None, 'MTU setting for vlan')
flags.DEFINE_string('dhcpbridge', _bin_file('engine-dhcpbridge'),
                        'location of engine-dhcpbridge')
flags.DEFINE_string('routing_source_ip', '$my_ip',
                    'Public IP of network host')
flags.DEFINE_integer('dhcp_lease_time', 120,
                     'Lifetime of a DHCP lease in seconds')
flags.DEFINE_string('dns_server', None,
                    'if set, uses specific dns server for dnsmasq')
flags.DEFINE_string('dmz_cidr', '10.128.0.0/24',
                    'dmz range that should be accepted')
flags.DEFINE_string('dnsmasq_config_file', "",
                    'Override the default dnsmasq settings with this file')
flags.DEFINE_string('linuxnet_interface_driver',
                    'engine.network.linux_net.LinuxBridgeInterfaceDriver',
                    'Driver used to create ethernet devices.')
flags.DEFINE_string('linuxnet_ovs_integration_bridge',
                    'br-int', 'Name of Open vSwitch bridge used with linuxnet')
flags.DEFINE_bool('send_arp_for_ha', False,
                  'send gratuitous ARPs for HA setup')
flags.DEFINE_bool('use_single_default_gateway',
                   False, 'Use single default gateway. Only first nic of vm'
Пример #8
0
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
"""VMRC console drivers."""

import base64
import json

from engine import exception
from engine import flags
from engine import log as logging
from engine.virt.vmwareapi import vim_util

FLAGS = flags.FLAGS
flags.DEFINE_integer('console_vmrc_port', 443,
                     "port for VMware VMRC connections")
flags.DEFINE_integer('console_vmrc_error_retries', 10,
                     "number of retries for retrieving VMRC information")


class VMRCConsole(object):
    """VMRC console driver with ESX credentials."""
    def __init__(self):
        super(VMRCConsole, self).__init__()

    @property
    def console_type(self):
        return 'vmrc+credentials'

    def get_port(self, context):
        """Get available port for consoles."""
Пример #9
0
It should be easy to create a replacement for this driver supporting
other backends by creating another class that exposes the same
public methods.
"""

import functools
import sys

from engine import exception
from engine import flags
from engine import log as logging


FLAGS = flags.FLAGS
flags.DEFINE_integer('ldap_schema_version', 2,
                     'Current version of the LDAP schema')
flags.DEFINE_string('ldap_url', 'ldap://localhost',
                    'Point this at your ldap server')
flags.DEFINE_string('ldap_password', 'changeme', 'LDAP password')
flags.DEFINE_string('ldap_user_dn', 'cn=Manager,dc=example,dc=com',
                    'DN of admin user')
flags.DEFINE_string('ldap_user_id_attribute', 'uid', 'Attribute to use as id')
flags.DEFINE_string('ldap_user_name_attribute', 'cn',
                    'Attribute to use as name')
flags.DEFINE_string('ldap_user_unit', 'Users', 'OID for Users')
flags.DEFINE_string('ldap_user_subtree', 'ou=Users,dc=example,dc=com',
                    'OU for Users')
flags.DEFINE_boolean('ldap_user_modify_only', False,
                    'Modify attributes for users instead of creating/deleting')
flags.DEFINE_string('ldap_project_subtree', 'ou=Groups,dc=example,dc=com',
                    'OU for Projects')
Пример #10
0
import webob.exc

from engine.api.ec2 import apirequest
from engine.api.ec2 import ec2utils
from engine.api.ec2 import faults
from engine.auth import manager
from engine import context
from engine import exception
from engine import flags
from engine import log as logging
from engine import utils
from engine import wsgi

FLAGS = flags.FLAGS
LOG = logging.getLogger("engine.api")
flags.DEFINE_integer('lockout_attempts', 5,
                     'Number of failed auths before lockout.')
flags.DEFINE_integer('lockout_minutes', 15,
                     'Number of minutes to lockout if triggered.')
flags.DEFINE_integer('lockout_window', 15,
                     'Number of minutes for lockout window.')
flags.DECLARE('use_forwarded_for', 'engine.api.auth')


## Fault Wrapper around all EC2 requests ##
class FaultWrapper(wsgi.Middleware):
    """Calls the middleware stack, captures any exceptions into faults."""

    @webob.dec.wsgify(RequestClass=wsgi.Request)
    def __call__(self, req):
        try:
            return req.get_response(self.application)
Пример #11
0
import json
import os
import tempfile

from engine import exception
from engine import flags
from engine import log as logging
from engine import utils
from engine.virt.disk import guestfs
from engine.virt.disk import loop
from engine.virt.disk import nbd

LOG = logging.getLogger('engine.compute.disk')
FLAGS = flags.FLAGS
flags.DEFINE_integer('minimum_root_size', 1024 * 1024 * 1024 * 10,
                     'minimum size in bytes of root partition')
flags.DEFINE_string('injected_network_template',
                    utils.abspath('virt/interfaces.template'),
                    'Template file for injected network')
flags.DEFINE_list('img_handlers', ['loop', 'nbd', 'guestfs'],
                  'Order of methods used to mount disk images')

# NOTE(yamahata): DEFINE_list() doesn't work because the command may
#                 include ','. For example,
#                 mkfs.ext3 -O dir_index,extent -E stride=8,stripe-width=16
#                 --label %(fs_label)s %(target)s
#
#                 DEFINE_list() parses its argument by
#                 [s.strip() for s in argument.split(self._token)]
#                 where self._token = ','
#                 No escape nor exceptional handling for ','.
Пример #12
0
from engine import utils
from engine.utils import ssh_execute
from engine.volume.driver import ISCSIDriver

LOG = logging.getLogger("engine.volume.driver")
FLAGS = flags.FLAGS
flags.DEFINE_boolean('san_thin_provision', 'true',
                     'Use thin provisioning for SAN volumes?')
flags.DEFINE_string('san_ip', '', 'IP address of SAN controller')
flags.DEFINE_string('san_login', 'admin', 'Username for SAN controller')
flags.DEFINE_string('san_password', '', 'Password for SAN controller')
flags.DEFINE_string('san_privatekey', '',
                    'Filename of private key to use for SSH authentication')
flags.DEFINE_string('san_clustername', '',
                    'Cluster name to use for creating volumes')
flags.DEFINE_integer('san_ssh_port', 22, 'SSH port to use with SAN')
flags.DEFINE_boolean(
    'san_is_local', 'false', 'Execute commands locally instead of over SSH; '
    'use if the volume service is running on the SAN device')
flags.DEFINE_string('san_zfs_volume_base', 'rpool/',
                    'The ZFS path under which to create zvols for volumes.')


class SanISCSIDriver(ISCSIDriver):
    """ Base class for SAN-style storage volumes

    A SAN-style storage value is 'different' because the volume controller
    probably won't run on it, so we need to access is over SSH or another
    remote protocol.
    """
    def __init__(self):
Пример #13
0
from engine import context
from engine import db
from engine import exception
from engine import flags
from engine import rpc
from engine import test
from engine import service
from engine import manager
from engine import wsgi
from engine.compute import manager as compute_manager

flags.DEFINE_string("fake_manager", "engine.tests.test_service.FakeManager",
                    "Manager for testing")
flags.DEFINE_string("test_service_listen", None,
                    "Host to bind test service to")
flags.DEFINE_integer("test_service_listen_port", 0,
                     "Port number to bind test service to")


class FakeManager(manager.Manager):
    """Fake manager for tests"""
    def test_method(self):
        return 'manager'


class ExtendedService(service.Service):
    def test_method(self):
        return 'service'


class ServiceManagerTestCase(test.TestCase):
    """Test cases for Services"""