raise n_exc.InvalidInput(error_message=msg)
if segment_type in [c_const.NETWORK_TYPE_TRUNK,
c_const.NETWORK_TYPE_OVERLAY]:
- if "sub_type" not in net_p:
+ if not attributes.is_attr_set(net_p.get("sub_type")):
msg = _("Argument sub_type missing "
"for network profile")
LOG.exception(msg)
netp['network_profile']['sub_type'] = 'enhanced' or 'native_vxlan'
netp['network_profile']['multicast_ip_range'] = ("224.1.1.1-"
"224.1.1.10")
+ elif segment_type == 'trunk':
+ netp['network_profile']['sub_type'] = 'vlan'
return netp
def test_create_network_profile_vlan(self):
res = net_p_req.get_response(self.ext_api)
self.assertEqual(res.status_int, 201)
+ def test_create_network_profile_trunk(self):
+ data = self._prepare_net_profile_data('trunk')
+ net_p_req = self.new_create_request('network_profiles', data)
+ res = net_p_req.get_response(self.ext_api)
+ self.assertEqual(res.status_int, 201)
+
+ def test_create_network_profile_trunk_missing_subtype(self):
+ data = self._prepare_net_profile_data('trunk')
+ data['network_profile'].pop('sub_type')
+ net_p_req = self.new_create_request('network_profiles', data)
+ res = net_p_req.get_response(self.ext_api)
+ self.assertEqual(res.status_int, 400)
+
def test_create_network_profile_overlay_unreasonable_seg_range(self):
data = self._prepare_net_profile_data('overlay')
data['network_profile']['segment_range'] = '10000-100000000001'