<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_port_precommit(self, context):
 """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 """

        vnic_type = context.current.get(bc.portbindings.VNIC_TYPE,
                                        bc.portbindings.VNIC_NORMAL)

        profile = context.current.get(bc.portbindings.PROFILE, {})
        host_id = self._get_host_id(
            context.current.get(bc.portbindings.HOST_ID))
        if not host_id:
            LOG.warning('Host id from port context is None. '
                'Ignoring this port')
            return

        vlan_id = self._get_vlanid(context)
        if not vlan_id:
            LOG.warning('Vlan_id is None. Ignoring this port')
            return

        ucsm_ip = self.driver.get_ucsm_ip_for_host(host_id)
        if not ucsm_ip:
            LOG.info('Host %s is not controlled by any known '
                     'UCS Manager.', host_id)
            return

        if not self.driver.check_vnic_type_and_vendor_info(vnic_type,
                                                           profile):
            # This is a neutron virtio port.
            # If VNIC templates are configured, that config would
            # take precedence and the VLAN is added to the VNIC template.
            physnet = self._get_physnet(context)
            if not physnet:
                LOG.debug('physnet is None. Not modifying VNIC '
                          'Template config')
            else:
                # Check if VNIC template is configured for this physnet
                ucsm = CONF.ml2_cisco_ucsm.ucsms[ucsm_ip]
                vnic_template = ucsm.vnic_template_list.get(physnet)
                if vnic_template:
                    LOG.debug('vnic_template %s', vnic_template)
                    self.ucsm_db.add_vnic_template(vlan_id, ucsm_ip,
                        vnic_template.name, physnet)
                    return
                else:
                    LOG.debug('VNIC Template not configured for '
                              'physnet %s', physnet)

            # In the absence of VNIC Templates, VLAN is directly added
            # to vNIC(s) on the SP Template.
            # Check if SP Template config has been provided. If so, find
            # the UCSM that controls this host and the Service Profile
            # Template for this host.

            sp_template_info = (CONF.ml2_cisco_ucsm.ucsms[
                ucsm_ip].sp_template_list.get(host_id))

            if sp_template_info:
                LOG.debug('SP Template: %s, VLAN_id: %d',
                          sp_template_info.name, vlan_id)
                self.ucsm_db.add_service_profile_template(
                    vlan_id, sp_template_info.name, ucsm_ip)
                return

        # If this is an Intel SR-IOV vnic, then no need to create port
        # profile on the UCS manager. So no need to update the DB.
        if not self.driver.is_vmfex_port(profile):
            LOG.debug('This is a SR-IOV port and hence not updating DB.')
            return

        # This is a Cisco VM-FEX port
        p_profile_name = self.make_profile_name(vlan_id)
        LOG.debug('Port Profile: %s for VLAN_id: %d', p_profile_name, vlan_id)

        # Create a new port profile entry in the db
        self.ucsm_db.add_port_profile(p_profile_name, vlan_id, ucsm_ip)