def _validate(body, gid): if not self.is_valid_body(body, "keypair"): msg = _("Invalid request body") raise exception.InvalidInput(reason=msg) self._uuid_check(gid) values = body["keypair"] name = values.get("name") is_default = values.get("is_default") if name: if isinstance(name, six.string_types): name = name.strip() utils.check_string_length(name, "name", min_length=1, max_length=255) if is_default: try: is_default = strutils.bool_from_string(is_default, strict=True) except ValueError: msg = _("is_default must be a boolean") raise exception.InvalidInput(reason=msg) else: is_default = False valid_values = {} valid_values["gid"] = gid valid_values["display_name"] = name valid_values["is_default"] = is_default return valid_values
def __new__(cls, *args, **kwargs): '''Create an instance of the servicegroup API. args and kwargs are passed down to the servicegroup driver when it gets created. No args currently exist, though. Valid kwargs are: db_allowed - Boolean. False if direct db access is not allowed and alternative data access (conductor) should be used instead. ''' if not cls._driver: LOG.debug(_('ServiceGroup driver defined as an instance of %s'), str(CONF.servicegroup_driver)) driver_name = CONF.servicegroup_driver try: driver_class = cls._driver_name_class_mapping[driver_name] except KeyError: raise TypeError(_("unknown ServiceGroup driver name: %s") % driver_name) cls._driver = importutils.import_object(driver_class, *args, **kwargs) utils.check_isinstance(cls._driver, ServiceGroupDriver) # we don't have to check that cls._driver is not NONE, # check_isinstance does it return super(API, cls).__new__(cls)
def __exit__(self, ex_type, ex_value, ex_traceback): if not ex_value: return True if isinstance(ex_value, exception.NotAuthorized): raise Fault(webob.exc.HTTPForbidden( explanation=ex_value.format_message())) elif isinstance(ex_value, exception.Invalid): raise Fault(exception.ConvertedException( code=ex_value.code, explanation=ex_value.format_message())) # Under python 2.6, TypeError's exception value is actually a string, # so test # here via ex_type instead: # http://bugs.python.org/issue7853 elif issubclass(ex_type, TypeError): exc_info = (ex_type, ex_value, ex_traceback) LOG.error(_('Exception handling resource: %s') % ex_value, exc_info=exc_info) raise Fault(webob.exc.HTTPBadRequest()) elif isinstance(ex_value, Fault): LOG.info(_("Fault thrown: %s"), unicode(ex_value)) raise ex_value elif isinstance(ex_value, webob.exc.HTTPException): LOG.info(_("HTTP exception thrown: %s"), unicode(ex_value)) raise Fault(ex_value) # We didn't handle the exception return False
def run_periodic_tasks(self, context, raise_on_error=False): """Tasks to be run at a periodic interval.""" idle_for = DEFAULT_INTERVAL for task_name, task in self._periodic_tasks: full_task_name = ".".join([self.__class__.__name__, task_name]) now = timeutils.utcnow() spacing = self._periodic_spacing[task_name] last_run = self._periodic_last_run[task_name] # If a periodic task is _nearly_ due, then we'll run it early if spacing is not None and last_run is not None: due = last_run + datetime.timedelta(seconds=spacing) if not timeutils.is_soon(due, 0.2): idle_for = min(idle_for, timeutils.delta_seconds(now, due)) continue if spacing is not None: idle_for = min(idle_for, spacing) LOG.debug(_("Running periodic task %(full_task_name)s"), {"full_task_name": full_task_name}) self._periodic_last_run[task_name] = timeutils.utcnow() try: task(self, context) except Exception as e: if raise_on_error: raise LOG.exception(_("Error during %(full_task_name)s: %(e)s"), {"full_task_name": full_task_name, "e": e}) time.sleep(0) return idle_for
def _inner(): if initial_delay: greenthread.sleep(initial_delay) try: while self._running: start = timeutils.utcnow() self.f(*self.args, **self.kw) end = timeutils.utcnow() if not self._running: break delay = interval - timeutils.delta_seconds(start, end) if delay <= 0: LOG.warn(_('task run outlasted interval by %s sec') % -delay) greenthread.sleep(delay if delay > 0 else 0) except LoopingCallDone as e: self.stop() done.send(e.retvalue) except Exception: LOG.exception(_('in fixed duration looping call')) done.send_exception(*sys.exc_info()) return else: done.send(True)
def wait(self): """Loop waiting on children to die and respawning as necessary.""" LOG.debug(_('Full set of CONF:')) CONF.log_opt_values(LOG, std_logging.DEBUG) while True: self.handle_signal() self._respawn_children() if self.sigcaught: signame = _signo_to_signame(self.sigcaught) LOG.info(_('Caught %s, stopping children'), signame) if not _is_sighup_and_daemon(self.sigcaught): break for pid in self.children: os.kill(pid, signal.SIGHUP) self.running = True self.sigcaught = None for pid in self.children: try: os.kill(pid, signal.SIGTERM) except OSError as exc: if exc.errno != errno.ESRCH: raise # Wait for children to die if self.children: LOG.info(_('Waiting on %d children to exit'), len(self.children)) while self.children: self._wait_child()
def _validate(body, gid): if not uuidutils.is_uuid_like(gid): raise exception.GroupNotFound(gid=gid) if not self.is_valid_body(body, 'proxy'): msg = _("Invalid request body") raise exception.InvalidInput(reason=msg) proxy = db.process_get_all( context, gid, {"is_proxy": True, "status": "ACTIVE"}) if len(proxy) == 0: msg = _("Proxy instance not exists in this group") raise exception.ProxyNotFound(msg) values = body["proxy"] app_status = values.get("app_status") if not app_status: msg = _("app_status is required") raise exception.InvalidInput(reason=msg) valid_values = {} if values.get("shm_endpoint"): valid_values["shm_endpoint"] = values.get("shm_endpoint") if values.get("ipc_endpoint"): valid_values["ipc_endpoint"] = values.get("ipc_endpoint") if values.get("fs_endpoint"): valid_values["fs_endpoint"] = values.get("fs_endpoint") valid_values["app_status"] = app_status valid_values["pid"] = proxy[0]["pid"] valid_values return valid_values
def _wait_child(self): try: # Don't block if no child processes have exited pid, status = os.waitpid(0, os.WNOHANG) if not pid: return None except OSError as exc: if exc.errno not in (errno.EINTR, errno.ECHILD): raise return None if os.WIFSIGNALED(status): sig = os.WTERMSIG(status) LOG.info(_('Child %(pid)d killed by signal %(sig)d'), dict(pid=pid, sig=sig)) else: code = os.WEXITSTATUS(status) LOG.info(_('Child %(pid)s exited with status %(code)d'), dict(pid=pid, code=code)) if pid not in self.children: LOG.warning(_('pid %d not in child list'), pid) return None wrap = self.children.pop(pid) wrap.children.remove(pid) return wrap
def _start_child(self, wrap): if len(wrap.forktimes) > wrap.workers: # Limit ourselves to one process a second (over the period of # number of workers * 1 second). This will allow workers to # start up quickly but ensure we don't fork off children that # die instantly too quickly. if time.time() - wrap.forktimes[0] < wrap.workers: LOG.info(_('Forking too fast, sleeping')) time.sleep(1) wrap.forktimes.pop(0) wrap.forktimes.append(time.time()) pid = os.fork() if pid == 0: launcher = self._child_process(wrap.service) while True: self._child_process_handle_signal() status, signo = self._child_wait_for_exit_or_signal(launcher) if not _is_sighup_and_daemon(signo): break launcher.restart() os._exit(status) LOG.info(_('Started child %d'), pid) wrap.children.add(pid) self.children[pid] = wrap return pid
def _wait_for_exit_or_signal(self, ready_callback=None): status = None signo = 0 LOG.debug(_('Full set of CONF:')) CONF.log_opt_values(LOG, std_logging.DEBUG) try: if ready_callback: ready_callback() super(ServiceLauncher, self).wait() except SignalExit as exc: signame = _signo_to_signame(exc.signo) LOG.info(_('Caught %s, exiting'), signame) status = exc.code signo = exc.signo except SystemExit as exc: status = exc.code finally: self.stop() if rpc: try: rpc.cleanup() except Exception: # We're shutting down, so it doesn't matter at this point. LOG.exception(_('Exception during rpc cleanup.')) return status, signo
def to_bytes(text, default=0): """Converts a string into an integer of bytes. Looks at the last characters of the text to determine what conversion is needed to turn the input text into a byte number. Supports "B, K(B), M(B), G(B), and T(B)". (case insensitive) :param text: String input for bytes size conversion. :param default: Default return value when text is blank. """ match = BYTE_REGEX.search(text) if match: magnitude = int(match.group(1)) mult_key_org = match.group(2) if not mult_key_org: return magnitude elif text: msg = _('Invalid string format: %s') % text raise TypeError(msg) else: return default mult_key = mult_key_org.lower().replace('b', '', 1) multiplier = BYTE_MULTIPLIERS.get(mult_key) if multiplier is None: msg = _('Unknown byte multiplier: %s') % mult_key_org raise TypeError(msg) return magnitude * multiplier
def _validate(body): if not self.is_valid_body(body, 'group'): msg = _("Invalid request body") raise exception.InvalidInput(reason=msg) values = body["group"] name = values.get("name") description = values.get("description") if not name: msg = _("Group name is required") raise exception.InvalidInput(reason=msg) if isinstance(name, six.string_types): name = name.strip() utils.check_string_length(name, 'name', min_length=1, max_length=255) if description: utils.check_string_length(description, 'description', min_length=0, max_length=255) valid_values = {} valid_values["display_name"] = name valid_values["display_description"] = description return valid_values
def check_shadow_table(migrate_engine, table_name): """This method checks that table with ``table_name`` and corresponding shadow table have same columns. """ meta = MetaData() meta.bind = migrate_engine table = Table(table_name, meta, autoload=True) shadow_table = Table(db._SHADOW_TABLE_PREFIX + table_name, meta, autoload=True) columns = dict([(c.name, c) for c in table.columns]) shadow_columns = dict([(c.name, c) for c in shadow_table.columns]) for name, column in columns.iteritems(): if name not in shadow_columns: raise exception.RackException( _("Missing column %(table)s.%(column)s in shadow table") % {'column': name, 'table': shadow_table.name}) shadow_column = shadow_columns[name] if not isinstance(shadow_column.type, type(column.type)): raise exception.RackException( _("Different types in %(table)s.%(column)s and shadow table: " "%(c_type)s %(shadow_c_type)s") % {'column': name, 'table': table.name, 'c_type': column.type, 'shadow_c_type': shadow_column.type}) for name, column in shadow_columns.iteritems(): if name not in columns: raise exception.RackException( _("Extra column %(table)s.%(column)s in shadow table") % {'column': name, 'table': shadow_table.name}) return True
def _error(self, inner, req): LOG.exception(_("Caught error: %s"), unicode(inner)) safe = getattr(inner, 'safe', False) headers = getattr(inner, 'headers', None) status = getattr(inner, 'code', 500) if status is None: status = 500 msg_dict = dict(url=req.url, status=status) LOG.info(_("%(url)s returned with HTTP %(status)d") % msg_dict) outer = self.status_to_type(status) if headers: outer.headers = headers # NOTE(johannes): We leave the explanation empty here on # purpose. It could possibly have sensitive information # that should not be returned back to the user. See # bugs 868360 and 874472 # NOTE(eglynn): However, it would be over-conservative and # inconsistent with the EC2 API to hide every exception, # including those that are safe to expose, see bug 1021373 if safe: if isinstance(inner.msg_fmt, gettextutils.Message): user_locale = req.best_match_language() inner_msg = gettextutils.translate( inner.msg_fmt, user_locale) else: inner_msg = unicode(inner) outer.explanation = '%s: %s' % (inner.__class__.__name__, inner_msg) #notifications.send_api_fault(req.url, status, inner) return wsgi.Fault(outer)
def ssh_execute(ssh, cmd, process_input=None, addl_env=None, check_exit_code=True): LOG.debug(_("Running cmd (SSH): %s"), cmd) if addl_env: raise InvalidArgumentError(_("Environment not supported over SSH")) if process_input: # This is (probably) fixable if we need it... raise InvalidArgumentError(_("process_input not supported over SSH")) stdin_stream, stdout_stream, stderr_stream = ssh.exec_command(cmd) channel = stdout_stream.channel # NOTE(justinsb): This seems suspicious... # ...other SSH clients have buffering issues with this approach stdout = stdout_stream.read() stderr = stderr_stream.read() stdin_stream.close() exit_status = channel.recv_exit_status() # exit_status == -1 if no exit code was returned if exit_status != -1: LOG.debug(_("Result was %s") % exit_status) if check_exit_code and exit_status != 0: raise ProcessExecutionError(exit_code=exit_status, stdout=stdout, stderr=stderr, cmd=cmd) return (stdout, stderr)
def _parse_check(rule): """ Parse a single base check rule into an appropriate Check object. """ # Handle the special checks if rule == '!': return FalseCheck() elif rule == '@': return TrueCheck() try: kind, match = rule.split(':', 1) except Exception: LOG.exception(_("Failed to understand rule %(rule)s") % locals()) # If the rule is invalid, we'll fail closed return FalseCheck() # Find what implements the check if kind in _checks: return _checks[kind](kind, match) elif None in _checks: return _checks[None](kind, match) else: LOG.error(_("No handler for matches of kind %s") % kind) return FalseCheck()
def inner(*args, **kwargs): if not CONF.allow_instance_snapshots: LOG.warn(_('Rejecting snapshot request, snapshots currently' ' disabled')) msg = _("Instance snapshots are not permitted at this time.") raise webob.exc.HTTPBadRequest(explanation=msg) return f(*args, **kwargs)
def limited(items, request, max_limit=CONF.osapi_max_limit): """Return a slice of items according to requested offset and limit. :param items: A sliceable entity :param request: ``wsgi.Request`` possibly containing 'offset' and 'limit' GET variables. 'offset' is where to start in the list, and 'limit' is the maximum number of items to return. If 'limit' is not specified, 0, or > max_limit, we default to max_limit. Negative values for either offset or limit will cause exc.HTTPBadRequest() exceptions to be raised. :kwarg max_limit: The maximum number of items to return from 'items' """ try: offset = int(request.GET.get('offset', 0)) except ValueError: msg = _('offset param must be an integer') raise webob.exc.HTTPBadRequest(explanation=msg) try: limit = int(request.GET.get('limit', max_limit)) except ValueError: msg = _('limit param must be an integer') raise webob.exc.HTTPBadRequest(explanation=msg) if limit < 0: msg = _('limit param must be positive') raise webob.exc.HTTPBadRequest(explanation=msg) if offset < 0: msg = _('offset param must be positive') raise webob.exc.HTTPBadRequest(explanation=msg) limit = min(max_limit, limit or max_limit) range_end = offset + limit return items[offset:range_end]
def _validate_securitygroup(gid, body): if not uuidutils.is_uuid_like(gid): raise exception.GroupNotFound(gid=gid) if not self.is_valid_body(body, 'securitygroup'): msg = _("Invalid request body") raise exception.InvalidInput(reason=msg) values = body["securitygroup"] name = values.get("name") is_default = values.get("is_default") if isinstance(name, six.string_types): name = name.strip() utils.check_string_length(name, 'name', min_length=1, max_length=255) if is_default: try: is_default = strutils.bool_from_string( is_default, strict=True) except ValueError: msg = _("is_default must be a boolean") raise exception.InvalidInput(reason=msg) else: is_default = False valid_values = {} valid_values["gid"] = gid valid_values["display_name"] = name valid_values["is_default"] = is_default return valid_values
def _validate(body, gid, securitygroup_id): if not self.is_valid_body(body, 'securitygroup'): msg = _("Invalid request body") raise exception.InvalidInput(reason=msg) values = body["securitygroup"] is_default = values.get("is_default") if not uuidutils.is_uuid_like(gid): raise exception.GroupNotFound(gid=gid) if not uuidutils.is_uuid_like(securitygroup_id): raise exception.SecuritygroupNotFound( securitygroup_id=securitygroup_id) if is_default: try: is_default = strutils.bool_from_string( is_default, strict=True) except ValueError: msg = _("is_default must be a boolean") raise exception.InvalidInput(reason=msg) else: msg = _("SecurityGroup is_default is required") raise exception.InvalidInput(reason=msg) valid_values = {} valid_values["is_default"] = is_default return valid_values
def _validate(body, gid): if not self.is_valid_body(body, 'group'): msg = _("Invalid request body") raise exception.InvalidInput(reason=msg) values = body["group"] name = values.get("name") description = values.get("description") if not uuidutils.is_uuid_like(gid): raise exception.GroupNotFound(gid=gid) if name is None and description is None: msg = _("Group name or description is required") raise exception.InvalidInput(reason=msg) if name is not None: if isinstance(name, six.string_types): name = name.strip() utils.check_string_length(name, 'name', min_length=1, max_length=255) if description is not None: utils.check_string_length(description, 'description', min_length=0, max_length=255) valid_values = {} if name: valid_values["display_name"] = name # allow blank string to clear description if description is not None: valid_values["display_description"] = description valid_values["gid"] = gid return valid_values
def inner(*args, **kwargs): try: with lock(name, lock_file_prefix, external, lock_path): LOG.debug(_('Got semaphore / lock "%(function)s"'), {'function': f.__name__}) return f(*args, **kwargs) finally: LOG.debug(_('Semaphore / lock released "%(function)s"'), {'function': f.__name__})
def start(self): verstr = version.version_string_with_package() LOG.audit(_('Starting %(topic)s node (version %(version)s)'), {'topic': self.topic, 'version': verstr}) self.basic_config_check() self.manager.init_host() self.model_disconnected = False ctxt = context.get_admin_context() try: self.service_ref = db.service_get_by_args(ctxt, self.host, self.binary) self.service_id = self.service_ref['id'] except exception.NotFound: try: self.service_ref = self._create_service_ref(ctxt) except exception.ServiceTopicExists: self.service_ref = db.service_get_by_args(ctxt, self.host, self.binary) self.manager.pre_start_hook() LOG.debug(_("Join ServiceGroup membership for this service %s") % self.topic) self.servicegroup_api.join(self.host, self.topic, self) if self.backdoor_port is not None: self.manager.backdoor_port = self.backdoor_port LOG.debug(_("Creating RPC server for service %s") % self.topic) target = messaging.Target(topic=self.topic, server=self.host) endpoints = [ self.manager, baserpc.BaseRPCAPI(self.manager.service_name, self.backdoor_port) ] endpoints.extend(self.manager.additional_endpoints) serializer = rack_object.RackObjectSerializer() self.rpcserver = rpc.get_server(target, endpoints, serializer) self.rpcserver.start() self.manager.post_start_hook() if self.periodic_enable: if self.periodic_fuzzy_delay: initial_delay = random.randint(0, self.periodic_fuzzy_delay) else: initial_delay = None self.tg.add_dynamic_timer( self.periodic_tasks, initial_delay=initial_delay, periodic_interval_max=self.periodic_interval_max)
def _get_int_param(request, param): """Extract integer param from request or fail.""" try: int_param = int(request.GET[param]) except ValueError: msg = _('%s param must be an integer') % param raise webob.exc.HTTPBadRequest(explanation=msg) if int_param < 0: msg = _('%s param must be positive') % param raise webob.exc.HTTPBadRequest(explanation=msg) return int_param
def __init__(self, name, app, host='0.0.0.0', port=0, pool_size=None, protocol=eventlet.wsgi.HttpProtocol, backlog=128, use_ssl=False, max_url_len=None): """Initialize, but do not start, a WSGI server. :param name: Pretty name for logging. :param app: The WSGI application to serve. :param host: IP address to serve the application. :param port: Port number to server the application. :param pool_size: Maximum number of eventlets to spawn concurrently. :param backlog: Maximum number of queued connections. :param max_url_len: Maximum length of permitted URLs. :returns: None :raises: rack.exception.InvalidInput """ # Allow operators to customize http requests max header line size. eventlet.wsgi.MAX_HEADER_LINE = CONF.max_header_line self.name = name self.app = app self._server = None self._protocol = protocol self._pool = eventlet.GreenPool(pool_size or self.default_pool_size) self._logger = logging.getLogger("rack.%s.wsgi.server" % self.name) self._wsgi_logger = logging.WritableLogger(self._logger) self._use_ssl = use_ssl self._max_url_len = max_url_len if backlog < 1: raise exception.InvalidInput( reason='The backlog must be more than 1') bind_addr = (host, port) # TODO(dims): eventlet's green dns/socket module does not actually # support IPv6 in getaddrinfo(). We need to get around this in the # future or monitor upstream for a fix try: info = socket.getaddrinfo(bind_addr[0], bind_addr[1], socket.AF_UNSPEC, socket.SOCK_STREAM)[0] family = info[0] bind_addr = info[-1] except Exception: family = socket.AF_INET try: self._socket = eventlet.listen(bind_addr, family, backlog=backlog) except EnvironmentError: LOG.error(_("Could not bind to %(host)s:%(port)s"), {'host': host, 'port': port}) raise (self.host, self.port) = self._socket.getsockname()[0:2] LOG.info(_("%(name)s listening on %(host)s:%(port)s") % self.__dict__)
def leave(self, member_id, group): """Remove the given member from the service group.""" LOG.debug(_('ZooKeeperDriver.leave: %(member)s from group %(group)s'), {'member': member_id, 'group': group}) try: key = (group, member_id) member = self._memberships[key] member.leave() del self._memberships[key] except KeyError: LOG.error(_('ZooKeeperDriver.leave: %(id)s has not joined to the ' '%(gr)s group'), {'id': member_id, 'gr': group})
def get_my_linklocal(interface): try: if_str = execute('ip', '-f', 'inet6', '-o', 'addr', 'show', interface) condition = '\s+inet6\s+([0-9a-f:]+)/\d+\s+scope\s+link' links = [re.search(condition, x) for x in if_str[0].split('\n')] address = [w.group(1) for w in links if w is not None] if address[0] is not None: return address[0] else: msg = _('Link Local address is not found.:%s') % if_str raise exception.RackException(msg) except Exception as ex: msg = _("Couldn't get Link Local IP of %(interface)s" " :%(ex)s") % {'interface': interface, 'ex': ex} raise exception.RackException(msg)
def _schedule(self, context, topic, request_spec, filter_properties): """Picks a host that is up at random.""" elevated = context.elevated() hosts = self.hosts_up(elevated, topic) if not hosts: msg = _("Is the appropriate service running?") raise exception.NoValidHost(reason=msg) hosts = self._filter_hosts(request_spec, hosts, filter_properties) if not hosts: msg = _("Could not find another resourceoperator") raise exception.NoValidHost(reason=msg) return random.choice(hosts)
def join(self, member_id, group_id, service=None): """Join the given service with its group.""" msg = _('Memcached_Driver: join new ServiceGroup member ' '%(member_id)s to the %(group_id)s group, ' 'service = %(service)s') LOG.debug(msg, {'member_id': member_id, 'group_id': group_id, 'service': service}) if service is None: raise RuntimeError(_('service is a mandatory argument for ' 'Memcached based ServiceGroup driver')) report_interval = service.report_interval if report_interval: service.tg.add_timer(report_interval, self._report_state, api.INITIAL_REPORTING_DELAY, service)
def _get_not_supported_column(col_name_col_instance, column_name): try: column = col_name_col_instance[column_name] except KeyError: msg = _("Please specify column %s in col_name_col_instance " "param. It is required because column has unsupported " "type by sqlite).") raise ColumnError(msg % column_name) if not isinstance(column, Column): msg = _("col_name_col_instance param has wrong type of " "column instance for column %s It should be instance " "of sqlalchemy.Column.") raise ColumnError(msg % column_name) return column
class InvalidBDMImage(InvalidBDM): msg_fmt = _("Block Device Mapping is Invalid: " "failed to get image %(id)s.")
class SecuritygroupruleCreateFailed(RackException): msg_fmt = _("Unable to create Securitygrouprule")
class SecuritygroupNotFound(NotFound): msg_fmt = _("Security group %(securitygroup_id)s not found.")
class ProcessDeleteFailed(RackException): msg_fmt = _("Unable to delete Process")
class SecuritygroupInUse(RackException): msg_fmt = _("Securitygroup %(securitygroup_id)s is still in use.")
class ProxyDeleteFailed(RackException): msg_fmt = _("Unable to delete Proxy")
class InvalidBDMSnapshot(InvalidBDM): msg_fmt = _("Block Device Mapping is Invalid: " "failed to get snapshot %(id)s.")
class InvalidBDMForLegacy(InvalidBDM): msg_fmt = _("Block Device Mapping cannot " "be converted to legacy format. ")
class InvalidAttribute(Invalid): msg_fmt = _("Attribute not supported: %(attr)s")
class InvalidBDMFormat(InvalidBDM): msg_fmt = _("Block Device Mapping is Invalid: " "%(details)s")
class InvalidBDMSwapSize(InvalidBDM): msg_fmt = _("Swap drive requested is larger than instance type allows.")
class InvalidBDMEphemeralSize(InvalidBDM): msg_fmt = _("Ephemeral disks requested are larger than " "the instance type allows.")
class ProxyNotFound(NotFound): msg_fmt = _("Proxy instance could not be found.")
class ProxyCreateFailed(RackException): msg_fmt = _("Unable to create Proxy")
class VolumeUnattached(Invalid): ec2_code = 'IncorrectState' msg_fmt = _("Volume %(volume_id)s is not attached to anything")
class InvalidBDMBootSequence(InvalidBDM): msg_fmt = _("Block Device Mapping is Invalid: " "Boot sequence for the instance " "and image/block device mapping " "combination is not valid.")
class VolumeNotCreated(RackException): msg_fmt = _("Volume %(volume_id)s did not finish being created" " even after we waited %(seconds)s seconds or %(attempts)s" " attempts.")
class InvalidBDM(Invalid): msg_fmt = _("Block Device Mapping is Invalid.")
class ProcessNotFound(NotFound): msg_fmt = _("Process %(pid)s could not be found.")
class Invalid(RackException): msg_fmt = _("Unacceptable parameters.") code = 400
class AdminRequired(NotAuthorized): msg_fmt = _("User does not have admin privileges")
class ImageNotAuthorized(RackException): msg_fmt = _("Not authorized for image %(image_id)s.")
class SecuritygroupruleDeleteFailed(RackException): msg_fmt = _("Unable to delete Securitygrouprule")
class ImageNotActive(RackException): # NOTE(jruzicka): IncorrectState is used for volumes only in EC2, # but it still seems like the most appropriate option. ec2_code = 'IncorrectState' msg_fmt = _("Image %(image_id)s is not active.")
class SecuritygroupruleNotFound(NotFound): msg_fmt = _("Securitygrouprule %(rule_id)s could not be found.")
class PolicyNotAuthorized(NotAuthorized): msg_fmt = _("Policy doesn't allow %(action)s to be performed.")
class InvalidOpenStackCredential(Invalid): msg_fmt = _("OpenStack credential %(credential)s is required.")
class NoNetworksFound(NotFound): msg_fmt = _("No networks defined for gid %(gid)s.")
class InvalidBDMLocalsLimit(InvalidBDM): msg_fmt = _("Block Device Mapping is Invalid: " "You specified more local devices than the " "limit allows")
class InvalidBDMVolume(InvalidBDM): msg_fmt = _("Block Device Mapping is Invalid: " "failed to get volume %(id)s.")