def get_vif_ids(request): vifs = [] attached_vifs = [] # Get a list of all networks networks_list = quantum_api(request).list_networks() for network in networks_list['networks']: ports = quantum_api(request).list_ports(network['id']) # Get port attachments for port in ports['ports']: port_attachment = quantum_api(request).show_port_attachment( network['id'], port['id']) if port_attachment['attachment']: attached_vifs.append( port_attachment['attachment']['id'].encode('ascii')) # Get all instances instances = nova.server_list(request) # Get virtual interface ids by instance for instance in instances: id = instance.id instance_vifs = extras_api(request).virtual_interfaces.list(id) for vif in instance_vifs: # Check if this VIF is already connected to any port if str(vif.id) in attached_vifs: vifs.append({ 'id': vif.id, 'instance': instance.id, 'instance_name': instance.name, 'available': False }) else: vifs.append({ 'id': vif.id, 'instance': instance.id, 'instance_name': instance.name, 'available': True }) return vifs
def get_vif_ids(request): vifs = [] attached_vifs = [] # Get a list of all networks networks_list = quantum_api(request).list_networks() for network in networks_list['networks']: ports = quantum_api(request).list_ports(network['id']) # Get port attachments for port in ports['ports']: port_attachment = quantum_api(request).show_port_attachment( network['id'], port['id']) if port_attachment['attachment']: attached_vifs.append( port_attachment['attachment']['id'].encode('ascii')) # Get all instances instances = nova.server_list(request) # Get virtual interface ids by instance for instance in instances: id = instance.id instance_vifs = extras_api(request).virtual_interfaces.list(id) for vif in instance_vifs: # Check if this VIF is already connected to any port if str(vif.id) in attached_vifs: vifs.append({ 'id': vif.id, 'instance': instance.id, 'instance_name': instance.name, 'available': False}) else: vifs.append({ 'id': vif.id, 'instance': instance.id, 'instance_name': instance.name, 'available': True}) return vifs
def usage_list(request, start, end): return [Usage(u) for u in extras_api(request).usage.list(start, end)]
def usage_get(request, tenant_id, start, end): return Usage(extras_api(request).usage.get(tenant_id, start, end))
def console_create(request, instance_id, kind="text"): return Console(extras_api(request).consoles.create(instance_id, kind))
def console_create(request, instance_id, kind='text'): return Console(extras_api(request).consoles.create(instance_id, kind))