예제 #1
0
파일: port.py 프로젝트: pshchelo/ironic
def hide_fields_in_newer_versions(obj):
    # if requested version is < 1.18, hide internal_info field
    if not api_utils.allow_port_internal_info():
        obj.internal_info = wsme.Unset
    # if requested version is < 1.19, hide local_link_connection and
    # pxe_enabled fields
    if not api_utils.allow_port_advanced_net_fields():
        obj.pxe_enabled = wsme.Unset
        obj.local_link_connection = wsme.Unset
    # if requested version is < 1.24, hide portgroup_uuid field
    if not api_utils.allow_portgroups_subcontrollers():
        obj.portgroup_uuid = wsme.Unset
    # if requested version is < 1.34, hide physical_network field.
    if not api_utils.allow_port_physical_network():
        obj.physical_network = wsme.Unset
예제 #2
0
파일: port.py 프로젝트: pshchelo/ironic
    def _check_allowed_port_fields(self, fields):
        """Check if fetching a particular field of a port is allowed.

        Check if the required version is being requested for fields
        that are only allowed to be fetched in a particular API version.

        :param fields: list or set of fields to check
        :raises: NotAcceptable if a field is not allowed
        """
        if fields is None:
            return
        if (not api_utils.allow_port_advanced_net_fields() and
                set(fields).intersection(self.advanced_net_fields)):
            raise exception.NotAcceptable()
        if ('portgroup_uuid' in fields and not
                api_utils.allow_portgroups_subcontrollers()):
            raise exception.NotAcceptable()
        if ('physical_network' in fields and not
                api_utils.allow_port_physical_network()):
            raise exception.NotAcceptable()
예제 #3
0
    def _check_allowed_port_fields(self, fields):
        """Check if fetching a particular field of a port is allowed.

        Check if the required version is being requested for fields
        that are only allowed to be fetched in a particular API version.

        :param fields: list or set of fields to check
        :raises: NotAcceptable if a field is not allowed
        """
        if fields is None:
            return
        if (not api_utils.allow_port_advanced_net_fields()
                and set(fields).intersection(self.advanced_net_fields)):
            raise exception.NotAcceptable()
        if ('portgroup_uuid' in fields
                and not api_utils.allow_portgroups_subcontrollers()):
            raise exception.NotAcceptable()
        if ('physical_network' in fields
                and not api_utils.allow_port_physical_network()):
            raise exception.NotAcceptable()
예제 #4
0
 def test_allow_port_physical_network_pin(self, mock_spn, mock_request):
     mock_spn.return_value = False
     mock_request.version.minor = 34
     self.assertFalse(utils.allow_port_physical_network())
     mock_request.version.minor = 33
     self.assertFalse(utils.allow_port_physical_network())
예제 #5
0
 def test_allow_port_physical_network_pin(self, mock_spn, mock_request):
     mock_spn.return_value = False
     mock_request.version.minor = 34
     self.assertFalse(utils.allow_port_physical_network())
     mock_request.version.minor = 33
     self.assertFalse(utils.allow_port_physical_network())