From 7647465914cd12108be7654e911e4aef3f499ba1 Mon Sep 17 00:00:00 2001 From: Bob Haddleton Date: Wed, 30 Mar 2016 22:53:36 -0500 Subject: [PATCH] Fix monitoring of TOSCA VNFDs Change-Id: I428bc68bfad90a80a43ba07f1632b39a10509fa3 Implements: bp/tosca-parser-integration --- .../sample-tosca-vnfd-http-monitor.yaml | 8 +++---- .../samples/sample-tosca-vnfd-monitor.yaml | 10 ++++---- devstack/samples/tosca_openwrt.yaml | 8 +++---- .../heat/data/test_tosca_flavor.yaml | 6 ++--- .../test_tosca_flavor_and_capabilities.yaml | 6 ++--- .../heat/data/test_tosca_flavor_defaults.yaml | 6 ++--- .../heat/data/test_tosca_flavor_no_units.yaml | 6 ++--- .../heat/data/test_tosca_image.yaml | 6 ++--- .../heat/data/test_tosca_openwrt.yaml | 17 +++----------- .../data/tosca_flavor_all_numa_count.yaml | 6 ++--- .../data/tosca_flavor_all_numa_nodes.yaml | 6 ++--- .../data/tosca_flavor_cpu_allocations.yaml | 6 ++--- .../heat/data/tosca_flavor_huge_pages.yaml | 6 ++--- .../heat/data/tosca_flavor_numa_nodes.yaml | 6 ++--- .../data/tosca_flavor_numa_nodes_count.yaml | 6 ++--- .../heat/data/tosca_mgmt_sriov.yaml | 8 +++---- .../infra_drivers/heat/data/tosca_sriov.yaml | 8 +++---- .../heat/data/tosca_vnic_port.yaml | 8 +++---- .../unit/vm/infra_drivers/heat/test_heat.py | 9 ++++---- tacker/tests/unit/vm/test_toscautils.py | 12 ++++++---- tacker/vm/infra_drivers/heat/heat.py | 5 ++-- tacker/vm/tosca/lib/tacker_defs.yaml | 23 ++++++++++++++----- tacker/vm/tosca/lib/tacker_nfv_defs.yaml | 3 ++- tacker/vm/tosca/utils.py | 6 ++++- 24 files changed, 100 insertions(+), 91 deletions(-) diff --git a/devstack/samples/sample-tosca-vnfd-http-monitor.yaml b/devstack/samples/sample-tosca-vnfd-http-monitor.yaml index 0a622ce23..89a92c961 100644 --- a/devstack/samples/sample-tosca-vnfd-http-monitor.yaml +++ b/devstack/samples/sample-tosca-vnfd-http-monitor.yaml @@ -20,11 +20,11 @@ topology_template: monitoring_policy: name: http_ping parameters: - retry: "5" - timeout: "10" - port: "8000" + retry: 5 + timeout: 10 + port: 8000 actions: - - {trigger: failure, action: respawn} + failure: respawn CP1: type: tosca.nodes.nfv.CP.Tacker diff --git a/devstack/samples/sample-tosca-vnfd-monitor.yaml b/devstack/samples/sample-tosca-vnfd-monitor.yaml index 9815d1194..22808ca57 100644 --- a/devstack/samples/sample-tosca-vnfd-monitor.yaml +++ b/devstack/samples/sample-tosca-vnfd-monitor.yaml @@ -20,12 +20,12 @@ topology_template: monitoring_policy: name: ping parameters: - monitoring_delay: "45" - count: "3" - interval: "0.5" - timeout: "2" + monitoring_delay: 45 + count: 3 + interval: 1 + timeout: 2 actions: - - {trigger: failure, action: respawn} + failure: respawn CP1: type: tosca.nodes.nfv.CP.Tacker diff --git a/devstack/samples/tosca_openwrt.yaml b/devstack/samples/tosca_openwrt.yaml index 9ff275fbc..74b4924f2 100644 --- a/devstack/samples/tosca_openwrt.yaml +++ b/devstack/samples/tosca_openwrt.yaml @@ -19,11 +19,11 @@ topology_template: mgmt_driver: openwrt monitoring_policy: name: ping - actions: - - {trigger: failure, action: respawn} parameters: - count: "3" - interval: "10" + count: 3 + interval: 10 + actions: + failure: respawn CP1: type: tosca.nodes.nfv.CP.Tacker diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor.yaml index 8ec4bfa5c..4f2197ee3 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor.yaml @@ -22,10 +22,10 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" + count: 3 + interval: 10 CP1: type: tosca.nodes.nfv.CP.Tacker diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor_and_capabilities.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor_and_capabilities.yaml index e5fbb0244..28b864457 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor_and_capabilities.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor_and_capabilities.yaml @@ -23,10 +23,10 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" + count: 3 + interval: 10 CP1: type: tosca.nodes.nfv.CP.Tacker properties: diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor_defaults.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor_defaults.yaml index 934c3924c..88d616452 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor_defaults.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor_defaults.yaml @@ -20,10 +20,10 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" + count: 3 + interval: 10 CP1: type: tosca.nodes.nfv.CP.Tacker properties: diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor_no_units.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor_no_units.yaml index f650b7169..4954cf186 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor_no_units.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_flavor_no_units.yaml @@ -22,10 +22,10 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" + count: 3 + interval: 10 CP1: type: tosca.nodes.nfv.CP.Tacker properties: diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_image.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_image.yaml index 1603c8938..023060ce9 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_image.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_image.yaml @@ -20,10 +20,10 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" + count: 3 + interval: 10 CP1: type: tosca.nodes.nfv.CP.Tacker diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_openwrt.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_openwrt.yaml index 70ec23e86..b869457d6 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_openwrt.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/test_tosca_openwrt.yaml @@ -20,10 +20,10 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" + count: 3 + interval: 10 CP1: type: tosca.nodes.nfv.CP.Tacker @@ -42,14 +42,3 @@ topology_template: network_name: existing_network_1 vendor: ACME -# policies: -# - monitor_policy: -# type: tosca.policies.tacker.Monitoring.Ping -# description: Apply monitoring policy to VDUs -# targets: [ VDU1 ] -# properties: -# parameters: -# count: "3" -# interval: "10" -# actions: -# - {trigger: failure, action: respawn} diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_all_numa_count.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_all_numa_count.yaml index 460599872..ecac354c6 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_all_numa_count.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_all_numa_count.yaml @@ -30,7 +30,7 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" \ No newline at end of file + count: 3 + interval: 10 diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_all_numa_nodes.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_all_numa_nodes.yaml index 32bdbafc3..3d2f4b0e5 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_all_numa_nodes.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_all_numa_nodes.yaml @@ -38,7 +38,7 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" \ No newline at end of file + count: 3 + interval: 10 diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_cpu_allocations.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_cpu_allocations.yaml index f7921bac6..578fed47e 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_cpu_allocations.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_cpu_allocations.yaml @@ -28,7 +28,7 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" \ No newline at end of file + count: 3 + interval: 10 diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_huge_pages.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_huge_pages.yaml index 18f6bac37..b5f8b49e6 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_huge_pages.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_huge_pages.yaml @@ -23,7 +23,7 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" \ No newline at end of file + count: 3 + interval: 10 diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_numa_nodes.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_numa_nodes.yaml index 567c178a4..8beba4ec7 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_numa_nodes.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_numa_nodes.yaml @@ -31,7 +31,7 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" \ No newline at end of file + count: 3 + interval: 10 diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_numa_nodes_count.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_numa_nodes_count.yaml index fa887c323..44cbf4ce6 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_numa_nodes_count.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_flavor_numa_nodes_count.yaml @@ -32,7 +32,7 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" \ No newline at end of file + count: 3 + interval: 10 diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_mgmt_sriov.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_mgmt_sriov.yaml index c4c324f2b..64dd65757 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_mgmt_sriov.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_mgmt_sriov.yaml @@ -17,10 +17,10 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" + count: 3 + interval: 10 config: | param0: key1 param1: key2 @@ -54,4 +54,4 @@ topology_template: type: tosca.nodes.nfv.VL properties: network_name: net0 - vendor: Tacker \ No newline at end of file + vendor: Tacker diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_sriov.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_sriov.yaml index 4a04a163c..42762481d 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_sriov.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_sriov.yaml @@ -17,10 +17,10 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" + count: 3 + interval: 10 config: | param0: key1 param1: key2 @@ -55,4 +55,4 @@ topology_template: type: tosca.nodes.nfv.VL properties: network_name: sr3010 - vendor: Tacker \ No newline at end of file + vendor: Tacker diff --git a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_vnic_port.yaml b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_vnic_port.yaml index a21c42cae..1b43cd6d0 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_vnic_port.yaml +++ b/tacker/tests/unit/vm/infra_drivers/heat/data/tosca_vnic_port.yaml @@ -17,10 +17,10 @@ topology_template: monitoring_policy: name: ping actions: - - {trigger: failure, action: respawn} + failure: respawn parameters: - count: "3" - interval: "10" + count: 3 + interval: 10 config: | param0: key1 param1: key2 @@ -55,4 +55,4 @@ topology_template: type: tosca.nodes.nfv.VL properties: network_name: net0 - vendor: Tacker \ No newline at end of file + vendor: Tacker diff --git a/tacker/tests/unit/vm/infra_drivers/heat/test_heat.py b/tacker/tests/unit/vm/infra_drivers/heat/test_heat.py index 0278bf9cf..8cf2eff8f 100644 --- a/tacker/tests/unit/vm/infra_drivers/heat/test_heat.py +++ b/tacker/tests/unit/vm/infra_drivers/heat/test_heat.py @@ -217,10 +217,11 @@ class TestDeviceHeat(base.TestCase): 'description': u'OpenWRT with services', 'attributes': {'heat_template': tosca_hw_dict, 'monitoring_policy': '{"vdus": {"VDU1":' - ' {"name": "ping", "actions": [{"trigger":' - ' "failure", "action": "respawn"}],' - ' "parameters": {"count": "3", "interval": "10"' - '}}}}', + ' {"ping": {"name": "ping",' + ' "actions": {"failure": "respawn"},' + ' "parameters": {"count": 3, "interval": 10' + '}, "monitoring_params": {"count": 3, ' + '"interval": 10}}}}}', 'param_values': ''}, 'id': 'eb84260e-5ff7-4332-b032-50a14d6c1123', 'instance_id': None, 'mgmt_url': None, 'name': u'test_openwrt', diff --git a/tacker/tests/unit/vm/test_toscautils.py b/tacker/tests/unit/vm/test_toscautils.py index 5ba346d31..bec96a64b 100644 --- a/tacker/tests/unit/vm/test_toscautils.py +++ b/tacker/tests/unit/vm/test_toscautils.py @@ -53,12 +53,14 @@ class TestToscaUtils(testtools.TestCase): self.assertEqual(mgmt_driver, expected_mgmt_driver) def test_get_vdu_monitoring(self): - expected_monitoring = {'vdus': {'VDU1': {'actions': - [{'action': 'respawn', - 'trigger': 'failure'}], + expected_monitoring = {'vdus': {'VDU1': {'ping': { + 'actions': + {'failure': 'respawn'}, 'name': 'ping', - 'parameters': {'count': '3', - 'interval': '10'}}}} + 'parameters': {'count': 3, + 'interval': 10}, + 'monitoring_params': {'count': 3, + 'interval': 10}}}}} monitoring = toscautils.get_vdu_monitoring(self.tosca) self.assertEqual(monitoring, expected_monitoring) diff --git a/tacker/vm/infra_drivers/heat/heat.py b/tacker/vm/infra_drivers/heat/heat.py index c3dc354c6..2114d89ba 100644 --- a/tacker/vm/infra_drivers/heat/heat.py +++ b/tacker/vm/infra_drivers/heat/heat.py @@ -109,8 +109,9 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver): device_template_dict['description'] == ''): device_template_dict['description'] = vnfd_dict.get( 'description', '') - if (('name' not in device_template_dict or not - len(device_template_dict['name'])) and ('metadata' in vnfd_dict)): + if (('name' not in device_template_dict or + not len(device_template_dict['name'])) and + 'metadata' in vnfd_dict): device_template_dict['name'] = vnfd_dict['metadata'].get( 'template_name', '') diff --git a/tacker/vm/tosca/lib/tacker_defs.yaml b/tacker/vm/tosca/lib/tacker_defs.yaml index 0ef7b07e8..da03c9a89 100644 --- a/tacker/vm/tosca/lib/tacker_defs.yaml +++ b/tacker/vm/tosca/lib/tacker_defs.yaml @@ -12,19 +12,30 @@ data_types: entry_schema: type: string + tosca.datatypes.tacker.MonitoringParams: + properties: + monitoring_delay: + type: int + count: + type: int + interval: + type: int + timeout: + type: int + retry: + type: int + port: + type: int + tosca.datatypes.tacker.MonitoringType: properties: name: type: string required: true actions: - type: list - entry_schema: - type: tosca.datatypes.tacker.ActionMap - parameters: type: map - entry_schema: - type: string + parameters: + type: tosca.datatypes.tacker.MonitoringParams tosca.datatypes.compute_properties: properties: diff --git a/tacker/vm/tosca/lib/tacker_nfv_defs.yaml b/tacker/vm/tosca/lib/tacker_nfv_defs.yaml index 178509353..6e263a688 100644 --- a/tacker/vm/tosca/lib/tacker_nfv_defs.yaml +++ b/tacker/vm/tosca/lib/tacker_nfv_defs.yaml @@ -26,7 +26,8 @@ node_types: monitoring_policy: # type: tosca.policies.tacker.Monitoring - type: tosca.datatypes.tacker.MonitoringType +# type: tosca.datatypes.tacker.MonitoringType + type: map config: type: string diff --git a/tacker/vm/tosca/utils.py b/tacker/vm/tosca/utils.py index 635bf02e2..7e1d33f68 100644 --- a/tacker/vm/tosca/utils.py +++ b/tacker/vm/tosca/utils.py @@ -106,7 +106,11 @@ def get_vdu_monitoring(template): # mon_data = {mon_policy['name']: {'actions': {'failure': # 'respawn'}}} if mon_policy != 'noop': - monitoring_dict['vdus'][nt.name] = mon_policy + if 'parameters' in mon_policy: + mon_policy['monitoring_params'] = mon_policy['parameters'] + monitoring_dict['vdus'][nt.name] = {} + monitoring_dict['vdus'][nt.name][mon_policy['name']] = \ + mon_policy return monitoring_dict