- @mock.patch.object(Client, "list_sfc_flow_classifiers")
- def test_get_classification_many_results(self, list_sfc_flow_classifiers):
- # what OpenStack is assumed to return to the VIM connector
- list_sfc_flow_classifiers.return_value = {
- "flow_classifiers": [
- {
- "source_port_range_min": 2000,
- "destination_ip_prefix": "192.168.3.0/24",
- "protocol": "udp",
- "description": "",
- "ethertype": "IPv4",
- "l7_parameters": {},
- "source_port_range_max": 2000,
- "destination_port_range_min": 3000,
- "source_ip_prefix": "192.168.2.0/24",
- "logical_destination_port": None,
- "tenant_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "destination_port_range_max": None,
- "project_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "logical_source_port": "aaab0ab0-1452-4636-bb3b-11dca833fa2b",
- "id": "22198366-d4e8-4d6b-b4d2-637d5d6cbb7d",
- "name": "fc1",
- },
- {
- "source_port_range_min": 1000,
- "destination_ip_prefix": "192.168.3.0/24",
- "protocol": "udp",
- "description": "",
- "ethertype": "IPv4",
- "l7_parameters": {},
- "source_port_range_max": 1000,
- "destination_port_range_min": 3000,
- "source_ip_prefix": "192.168.2.0/24",
- "logical_destination_port": None,
- "tenant_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "destination_port_range_max": None,
- "project_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "logical_source_port": "aaab0ab0-1452-4636-bb3b-11dca833fa2b",
- "id": "3196bafc-82dd-11e7-a205-9bf6c14b0721",
- "name": "fc2",
- },
- ]
- }
-
- # call the VIM connector
- self.assertRaises(
- vimconn.VimConnConflictException,
- self.vimconn.get_classification,
- "3196bafc-82dd-11e7-a205-9bf6c14b0721",
- )
-
- # assert the VIM connector called OpenStack with the expected filter
- list_sfc_flow_classifiers.assert_called_with(
- id="3196bafc-82dd-11e7-a205-9bf6c14b0721"
- )
-
- @mock.patch.object(Client, "list_sfc_flow_classifiers")
- def test_get_classification_no_results(self, list_sfc_flow_classifiers):
- # what OpenStack is assumed to return to the VIM connector
- list_sfc_flow_classifiers.return_value = {"flow_classifiers": []}
-
- # call the VIM connector
- self.assertRaises(
- vimconn.VimConnNotFoundException,
- self.vimconn.get_classification,
- "3196bafc-82dd-11e7-a205-9bf6c14b0721",
- )
-
- # assert the VIM connector called OpenStack with the expected filter
- list_sfc_flow_classifiers.assert_called_with(
- id="3196bafc-82dd-11e7-a205-9bf6c14b0721"
- )
-
- @mock.patch.object(Client, "list_sfc_port_pairs")
- def test_get_sfi(self, list_sfc_port_pairs):
- # what OpenStack is assumed to return to the VIM connector
- list_sfc_port_pairs.return_value = {
- "port_pairs": [
- {
- "ingress": "5311c75d-d718-4369-bbda-cdcc6da60fcc",
- "description": "",
- "tenant_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "egress": "5311c75d-d718-4369-bbda-cdcc6da60fcc",
- "service_function_parameters": {"correlation": "nsh"},
- "project_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "id": "c121ebdd-7f2d-4213-b933-3325298a6966",
- "name": "osm_sfi1",
- },
- ]
- }
-
- # call the VIM connector
- result = self.vimconn.get_sfi("c121ebdd-7f2d-4213-b933-3325298a6966")
-
- # assert the VIM connector called OpenStack with the expected filter
- list_sfc_port_pairs.assert_called_with(
- id="c121ebdd-7f2d-4213-b933-3325298a6966"
- )
- # assert the VIM connector successfully returned the OpenStack result
- self.assertEqual(
- result,
- {
- "ingress_ports": ["5311c75d-d718-4369-bbda-cdcc6da60fcc"],
- "egress_ports": ["5311c75d-d718-4369-bbda-cdcc6da60fcc"],
- "sfc_encap": True,
- "description": "",
- "tenant_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "project_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "id": "c121ebdd-7f2d-4213-b933-3325298a6966",
- "name": "osm_sfi1",
- },
- )
-
- @mock.patch.object(Client, "list_sfc_port_pairs")
- def test_get_sfi_many_results(self, list_sfc_port_pairs):
- # what OpenStack is assumed to return to the VIM connector
- list_sfc_port_pairs.return_value = {
- "port_pairs": [
- {
- "ingress": "5311c75d-d718-4369-bbda-cdcc6da60fcc",
- "description": "",
- "tenant_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "egress": "5311c75d-d718-4369-bbda-cdcc6da60fcc",
- "service_function_parameters": {"correlation": "nsh"},
- "project_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "id": "c121ebdd-7f2d-4213-b933-3325298a6966",
- "name": "osm_sfi1",
- },
- {
- "ingress": "5311c75d-d718-4369-bbda-cdcc6da60fcc",
- "description": "",
- "tenant_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "egress": "5311c75d-d718-4369-bbda-cdcc6da60fcc",
- "service_function_parameters": {"correlation": "nsh"},
- "project_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "id": "c0436d92-82db-11e7-8f9c-5fa535f1261f",
- "name": "osm_sfi2",
- },
- ]
- }
-
- # call the VIM connector
- self.assertRaises(
- vimconn.VimConnConflictException,
- self.vimconn.get_sfi,
- "c0436d92-82db-11e7-8f9c-5fa535f1261f",
- )
-
- # assert that VIM connector called OpenStack with the expected filter
- list_sfc_port_pairs.assert_called_with(
- id="c0436d92-82db-11e7-8f9c-5fa535f1261f"
- )
-
- @mock.patch.object(Client, "list_sfc_port_pairs")
- def test_get_sfi_no_results(self, list_sfc_port_pairs):
- # what OpenStack is assumed to return to the VIM connector
- list_sfc_port_pairs.return_value = {"port_pairs": []}
-
- # call the VIM connector
- self.assertRaises(
- vimconn.VimConnNotFoundException,
- self.vimconn.get_sfi,
- "b22892fc-82d9-11e7-ae85-0fea6a3b3757",
- )
-
- # assert that VIM connector called OpenStack with the expected filter
- list_sfc_port_pairs.assert_called_with(
- id="b22892fc-82d9-11e7-ae85-0fea6a3b3757"
- )
-
- @mock.patch.object(Client, "list_sfc_port_pair_groups")
- def test_get_sf(self, list_sfc_port_pair_groups):
- # what OpenStack is assumed to return to the VIM connector
- list_sfc_port_pair_groups.return_value = {
- "port_pair_groups": [
- {
- "port_pairs": ["08fbdbb0-82d6-11e7-ad95-9bb52fbec2f2"],
- "description": "",
- "tenant_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "port_pair_group_parameters": {},
- "project_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "id": "aabba8a6-82d9-11e7-a18a-d3c7719b742d",
- "name": "osm_sf1",
- }
- ]
- }
-
- # call the VIM connector
- result = self.vimconn.get_sf("b22892fc-82d9-11e7-ae85-0fea6a3b3757")
-
- # assert that VIM connector called OpenStack with the expected filter
- list_sfc_port_pair_groups.assert_called_with(
- id="b22892fc-82d9-11e7-ae85-0fea6a3b3757"
- )
- # assert that VIM connector successfully returned the OpenStack result
- self.assertEqual(
- result,
- {
- "description": "",
- "tenant_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "project_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "sfis": ["08fbdbb0-82d6-11e7-ad95-9bb52fbec2f2"],
- "id": "aabba8a6-82d9-11e7-a18a-d3c7719b742d",
- "name": "osm_sf1",
- },
- )
-
- @mock.patch.object(Client, "list_sfc_port_pair_groups")
- def test_get_sf_many_results(self, list_sfc_port_pair_groups):
- # what OpenStack is assumed to return to the VIM connector
- list_sfc_port_pair_groups.return_value = {
- "port_pair_groups": [
- {
- "port_pairs": ["08fbdbb0-82d6-11e7-ad95-9bb52fbec2f2"],
- "description": "",
- "tenant_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "port_pair_group_parameters": {},
- "project_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "id": "aabba8a6-82d9-11e7-a18a-d3c7719b742d",
- "name": "osm_sf1",
- },
- {
- "port_pairs": ["0d63799c-82d6-11e7-8deb-a746bb3ae9f5"],
- "description": "",
- "tenant_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "port_pair_group_parameters": {},
- "project_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "id": "b22892fc-82d9-11e7-ae85-0fea6a3b3757",
- "name": "osm_sf2",
- },
- ]
- }
-
- # call the VIM connector
- self.assertRaises(
- vimconn.VimConnConflictException,
- self.vimconn.get_sf,
- "b22892fc-82d9-11e7-ae85-0fea6a3b3757",
- )
-
- # assert that VIM connector called OpenStack with the expected filter
- list_sfc_port_pair_groups.assert_called_with(
- id="b22892fc-82d9-11e7-ae85-0fea6a3b3757"
- )
-
- @mock.patch.object(Client, "list_sfc_port_pair_groups")
- def test_get_sf_no_results(self, list_sfc_port_pair_groups):
- # what OpenStack is assumed to return to the VIM connector
- list_sfc_port_pair_groups.return_value = {"port_pair_groups": []}
-
- # call the VIM connector
- self.assertRaises(
- vimconn.VimConnNotFoundException,
- self.vimconn.get_sf,
- "b22892fc-82d9-11e7-ae85-0fea6a3b3757",
- )
-
- # assert that VIM connector called OpenStack with the expected filter
- list_sfc_port_pair_groups.assert_called_with(
- id="b22892fc-82d9-11e7-ae85-0fea6a3b3757"
- )
-
- @mock.patch.object(Client, "list_sfc_port_chains")
- def test_get_sfp(self, list_sfc_port_chains):
- # what OpenStack is assumed to return to the VIM connector
- list_sfc_port_chains.return_value = {
- "port_chains": [
- {
- "port_pair_groups": ["7d8e3bf8-82d6-11e7-a032-8ff028839d25"],
- "flow_classifiers": ["1333c2f4-82d7-11e7-a5df-9327f33d104e"],
- "description": "",
- "tenant_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "chain_parameters": {"correlation": "nsh"},
- "chain_id": 40,
- "project_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "id": "821bc9be-82d7-11e7-8ce3-23a08a27ab47",
- "name": "osm_sfp1",
- }
- ]
- }
-
- # call the VIM connector
- result = self.vimconn.get_sfp("821bc9be-82d7-11e7-8ce3-23a08a27ab47")
-
- # assert that VIM connector called OpenStack with the expected filter
- list_sfc_port_chains.assert_called_with(
- id="821bc9be-82d7-11e7-8ce3-23a08a27ab47"
- )
- # assert that VIM connector successfully returned the OpenStack result
- self.assertEqual(
- result,
- {
- "service_functions": ["7d8e3bf8-82d6-11e7-a032-8ff028839d25"],
- "classifications": ["1333c2f4-82d7-11e7-a5df-9327f33d104e"],
- "description": "",
- "tenant_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "project_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "sfc_encap": True,
- "spi": 40,
- "id": "821bc9be-82d7-11e7-8ce3-23a08a27ab47",
- "name": "osm_sfp1",
- },
- )
-
- @mock.patch.object(Client, "list_sfc_port_chains")
- def test_get_sfp_many_results(self, list_sfc_port_chains):
- # what OpenStack is assumed to return to the VIM connector
- list_sfc_port_chains.return_value = {
- "port_chains": [
- {
- "port_pair_groups": ["7d8e3bf8-82d6-11e7-a032-8ff028839d25"],
- "flow_classifiers": ["1333c2f4-82d7-11e7-a5df-9327f33d104e"],
- "description": "",
- "tenant_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "chain_parameters": {"correlation": "nsh"},
- "chain_id": 40,
- "project_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "id": "821bc9be-82d7-11e7-8ce3-23a08a27ab47",
- "name": "osm_sfp1",
- },
- {
- "port_pair_groups": ["7d8e3bf8-82d6-11e7-a032-8ff028839d25"],
- "flow_classifiers": ["1333c2f4-82d7-11e7-a5df-9327f33d104e"],
- "description": "",
- "tenant_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "chain_parameters": {"correlation": "nsh"},
- "chain_id": 50,
- "project_id": "8f3019ef06374fa880a0144ad4bc1d7b",
- "id": "5d002f38-82de-11e7-a770-f303f11ce66a",
- "name": "osm_sfp2",
- },
- ]
- }
-
- # call the VIM connector
- self.assertRaises(
- vimconn.VimConnConflictException,
- self.vimconn.get_sfp,
- "5d002f38-82de-11e7-a770-f303f11ce66a",
- )
-
- # assert that VIM connector called OpenStack with the expected filter
- list_sfc_port_chains.assert_called_with(
- id="5d002f38-82de-11e7-a770-f303f11ce66a"
- )
-
- @mock.patch.object(Client, "list_sfc_port_chains")
- def test_get_sfp_no_results(self, list_sfc_port_chains):
- # what OpenStack is assumed to return to the VIM connector
- list_sfc_port_chains.return_value = {"port_chains": []}
-
- # call the VIM connector
- self.assertRaises(
- vimconn.VimConnNotFoundException,
- self.vimconn.get_sfp,
- "5d002f38-82de-11e7-a770-f303f11ce66a",
- )
-
- # assert that VIM connector called OpenStack with the expected filter
- list_sfc_port_chains.assert_called_with(
- id="5d002f38-82de-11e7-a770-f303f11ce66a"
- )
-
- @mock.patch.object(Client, "delete_sfc_flow_classifier")
- def test_delete_classification(self, delete_sfc_flow_classifier):
- result = self.vimconn.delete_classification(
- "638f957c-82df-11e7-b7c8-132706021464"
- )
- delete_sfc_flow_classifier.assert_called_with(
- "638f957c-82df-11e7-b7c8-132706021464"
- )
- self.assertEqual(result, "638f957c-82df-11e7-b7c8-132706021464")
-
- @mock.patch.object(Client, "delete_sfc_port_pair")
- def test_delete_sfi(self, delete_sfc_port_pair):
- result = self.vimconn.delete_sfi("638f957c-82df-11e7-b7c8-132706021464")
- delete_sfc_port_pair.assert_called_with("638f957c-82df-11e7-b7c8-132706021464")
- self.assertEqual(result, "638f957c-82df-11e7-b7c8-132706021464")
-
- @mock.patch.object(Client, "delete_sfc_port_pair_group")
- def test_delete_sf(self, delete_sfc_port_pair_group):
- result = self.vimconn.delete_sf("638f957c-82df-11e7-b7c8-132706021464")
- delete_sfc_port_pair_group.assert_called_with(
- "638f957c-82df-11e7-b7c8-132706021464"
- )
- self.assertEqual(result, "638f957c-82df-11e7-b7c8-132706021464")
-
- @mock.patch.object(Client, "delete_sfc_port_chain")
- def test_delete_sfp(self, delete_sfc_port_chain):
- result = self.vimconn.delete_sfp("638f957c-82df-11e7-b7c8-132706021464")
- delete_sfc_port_chain.assert_called_with("638f957c-82df-11e7-b7c8-132706021464")
- self.assertEqual(result, "638f957c-82df-11e7-b7c8-132706021464")
-
-
-class Status:
- def __init__(self, s):