def add_interface(interface_name, vmi, vm, mac): from nova_contrail_vif.gen_py.instance_service import ttypes data = ttypes.Port(uuid_from_string(vmi), uuid_from_string(vm), interface_name, '0.0.0.0', [0] * 16, mac) logging.debug(data) rpc = rpc_client_instance() if not rpc: return try: rpc.AddPort([data]) except socket.error: logging.error('RPC failure')
def add_interface(interface_name, vmi, vm, mac): from nova_contrail_vif.gen_py.instance_service import ttypes data = ttypes.Port( uuid_from_string(vmi), uuid_from_string(vm), interface_name, '0.0.0.0', [0] * 16, mac) logging.debug(data) rpc = rpc_client_instance() if not rpc: return try: rpc.AddPort([data]) except socket.error: logging.error('RPC failure')
def del_interface(vmi): rpc = rpc_client_instance() if not rpc: return try: rpc.DeletePort(uuid_from_string(vmi)) except socket.error: logging.error('RPC failure') logging.info('Deleted virtual-machine-interface uuid = ' + vmi)
def _add_port_to_agent(self, port_id, net_id, iface_name, mac_address): port_obj = self._client.virtual_machine_interface_read(id=port_id) if port_obj is None: LOG.debug(_("Invalid port_id : %s"), port_id) return ips = port_obj.get_instance_ip_back_refs() ip_addr = '0.0.0.0' # get the ip address of the port if associated if ips and len(ips): ip_uuid = ips[0]['uuid'] ip = self._client.instance_ip_read(id=ip_uuid) ip_addr = ip.get_instance_ip_address() net_obj = self._client.virtual_network_read(id=net_id) if net_obj is None: LOG.debug(_("Invalid net_id : %s"), net_id) return # get the instance object the port is attached to instance_obj = self._instance_lookup(port_obj.parent_name) if instance_obj is None: return from nova_contrail_vif.gen_py.instance_service import ttypes data = ttypes.Port(uuid_from_string(port_id), uuid_from_string(instance_obj.uuid), iface_name, ip_addr, uuid_from_string(net_id), mac_address, None, None, None, uuid_from_string(net_obj.parent_uuid)) if self._add_port(data): return data