| Igor Duarte Cardoso | 3cf9bcd | 2017-08-14 16:39:34 +0000 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | ## |
| 4 | # Copyright 2017 Intel Corporation. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. You may obtain |
| 8 | # a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | # License for the specific language governing permissions and limitations |
| 16 | # under the License. |
| 17 | # |
| 18 | # For those usages not covered by the Apache License, Version 2.0 please |
| 19 | # contact with: nfvlabs@tid.es |
| 20 | ## |
| 21 | |
| 22 | """ |
| 23 | This module contains unit tests for the OpenStack VIM connector |
| 24 | Run this directly with python2 or python3. |
| 25 | """ |
| 26 | |
| 27 | import copy |
| 28 | import unittest |
| 29 | |
| 30 | import mock |
| 31 | from neutronclient.v2_0.client import Client |
| 32 | |
| 33 | from osm_ro import vimconn |
| 34 | from osm_ro.vimconn_openstack import vimconnector |
| 35 | |
| 36 | |
| 37 | __author__ = "Igor D.C." |
| 38 | __date__ = "$23-aug-2017 23:59:59$" |
| 39 | |
| 40 | |
| 41 | class TestSfcOperations(unittest.TestCase): |
| 42 | def setUp(self): |
| 43 | # instantiate dummy VIM connector so we can test it |
| 44 | self.vimconn = vimconnector( |
| 45 | '123', 'openstackvim', '456', '789', 'http://dummy.url', None, |
| 46 | 'user', 'pass') |
| 47 | |
| 48 | def _test_new_sfi(self, create_port_pair, sfc_encap, |
| 49 | ingress_ports=['5311c75d-d718-4369-bbda-cdcc6da60fcc'], |
| 50 | egress_ports=['230cdf1b-de37-4891-bc07-f9010cf1f967']): |
| 51 | # input to VIM connector |
| 52 | name = 'osm_sfi' |
| 53 | # + ingress_ports |
| 54 | # + egress_ports |
| 55 | # TODO(igordc): must be changed to NSH in Queens (MPLS is a workaround) |
| 56 | correlation = 'mpls' |
| 57 | if sfc_encap is not None: |
| 58 | if not sfc_encap: |
| 59 | correlation = None |
| 60 | |
| 61 | # what OpenStack is assumed to respond (patch OpenStack's return value) |
| 62 | dict_from_neutron = {'port_pair': { |
| 63 | 'id': '3d7ddc13-923c-4332-971e-708ed82902ce', |
| 64 | 'name': name, |
| 65 | 'description': '', |
| 66 | 'tenant_id': '130b1e97-b0f1-40a8-8804-b6ad9b8c3e0c', |
| 67 | 'project_id': '130b1e97-b0f1-40a8-8804-b6ad9b8c3e0c', |
| 68 | 'ingress': ingress_ports[0] if len(ingress_ports) else None, |
| 69 | 'egress': egress_ports[0] if len(egress_ports) else None, |
| 70 | 'service_function_parameters': {'correlation': correlation} |
| 71 | }} |
| 72 | create_port_pair.return_value = dict_from_neutron |
| 73 | |
| 74 | # what the VIM connector is expected to |
| 75 | # send to OpenStack based on the input |
| 76 | dict_to_neutron = {'port_pair': { |
| 77 | 'name': name, |
| 78 | 'ingress': '5311c75d-d718-4369-bbda-cdcc6da60fcc', |
| 79 | 'egress': '230cdf1b-de37-4891-bc07-f9010cf1f967', |
| 80 | 'service_function_parameters': {'correlation': correlation} |
| 81 | }} |
| 82 | |
| 83 | # call the VIM connector |
| 84 | if sfc_encap is None: |
| 85 | result = self.vimconn.new_sfi(name, ingress_ports, egress_ports) |
| 86 | else: |
| 87 | result = self.vimconn.new_sfi(name, ingress_ports, egress_ports, |
| 88 | sfc_encap) |
| 89 | |
| 90 | # assert that the VIM connector made the expected call to OpenStack |
| 91 | create_port_pair.assert_called_with(dict_to_neutron) |
| 92 | # assert that the VIM connector had the expected result / return value |
| 93 | self.assertEqual(result, dict_from_neutron['port_pair']['id']) |
| 94 | |
| 95 | def _test_new_sf(self, create_port_pair_group): |
| 96 | # input to VIM connector |
| 97 | name = 'osm_sf' |
| 98 | instances = ['bbd01220-cf72-41f2-9e70-0669c2e5c4cd', |
| 99 | '12ba215e-3987-4892-bd3a-d0fd91eecf98', |
| 100 | 'e25a7c79-14c8-469a-9ae1-f601c9371ffd'] |
| 101 | |
| 102 | # what OpenStack is assumed to respond (patch OpenStack's return value) |
| 103 | dict_from_neutron = {'port_pair_group': { |
| 104 | 'id': '3d7ddc13-923c-4332-971e-708ed82902ce', |
| 105 | 'name': name, |
| 106 | 'description': '', |
| 107 | 'tenant_id': '130b1e97-b0f1-40a8-8804-b6ad9b8c3e0c', |
| 108 | 'project_id': '130b1e97-b0f1-40a8-8804-b6ad9b8c3e0c', |
| 109 | 'port_pairs': instances, |
| 110 | 'group_id': 1, |
| 111 | 'port_pair_group_parameters': { |
| 112 | "lb_fields": [], |
| 113 | "ppg_n_tuple_mapping": { |
| 114 | "ingress_n_tuple": {}, |
| 115 | "egress_n_tuple": {} |
| 116 | }} |
| 117 | }} |
| 118 | create_port_pair_group.return_value = dict_from_neutron |
| 119 | |
| 120 | # what the VIM connector is expected to |
| 121 | # send to OpenStack based on the input |
| 122 | dict_to_neutron = {'port_pair_group': { |
| 123 | 'name': name, |
| 124 | 'port_pairs': ['bbd01220-cf72-41f2-9e70-0669c2e5c4cd', |
| 125 | '12ba215e-3987-4892-bd3a-d0fd91eecf98', |
| 126 | 'e25a7c79-14c8-469a-9ae1-f601c9371ffd'] |
| 127 | }} |
| 128 | |
| 129 | # call the VIM connector |
| 130 | result = self.vimconn.new_sf(name, instances) |
| 131 | |
| 132 | # assert that the VIM connector made the expected call to OpenStack |
| 133 | create_port_pair_group.assert_called_with(dict_to_neutron) |
| 134 | # assert that the VIM connector had the expected result / return value |
| 135 | self.assertEqual(result, dict_from_neutron['port_pair_group']['id']) |
| 136 | |
| 137 | def _test_new_sfp(self, create_port_chain, sfc_encap, spi): |
| 138 | # input to VIM connector |
| 139 | name = 'osm_sfp' |
| 140 | classifications = ['2bd2a2e5-c5fd-4eac-a297-d5e255c35c19', |
| 141 | '00f23389-bdfa-43c2-8b16-5815f2582fa8'] |
| 142 | sfs = ['2314daec-c262-414a-86e3-69bb6fa5bc16', |
| 143 | 'd8bfdb5d-195e-4f34-81aa-6135705317df'] |
| 144 | |
| 145 | # TODO(igordc): must be changed to NSH in Queens (MPLS is a workaround) |
| 146 | correlation = 'mpls' |
| 147 | chain_id = 33 |
| 148 | if sfc_encap is not None: |
| 149 | if not sfc_encap: |
| 150 | correlation = None |
| 151 | if spi: |
| 152 | chain_id = spi |
| 153 | |
| 154 | # what OpenStack is assumed to respond (patch OpenStack's return value) |
| 155 | dict_from_neutron = {'port_chain': { |
| 156 | 'id': '5bc05721-079b-4b6e-a235-47cac331cbb6', |
| 157 | 'name': name, |
| 158 | 'description': '', |
| 159 | 'tenant_id': '130b1e97-b0f1-40a8-8804-b6ad9b8c3e0c', |
| 160 | 'project_id': '130b1e97-b0f1-40a8-8804-b6ad9b8c3e0c', |
| 161 | 'chain_id': chain_id, |
| 162 | 'flow_classifiers': classifications, |
| 163 | 'port_pair_groups': sfs, |
| 164 | 'chain_parameters': {'correlation': correlation} |
| 165 | }} |
| 166 | create_port_chain.return_value = dict_from_neutron |
| 167 | |
| 168 | # what the VIM connector is expected to |
| 169 | # send to OpenStack based on the input |
| 170 | dict_to_neutron = {'port_chain': { |
| 171 | 'name': name, |
| 172 | 'flow_classifiers': ['2bd2a2e5-c5fd-4eac-a297-d5e255c35c19', |
| 173 | '00f23389-bdfa-43c2-8b16-5815f2582fa8'], |
| 174 | 'port_pair_groups': ['2314daec-c262-414a-86e3-69bb6fa5bc16', |
| 175 | 'd8bfdb5d-195e-4f34-81aa-6135705317df'], |
| 176 | 'chain_parameters': {'correlation': correlation} |
| 177 | }} |
| 178 | if spi: |
| 179 | dict_to_neutron['port_chain']['chain_id'] = spi |
| 180 | |
| 181 | # call the VIM connector |
| 182 | if sfc_encap is None: |
| 183 | if spi is None: |
| 184 | result = self.vimconn.new_sfp(name, classifications, sfs) |
| 185 | else: |
| 186 | result = self.vimconn.new_sfp(name, classifications, sfs, |
| 187 | spi=spi) |
| 188 | else: |
| 189 | if spi is None: |
| 190 | result = self.vimconn.new_sfp(name, classifications, sfs, |
| 191 | sfc_encap) |
| 192 | else: |
| 193 | result = self.vimconn.new_sfp(name, classifications, sfs, |
| 194 | sfc_encap, spi) |
| 195 | |
| 196 | # assert that the VIM connector made the expected call to OpenStack |
| 197 | create_port_chain.assert_called_with(dict_to_neutron) |
| 198 | # assert that the VIM connector had the expected result / return value |
| 199 | self.assertEqual(result, dict_from_neutron['port_chain']['id']) |
| 200 | |
| 201 | def _test_new_classification(self, create_flow_classifier, ctype): |
| 202 | # input to VIM connector |
| 203 | name = 'osm_classification' |
| 204 | definition = {'ethertype': 'IPv4', |
| 205 | 'logical_source_port': |
| 206 | 'aaab0ab0-1452-4636-bb3b-11dca833fa2b', |
| 207 | 'protocol': 'tcp', |
| 208 | 'source_ip_prefix': '192.168.2.0/24', |
| 209 | 'source_port_range_max': 99, |
| 210 | 'source_port_range_min': 50} |
| 211 | |
| 212 | # what OpenStack is assumed to respond (patch OpenStack's return value) |
| 213 | dict_from_neutron = {'flow_classifier': copy.copy(definition)} |
| 214 | dict_from_neutron['flow_classifier'][ |
| 215 | 'id'] = '7735ec2c-fddf-4130-9712-32ed2ab6a372' |
| 216 | dict_from_neutron['flow_classifier']['name'] = name |
| 217 | dict_from_neutron['flow_classifier']['description'] = '' |
| 218 | dict_from_neutron['flow_classifier'][ |
| 219 | 'tenant_id'] = '130b1e97-b0f1-40a8-8804-b6ad9b8c3e0c' |
| 220 | dict_from_neutron['flow_classifier'][ |
| 221 | 'project_id'] = '130b1e97-b0f1-40a8-8804-b6ad9b8c3e0c' |
| 222 | create_flow_classifier.return_value = dict_from_neutron |
| 223 | |
| 224 | # what the VIM connector is expected to |
| 225 | # send to OpenStack based on the input |
| 226 | dict_to_neutron = {'flow_classifier': copy.copy(definition)} |
| 227 | dict_to_neutron['flow_classifier']['name'] = 'osm_classification' |
| 228 | |
| 229 | # call the VIM connector |
| 230 | result = self.vimconn.new_classification(name, ctype, definition) |
| 231 | |
| 232 | # assert that the VIM connector made the expected call to OpenStack |
| 233 | create_flow_classifier.assert_called_with(dict_to_neutron) |
| 234 | # assert that the VIM connector had the expected result / return value |
| 235 | self.assertEqual(result, dict_from_neutron['flow_classifier']['id']) |
| 236 | |
| 237 | @mock.patch.object(Client, 'create_flow_classifier') |
| 238 | def test_new_classification(self, create_flow_classifier): |
| 239 | self._test_new_classification(create_flow_classifier, |
| 240 | 'legacy_flow_classifier') |
| 241 | |
| 242 | @mock.patch.object(Client, 'create_flow_classifier') |
| 243 | def test_new_classification_unsupported_type(self, create_flow_classifier): |
| 244 | self.assertRaises(vimconn.vimconnNotSupportedException, |
| 245 | self._test_new_classification, |
| 246 | create_flow_classifier, 'h265') |
| 247 | |
| 248 | @mock.patch.object(Client, 'create_port_pair') |
| 249 | def test_new_sfi_with_sfc_encap(self, create_port_pair): |
| 250 | self._test_new_sfi(create_port_pair, True) |
| 251 | |
| 252 | @mock.patch.object(Client, 'create_port_pair') |
| 253 | def test_new_sfi_without_sfc_encap(self, create_port_pair): |
| 254 | self._test_new_sfi(create_port_pair, False) |
| 255 | |
| 256 | @mock.patch.object(Client, 'create_port_pair') |
| 257 | def test_new_sfi_default_sfc_encap(self, create_port_pair): |
| 258 | self._test_new_sfi(create_port_pair, None) |
| 259 | |
| 260 | @mock.patch.object(Client, 'create_port_pair') |
| 261 | def test_new_sfi_bad_ingress_ports(self, create_port_pair): |
| 262 | ingress_ports = ['5311c75d-d718-4369-bbda-cdcc6da60fcc', |
| 263 | 'a0273f64-82c9-11e7-b08f-6328e53f0fa7'] |
| 264 | self.assertRaises(vimconn.vimconnNotSupportedException, |
| 265 | self._test_new_sfi, |
| 266 | create_port_pair, True, ingress_ports=ingress_ports) |
| 267 | ingress_ports = [] |
| 268 | self.assertRaises(vimconn.vimconnNotSupportedException, |
| 269 | self._test_new_sfi, |
| 270 | create_port_pair, True, ingress_ports=ingress_ports) |
| 271 | |
| 272 | @mock.patch.object(Client, 'create_port_pair') |
| 273 | def test_new_sfi_bad_egress_ports(self, create_port_pair): |
| 274 | egress_ports = ['230cdf1b-de37-4891-bc07-f9010cf1f967', |
| 275 | 'b41228fe-82c9-11e7-9b44-17504174320b'] |
| 276 | self.assertRaises(vimconn.vimconnNotSupportedException, |
| 277 | self._test_new_sfi, |
| 278 | create_port_pair, True, egress_ports=egress_ports) |
| 279 | egress_ports = [] |
| 280 | self.assertRaises(vimconn.vimconnNotSupportedException, |
| 281 | self._test_new_sfi, |
| 282 | create_port_pair, True, egress_ports=egress_ports) |
| 283 | |
| 284 | @mock.patch.object(vimconnector, 'get_sfi') |
| 285 | @mock.patch.object(Client, 'create_port_pair_group') |
| 286 | def test_new_sf(self, create_port_pair_group, get_sfi): |
| 287 | get_sfi.return_value = {'sfc_encap': 'mpls'} |
| 288 | self._test_new_sf(create_port_pair_group) |
| 289 | |
| 290 | @mock.patch.object(vimconnector, 'get_sfi') |
| 291 | @mock.patch.object(Client, 'create_port_pair_group') |
| 292 | def test_new_sf_inconsistent_sfc_encap(self, create_port_pair_group, |
| 293 | get_sfi): |
| 294 | get_sfi.return_value = {'sfc_encap': 'nsh'} |
| 295 | self.assertRaises(vimconn.vimconnNotSupportedException, |
| 296 | self._test_new_sf, create_port_pair_group) |
| 297 | |
| 298 | @mock.patch.object(Client, 'create_port_chain') |
| 299 | def test_new_sfp_with_sfc_encap(self, create_port_chain): |
| 300 | self._test_new_sfp(create_port_chain, True, None) |
| 301 | |
| 302 | @mock.patch.object(Client, 'create_port_chain') |
| 303 | def test_new_sfp_without_sfc_encap(self, create_port_chain): |
| 304 | self.assertRaises(vimconn.vimconnNotSupportedException, |
| 305 | self._test_new_sfp, |
| 306 | create_port_chain, False, None) |
| 307 | self.assertRaises(vimconn.vimconnNotSupportedException, |
| 308 | self._test_new_sfp, |
| 309 | create_port_chain, False, 25) |
| 310 | |
| 311 | @mock.patch.object(Client, 'create_port_chain') |
| 312 | def test_new_sfp_default_sfc_encap(self, create_port_chain): |
| 313 | self._test_new_sfp(create_port_chain, None, None) |
| 314 | |
| 315 | @mock.patch.object(Client, 'create_port_chain') |
| 316 | def test_new_sfp_with_sfc_encap_spi(self, create_port_chain): |
| 317 | self._test_new_sfp(create_port_chain, True, 25) |
| 318 | |
| 319 | @mock.patch.object(Client, 'create_port_chain') |
| 320 | def test_new_sfp_default_sfc_encap_spi(self, create_port_chain): |
| 321 | self._test_new_sfp(create_port_chain, None, 25) |
| 322 | |
| 323 | @mock.patch.object(Client, 'list_flow_classifier') |
| 324 | def test_get_classification_list(self, list_flow_classifier): |
| 325 | # what OpenStack is assumed to return to the VIM connector |
| 326 | list_flow_classifier.return_value = {'flow_classifiers': [ |
| 327 | {'source_port_range_min': 2000, |
| 328 | 'destination_ip_prefix': '192.168.3.0/24', |
| 329 | 'protocol': 'udp', |
| 330 | 'description': '', |
| 331 | 'ethertype': 'IPv4', |
| 332 | 'l7_parameters': {}, |
| 333 | 'source_port_range_max': 2000, |
| 334 | 'destination_port_range_min': 3000, |
| 335 | 'source_ip_prefix': '192.168.2.0/24', |
| 336 | 'logical_destination_port': None, |
| 337 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 338 | 'destination_port_range_max': None, |
| 339 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 340 | 'logical_source_port': 'aaab0ab0-1452-4636-bb3b-11dca833fa2b', |
| 341 | 'id': '22198366-d4e8-4d6b-b4d2-637d5d6cbb7d', |
| 342 | 'name': 'fc1'}]} |
| 343 | |
| 344 | # call the VIM connector |
| 345 | filter_dict = {'protocol': 'tcp', 'ethertype': 'IPv4'} |
| 346 | result = self.vimconn.get_classification_list(filter_dict.copy()) |
| 347 | |
| 348 | # assert that VIM connector called OpenStack with the expected filter |
| 349 | list_flow_classifier.assert_called_with(**filter_dict) |
| 350 | # assert that the VIM connector successfully |
| 351 | # translated and returned the OpenStack result |
| 352 | self.assertEqual(result, [ |
| 353 | {'id': '22198366-d4e8-4d6b-b4d2-637d5d6cbb7d', |
| 354 | 'name': 'fc1', |
| 355 | 'description': '', |
| 356 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 357 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 358 | 'ctype': 'legacy_flow_classifier', |
| 359 | 'definition': { |
| 360 | 'source_port_range_min': 2000, |
| 361 | 'destination_ip_prefix': '192.168.3.0/24', |
| 362 | 'protocol': 'udp', |
| 363 | 'ethertype': 'IPv4', |
| 364 | 'l7_parameters': {}, |
| 365 | 'source_port_range_max': 2000, |
| 366 | 'destination_port_range_min': 3000, |
| 367 | 'source_ip_prefix': '192.168.2.0/24', |
| 368 | 'logical_destination_port': None, |
| 369 | 'destination_port_range_max': None, |
| 370 | 'logical_source_port': 'aaab0ab0-1452-4636-bb3b-11dca833fa2b'} |
| 371 | }]) |
| 372 | |
| 373 | def _test_get_sfi_list(self, list_port_pair, correlation, sfc_encap): |
| 374 | # what OpenStack is assumed to return to the VIM connector |
| 375 | list_port_pair.return_value = {'port_pairs': [ |
| 376 | {'ingress': '5311c75d-d718-4369-bbda-cdcc6da60fcc', |
| 377 | 'description': '', |
| 378 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 379 | 'egress': '5311c75d-d718-4369-bbda-cdcc6da60fcc', |
| 380 | 'service_function_parameters': {'correlation': correlation}, |
| 381 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 382 | 'id': 'c121ebdd-7f2d-4213-b933-3325298a6966', |
| 383 | 'name': 'osm_sfi'}]} |
| 384 | |
| 385 | # call the VIM connector |
| 386 | filter_dict = {'name': 'osm_sfi', 'description': ''} |
| 387 | result = self.vimconn.get_sfi_list(filter_dict.copy()) |
| 388 | |
| 389 | # assert that VIM connector called OpenStack with the expected filter |
| 390 | list_port_pair.assert_called_with(**filter_dict) |
| 391 | # assert that the VIM connector successfully |
| 392 | # translated and returned the OpenStack result |
| 393 | self.assertEqual(result, [ |
| 394 | {'ingress_ports': ['5311c75d-d718-4369-bbda-cdcc6da60fcc'], |
| 395 | 'description': '', |
| 396 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 397 | 'egress_ports': ['5311c75d-d718-4369-bbda-cdcc6da60fcc'], |
| 398 | 'sfc_encap': sfc_encap, |
| 399 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 400 | 'id': 'c121ebdd-7f2d-4213-b933-3325298a6966', |
| 401 | 'name': 'osm_sfi'}]) |
| 402 | |
| 403 | @mock.patch.object(Client, 'list_port_pair') |
| 404 | def test_get_sfi_list_with_sfc_encap(self, list_port_pair): |
| 405 | self._test_get_sfi_list(list_port_pair, 'nsh', True) |
| 406 | |
| 407 | @mock.patch.object(Client, 'list_port_pair') |
| 408 | def test_get_sfi_list_without_sfc_encap(self, list_port_pair): |
| 409 | self._test_get_sfi_list(list_port_pair, None, False) |
| 410 | |
| 411 | @mock.patch.object(Client, 'list_port_pair_group') |
| 412 | def test_get_sf_list(self, list_port_pair_group): |
| 413 | # what OpenStack is assumed to return to the VIM connector |
| 414 | list_port_pair_group.return_value = {'port_pair_groups': [ |
| 415 | {'port_pairs': ['08fbdbb0-82d6-11e7-ad95-9bb52fbec2f2', |
| 416 | '0d63799c-82d6-11e7-8deb-a746bb3ae9f5'], |
| 417 | 'description': '', |
| 418 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 419 | 'port_pair_group_parameters': {}, |
| 420 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 421 | 'id': 'f4a0bde8-82d5-11e7-90e1-a72b762fa27f', |
| 422 | 'name': 'osm_sf'}]} |
| 423 | |
| 424 | # call the VIM connector |
| 425 | filter_dict = {'name': 'osm_sf', 'description': ''} |
| 426 | result = self.vimconn.get_sf_list(filter_dict.copy()) |
| 427 | |
| 428 | # assert that VIM connector called OpenStack with the expected filter |
| 429 | list_port_pair_group.assert_called_with(**filter_dict) |
| 430 | # assert that the VIM connector successfully |
| 431 | # translated and returned the OpenStack result |
| 432 | self.assertEqual(result, [ |
| 433 | {'instances': ['08fbdbb0-82d6-11e7-ad95-9bb52fbec2f2', |
| 434 | '0d63799c-82d6-11e7-8deb-a746bb3ae9f5'], |
| 435 | 'description': '', |
| 436 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 437 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 438 | 'id': 'f4a0bde8-82d5-11e7-90e1-a72b762fa27f', |
| 439 | 'name': 'osm_sf'}]) |
| 440 | |
| 441 | def _test_get_sfp_list(self, list_port_chain, correlation, sfc_encap): |
| 442 | # what OpenStack is assumed to return to the VIM connector |
| 443 | list_port_chain.return_value = {'port_chains': [ |
| 444 | {'port_pair_groups': ['7d8e3bf8-82d6-11e7-a032-8ff028839d25', |
| 445 | '7dc9013e-82d6-11e7-a5a6-a3a8d78a5518'], |
| 446 | 'flow_classifiers': ['1333c2f4-82d7-11e7-a5df-9327f33d104e', |
| 447 | '1387ab44-82d7-11e7-9bb0-476337183905'], |
| 448 | 'description': '', |
| 449 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 450 | 'chain_parameters': {'correlation': correlation}, |
| 451 | 'chain_id': 40, |
| 452 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 453 | 'id': '821bc9be-82d7-11e7-8ce3-23a08a27ab47', |
| 454 | 'name': 'osm_sfp'}]} |
| 455 | |
| 456 | # call the VIM connector |
| 457 | filter_dict = {'name': 'osm_sfp', 'description': ''} |
| 458 | result = self.vimconn.get_sfp_list(filter_dict.copy()) |
| 459 | |
| 460 | # assert that VIM connector called OpenStack with the expected filter |
| 461 | list_port_chain.assert_called_with(**filter_dict) |
| 462 | # assert that the VIM connector successfully |
| 463 | # translated and returned the OpenStack result |
| 464 | self.assertEqual(result, [ |
| 465 | {'service_functions': ['7d8e3bf8-82d6-11e7-a032-8ff028839d25', |
| 466 | '7dc9013e-82d6-11e7-a5a6-a3a8d78a5518'], |
| 467 | 'classifications': ['1333c2f4-82d7-11e7-a5df-9327f33d104e', |
| 468 | '1387ab44-82d7-11e7-9bb0-476337183905'], |
| 469 | 'description': '', |
| 470 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 471 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 472 | 'sfc_encap': sfc_encap, |
| 473 | 'spi': 40, |
| 474 | 'id': '821bc9be-82d7-11e7-8ce3-23a08a27ab47', |
| 475 | 'name': 'osm_sfp'}]) |
| 476 | |
| 477 | @mock.patch.object(Client, 'list_port_chain') |
| 478 | def test_get_sfp_list_with_sfc_encap(self, list_port_chain): |
| 479 | self._test_get_sfp_list(list_port_chain, 'nsh', True) |
| 480 | |
| 481 | @mock.patch.object(Client, 'list_port_chain') |
| 482 | def test_get_sfp_list_without_sfc_encap(self, list_port_chain): |
| 483 | self._test_get_sfp_list(list_port_chain, None, False) |
| 484 | |
| 485 | @mock.patch.object(Client, 'list_flow_classifier') |
| 486 | def test_get_classification(self, list_flow_classifier): |
| 487 | # what OpenStack is assumed to return to the VIM connector |
| 488 | list_flow_classifier.return_value = {'flow_classifiers': [ |
| 489 | {'source_port_range_min': 2000, |
| 490 | 'destination_ip_prefix': '192.168.3.0/24', |
| 491 | 'protocol': 'udp', |
| 492 | 'description': '', |
| 493 | 'ethertype': 'IPv4', |
| 494 | 'l7_parameters': {}, |
| 495 | 'source_port_range_max': 2000, |
| 496 | 'destination_port_range_min': 3000, |
| 497 | 'source_ip_prefix': '192.168.2.0/24', |
| 498 | 'logical_destination_port': None, |
| 499 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 500 | 'destination_port_range_max': None, |
| 501 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 502 | 'logical_source_port': 'aaab0ab0-1452-4636-bb3b-11dca833fa2b', |
| 503 | 'id': '22198366-d4e8-4d6b-b4d2-637d5d6cbb7d', |
| 504 | 'name': 'fc1'} |
| 505 | ]} |
| 506 | |
| 507 | # call the VIM connector |
| 508 | result = self.vimconn.get_classification( |
| 509 | '22198366-d4e8-4d6b-b4d2-637d5d6cbb7d') |
| 510 | |
| 511 | # assert that VIM connector called OpenStack with the expected filter |
| 512 | list_flow_classifier.assert_called_with( |
| 513 | id='22198366-d4e8-4d6b-b4d2-637d5d6cbb7d') |
| 514 | # assert that VIM connector successfully returned the OpenStack result |
| 515 | self.assertEqual(result, |
| 516 | {'id': '22198366-d4e8-4d6b-b4d2-637d5d6cbb7d', |
| 517 | 'name': 'fc1', |
| 518 | 'description': '', |
| 519 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 520 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 521 | 'ctype': 'legacy_flow_classifier', |
| 522 | 'definition': { |
| 523 | 'source_port_range_min': 2000, |
| 524 | 'destination_ip_prefix': '192.168.3.0/24', |
| 525 | 'protocol': 'udp', |
| 526 | 'ethertype': 'IPv4', |
| 527 | 'l7_parameters': {}, |
| 528 | 'source_port_range_max': 2000, |
| 529 | 'destination_port_range_min': 3000, |
| 530 | 'source_ip_prefix': '192.168.2.0/24', |
| 531 | 'logical_destination_port': None, |
| 532 | 'destination_port_range_max': None, |
| 533 | 'logical_source_port': |
| 534 | 'aaab0ab0-1452-4636-bb3b-11dca833fa2b'} |
| 535 | }) |
| 536 | |
| 537 | @mock.patch.object(Client, 'list_flow_classifier') |
| 538 | def test_get_classification_many_results(self, list_flow_classifier): |
| 539 | # what OpenStack is assumed to return to the VIM connector |
| 540 | list_flow_classifier.return_value = {'flow_classifiers': [ |
| 541 | {'source_port_range_min': 2000, |
| 542 | 'destination_ip_prefix': '192.168.3.0/24', |
| 543 | 'protocol': 'udp', |
| 544 | 'description': '', |
| 545 | 'ethertype': 'IPv4', |
| 546 | 'l7_parameters': {}, |
| 547 | 'source_port_range_max': 2000, |
| 548 | 'destination_port_range_min': 3000, |
| 549 | 'source_ip_prefix': '192.168.2.0/24', |
| 550 | 'logical_destination_port': None, |
| 551 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 552 | 'destination_port_range_max': None, |
| 553 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 554 | 'logical_source_port': 'aaab0ab0-1452-4636-bb3b-11dca833fa2b', |
| 555 | 'id': '22198366-d4e8-4d6b-b4d2-637d5d6cbb7d', |
| 556 | 'name': 'fc1'}, |
| 557 | {'source_port_range_min': 1000, |
| 558 | 'destination_ip_prefix': '192.168.3.0/24', |
| 559 | 'protocol': 'udp', |
| 560 | 'description': '', |
| 561 | 'ethertype': 'IPv4', |
| 562 | 'l7_parameters': {}, |
| 563 | 'source_port_range_max': 1000, |
| 564 | 'destination_port_range_min': 3000, |
| 565 | 'source_ip_prefix': '192.168.2.0/24', |
| 566 | 'logical_destination_port': None, |
| 567 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 568 | 'destination_port_range_max': None, |
| 569 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 570 | 'logical_source_port': 'aaab0ab0-1452-4636-bb3b-11dca833fa2b', |
| 571 | 'id': '3196bafc-82dd-11e7-a205-9bf6c14b0721', |
| 572 | 'name': 'fc2'} |
| 573 | ]} |
| 574 | |
| 575 | # call the VIM connector |
| 576 | self.assertRaises(vimconn.vimconnConflictException, |
| 577 | self.vimconn.get_classification, |
| 578 | '3196bafc-82dd-11e7-a205-9bf6c14b0721') |
| 579 | |
| 580 | # assert the VIM connector called OpenStack with the expected filter |
| 581 | list_flow_classifier.assert_called_with( |
| 582 | id='3196bafc-82dd-11e7-a205-9bf6c14b0721') |
| 583 | |
| 584 | @mock.patch.object(Client, 'list_flow_classifier') |
| 585 | def test_get_classification_no_results(self, list_flow_classifier): |
| 586 | # what OpenStack is assumed to return to the VIM connector |
| 587 | list_flow_classifier.return_value = {'flow_classifiers': []} |
| 588 | |
| 589 | # call the VIM connector |
| 590 | self.assertRaises(vimconn.vimconnNotFoundException, |
| 591 | self.vimconn.get_classification, |
| 592 | '3196bafc-82dd-11e7-a205-9bf6c14b0721') |
| 593 | |
| 594 | # assert the VIM connector called OpenStack with the expected filter |
| 595 | list_flow_classifier.assert_called_with( |
| 596 | id='3196bafc-82dd-11e7-a205-9bf6c14b0721') |
| 597 | |
| 598 | @mock.patch.object(Client, 'list_port_pair') |
| 599 | def test_get_sfi(self, list_port_pair): |
| 600 | # what OpenStack is assumed to return to the VIM connector |
| 601 | list_port_pair.return_value = {'port_pairs': [ |
| 602 | {'ingress': '5311c75d-d718-4369-bbda-cdcc6da60fcc', |
| 603 | 'description': '', |
| 604 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 605 | 'egress': '5311c75d-d718-4369-bbda-cdcc6da60fcc', |
| 606 | 'service_function_parameters': {'correlation': 'nsh'}, |
| 607 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 608 | 'id': 'c121ebdd-7f2d-4213-b933-3325298a6966', |
| 609 | 'name': 'osm_sfi1'}, |
| 610 | ]} |
| 611 | |
| 612 | # call the VIM connector |
| 613 | result = self.vimconn.get_sfi('c121ebdd-7f2d-4213-b933-3325298a6966') |
| 614 | |
| 615 | # assert the VIM connector called OpenStack with the expected filter |
| 616 | list_port_pair.assert_called_with( |
| 617 | id='c121ebdd-7f2d-4213-b933-3325298a6966') |
| 618 | # assert the VIM connector successfully returned the OpenStack result |
| 619 | self.assertEqual(result, |
| 620 | {'ingress_ports': [ |
| 621 | '5311c75d-d718-4369-bbda-cdcc6da60fcc'], |
| 622 | 'egress_ports': [ |
| 623 | '5311c75d-d718-4369-bbda-cdcc6da60fcc'], |
| 624 | 'sfc_encap': True, |
| 625 | 'description': '', |
| 626 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 627 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 628 | 'id': 'c121ebdd-7f2d-4213-b933-3325298a6966', |
| 629 | 'name': 'osm_sfi1'}) |
| 630 | |
| 631 | @mock.patch.object(Client, 'list_port_pair') |
| 632 | def test_get_sfi_many_results(self, list_port_pair): |
| 633 | # what OpenStack is assumed to return to the VIM connector |
| 634 | list_port_pair.return_value = {'port_pairs': [ |
| 635 | {'ingress': '5311c75d-d718-4369-bbda-cdcc6da60fcc', |
| 636 | 'description': '', |
| 637 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 638 | 'egress': '5311c75d-d718-4369-bbda-cdcc6da60fcc', |
| 639 | 'service_function_parameters': {'correlation': 'nsh'}, |
| 640 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 641 | 'id': 'c121ebdd-7f2d-4213-b933-3325298a6966', |
| 642 | 'name': 'osm_sfi1'}, |
| 643 | {'ingress': '5311c75d-d718-4369-bbda-cdcc6da60fcc', |
| 644 | 'description': '', |
| 645 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 646 | 'egress': '5311c75d-d718-4369-bbda-cdcc6da60fcc', |
| 647 | 'service_function_parameters': {'correlation': 'nsh'}, |
| 648 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 649 | 'id': 'c0436d92-82db-11e7-8f9c-5fa535f1261f', |
| 650 | 'name': 'osm_sfi2'} |
| 651 | ]} |
| 652 | |
| 653 | # call the VIM connector |
| 654 | self.assertRaises(vimconn.vimconnConflictException, |
| 655 | self.vimconn.get_sfi, |
| 656 | 'c0436d92-82db-11e7-8f9c-5fa535f1261f') |
| 657 | |
| 658 | # assert that VIM connector called OpenStack with the expected filter |
| 659 | list_port_pair.assert_called_with( |
| 660 | id='c0436d92-82db-11e7-8f9c-5fa535f1261f') |
| 661 | |
| 662 | @mock.patch.object(Client, 'list_port_pair') |
| 663 | def test_get_sfi_no_results(self, list_port_pair): |
| 664 | # what OpenStack is assumed to return to the VIM connector |
| 665 | list_port_pair.return_value = {'port_pairs': []} |
| 666 | |
| 667 | # call the VIM connector |
| 668 | self.assertRaises(vimconn.vimconnNotFoundException, |
| 669 | self.vimconn.get_sfi, |
| 670 | 'b22892fc-82d9-11e7-ae85-0fea6a3b3757') |
| 671 | |
| 672 | # assert that VIM connector called OpenStack with the expected filter |
| 673 | list_port_pair.assert_called_with( |
| 674 | id='b22892fc-82d9-11e7-ae85-0fea6a3b3757') |
| 675 | |
| 676 | @mock.patch.object(Client, 'list_port_pair_group') |
| 677 | def test_get_sf(self, list_port_pair_group): |
| 678 | # what OpenStack is assumed to return to the VIM connector |
| 679 | list_port_pair_group.return_value = {'port_pair_groups': [ |
| 680 | {'port_pairs': ['08fbdbb0-82d6-11e7-ad95-9bb52fbec2f2'], |
| 681 | 'description': '', |
| 682 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 683 | 'port_pair_group_parameters': {}, |
| 684 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 685 | 'id': 'aabba8a6-82d9-11e7-a18a-d3c7719b742d', |
| 686 | 'name': 'osm_sf1'} |
| 687 | ]} |
| 688 | |
| 689 | # call the VIM connector |
| 690 | result = self.vimconn.get_sf('b22892fc-82d9-11e7-ae85-0fea6a3b3757') |
| 691 | |
| 692 | # assert that VIM connector called OpenStack with the expected filter |
| 693 | list_port_pair_group.assert_called_with( |
| 694 | id='b22892fc-82d9-11e7-ae85-0fea6a3b3757') |
| 695 | # assert that VIM connector successfully returned the OpenStack result |
| 696 | self.assertEqual(result, |
| 697 | {'instances': [ |
| 698 | '08fbdbb0-82d6-11e7-ad95-9bb52fbec2f2'], |
| 699 | 'description': '', |
| 700 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 701 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 702 | 'id': 'aabba8a6-82d9-11e7-a18a-d3c7719b742d', |
| 703 | 'name': 'osm_sf1'}) |
| 704 | |
| 705 | @mock.patch.object(Client, 'list_port_pair_group') |
| 706 | def test_get_sf_many_results(self, list_port_pair_group): |
| 707 | # what OpenStack is assumed to return to the VIM connector |
| 708 | list_port_pair_group.return_value = {'port_pair_groups': [ |
| 709 | {'port_pairs': ['08fbdbb0-82d6-11e7-ad95-9bb52fbec2f2'], |
| 710 | 'description': '', |
| 711 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 712 | 'port_pair_group_parameters': {}, |
| 713 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 714 | 'id': 'aabba8a6-82d9-11e7-a18a-d3c7719b742d', |
| 715 | 'name': 'osm_sf1'}, |
| 716 | {'port_pairs': ['0d63799c-82d6-11e7-8deb-a746bb3ae9f5'], |
| 717 | 'description': '', |
| 718 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 719 | 'port_pair_group_parameters': {}, |
| 720 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 721 | 'id': 'b22892fc-82d9-11e7-ae85-0fea6a3b3757', |
| 722 | 'name': 'osm_sf2'} |
| 723 | ]} |
| 724 | |
| 725 | # call the VIM connector |
| 726 | self.assertRaises(vimconn.vimconnConflictException, |
| 727 | self.vimconn.get_sf, |
| 728 | 'b22892fc-82d9-11e7-ae85-0fea6a3b3757') |
| 729 | |
| 730 | # assert that VIM connector called OpenStack with the expected filter |
| 731 | list_port_pair_group.assert_called_with( |
| 732 | id='b22892fc-82d9-11e7-ae85-0fea6a3b3757') |
| 733 | |
| 734 | @mock.patch.object(Client, 'list_port_pair_group') |
| 735 | def test_get_sf_no_results(self, list_port_pair_group): |
| 736 | # what OpenStack is assumed to return to the VIM connector |
| 737 | list_port_pair_group.return_value = {'port_pair_groups': []} |
| 738 | |
| 739 | # call the VIM connector |
| 740 | self.assertRaises(vimconn.vimconnNotFoundException, |
| 741 | self.vimconn.get_sf, |
| 742 | 'b22892fc-82d9-11e7-ae85-0fea6a3b3757') |
| 743 | |
| 744 | # assert that VIM connector called OpenStack with the expected filter |
| 745 | list_port_pair_group.assert_called_with( |
| 746 | id='b22892fc-82d9-11e7-ae85-0fea6a3b3757') |
| 747 | |
| 748 | @mock.patch.object(Client, 'list_port_chain') |
| 749 | def test_get_sfp(self, list_port_chain): |
| 750 | # what OpenStack is assumed to return to the VIM connector |
| 751 | list_port_chain.return_value = {'port_chains': [ |
| 752 | {'port_pair_groups': ['7d8e3bf8-82d6-11e7-a032-8ff028839d25'], |
| 753 | 'flow_classifiers': ['1333c2f4-82d7-11e7-a5df-9327f33d104e'], |
| 754 | 'description': '', |
| 755 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 756 | 'chain_parameters': {'correlation': 'nsh'}, |
| 757 | 'chain_id': 40, |
| 758 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 759 | 'id': '821bc9be-82d7-11e7-8ce3-23a08a27ab47', |
| 760 | 'name': 'osm_sfp1'}]} |
| 761 | |
| 762 | # call the VIM connector |
| 763 | result = self.vimconn.get_sfp('821bc9be-82d7-11e7-8ce3-23a08a27ab47') |
| 764 | |
| 765 | # assert that VIM connector called OpenStack with the expected filter |
| 766 | list_port_chain.assert_called_with( |
| 767 | id='821bc9be-82d7-11e7-8ce3-23a08a27ab47') |
| 768 | # assert that VIM connector successfully returned the OpenStack result |
| 769 | self.assertEqual(result, |
| 770 | {'service_functions': [ |
| 771 | '7d8e3bf8-82d6-11e7-a032-8ff028839d25'], |
| 772 | 'classifications': [ |
| 773 | '1333c2f4-82d7-11e7-a5df-9327f33d104e'], |
| 774 | 'description': '', |
| 775 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 776 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 777 | 'sfc_encap': True, |
| 778 | 'spi': 40, |
| 779 | 'id': '821bc9be-82d7-11e7-8ce3-23a08a27ab47', |
| 780 | 'name': 'osm_sfp1'}) |
| 781 | |
| 782 | @mock.patch.object(Client, 'list_port_chain') |
| 783 | def test_get_sfp_many_results(self, list_port_chain): |
| 784 | # what OpenStack is assumed to return to the VIM connector |
| 785 | list_port_chain.return_value = {'port_chains': [ |
| 786 | {'port_pair_groups': ['7d8e3bf8-82d6-11e7-a032-8ff028839d25'], |
| 787 | 'flow_classifiers': ['1333c2f4-82d7-11e7-a5df-9327f33d104e'], |
| 788 | 'description': '', |
| 789 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 790 | 'chain_parameters': {'correlation': 'nsh'}, |
| 791 | 'chain_id': 40, |
| 792 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 793 | 'id': '821bc9be-82d7-11e7-8ce3-23a08a27ab47', |
| 794 | 'name': 'osm_sfp1'}, |
| 795 | {'port_pair_groups': ['7d8e3bf8-82d6-11e7-a032-8ff028839d25'], |
| 796 | 'flow_classifiers': ['1333c2f4-82d7-11e7-a5df-9327f33d104e'], |
| 797 | 'description': '', |
| 798 | 'tenant_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 799 | 'chain_parameters': {'correlation': 'nsh'}, |
| 800 | 'chain_id': 50, |
| 801 | 'project_id': '8f3019ef06374fa880a0144ad4bc1d7b', |
| 802 | 'id': '5d002f38-82de-11e7-a770-f303f11ce66a', |
| 803 | 'name': 'osm_sfp2'} |
| 804 | ]} |
| 805 | |
| 806 | # call the VIM connector |
| 807 | self.assertRaises(vimconn.vimconnConflictException, |
| 808 | self.vimconn.get_sfp, |
| 809 | '5d002f38-82de-11e7-a770-f303f11ce66a') |
| 810 | |
| 811 | # assert that VIM connector called OpenStack with the expected filter |
| 812 | list_port_chain.assert_called_with( |
| 813 | id='5d002f38-82de-11e7-a770-f303f11ce66a') |
| 814 | |
| 815 | @mock.patch.object(Client, 'list_port_chain') |
| 816 | def test_get_sfp_no_results(self, list_port_chain): |
| 817 | # what OpenStack is assumed to return to the VIM connector |
| 818 | list_port_chain.return_value = {'port_chains': []} |
| 819 | |
| 820 | # call the VIM connector |
| 821 | self.assertRaises(vimconn.vimconnNotFoundException, |
| 822 | self.vimconn.get_sfp, |
| 823 | '5d002f38-82de-11e7-a770-f303f11ce66a') |
| 824 | |
| 825 | # assert that VIM connector called OpenStack with the expected filter |
| 826 | list_port_chain.assert_called_with( |
| 827 | id='5d002f38-82de-11e7-a770-f303f11ce66a') |
| 828 | |
| 829 | @mock.patch.object(Client, 'delete_flow_classifier') |
| 830 | def test_delete_classification(self, delete_flow_classifier): |
| 831 | result = self.vimconn.delete_classification( |
| 832 | '638f957c-82df-11e7-b7c8-132706021464') |
| 833 | delete_flow_classifier.assert_called_with( |
| 834 | '638f957c-82df-11e7-b7c8-132706021464') |
| 835 | self.assertEqual(result, '638f957c-82df-11e7-b7c8-132706021464') |
| 836 | |
| 837 | @mock.patch.object(Client, 'delete_port_pair') |
| 838 | def test_delete_sfi(self, delete_port_pair): |
| 839 | result = self.vimconn.delete_sfi( |
| 840 | '638f957c-82df-11e7-b7c8-132706021464') |
| 841 | delete_port_pair.assert_called_with( |
| 842 | '638f957c-82df-11e7-b7c8-132706021464') |
| 843 | self.assertEqual(result, '638f957c-82df-11e7-b7c8-132706021464') |
| 844 | |
| 845 | @mock.patch.object(Client, 'delete_port_pair_group') |
| 846 | def test_delete_sf(self, delete_port_pair_group): |
| 847 | result = self.vimconn.delete_sf('638f957c-82df-11e7-b7c8-132706021464') |
| 848 | delete_port_pair_group.assert_called_with( |
| 849 | '638f957c-82df-11e7-b7c8-132706021464') |
| 850 | self.assertEqual(result, '638f957c-82df-11e7-b7c8-132706021464') |
| 851 | |
| 852 | @mock.patch.object(Client, 'delete_port_chain') |
| 853 | def test_delete_sfp(self, delete_port_chain): |
| 854 | result = self.vimconn.delete_sfp( |
| 855 | '638f957c-82df-11e7-b7c8-132706021464') |
| 856 | delete_port_chain.assert_called_with( |
| 857 | '638f957c-82df-11e7-b7c8-132706021464') |
| 858 | self.assertEqual(result, '638f957c-82df-11e7-b7c8-132706021464') |
| 859 | |
| 860 | |
| 861 | if __name__ == '__main__': |
| 862 | unittest.main() |