from nova import context from nova import flags from nova import log as logging from nova import rpc from nova import version from nova import wsgi LOG = logging.getLogger('nova.xvpvncproxy') FLAGS = flags.FLAGS flags.DECLARE('consoleauth_topic', 'nova.consoleauth') flags.DEFINE_integer('xvpvncproxy_port', 6081, 'Port that the XCP VNC proxy should bind to') flags.DEFINE_string('xvpvncproxy_host', '0.0.0.0', 'Address that the XCP VNC proxy should bind to') class XCPVNCProxy(object): """Class to use the xvp auth protocol to proxy instance vnc consoles.""" def one_way_proxy(self, source, dest): """Proxy tcp connection from source to dest.""" while True: try: d = source.recv(32384) except Exception as e: d = None # If recv fails, send a write shutdown the other direction if d is None or len(d) == 0:
# License for the specific language governing permissions and limitations # under the License. import json import nova import nova.context from nova.exception import Error from nova import flags from nova import rpc import logging import logging.handlers from nova import log as LOG from nova.notifier import api FLAGS = flags.FLAGS flags.DEFINE_string('notification_topic', 'notification', 'RabbitMQ topic used for Nova notifications') def api_decorator(name, fn): """ decorator for notify which is used from utils.monkey_patch() :param name: name of the function :param function: - object of the function :returns: function -- decorated function """ def wrapped_func(*args, **kwarg): body = {} body['args'] = [] body['kwarg'] = {} original_args = args
# # 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 nova import flags from nova import log as logging from nova.network.quantum import client as quantum_client from nova import utils LOG = logging.getLogger("nova.network.quantum.quantum_connection") FLAGS = flags.FLAGS flags.DEFINE_string('quantum_connection_host', '127.0.0.1', 'HOST for connecting to quantum') flags.DEFINE_string('quantum_connection_port', '9696', 'PORT for connecting to quantum') flags.DEFINE_string('quantum_default_tenant_id', "default", 'Default tenant id when creating quantum networks') class QuantumClientConnection(object): """Abstracts connection to Quantum service into higher level operations performed by the QuantumManager. Separating this out as a class also let's us create a 'fake' version of this class for unit tests. """
import uuid from nova import context as nova_context from nova import exception from nova import flags from nova import log as logging from nova import utils from nova.compute import power_state from nova.virt.vmwareapi import vim_util from nova.virt.vmwareapi import vm_util from nova.virt.vmwareapi import vmware_images from nova.virt.vmwareapi import network_utils FLAGS = flags.FLAGS flags.DEFINE_string('vmware_vif_driver', 'nova.virt.vmwareapi.vif.VMWareVlanBridgeDriver', 'The VMWare VIF driver to configure the VIFs.') LOG = logging.getLogger("nova.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."""
import os import sys import time from nova import flags from nova import log as logging from nova import manager from nova import utils LOG = logging.getLogger('nova.consoleauth') FLAGS = flags.FLAGS flags.DEFINE_integer('console_token_ttl', 600, 'How many seconds before deleting tokens') flags.DEFINE_string('consoleauth_manager', 'nova.consoleauth.manager.ConsoleAuthManager', 'Manager for console auth') class ConsoleAuthManager(manager.Manager): """Manages token based authentication.""" def __init__(self, scheduler_driver=None, *args, **kwargs): super(ConsoleAuthManager, self).__init__(*args, **kwargs) self.tokens = {} utils.LoopingCall(self._delete_expired_tokens).start(1) def _delete_expired_tokens(self): now = time.time() to_delete = [] for k, v in self.tokens.items(): if now - v['last_activity_at'] > FLAGS.console_token_ttl:
import fcntl import os import signal import subprocess from Cheetah.Template import Template from nova import context from nova import db from nova import exception from nova import flags from nova import log as logging from nova import utils 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") FLAGS = flags.FLAGS class XVPConsoleProxy(object): """Sets up XVP config, and manages xvp daemon""" def __init__(self): self.xvpconf_template = open(FLAGS.console_xvp_conf_template).read()
import binascii import glob import json import os import shutil import tarfile import tempfile from xml.etree import ElementTree from nova import exception from nova import flags from nova import utils from nova.objectstore import bucket FLAGS = flags.FLAGS flags.DEFINE_string('images_path', utils.abspath('../images'), 'path to decrypted images') class Image(object): def __init__(self, image_id): self.image_id = image_id self.path = os.path.abspath(os.path.join(FLAGS.images_path, image_id)) if not self.path.startswith(os.path.abspath(FLAGS.images_path)) or \ not os.path.isdir(self.path): raise exception.NotFound @property def image_path(self): return os.path.join(self.path, 'image') def delete(self):
""" import functools from nova import db from nova import flags from nova import log as logging from nova import manager from nova import rpc from nova import utils from nova.scheduler import zone_manager LOG = logging.getLogger('nova.scheduler.manager') FLAGS = flags.FLAGS flags.DEFINE_string('scheduler_driver', 'nova.scheduler.chance.ChanceScheduler', 'Driver to use for the scheduler') class SchedulerManager(manager.Manager): """Chooses a host to run instances on.""" def __init__(self, scheduler_driver=None, *args, **kwargs): self.zone_manager = zone_manager.ZoneManager() if not scheduler_driver: scheduler_driver = FLAGS.scheduler_driver self.driver = utils.import_object(scheduler_driver) self.driver.set_zone_manager(self.zone_manager) super(SchedulerManager, self).__init__(*args, **kwargs) def __getattr__(self, key): """Converts all method calls to use the schedule method"""
""" import mox from nova import context from nova import db from nova import exception from nova import flags from nova import rpc from nova import test from nova import service from nova import manager from nova import wsgi from nova.compute import manager as compute_manager flags.DEFINE_string("fake_manager", "nova.tests.test_service.FakeManager", "Manager for testing") 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"""
from nova import context from nova import exception from nova import flags from nova import log as logging from nova import manager from nova import rpc from nova import utils from nova.volume import volume_types LOG = logging.getLogger('nova.volume.manager') FLAGS = flags.FLAGS flags.DEFINE_string('storage_availability_zone', 'nova', 'availability zone of this service') flags.DEFINE_string('volume_driver', 'nova.volume.driver.ISCSIDriver', 'Driver to use for volume creation') flags.DEFINE_boolean('use_local_volumes', True, 'if True, will not discover local volumes') flags.DEFINE_boolean('volume_force_update_capabilities', False, 'if True will force update capabilities on each check') class VolumeManager(manager.SchedulerDependentManager): """Manages attachable block storage devices.""" def __init__(self, volume_driver=None, *args, **kwargs): """Load the driver from the one specified in args, or from flags.""" if not volume_driver: volume_driver = FLAGS.volume_driver
except Exception, err: logging.warning('no libvirt found') from nova import exception from nova import fakevirt from nova import flags from nova import process from nova import utils from nova.compute import disk from nova.compute import model from nova.compute import network from nova.objectstore import image # for image_path flag FLAGS = flags.FLAGS flags.DEFINE_string('libvirt_xml_template', utils.abspath('compute/libvirt.xml.template'), 'Network XML Template') flags.DEFINE_bool('use_s3', True, 'whether to get images from s3 or use local copy') flags.DEFINE_string('instances_path', utils.abspath('../instances'), 'where instances are stored on disk') INSTANCE_TYPES = {} INSTANCE_TYPES['m1.tiny'] = {'memory_mb': 512, 'vcpus': 1, 'local_gb': 0} INSTANCE_TYPES['m1.small'] = {'memory_mb': 1024, 'vcpus': 1, 'local_gb': 10} INSTANCE_TYPES['m1.medium'] = {'memory_mb': 2048, 'vcpus': 2, 'local_gb': 10} INSTANCE_TYPES['m1.large'] = {'memory_mb': 4096, 'vcpus': 4, 'local_gb': 10} INSTANCE_TYPES['m1.xlarge'] = {'memory_mb': 8192, 'vcpus': 4, 'local_gb': 10} INSTANCE_TYPES['c1.medium'] = {'memory_mb': 2048, 'vcpus': 4, 'local_gb': 10} # The number of processes to start in our process pool
import os import paramiko from xml.etree import ElementTree from nova import exception from nova import flags from nova import log as logging from nova.utils import ssh_execute from nova.volume.driver import ISCSIDriver LOG = logging.getLogger("nova.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') 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.
import fakeldap from nova import datastore # TODO(termie): clean up these imports import signer from nova import exception from nova import flags from nova import crypto from nova import utils from nova import objectstore # for flags FLAGS = flags.FLAGS flags.DEFINE_string('ldap_url', 'ldap://localhost', 'Point this at your ldap server') flags.DEFINE_string('ldap_password', 'changeme', 'LDAP password') flags.DEFINE_string('user_dn', 'cn=Manager,dc=example,dc=com', 'DN of admin user') flags.DEFINE_string('user_unit', 'Users', 'OID for Users') flags.DEFINE_string('user_ldap_subtree', 'ou=Users,dc=example,dc=com', 'OU for Users') flags.DEFINE_string('project_ldap_subtree', 'ou=Groups,dc=example,dc=com', 'OU for Projects') flags.DEFINE_string('role_ldap_subtree', 'ou=Groups,dc=example,dc=com', 'OU for Roles') # mapping with these flags is necessary because we're going to tie in to an existing ldap schema flags.DEFINE_string('ldap_cloudadmin', 'cn=cloudadmins,ou=Groups,dc=example,dc=com', 'cn for Cloud Admins')
# 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. """Base class for classes that need modular database access.""" from nova import utils from nova import flags FLAGS = flags.FLAGS flags.DEFINE_string('db_driver', 'nova.db.api', 'driver to use for database access') class Base(object): """DB driver is injected in the init method.""" def __init__(self, db_driver=None): if not db_driver: db_driver = FLAGS.db_driver self.db = utils.import_object(db_driver) # pylint: disable=C0103
from nova import exception from nova import flags from nova.image import glance from nova import log as logging from nova import utils from nova.compute import instance_types from nova.compute import power_state from nova.virt import disk from nova.virt.injector import FileInjector from nova.virt.xenapi import HelperBase from nova.virt.xenapi.volume_utils import StorageError LOG = logging.getLogger("nova.virt.xenapi.vm_utils") FLAGS = flags.FLAGS flags.DEFINE_string('default_os_type', 'linux', 'Default OS type') flags.DEFINE_integer('block_device_creation_timeout', 10, 'time to wait for a block device to be created') flags.DEFINE_integer('max_kernel_ramdisk_size', 16 * 1024 * 1024, 'maximum size in bytes of kernel or ramdisk images') XENAPI_POWER_STATE = { 'Halted': power_state.SHUTDOWN, 'Running': power_state.RUNNING, 'Paused': power_state.PAUSED, 'Suspended': power_state.SUSPENDED, 'Crashed': power_state.CRASHED } SECTOR_SIZE = 512 MBR_SIZE_SECTORS = 63
# 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 nova import flags from nova import utils from nova import log as logging LOG = logging.getLogger('nova.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
import mox import nose.plugins.skip import nova.image.fake import shutil import stubout from nova import flags from nova import log from nova import rpc from nova import utils from nova import service from nova.testing.fake import rabbit from nova.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('nova.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):
import subprocess import time from nova import vendor from tornado import ioloop from twisted.internet import defer from nova import datastore from nova import exception from nova import flags from nova import rpc from nova import utils from nova import validate FLAGS = flags.FLAGS flags.DEFINE_string('storage_dev', '/dev/sdb', 'Physical device to use for volumes') flags.DEFINE_string('volume_group', 'nova-volumes', 'Name for the VG that will contain exported volumes') flags.DEFINE_string('aoe_eth_dev', 'eth0', 'Which device to export the volumes on') flags.DEFINE_string('storage_name', socket.gethostname(), 'name of this node') flags.DEFINE_integer('shelf_id', utils.last_octet(utils.get_my_ip()), 'AoE shelf_id for this node') flags.DEFINE_string('storage_availability_zone', 'nova', 'availability zone of this node') flags.DEFINE_boolean('fake_storage', False, 'Should we make real storage volumes to attach?') # TODO(joshua) Index of volumes by project
from nova import context from nova import db from nova import exception from nova import flags from nova import log as logging from nova import manager from nova.network import manager from nova.network.quantum import quantum_connection from nova.network.quantum import melange_ipam_lib from nova import utils LOG = logging.getLogger("nova.network.quantum.manager") FLAGS = flags.FLAGS flags.DEFINE_string('quantum_ipam_lib', 'nova.network.quantum.nova_ipam_lib', "Indicates underlying IP address management library") # TODO(Vek): Eventually, this needs to mean more than just using # Melange for assignment of MAC addresses (with an # appropriate flag name change, of course), but this is all # it does right now flags.DEFINE_bool('use_melange_mac_generation', False, "Use Melange for assignment of MAC addresses") flags.DEFINE_bool('quantum_use_dhcp', False, 'Whether or not to enable DHCP for networks') class QuantumManager(manager.FlatManager): """NetworkManager class that communicates with a Quantum service via a web services API to provision VM network connectivity.
from nova import exception from nova import flags from nova import log as logging from nova import utils from nova.virt import driver from nova.virt.vmwareapi import error_util from nova.virt.vmwareapi import vim from nova.virt.vmwareapi import vim_util from nova.virt.vmwareapi.vmops import VMWareVMOps LOG = logging.getLogger("nova.virt.vmwareapi_conn") FLAGS = flags.FLAGS flags.DEFINE_string('vmwareapi_host_ip', None, 'URL for connection to VMWare ESX host.' 'Required if connection_type is vmwareapi.') flags.DEFINE_string('vmwareapi_host_username', None, 'Username for connection to VMWare ESX host.' 'Used only if connection_type is vmwareapi.') flags.DEFINE_string('vmwareapi_host_password', None, 'Password for connection to VMWare ESX host.' 'Used only if connection_type is vmwareapi.') flags.DEFINE_float('vmwareapi_task_poll_interval', 5.0, 'The interval used for polling of remote tasks ' 'Used only if connection_type is vmwareapi') flags.DEFINE_float('vmwareapi_api_retry_count', 10,
# 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 nova.utils import import_object from nova.rpc.common import RemoteError, LOG from nova import flags FLAGS = flags.FLAGS flags.DEFINE_string('rpc_backend', 'nova.rpc.amqp', "The messaging module to use, defaults to AMQP.") RPCIMPL = import_object(FLAGS.rpc_backend) def create_connection(new=True): return RPCIMPL.Connection.instance(new=True) def create_consumer(conn, topic, proxy, fanout=False): if fanout: return RPCIMPL.FanoutAdapterConsumer(connection=conn, topic=topic, proxy=proxy) else: return RPCIMPL.TopicAdapterConsumer(connection=conn,
from nova import context from nova import db from nova import exception from nova import flags from nova import log as logging from nova import utils LOG = logging.getLogger('nova.compute.disk') FLAGS = flags.FLAGS flags.DEFINE_integer('minimum_root_size', 1024 * 1024 * 1024 * 10, 'minimum size in bytes of root partition') flags.DEFINE_integer('block_size', 1024 * 1024 * 256, 'block_size to use for dd') flags.DEFINE_string('injected_network_template', utils.abspath('virt/interfaces.template'), 'Template file for injected network') flags.DEFINE_integer('timeout_nbd', 10, 'time to wait for a NBD device coming up') flags.DEFINE_integer('max_nbd_devices', 16, 'maximum number of possible nbd devices') def extend(image, size): """Increase image to size""" file_size = os.path.getsize(image) if file_size >= size: return utils.execute('truncate', '-s', size, image) # NOTE(vish): attempts to resize filesystem utils.execute('e2fsck', '-fp', image, check_exit_code=False)
from nova import utils from nova import version from nova import wsgi LOG = logging.getLogger('nova.service') FLAGS = flags.FLAGS flags.DEFINE_integer('report_interval', 10, 'seconds between nodes reporting state to datastore', lower_bound=1) flags.DEFINE_integer('periodic_interval', 60, 'seconds between running periodic tasks', lower_bound=1) flags.DEFINE_string('ec2_listen', "0.0.0.0", 'IP address for EC2 API to listen') flags.DEFINE_integer('ec2_listen_port', 8773, 'port for ec2 api to listen') flags.DEFINE_string('osapi_compute_listen', "0.0.0.0", 'IP address for OpenStack API to listen') flags.DEFINE_integer('osapi_compute_listen_port', 8774, 'list port for osapi compute') flags.DEFINE_string('metadata_manager', 'nova.api.manager.MetadataManager', 'OpenStack metadata service manager') flags.DEFINE_string('metadata_listen', "0.0.0.0", 'IP address for metadata api to listen') flags.DEFINE_integer('metadata_listen_port', 8775, 'port for metadata api to listen') flags.DEFINE_string('api_paste_config', "api-paste.ini", 'File name for the paste.deploy config for nova-api') flags.DEFINE_string('osapi_volume_listen', "0.0.0.0", 'IP address for OpenStack Volume API to listen')
can take the more esoteric factors into consideration (such as server affinity and customer separation). """ import json from nova import exception from nova import flags from nova import log as logging from nova import utils LOG = logging.getLogger('nova.scheduler.host_filter') FLAGS = flags.FLAGS flags.DEFINE_string('default_host_filter_driver', 'nova.scheduler.host_filter.AllHostsFilter', 'Which driver to use for filtering hosts.') class HostFilter(object): """Base class for host filter drivers.""" def instance_type_to_filter(self, instance_type): """Convert instance_type into a filter for most common use-case.""" raise NotImplementedError() def filter_hosts(self, zone_manager, query): """Return a list of hosts that fulfill the filter.""" raise NotImplementedError() def _full_name(self): """module.classname of the filter driver"""
from nova import datastore from nova import flags from nova import rpc from nova import utils from nova import exception from nova.auth import rbac from nova.auth import users from nova.compute import model from nova.compute import network from nova.compute import node from nova.endpoint import images from nova.volume import storage FLAGS = flags.FLAGS flags.DEFINE_string('cloud_topic', 'cloud', 'the topic clouds listen on') def _gen_key(user_id, key_name): """ Tuck this into UserManager """ try: manager = users.UserManager.instance() private_key, fingerprint = manager.generate_key_pair(user_id, key_name) except Exception as ex: return {'exception': ex} return {'private_key': private_key, 'fingerprint': fingerprint} class CloudController(object): """ CloudController provides the critical dispatch between inbound API calls through the endpoint and messages
import json import logging import logging.handlers import os import stat import sys import traceback import nova from nova import flags from nova 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', 'eventlet.wsgi.server=WARN' ], 'list of logger=LEVEL pairs')
:db_backend: string to lookup in the list of LazyPluggable backends. `sqlalchemy` is the only supported backend right now. :sql_connection: string specifying the sqlalchemy connection to use, like: `sqlite:///var/lib/nova/nova.sqlite`. :enable_new_services: when adding a new service to the database, is it in the pool of available hardware (Default: True) """ from nova import exception from nova import flags from nova import utils FLAGS = flags.FLAGS flags.DEFINE_string('db_backend', 'sqlalchemy', 'The backend to use for db') flags.DEFINE_boolean('enable_new_services', True, 'Services to be added to the available pool on create') flags.DEFINE_string('instance_name_template', 'instance-%08x', 'Template string to be used to generate instance names') flags.DEFINE_string('volume_name_template', 'volume-%08x', 'Template string to be used to generate instance names') IMPL = utils.LazyPluggable(FLAGS['db_backend'], sqlalchemy='nova.db.sqlalchemy.api') class NoMoreAddresses(exception.Error): """No more available addresses.""" pass
# 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 nova import exception from nova import flags from nova 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) flags.DEFINE_string('string',
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/novarc.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', 'nova-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 (nova by default)') flags.DEFINE_string('auth_driver', 'nova.auth.dbdriver.DbDriver',
""" import functools from nova.compute import vm_states from nova import db from nova import exception from nova import flags from nova import log as logging from nova import manager from nova import rpc from nova import utils LOG = logging.getLogger('nova.scheduler.manager') FLAGS = flags.FLAGS flags.DEFINE_string('scheduler_driver', 'nova.scheduler.multi.MultiScheduler', 'Default driver to use for the scheduler') class SchedulerManager(manager.Manager): """Chooses a host to run instances on.""" def __init__(self, scheduler_driver=None, *args, **kwargs): if not scheduler_driver: scheduler_driver = FLAGS.scheduler_driver self.driver = utils.import_object(scheduler_driver) super(SchedulerManager, self).__init__(*args, **kwargs) def __getattr__(self, key): """Converts all method calls to use the schedule method""" return functools.partial(self._schedule, key) @manager.periodic_task