def test_convert_subnet_dict_to_model(self): model_obj = utils.convert_subnet_dict_to_model(t_constants.MOCK_SUBNET) assert_dict = dict(id=t_constants.MOCK_SUBNET_ID, name=t_constants.MOCK_SUBNET_NAME, network_id=t_constants.MOCK_NETWORK_ID, project_id=t_constants.MOCK_PROJECT_ID, gateway_ip=t_constants.MOCK_GATEWAY_IP, cidr=t_constants.MOCK_CIDR, ip_version=t_constants.MOCK_IP_VERSION) self._compare_ignore_value_none(model_obj.to_dict(), assert_dict)
def test_convert_subnet_dict_to_model(self): model_obj = utils.convert_subnet_dict_to_model( t_constants.MOCK_SUBNET) assert_dict = dict( id=t_constants.MOCK_SUBNET_ID, name=t_constants.MOCK_SUBNET_NAME, network_id=t_constants.MOCK_NETWORK_ID, project_id=t_constants.MOCK_PROJECT_ID, gateway_ip=t_constants.MOCK_GATEWAY_IP, cidr=t_constants.MOCK_CIDR, ip_version=t_constants.MOCK_IP_VERSION ) self._compare_ignore_value_none(model_obj.to_dict(), assert_dict)
def get_subnet(self, subnet_id): try: subnet = self.neutron_client.show_subnet(subnet_id) return utils.convert_subnet_dict_to_model(subnet) except neutron_client_exceptions.NotFound: message = _LE('Subnet not found ' '(subnet id: {subnet_id}.').format( subnet_id=subnet_id) LOG.exception(message) raise base.SubnetNotFound(message) except Exception: message = _LE('Error retrieving subnet ' '(subnet id: {subnet_id}.').format( subnet_id=subnet_id) LOG.exception(message) raise base.NetworkException(message)
def get_subnet(self, subnet_id): try: subnet = self.neutron_client.show_subnet(subnet_id) return utils.convert_subnet_dict_to_model(subnet) except neutron_client_exceptions.NotFound: message = _LE( 'Subnet not found ' '(subnet id: {subnet_id}.').format(subnet_id=subnet_id) LOG.exception(message) raise base.SubnetNotFound(message) except Exception: message = _LE( 'Error retrieving subnet ' '(subnet id: {subnet_id}.').format(subnet_id=subnet_id) LOG.exception(message) raise base.NetworkException(message)