def get_by_id(cls, context, id, expected_attrs=None): if expected_attrs is None: expected_attrs = [] get_network = 'network' in expected_attrs db_fixedip = db.fixed_ip_get(context, id, get_network=get_network) return cls._from_db_object(context, cls(context), db_fixedip, expected_attrs)
def _get_floating_ip_info(self, context, host=None): floating_ip_info = {"floating_ip_info": []} try: if host is None: floating_ips = db.floating_ip_get_all(context) else: floating_ips = db.floating_ip_get_all_by_host(context, host) except exception.NoFloatingIpsDefined: return floating_ip_info for floating_ip in floating_ips: instance_uuid = None if floating_ip['fixed_ip_id']: fixed_ip = db.fixed_ip_get(context, floating_ip['fixed_ip_id']) instance_uuid = fixed_ip['instance_uuid'] result = {'address': floating_ip['address'], 'pool': floating_ip['pool'], 'interface': floating_ip['interface'], 'project_id': floating_ip['project_id'], 'instance_uuid': instance_uuid} floating_ip_info['floating_ip_info'].append(result) return floating_ip_info
def _get_floating_ip_info(self, context, host=None): floating_ip_info = {"floating_ip_info": []} try: if host is None: floating_ips = db.floating_ip_get_all(context) else: floating_ips = db.floating_ip_get_all_by_host(context, host) except exception.NoFloatingIpsDefined: return floating_ip_info for floating_ip in floating_ips: instance_uuid = None if floating_ip['fixed_ip_id']: fixed_ip = db.fixed_ip_get(context, floating_ip['fixed_ip_id']) instance_uuid = fixed_ip['instance_uuid'] result = { 'address': floating_ip['address'], 'pool': floating_ip['pool'], 'interface': floating_ip['interface'], 'project_id': floating_ip['project_id'], 'instance_uuid': instance_uuid } floating_ip_info['floating_ip_info'].append(result) return floating_ip_info
def list(self, host=None): """Lists all floating ips (optionally by host) Note: if host is given, only active floating IPs are returned""" ctxt = context.get_admin_context() try: if host is None: floating_ips = db.floating_ip_get_all(ctxt) else: floating_ips = db.floating_ip_get_all_by_host(ctxt, host) except exception.NoFloatingIpsDefined: print _("No floating IP addresses have been defined.") return for floating_ip in floating_ips: instance_id = None if floating_ip['fixed_ip_id']: fixed_ip = db.fixed_ip_get(ctxt, floating_ip['fixed_ip_id']) try: instance = db.instance_get(ctxt, fixed_ip['instance_id']) instance_id = instance.get('uuid', "none") except exception.InstanceNotFound: msg = _('Missing instance %s') instance_id = msg % fixed_ip['instance_id'] print "%s\t%s\t%s\t%s\t%s" % (floating_ip['project_id'], floating_ip['address'], instance_id, floating_ip['pool'], floating_ip['interface'])
def _get_floating_ip_info(self, context, host=None): floating_ip_info = {"floating_ip_info": []} if host is None: try: floating_ips = db.floating_ip_get_all(context) except exception.NoFloatingIpsDefined: return floating_ip_info else: try: floating_ips = db.floating_ip_get_all_by_host(context, host) except exception.FloatingIpNotFoundForHost as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) for floating_ip in floating_ips: instance_uuid = None if floating_ip['fixed_ip_id']: fixed_ip = db.fixed_ip_get(context, floating_ip['fixed_ip_id']) instance_uuid = fixed_ip['instance_uuid'] result = {'address': floating_ip['address'], 'pool': floating_ip['pool'], 'interface': floating_ip['interface'], 'project_id': floating_ip['project_id'], 'instance_uuid': instance_uuid} floating_ip_info['floating_ip_info'].append(result) return floating_ip_info
def list(self, host=None): """Lists all floating ips (optionally by host) Note: if host is given, only active floating IPs are returned""" ctxt = context.get_admin_context() try: if host is None: floating_ips = db.floating_ip_get_all(ctxt) else: floating_ips = db.floating_ip_get_all_by_host(ctxt, host) except exception.NoFloatingIpsDefined: print _("No floating IP addresses have been defined.") return for floating_ip in floating_ips: instance_uuid = None if floating_ip["fixed_ip_id"]: fixed_ip = db.fixed_ip_get(ctxt, floating_ip["fixed_ip_id"]) instance_uuid = fixed_ip["instance_uuid"] print "%s\t%s\t%s\t%s\t%s" % ( floating_ip["project_id"], floating_ip["address"], instance_uuid, floating_ip["pool"], floating_ip["interface"], )
def _get_floating_ip_info(self, context, host=None): floating_ip_info = {"floating_ip_info": []} try: if host is None: floating_ips = db.floating_ip_get_all(context) else: floating_ips = db.floating_ip_get_all_by_host(context, host) except exception.NoFloatingIpsDefined: return floating_ip_info for floating_ip in floating_ips: instance_uuid = None if floating_ip["fixed_ip_id"]: fixed_ip = db.fixed_ip_get(context, floating_ip["fixed_ip_id"]) instance_uuid = fixed_ip["instance_uuid"] result = { "address": floating_ip["address"], "pool": floating_ip["pool"], "interface": floating_ip["interface"], "project_id": floating_ip["project_id"], "instance_uuid": instance_uuid, } floating_ip_info["floating_ip_info"].append(result) return floating_ip_info
def list(self, host=None): """Lists all floating ips (optionally by host) Note: if host is given, only active floating IPs are returned""" ctxt = context.get_admin_context() try: if host is None: floating_ips = db.floating_ip_get_all(ctxt) else: floating_ips = db.floating_ip_get_all_by_host(ctxt, host) except exception.NoFloatingIpsDefined: print _("No floating IP addresses have been defined.") return for floating_ip in floating_ips: instance_uuid = None if floating_ip['fixed_ip_id']: fixed_ip = db.fixed_ip_get(ctxt, floating_ip['fixed_ip_id']) instance_uuid = fixed_ip['instance_uuid'] print "%s\t%s\t%s\t%s\t%s" % (floating_ip['project_id'], floating_ip['address'], instance_uuid, floating_ip['pool'], floating_ip['interface'])