def update_port_precommit(self, context):
vnic_type = context.current.get(bc.portbindings.VNIC_TYPE,<EOL>bc.portbindings.VNIC_NORMAL)<EOL>profile = context.current.get(bc.portbindings.PROFILE, {})<EOL>host_id = self._get_host_id(<EOL>context.current.get(bc.portbindings.HOST_ID))<EOL>if not host_id:<EOL><INDENT>LOG.warning('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>return<EOL><DEDENT>vlan_id = self._get_vlanid(context)<EOL>if not vlan_id:<EOL><INDENT>LOG.warning('<STR_LIT>')<EOL>return<EOL><DEDENT>ucsm_ip = self.driver.get_ucsm_ip_for_host(host_id)<EOL>if not ucsm_ip:<EOL><INDENT>LOG.info('<STR_LIT>'<EOL>'<STR_LIT>', host_id)<EOL>return<EOL><DEDENT>if not self.driver.check_vnic_type_and_vendor_info(vnic_type,<EOL>profile):<EOL><INDENT>physnet = self._get_physnet(context)<EOL>if not physnet:<EOL><INDENT>LOG.debug('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>ucsm = CONF.ml2_cisco_ucsm.ucsms[ucsm_ip]<EOL>vnic_template = ucsm.vnic_template_list.get(physnet)<EOL>if vnic_template:<EOL><INDENT>LOG.debug('<STR_LIT>', vnic_template)<EOL>self.ucsm_db.add_vnic_template(vlan_id, ucsm_ip,<EOL>vnic_template.name, physnet)<EOL>return<EOL><DEDENT>else:<EOL><INDENT>LOG.debug('<STR_LIT>'<EOL>'<STR_LIT>', physnet)<EOL><DEDENT><DEDENT>sp_template_info = (CONF.ml2_cisco_ucsm.ucsms[<EOL>ucsm_ip].sp_template_list.get(host_id))<EOL>if sp_template_info:<EOL><INDENT>LOG.debug('<STR_LIT>',<EOL>sp_template_info.name, vlan_id)<EOL>self.ucsm_db.add_service_profile_template(<EOL>vlan_id, sp_template_info.name, ucsm_ip)<EOL>return<EOL><DEDENT><DEDENT>if not self.driver.is_vmfex_port(profile):<EOL><INDENT>LOG.debug('<STR_LIT>')<EOL>return<EOL><DEDENT>p_profile_name = self.make_profile_name(vlan_id)<EOL>LOG.debug('<STR_LIT>', p_profile_name, vlan_id)<EOL>self.ucsm_db.add_port_profile(p_profile_name, vlan_id, ucsm_ip)<EOL>
Adds port profile and vlan information to the DB.

        Assign a port profile to this port. To do that:
        1. Get the vlan_id associated with the bound segment
        2. Check if a port profile already exists for this vlan_id
        3. If yes, associate that port profile with this port.
        4. If no, create a new port profile with this vlan_id and
        associate with this port