def mgmt_sec_grp_id(cls):
        """Returns id of security group used by the management network."""
        if not extensions.is_extension_supported(bc.get_plugin(),
                                                 "security-group"):
            return
        if cls._mgmt_sec_grp_id is None:
            # Get the id for the _mgmt_security_group_id
            tenant_id = cls.l3_tenant_id()
            res = bc.get_plugin().get_security_groups(
                bc.context.get_admin_context(),
                {'tenant_id': [tenant_id],
                 'name': [cfg.CONF.general.default_security_group]},
                ['id'])
            if len(res) == 1:
                sec_grp_id = res[0].get('id', None)
                cls._mgmt_sec_grp_id = sec_grp_id
            elif len(res) > 1:
                # the mgmt sec group must be unique.
                LOG.error('The security group for the management network '
                          'does not have unique name. Please ensure that '
                          'it is.')
            else:
                # Service VM Mgmt security group is not present.
                LOG.error('There is no security group for the management '
                          'network. Please create one.')
        return cls._mgmt_sec_grp_id
def mgmt_sec_grp_id ( cls ) : if not extensions . is_extension_supported ( bc . get_plugin ( ) , "security-group" ) : return if cls . _mgmt_sec_grp_id is None : tenant_id = cls . l3_tenant_id ( ) res = bc . get_plugin ( ) . get_security_groups ( bc . context . get_admin_context ( ) , { 'tenant_id' : [ tenant_id ] , 'name' : [ cfg . CONF . general . default_security_group ] } , [ 'id' ] ) if len ( res ) == 1 : sec_grp_id = res [ 0 ] . get ( 'id' , None ) cls . _mgmt_sec_grp_id = sec_grp_id elif len ( res ) > 1 : LOG . error ( 'The security group for the management network ' 'does not have unique name. Please ensure that ' 'it is.' ) else : LOG . error ( 'There is no security group for the management ' 'network. Please create one.' ) return cls . _mgmt_sec_grp_id
Returns id of security group used by the management network.