#NEWLINE# def add_port( self , br_name , port_name , may_exist , fake_iface , iface_names , settings = None ) : #NEWLINE# #INDENT# '\n        :type settings: list of (column, key, value_json)\n                                where column and key are str,\n                                      value_json is json that is represented\n                                      by Datum.to_json()\n        ' #NEWLINE# settings = ( settings or [ ] ) #NEWLINE# self . populate_cache ( ) #NEWLINE# if may_exist : #NEWLINE# #INDENT# vsctl_port = self . find_port ( port_name , False ) #NEWLINE# if vsctl_port : #NEWLINE# #INDENT# want_names = set ( iface_names ) #NEWLINE# have_names = set ( ( ovsrec_iface . name for ovsrec_iface in vsctl_port . port_cfg . interfaces ) ) #NEWLINE# if ( vsctl_port . bridge ( ) . name != br_name ) : #NEWLINE# #INDENT# vsctl_fatal ( '"%s" but %s is actually attached to vsctl_bridge %s' , br_name , port_name , vsctl_port . bridge ( ) . name ) #NEWLINE# #UNINDENT# if ( want_names != have_names ) : #NEWLINE# #INDENT# want_names_string = ',' . join ( want_names ) #NEWLINE# have_names_string = ',' . join ( have_names ) #NEWLINE# vsctl_fatal ( ( '"%s" but %s actually has interface(s) %s' % ( want_names_string , port_name , have_names_string ) ) ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# #UNINDENT# self . check_conflicts ( port_name , ( 'cannot create a port named %s' % port_name ) ) #NEWLINE# for iface_name in iface_names : #NEWLINE# #INDENT# self . check_conflicts ( iface_name , ( 'cannot create an interface named %s' % iface_name ) ) #NEWLINE# #UNINDENT# vsctl_bridge = self . find_bridge ( br_name , True ) #NEWLINE# ifaces = [ ] #NEWLINE# for iface_name in iface_names : #NEWLINE# #INDENT# ovsrec_iface = self . txn . insert ( self . idl . tables [ vswitch_idl . OVSREC_TABLE_INTERFACE ] ) #NEWLINE# ovsrec_iface . name = iface_name #NEWLINE# ifaces . append ( ovsrec_iface ) #NEWLINE# #UNINDENT# ovsrec_port = self . txn . insert ( self . idl . tables [ vswitch_idl . OVSREC_TABLE_PORT ] ) #NEWLINE# ovsrec_port . name = port_name #NEWLINE# ovsrec_port . interfaces = ifaces #NEWLINE# ovsrec_port . bond_fake_iface = fake_iface #NEWLINE# if vsctl_bridge . parent : #NEWLINE# #INDENT# tag = vsctl_bridge . vlan #NEWLINE# ovsrec_port . tag = tag #NEWLINE# #UNINDENT# for setting in settings : #NEWLINE# #INDENT# ( column , key , value ) = setting #NEWLINE# self . set_column ( ovsrec_port , column , key , value ) #NEWLINE# #UNINDENT# if vsctl_bridge . parent : #NEWLINE# #INDENT# ovsrec_bridge = vsctl_bridge . parent . br_cfg #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ovsrec_bridge = vsctl_bridge . br_cfg #NEWLINE# #UNINDENT# self . bridge_insert_port ( ovsrec_bridge , ovsrec_port ) #NEWLINE# vsctl_port = self . add_port_to_cache ( vsctl_bridge , ovsrec_port ) #NEWLINE# for ovsrec_iface in ifaces : #NEWLINE# #INDENT# self . add_iface_to_cache ( vsctl_port , ovsrec_iface )