def test_flagfile(self): flags.DEFINE_string('string', 'default', 'desc', flag_values=self.FLAGS) flags.DEFINE_integer('int', 1, 'desc', flag_values=self.FLAGS) flags.DEFINE_bool('false', False, 'desc', flag_values=self.FLAGS) flags.DEFINE_bool('true', True, 'desc', flag_values=self.FLAGS) flags.DEFINE_multistring('multi', ['blaa'], 'desc', flag_values=self.FLAGS) (fd, path) = tempfile.mkstemp(prefix='engine', suffix='.flags') try: os.write(fd, '--string=foo\n--int=2\n--false\n--notrue\n') os.write(fd, '--multi=foo\n--multi=bar\n') os.close(fd) self.FLAGS(['flags_test', '--flagfile=' + path]) self.assertEqual(self.FLAGS.string, 'foo') self.assertEqual(self.FLAGS.int, 2) self.assertEqual(self.FLAGS.false, True) self.assertEqual(self.FLAGS.true, False) self.assertEqual(self.FLAGS.multi, ['foo', 'bar']) # Re-parse to test multistring isn't append multiple times self.FLAGS(['flags_test', '--flagfile=' + path]) self.assertEqual(self.FLAGS.multi, ['foo', 'bar']) finally: os.remove(path)
def test_define(self): self.assert_('string' not in self.FLAGS) self.assert_('int' not in self.FLAGS) self.assert_('false' not in self.FLAGS) self.assert_('true' not in self.FLAGS) flags.DEFINE_string('string', 'default', 'desc', flag_values=self.FLAGS) flags.DEFINE_integer('int', 1, 'desc', flag_values=self.FLAGS) flags.DEFINE_bool('false', False, 'desc', flag_values=self.FLAGS) flags.DEFINE_bool('true', True, 'desc', flag_values=self.FLAGS) self.assert_(self.FLAGS['string']) self.assert_(self.FLAGS['int']) self.assert_(self.FLAGS['false']) self.assert_(self.FLAGS['true']) self.assertEqual(self.FLAGS.string, 'default') self.assertEqual(self.FLAGS.int, 1) self.assertEqual(self.FLAGS.false, False) self.assertEqual(self.FLAGS.true, True) argv = ['flags_test', '--string', 'foo', '--int', '2', '--false', '--notrue'] self.FLAGS(argv) self.assertEqual(self.FLAGS.string, 'foo') self.assertEqual(self.FLAGS.int, 2) self.assertEqual(self.FLAGS.false, True) self.assertEqual(self.FLAGS.true, False)
def test_long_vs_short_flags(self): flags.DEFINE_string('duplicate_answer_long', 'val', 'desc', flag_values=self.global_FLAGS) argv = ['flags_test', '--duplicate_answer=60', 'extra_arg'] args = self.global_FLAGS(argv) self.assert_('duplicate_answer' not in self.global_FLAGS) self.assert_(self.global_FLAGS.duplicate_answer_long, 60) flags.DEFINE_integer('duplicate_answer', 60, 'desc', flag_values=self.global_FLAGS) self.assertEqual(self.global_FLAGS.duplicate_answer, 60) self.assertEqual(self.global_FLAGS.duplicate_answer_long, 'val')
# License for the specific language governing permissions and limitations # under the License. """Console Proxy Service.""" import functools import socket from engine import exception from engine import flags from engine import log as logging from engine import manager from engine import rpc from engine import utils FLAGS = flags.FLAGS flags.DEFINE_string('console_driver', 'engine.console.xvp.XVPConsoleProxy', 'Driver to use for the console proxy') flags.DEFINE_boolean('stub_compute', False, 'Stub calls to compute worker for tests') flags.DEFINE_string('console_public_hostname', socket.gethostname(), 'Publicly visable name for this console host') class ConsoleProxyManager(manager.Manager): """Sets up and tears down any console proxy connections. Needed for accessing instance consoles securely. """ def __init__(self, console_driver=None, *args, **kwargs): if not console_driver: console_driver = FLAGS.console_driver
import fcntl import os import signal from Cheetah import Template from engine import context from engine import db from engine import exception from engine import flags from engine import log as logging from engine import utils FLAGS = flags.FLAGS flags.DEFINE_string('console_xvp_conf_template', utils.abspath('console/xvp.conf.template'), 'XVP conf template') flags.DEFINE_string('console_xvp_conf', '/etc/xvp.conf', 'generated XVP conf file') flags.DEFINE_string('console_xvp_pid', '/var/run/xvp.pid', 'XVP master process pid file') flags.DEFINE_string('console_xvp_log', '/var/log/xvp.log', 'XVP log file') flags.DEFINE_integer('console_xvp_multiplex_port', 5900, 'port for XVP to multiplex VNC connections on') class XVPConsoleProxy(object): """Sets up XVP config, and manages XVP daemon.""" def __init__(self): self.xvpconf_template = open(FLAGS.console_xvp_conf_template).read() self.host = FLAGS.host # default, set by manager.
""" import os import time from xml.etree import ElementTree from engine import exception from engine import flags from engine import log as logging from engine import utils from engine.volume import iscsi from engine.volume import volume_types LOG = logging.getLogger("engine.volume.driver") FLAGS = flags.FLAGS flags.DEFINE_string('volume_group', 'engine-volumes', 'Name for the VG that will contain exported volumes') flags.DEFINE_string('num_shell_tries', 3, 'number of times to attempt to run flakey shell commands') flags.DEFINE_string('num_iscsi_scan_tries', 3, 'number of times to rescan iSCSI target to find volume') flags.DEFINE_integer('iscsi_num_targets', 100, 'Number of iscsi target ids per host') flags.DEFINE_string('iscsi_target_prefix', 'iqn.2010-10.org.x7:', 'prefix for iscsi volumes') flags.DEFINE_string('iscsi_ip_address', '$my_ip', 'use this ip for iscsi') flags.DEFINE_integer('iscsi_port', 3260, 'The port that the iSCSI daemon is listening on') flags.DEFINE_string('rbd_pool', 'rbd', 'the rbd pool in which volumes are stored')
def test_defaults(self): flags.DEFINE_string('foo', 'bar', 'help', flag_values=self.FLAGS) self.assertEqual(self.FLAGS.foo, 'bar') self.FLAGS['foo'].SetDefault('blaa') self.assertEqual(self.FLAGS.foo, 'blaa')
import logging import logging.handlers import os import stat import sys import traceback import engine from engine import flags from engine import local from engine import version FLAGS = flags.FLAGS flags.DEFINE_string( 'logging_context_format_string', '%(asctime)s %(levelname)s %(name)s ' '[%(request_id)s %(user_id)s ' '%(project_id)s] %(message)s', 'format string to use for log messages with context') flags.DEFINE_string('logging_default_format_string', '%(asctime)s %(levelname)s %(name)s [-] ' '%(message)s', 'format string to use for log messages without context') flags.DEFINE_string( 'logging_debug_format_suffix', 'from (pid=%(process)d) %(funcName)s' ' %(pathname)s:%(lineno)d', 'data to append to log format when level is DEBUG') flags.DEFINE_string('logging_exception_prefix', '(%(name)s): TRACE: ', 'prefix each line of exception output with this format') flags.DEFINE_list('default_log_levels', [ 'amqplib=WARN', 'sqlalchemy=WARN', 'boto=WARN', 'suds=INFO', 'eventlet.wsgi.server=WARN'
flags.DEFINE_list('allowed_roles', ['cloudadmin', 'itsec', 'sysadmin', 'netadmin', 'developer'], 'Allowed roles for project') # NOTE(vish): a user with one of these roles will be a superuser and # have access to all api commands flags.DEFINE_list('superuser_roles', ['cloudadmin'], 'Roles that ignore authorization checking completely') # NOTE(vish): a user with one of these roles will have it for every # project, even if he or she is not a member of the project flags.DEFINE_list('global_roles', ['cloudadmin', 'itsec'], 'Roles that apply to all projects') flags.DEFINE_string('credentials_template', utils.abspath('auth/enginerc.template'), 'Template for creating users rc file') flags.DEFINE_string('vpn_client_template', utils.abspath('cloudpipe/client.ovpn.template'), 'Template for creating users vpn file') flags.DEFINE_string('credential_vpn_file', 'engine-vpn.conf', 'Filename of certificate in credentials zip') flags.DEFINE_string('credential_key_file', 'pk.pem', 'Filename of private key in credentials zip') flags.DEFINE_string('credential_cert_file', 'cert.pem', 'Filename of certificate in credentials zip') flags.DEFINE_string('credential_rc_file', '%src', 'Filename of rc in credentials zip, %s will be ' 'replaced by name of the region (engine by default)') flags.DEFINE_string('auth_driver', 'engine.auth.dbdriver.DbDriver', 'Driver that auth manager uses')
it if needed. This file is converted to a data structure and passed into the filtering and weighing functions which can use it for dynamic configuration. """ import datetime import json import os from engine import flags from engine import log as logging FLAGS = flags.FLAGS flags.DEFINE_string('scheduler_json_config_location', '', 'Absolute path to scheduler configuration JSON file.') LOG = logging.getLogger('engine.scheduler.scheduler_options') class SchedulerOptions(object): """ SchedulerOptions monitors a local .json file for changes and loads it if needed. This file is converted to a data structure and passed into the filtering and weighing functions which can use it for dynamic configuration. """ def __init__(self): super(SchedulerOptions, self).__init__()
# 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. import engine.context from engine import flags from engine import rpc FLAGS = flags.FLAGS flags.DEFINE_string('notification_topic', 'notifications', 'RabbitMQ topic used for Engine notifications') def notify(message): """Sends a notification to the RabbitMQ""" context = engine.context.get_admin_context() priority = message.get('priority', FLAGS.default_notification_level) priority = priority.lower() topic = '%s.%s' % (FLAGS.notification_topic, priority) rpc.notify(context, topic, message)
# # 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 from engine import utils FLAGS = flags.FLAGS flags.DEFINE_string('ipv6_backend', 'rfc2462', 'Backend to use for IPv6 generation') def reset_backend(): global IMPL IMPL = utils.LazyPluggable(FLAGS['ipv6_backend'], rfc2462='engine.ipv6.rfc2462', account_identifier='engine.ipv6.account_identifier') def to_global(prefix, mac, project_id): return IMPL.to_global(prefix, mac, project_id) def to_mac(ipv6_address):
# License for the specific language governing permissions and limitations # under the License. import os import random import shutil from engine import exception from engine import flags from engine import utils from engine.virt.disk import api as disk from engine.virt import images FLAGS = flags.FLAGS flags.DEFINE_string('qemu_img', 'qemu-img', 'binary to use for qemu-img commands') def execute(*args, **kwargs): return utils.execute(*args, **kwargs) def create_image(disk_format, path, size): """Create a disk image :param disk_format: Disk image format (as known by qemu-img) :param path: Desired location of the disk image :param size: Desired size of disk image. May be given as an int or a string. If given as an int, it will be interpreted as bytes. If it's a string, it should consist of a number followed by an optional prefix ('k' for kilobytes, 'm'
""" 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): """Picks a host that is up and has the fewest running instances.""" elevated = context.elevated() availability_zone = instance_opts.get('availability_zone') zone, host = FLAGS.default_schedule_zone, None
# 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.utils import import_object from engine.rpc.common import RemoteError, LOG from engine import flags FLAGS = flags.FLAGS flags.DEFINE_string('rpc_backend', 'engine.rpc.impl_kombu', "The messaging module to use, defaults to kombu.") def create_connection(new=True): """Create a connection to the message bus used for rpc. For some example usage of creating a connection and some consumers on that connection, see engine.service. :param new: Whether or not to create a new connection. A new connection will be created by default. If new is False, the implementation is free to return an existing connection from a pool. :returns: An instance of engine.rpc.common.Connection
# limitations under the License. """Auth Components for VNC Console.""" import os import sys from engine import flags from engine import log as logging from engine import version from engine import wsgi from engine.vnc import auth from engine.vnc import proxy LOG = logging.getLogger('engine.vncproxy') FLAGS = flags.FLAGS flags.DEFINE_string('vncproxy_wwwroot', '/var/lib/engine/noVNC/', 'Full path to noVNC directory') flags.DEFINE_boolean('vnc_debug', False, 'Enable debugging features, like token bypassing') flags.DEFINE_integer('vncproxy_port', 6080, 'Port that the VNC proxy should bind to') flags.DEFINE_string('vncproxy_host', '0.0.0.0', 'Address that the VNC proxy should bind to') flags.DEFINE_integer('vncproxy_flash_socket_policy_port', 843, 'Port that the socket policy listener should bind to') flags.DEFINE_string('vncproxy_flash_socket_policy_host', '0.0.0.0', 'Address that the socket policy listener should bind to') flags.DEFINE_integer('vnc_token_ttl', 300, 'How many seconds before deleting tokens') flags.DEFINE_string('vncproxy_manager', 'engine.vnc.auth.VNCProxyAuthManager', 'Manager for vncproxy auth')
# 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. """ Scheduler that allows routing some calls to one driver and others to another. """ from engine import flags from engine import utils from engine.scheduler import driver FLAGS = flags.FLAGS flags.DEFINE_string('compute_scheduler_driver', 'engine.scheduler.chance.ChanceScheduler', 'Driver to use for scheduling compute calls') flags.DEFINE_string('volume_scheduler_driver', 'engine.scheduler.chance.ChanceScheduler', 'Driver to use for scheduling volume calls') # A mapping of methods to topics so we can figure out which driver to use. _METHOD_MAP = { 'run_instance': 'compute', 'start_instance': 'compute', 'prep_resize': 'compute', 'create_volume': 'volume', 'create_volumes': 'volume' }
"""VIF drivers for interface type direct.""" 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'
# 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. import exceptions import os import tempfile from engine import exception from engine import flags from engine import test FLAGS = flags.FLAGS flags.DEFINE_string('flags_unittest', 'foo', 'for testing purposes only') class FlagsTestCase(test.TestCase): def setUp(self): super(FlagsTestCase, self).setUp() self.FLAGS = flags.FlagValues() self.global_FLAGS = flags.FLAGS def test_define(self): self.assert_('string' not in self.FLAGS) self.assert_('int' not in self.FLAGS) self.assert_('false' not in self.FLAGS) self.assert_('true' not in self.FLAGS)
# 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. import uuid from engine import flags from engine import utils from engine import log as logging LOG = logging.getLogger('engine.exception') FLAGS = flags.FLAGS flags.DEFINE_string('default_notification_level', 'INFO', 'Default notification level for outgoing notifications') flags.DEFINE_string('default_publisher_id', FLAGS.host, 'Default publisher_id for outgoing notifications') WARN = 'WARN' INFO = 'INFO' ERROR = 'ERROR' CRITICAL = 'CRITICAL' DEBUG = 'DEBUG' log_levels = (DEBUG, WARN, INFO, ERROR, CRITICAL) class BadPriorityException(Exception): pass
# 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. """VIF drivers for XenAPI.""" from engine import flags from engine import log as logging from engine.virt.vif import VIFDriver from engine.virt.xenapi.network_utils import NetworkHelper from engine.virt.xenapi.vm_utils import VMHelper FLAGS = flags.FLAGS flags.DEFINE_string('xenapi_ovs_integration_bridge', 'xapi1', 'Name of Integration Bridge used by Open vSwitch') LOG = logging.getLogger("engine.virt.xenapi.vif") class XenVIFDriver(VIFDriver): def __init__(self, xenapi_session): self._session = xenapi_session class XenAPIBridgeDriver(XenVIFDriver): """VIF Driver for XenAPI that uses XenAPI to create Networks.""" def plug(self, instance, network, mapping, vm_ref=None, device=None): if not vm_ref: vm_ref = VMHelper.lookup(self._session, instance.name)
import urllib2 import uuid from engine.compute import power_state from engine import exception from engine import flags from engine import log as logging from engine import utils from engine.virt.vmwareapi import vim_util from engine.virt.vmwareapi import vm_util from engine.virt.vmwareapi import vmware_images from engine.virt.vmwareapi import network_utils FLAGS = flags.FLAGS flags.DEFINE_string('vmware_vif_driver', 'engine.virt.vmwareapi.vif.VMWareVlanBridgeDriver', 'The VMWare VIF driver to configure the VIFs.') LOG = logging.getLogger("engine.virt.vmwareapi.vmops") VMWARE_POWER_STATES = { 'poweredOff': power_state.SHUTDOWN, 'poweredOn': power_state.RUNNING, 'suspended': power_state.PAUSED } class VMWareVMOps(object): """Management class for VM-related tasks.""" def __init__(self, session): """Initializer."""
def test_templated_values(self): flags.DEFINE_string('foo', 'foo', 'help', flag_values=self.FLAGS) flags.DEFINE_string('bar', 'bar', 'help', flag_values=self.FLAGS) flags.DEFINE_string('blaa', '$foo$bar', 'help', flag_values=self.FLAGS) self.assertEqual(self.FLAGS.blaa, 'foobar')
import unittest import mox import nose.plugins.skip import stubout from engine import flags import engine.image.fake from engine import log from engine import utils from engine import service from engine.testing.fake import rabbit from engine.virt import fake FLAGS = flags.FLAGS flags.DEFINE_string('sqlite_clean_db', 'clean.sqlite', 'File name of clean sqlite db') flags.DEFINE_bool('fake_tests', True, 'should we use everything for testing') LOG = log.getLogger('engine.tests') class skip_test(object): """Decorator that skips a test.""" # TODO(tr3buchet): remember forever what comstud did here def __init__(self, msg): self.message = msg def __call__(self, func): @functools.wraps(func) def _skipper(*args, **kw):
try: import suds except ImportError: suds = None from engine import flags from engine.virt.vmwareapi import error_util RESP_NOT_XML_ERROR = 'Response is "text/html", not "text/xml"' CONN_ABORT_ERROR = 'Software caused connection abort' ADDRESS_IN_USE_ERROR = 'Address already in use' FLAGS = flags.FLAGS flags.DEFINE_string( 'vmwareapi_wsdl_loc', None, 'VIM Service WSDL Location' 'e.g http://<server>/vimService.wsdl' 'Due to a bug in vSphere ESX 4.1 default wsdl' 'Refer readme-vmware to setup') if suds: class VIMMessagePlugin(suds.plugin.MessagePlugin): def addAttributeForValue(self, node): # suds does not handle AnyType properly. # VI SDK requires type attribute to be set when AnyType is used if node.name == 'value': node.set('xsi:type', 'xsd:string') def marshalled(self, context): """suds will send the specified soap envelope. Provides the plugin with the opportunity to prune empty
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright (c) 2010 X7, LLC. # 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. """Module for VNC Proxying.""" from engine import flags FLAGS = flags.FLAGS flags.DEFINE_string('vncproxy_topic', 'vncproxy', 'the topic vnc proxy nodes listen on') flags.DEFINE_string( 'vncproxy_url', 'http://127.0.0.1:6080', 'location of vnc console proxy, \ in the form "http://127.0.0.1:6080"') flags.DEFINE_string('vncserver_host', '0.0.0.0', 'the host interface on which vnc server should listen') flags.DEFINE_bool('vnc_enabled', True, 'enable vnc related features') flags.DEFINE_string('vnc_keymap', 'en-us', 'keymap for vnc')
# under the License. """VIF drivers for libvirt.""" from engine import exception from engine import flags from engine import log as logging from engine.network import linux_net from engine import utils from engine.virt.libvirt import netutils from engine.virt.vif import VIFDriver LOG = logging.getLogger('engine.virt.libvirt.vif') FLAGS = flags.FLAGS flags.DEFINE_string('libvirt_ovs_bridge', 'br-int', 'Name of Integration Bridge used by Open vSwitch') class LibvirtBridgeDriver(VIFDriver): """VIF driver for Linux bridge.""" def _get_configurations(self, network, mapping): """Get a dictionary of VIF configurations for bridge type.""" # Assume that the gateway also acts as the dhcp server. gateway_v6 = mapping.get('gateway_v6') mac_id = mapping['mac'].replace(':', '') if FLAGS.allow_same_net_traffic: template = "<parameter name=\"%s\" value=\"%s\" />\n" net, mask = netutils.get_net_and_mask(network['cidr']) values = [("PROJNET", net), ("PROJMASK", mask)] if FLAGS.use_ipv6:
from engine import db from engine import exception from engine import utils from engine import flags from engine import log as logging from engine.virt import driver from engine.virt.xenapi import vm_utils from engine.virt.xenapi.vmops import VMOps from engine.virt.xenapi.volumeops import VolumeOps LOG = logging.getLogger("engine.virt.xenapi") FLAGS = flags.FLAGS flags.DEFINE_string( 'xenapi_connection_url', None, 'URL for connection to XenServer/Xen Cloud Platform.' ' Required if connection_type=xenapi.') flags.DEFINE_string( 'xenapi_connection_username', 'root', 'Username for connection to XenServer/Xen Cloud Platform.' ' Used only if connection_type=xenapi.') flags.DEFINE_string( 'xenapi_connection_password', None, 'Password for connection to XenServer/Xen Cloud Platform.' ' Used only if connection_type=xenapi.') flags.DEFINE_integer( 'xenapi_connection_concurrent', 5, 'Maximum number of concurrent XenAPI connections.' ' Used only if connection_type=xenapi.') flags.DEFINE_float( 'xenapi_task_poll_interval', 0.5,
"""VMRC Console Manager.""" from engine import exception from engine import flags from engine import log as logging from engine import manager from engine import rpc from engine import utils from engine.virt import vmwareapi_conn LOG = logging.getLogger("engine.console.vmrc_manager") FLAGS = flags.FLAGS flags.DEFINE_string('console_public_hostname', '', 'Publicly visible name for this console host') flags.DEFINE_string('console_driver', 'engine.console.vmrc.VMRCConsole', 'Driver to use for the console') class ConsoleVMRCManager(manager.Manager): """Manager to handle VMRC connections for accessing instance consoles.""" def __init__(self, console_driver=None, *args, **kwargs): self.driver = utils.import_object(FLAGS.console_driver) super(ConsoleVMRCManager, self).__init__(*args, **kwargs) def init_host(self): self.sessions = {} self.driver.init_host()
# 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. import httplib import socket import urllib import json from engine import flags FLAGS = flags.FLAGS flags.DEFINE_string('melange_host', '127.0.0.1', 'HOST for connecting to melange') flags.DEFINE_string('melange_port', '9898', 'PORT for connecting to melange') json_content_type = {'Content-type': "application/json"} # FIXME(danwent): talk to the Melange folks about creating a # client lib that we can import as a library, instead of # have to have all of the client code in here. class MelangeConnection(object): def __init__(self, host=None, port=None, use_ssl=False): if host is None: host = FLAGS.melange_host if port is None: port = int(FLAGS.melange_port)