def update_port_postcommit(self, context):
        """Creates a port profile on UCS Manager.

        Creates a Port Profile for this VLAN if it does not already
        exist.
        """
        vlan_id = self._get_vlanid(context)

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

        if (not self._is_supported_deviceowner(context.current) or
            not self._is_status_active(context.current)):
            LOG.debug("Unsupported device_owner '%(owner)s' or port not"
                      " active (vlan_id '%(vlan)d', status %(status)s)."
                      "   Nothing to do.",
                      {'owner': context.current['device_owner'],
                       'vlan': vlan_id,
                       'status': context.current['status']})
            return

        # Checks to perform before UCS Manager can create a Port Profile.
        # 1. Make sure this host is on a known UCS Manager.
        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

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

        profile = context.current.get(bc.portbindings.PROFILE, {})
        vnic_type = context.current.get(bc.portbindings.VNIC_TYPE,
                                        bc.portbindings.VNIC_NORMAL)

        # 2. Make sure this is a vm_fex_port.(Port profiles are created
        # only for VM-FEX ports.)
        if (self.driver.check_vnic_type_and_vendor_info(vnic_type, profile) and
            self.driver.is_vmfex_port(profile)):

            # 3. Make sure update_port_precommit added an entry in the DB
            # for this port profile
            profile_name = self.ucsm_db.get_port_profile_for_vlan(vlan_id,
                ucsm_ip)

            # 4. Make sure that the Port Profile hasn't already been created
            # on the UCS Manager
            if profile_name and self.ucsm_db.is_port_profile_created(vlan_id,
                ucsm_ip):
                LOG.debug('Port Profile %s for vlan_id %d already exists '
                          'on UCSM %s.', profile_name, vlan_id, ucsm_ip)
                return

            # Multi VLAN trunk support
            # Check if this network is a trunk network. If so pass the
            # additional VLAN ids to the UCSM driver.
            network = context.network.current['name']
            trunk_vlans = (
                CONF.sriov_multivlan_trunk.network_vlans.get(network, []))

            # All checks are done. Ask the UCS Manager driver to create the
            # above Port Profile.
            if self.driver.create_portprofile(profile_name, vlan_id,
                                              vnic_type, host_id, trunk_vlans):
                # Port profile created on UCS, record that in the DB.
                self.ucsm_db.set_port_profile_created(vlan_id, profile_name,
                    ucsm_ip)
            return
        else:
            # Enable vlan-id for this Neutron virtual port.
            LOG.debug('Host_id is %s', host_id)
            physnet = self._get_physnet(context)

            ucsm = CONF.ml2_cisco_ucsm.ucsms[ucsm_ip]
            vnic_template = ucsm.vnic_template_list.get(physnet)

            if vnic_template:
                LOG.debug('Update VNIC Template for physnet: %s', physnet)
                LOG.debug('vnic_template %s', vnic_template)
                if (self.driver.update_vnic_template(
                        host_id, vlan_id, physnet, vnic_template.path,
                        vnic_template.name)):
                    LOG.debug('Setting ucsm_updated flag for '
                              'vlan : %(vlan)d, '
                              'vnic_template : %(vnic_template)s '
                              'on ucsm_ip: %(ucsm_ip)s',
                              {'vlan': vlan_id,
                              'vnic_template': vnic_template.name,
                              'ucsm_ip': ucsm_ip})
                    self.ucsm_db.set_vnic_template_updated(
                        vlan_id, ucsm_ip, vnic_template.name, physnet)
                return

            if (CONF.ml2_cisco_ucsm.ucsms[ucsm_ip].sp_template_list and
                self.driver.update_service_profile_template(
                    vlan_id, host_id, ucsm_ip)):
                sp_template_info = (CONF.ml2_cisco_ucsm.ucsms[
                    ucsm_ip].sp_template_list.get(host_id))
                if not sp_template_info:
                    sp_template = None
                else:
                    sp_template = sp_template_info.name
                LOG.debug('Setting ucsm_updated flag for vlan : %(vlan)d, '
                          'sp_template : %(sp_template)s on ucsm_ip: '
                          '%(ucsm_ip)s', {'vlan': vlan_id,
                          'sp_template': sp_template, 'ucsm_ip': ucsm_ip})
                self.ucsm_db.set_sp_template_updated(vlan_id, sp_template,
                                                     ucsm_ip)
            else:
                self.driver.update_serviceprofile(host_id, vlan_id)
def update_port_postcommit ( self , context ) : vlan_id = self . _get_vlanid ( context ) if not vlan_id : LOG . warning ( 'Vlan_id is None. Ignoring this port.' ) return if ( not self . _is_supported_deviceowner ( context . current ) or not self . _is_status_active ( context . current ) ) : LOG . debug ( "Unsupported device_owner '%(owner)s' or port not" " active (vlan_id '%(vlan)d', status %(status)s)." "   Nothing to do." , { 'owner' : context . current [ 'device_owner' ] , 'vlan' : vlan_id , 'status' : context . current [ 'status' ] } ) return 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 ucsm_ip = self . driver . get_ucsm_ip_for_host ( host_id ) if not ucsm_ip : LOG . info ( 'Host_id %s is not controlled by any known UCS ' 'Manager' , str ( host_id ) ) return profile = context . current . get ( bc . portbindings . PROFILE , { } ) vnic_type = context . current . get ( bc . portbindings . VNIC_TYPE , bc . portbindings . VNIC_NORMAL ) if ( self . driver . check_vnic_type_and_vendor_info ( vnic_type , profile ) and self . driver . is_vmfex_port ( profile ) ) : profile_name = self . ucsm_db . get_port_profile_for_vlan ( vlan_id , ucsm_ip ) if profile_name and self . ucsm_db . is_port_profile_created ( vlan_id , ucsm_ip ) : LOG . debug ( 'Port Profile %s for vlan_id %d already exists ' 'on UCSM %s.' , profile_name , vlan_id , ucsm_ip ) return network = context . network . current [ 'name' ] trunk_vlans = ( CONF . sriov_multivlan_trunk . network_vlans . get ( network , [ ] ) ) if self . driver . create_portprofile ( profile_name , vlan_id , vnic_type , host_id , trunk_vlans ) : self . ucsm_db . set_port_profile_created ( vlan_id , profile_name , ucsm_ip ) return else : LOG . debug ( 'Host_id is %s' , host_id ) physnet = self . _get_physnet ( context ) ucsm = CONF . ml2_cisco_ucsm . ucsms [ ucsm_ip ] vnic_template = ucsm . vnic_template_list . get ( physnet ) if vnic_template : LOG . debug ( 'Update VNIC Template for physnet: %s' , physnet ) LOG . debug ( 'vnic_template %s' , vnic_template ) if ( self . driver . update_vnic_template ( host_id , vlan_id , physnet , vnic_template . path , vnic_template . name ) ) : LOG . debug ( 'Setting ucsm_updated flag for ' 'vlan : %(vlan)d, ' 'vnic_template : %(vnic_template)s ' 'on ucsm_ip: %(ucsm_ip)s' , { 'vlan' : vlan_id , 'vnic_template' : vnic_template . name , 'ucsm_ip' : ucsm_ip } ) self . ucsm_db . set_vnic_template_updated ( vlan_id , ucsm_ip , vnic_template . name , physnet ) return if ( CONF . ml2_cisco_ucsm . ucsms [ ucsm_ip ] . sp_template_list and self . driver . update_service_profile_template ( vlan_id , host_id , ucsm_ip ) ) : sp_template_info = ( CONF . ml2_cisco_ucsm . ucsms [ ucsm_ip ] . sp_template_list . get ( host_id ) ) if not sp_template_info : sp_template = None else : sp_template = sp_template_info . name LOG . debug ( 'Setting ucsm_updated flag for vlan : %(vlan)d, ' 'sp_template : %(sp_template)s on ucsm_ip: ' '%(ucsm_ip)s' , { 'vlan' : vlan_id , 'sp_template' : sp_template , 'ucsm_ip' : ucsm_ip } ) self . ucsm_db . set_sp_template_updated ( vlan_id , sp_template , ucsm_ip ) else : self . driver . update_serviceprofile ( host_id , vlan_id )
Creates a port profile on UCS Manager.

        Creates a Port Profile for this VLAN if it does not already
        exist.