ZoneManager oversees all communications with child Zones. """ import novaclient import thread import traceback from datetime import datetime from eventlet import greenpool from nova import db from nova import flags from nova import log as logging 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') class ZoneState(object): """Holds the state of all connected child zones.""" def __init__(self): self.is_active = True self.name = None self.capabilities = None self.attempt = 0 self.last_seen = datetime.min self.last_exception = None self.last_exception_time = None
# under the License. """ Scheduler base class that all Schedulers should inherit from """ import datetime from nova import db from nova import exception from nova import flags from nova import log as logging from nova import rpc from nova.compute import power_state FLAGS = flags.FLAGS flags.DEFINE_integer('service_down_time', 60, 'maximum time since last checkin for up service') flags.DECLARE('instances_path', 'nova.compute.manager') class NoValidHost(exception.Error): """There is no valid host for the command.""" pass class WillNotSchedule(exception.Error): """The specified host is not up or doesn't exist.""" pass class Scheduler(object): """The base class that all Scheduler clases should inherit from."""
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 nova import exception from nova import flags from nova 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')
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() self.host = FLAGS.host # default, set by manager. super(XVPConsoleProxy, self).__init__() @property def console_type(self): return "vnc+xvp" def get_port(self, context):
# See the License for the specific language governing permissions and # limitations under the License. """Auth Components for Consoles.""" 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 = []
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 def get_volume(volume_id): """ Returns a redis-backed volume object """ volume_class = Volume if FLAGS.fake_storage: volume_class = FakeVolume if datastore.Redis.instance().sismember('volumes', volume_id): return volume_class(volume_id=volume_id)
from nova import exception from nova import flags from nova import log as logging from nova import utils from nova import wsgi from nova.api.ec2 import apirequest from nova.api.ec2 import ec2utils from nova.auth import manager FLAGS = flags.FLAGS LOG = logging.getLogger("nova.api") flags.DEFINE_boolean('use_forwarded_for', False, 'Treat X-Forwarded-For as the canonical remote address. ' 'Only enable this if you have a sanitizing proxy.') 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.DEFINE_list('lockout_memcached_servers', None, 'Memcached servers or None for in process cache.') class RequestLogging(wsgi.Middleware): """Access-Log akin logging for all EC2 API requests.""" @webob.dec.wsgify(RequestClass=wsgi.Request) def __call__(self, req): start = utils.utcnow() rv = req.get_response(self.application)
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, 'The interval used for polling of remote tasks ' '(Async.VM.start, etc). Used only if ' 'connection_type=xenapi.') flags.DEFINE_float('xenapi_vhd_coalesce_poll_interval', 5.0, 'The interval used for polling of coalescing vhds.' ' Used only if connection_type=xenapi.') flags.DEFINE_integer('xenapi_vhd_coalesce_max_attempts', 5, 'Max number of times to poll for VHD to coalesce.' ' Used only if connection_type=xenapi.') flags.DEFINE_string('xenapi_agent_path',
# 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. """Support for mounting images with qemu-nbd""" import os import time from nova import flags from nova import utils from nova.virt.disk import mount FLAGS = flags.FLAGS 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') class Mount(mount.Mount): """qemu-nbd support disk images.""" mode = 'nbd' # NOTE(padraig): There are three issues with this nbd device handling # 1. max_nbd_devices should be inferred (#861504) # 2. We assume nothing else on the system uses nbd devices # 3. Multiple workers on a system can race against each other # A patch has been proposed in Nov 2011, to add add a -f option to # qemu-nbd, akin to losetup -f. One could test for this by running qemu-nbd # with just the -f option, where it will fail if not supported, or if there
from nova import exception from nova import flags from nova import log as logging from nova import utils LOG = logging.getLogger("nova.volume.driver") FLAGS = flags.FLAGS 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('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('num_shelves', 100, 'Number of vblade shelves') flags.DEFINE_integer('blades_per_shelf', 16, 'Number of vblade blades per shelf') flags.DEFINE_integer('iscsi_num_targets', 100, 'Number of iscsi target ids per host') flags.DEFINE_string('iscsi_target_prefix', 'iqn.2010-10.org.openstack:', 'prefix for iscsi volumes') flags.DEFINE_string('iscsi_ip_prefix', '$my_ip', 'discover volumes on the ip that starts with this prefix') flags.DEFINE_string('rbd_pool', 'rbd', 'the rbd pool in which volumes are stored') class VolumeDriver(object): """Executes commands relating to Volumes.""" def __init__(self,
from nova import exception as excp from nova import flags from nova import log as logging from nova.network import linux_net from nova.virt.libvirt import netutils from nova import utils from nova.virt.vif import VIFDriver from quantum.client import Client from quantum.common.wsgi import Serializer LOG = logging.getLogger('quantum.plugins.cisco.nova.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 = 'nova' ACTION_PREFIX_EXT = '/v1.0' ACTION_PREFIX_CSCO = ACTION_PREFIX_EXT + \ '/extensions/csco/tenants/{tenant_id}' TENANT_ID = 'nova' CSCO_EXT_NAME = 'Cisco Nova Tenant' ASSOCIATE_ACTION = '/associate_port' DETACH_ACTION = '/detach_port' class Libvirt802dot1QbhDriver(VIFDriver):
from eventlet import greenpool 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 rpc from nova import utils from nova import version from nova import wsgi 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_listen', "0.0.0.0", 'IP address for OpenStack API to listen') flags.DEFINE_integer('osapi_listen_port', 8774, 'port for os api to listen') flags.DEFINE_string('api_paste_config', "api-paste.ini", 'File name for the paste.deploy config for nova-api') class Service(object):
""" import datetime import traceback import UserDict from eventlet import greenpool from novaclient import v1_1 as novaclient from nova import db from nova import flags from nova import log as logging from nova 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 self.attempt = 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 nova import flags FLAGS = flags.FLAGS flags.DEFINE_integer('answer', 42, 'test flag')
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. """ def _build_iscsi_target_name(self, volume): return "%s%s" % (FLAGS.iscsi_target_prefix, volume['name']) # discover_volume is still OK # undiscover_volume is still OK
import sqlite3 import time from nova import vendor import redis from nova import flags from nova import utils FLAGS = flags.FLAGS flags.DEFINE_string('datastore_path', utils.abspath('../keeper'), 'where keys are stored on disk') flags.DEFINE_string('redis_host', '127.0.0.1', 'Host that redis is running on.') flags.DEFINE_integer('redis_port', 6379, 'Port that redis is running on.') flags.DEFINE_integer('redis_db', 0, 'Multiple DB keeps tests away') flags.DEFINE_string('keeper_backend', 'redis', 'which backend to use for keeper') class Redis(object): def __init__(self): if hasattr(self.__class__, '_instance'): raise Exception('Attempted to instantiate singleton') @classmethod def instance(cls): if not hasattr(cls, '_instance'): inst = redis.Redis(host=FLAGS.redis_host, port=FLAGS.redis_port, db=FLAGS.redis_db) cls._instance = inst
from nova import exception from nova import flags from nova import log as logging LOG = logging.getLogger('nova.rpc') flags.DEFINE_integer('rpc_thread_pool_size', 1024, 'Size of RPC thread pool') flags.DEFINE_integer('rpc_conn_pool_size', 30, 'Size of RPC connection pool') class RemoteError(exception.NovaException): """Signifies that a remote class has raised an exception. Contains a string representation of the type of the original exception, the value of the original exception, and the traceback. These are sent to the parent as a joined string so printing the exception contains all of the relevant info. """ message = _("Remote error: %(exc_type)s %(value)s\n%(traceback)s.") def __init__(self, exc_type=None, value=None, traceback=None): self.exc_type = exc_type self.value = value self.traceback = traceback super(RemoteError, self).__init__(**self.__dict__)
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") 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"""
import os import tempfile import time 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:
import json import os import tempfile from nova import exception from nova import flags from nova import log as logging from nova import utils from nova.virt.disk import guestfs from nova.virt.disk import loop from nova.virt.disk import nbd 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_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 ','.
# 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. """Quotas for instances, volumes, and floating ips.""" from nova import db from nova 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,
from nova import flags from nova import log as logging from nova.scheduler import zone_aware_scheduler from nova import utils from nova import exception LOG = logging.getLogger('nova.scheduler.least_cost') FLAGS = flags.FLAGS flags.DEFINE_list('least_cost_scheduler_cost_functions', ['nova.scheduler.least_cost.noop_cost_fn'], 'Which cost functions the LeastCostScheduler should use.') # TODO(sirp): Once we have enough of these rules, we can break them out into a # cost_functions.py file (perhaps in a least_cost_scheduler directory) flags.DEFINE_integer('noop_cost_fn_weight', 1, 'How much weight to give the noop cost function') def noop_cost_fn(host): """Return a pre-weight cost of 1 for each host""" return 1 flags.DEFINE_integer('compute_fill_first_cost_fn_weight', 1, 'How much weight to give the fill-first cost function') def compute_fill_first_cost_fn(host): """Prefer hosts that have less ram available, filter_hosts will exclude hosts that don't have enough ram""" hostname, caps = host
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 rpc 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",
from nova import exception from nova import flags from nova import log as logging from nova import utils from nova.volume import iscsi from nova.volume import volume_types LOG = logging.getLogger("nova.volume.driver") FLAGS = flags.FLAGS flags.DEFINE_string('volume_group', 'nova-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.openstack:', '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') class VolumeDriver(object): """Executes commands relating to Volumes.""" def __init__(self, execute=utils.execute, *args, **kwargs): # NOTE(vish): db is set by Manager self.db = None self.set_execute(execute)
import sys from nova import flags from nova import log as logging from nova import version from nova import wsgi from nova.vnc import auth from nova.vnc import proxy LOG = logging.getLogger('nova.vncproxy') FLAGS = flags.FLAGS flags.DEFINE_string('vncproxy_wwwroot', '/var/lib/nova/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', 'nova.vnc.auth.VNCProxyAuthManager', 'Manager for vncproxy auth') def get_wsgi_server(): LOG.audit(_("Starting nova-vncproxy node (version %s)"), version.version_string_with_vcs())
"""Return the absolute path to scipt in the bin directory.""" return os.path.abspath(os.path.join(__file__, '../../../bin', script)) FLAGS = flags.FLAGS flags.DEFINE_string('dhcpbridge_flagfile', '/etc/nova/nova-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('dhcpbridge', _bin_file('nova-dhcpbridge'), 'location of nova-dhcpbridge') flags.DEFINE_string('routing_source_ip', '$my_ip', 'Public IP of network host') flags.DEFINE_string('input_chain', 'INPUT', 'chain to add nova_input to') flags.DEFINE_integer('dhcp_lease_time', 120, 'Lifetime of a DHCP lease') 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', 'nova.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,
# 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 nova import db from nova import flags from nova import exception from nova.scheduler import driver from nova.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') 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')
import eventlet.greenio import eventlet.wsgi 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
import nova.image from nova.image import glance as glance_image_service 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 import images 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 MBR_SIZE_BYTES = MBR_SIZE_SECTORS * SECTOR_SIZE KERNEL_DIR = '/boot/guest'
'xenapi_connection_password', None, 'Password for connection to XenServer/Xen Cloud Platform.' ' Used only if connection_type=xenapi.') flags.DEFINE_float( 'xenapi_task_poll_interval', 0.5, 'The interval used for polling of remote tasks ' '(Async.VM.start, etc). Used only if ' 'connection_type=xenapi.') flags.DEFINE_string('xenapi_image_service', 'glance', 'Where to get VM images: glance or objectstore.') flags.DEFINE_float( 'xenapi_vhd_coalesce_poll_interval', 5.0, 'The interval used for polling of coalescing vhds.' ' Used only if connection_type=xenapi.') flags.DEFINE_integer( 'xenapi_vhd_coalesce_max_attempts', 5, 'Max number of times to poll for VHD to coalesce.' ' Used only if connection_type=xenapi.') flags.DEFINE_string('xenapi_sr_base_path', '/var/run/sr-mount', 'Base path to the storage repository') flags.DEFINE_string('target_host', None, 'iSCSI Target Host') flags.DEFINE_string('target_port', '3260', 'iSCSI Target Port, 3260 Default') flags.DEFINE_string('iqn_prefix', 'iqn.2010-10.org.openstack', 'IQN Prefix') # NOTE(sirp): This is a work-around for a bug in Ubuntu Maverick, when we pull # support for it, we should remove this flags.DEFINE_bool( 'xenapi_remap_vbd_dev', False, 'Used to enable the remapping of VBD dev ' '(Works around an issue in Ubuntu Maverick)') flags.DEFINE_string( 'xenapi_remap_vbd_dev_prefix', 'sd', 'Specify prefix to remap VBD dev to ' '(ex. /dev/xvdb -> /dev/sdb)')