+class TestDeployHackfest3Charmed3(TestDeployHackfest3Charmed):
+ description = "Load and deploy Hackfest 3charmed_ns example modified version to test scaling and NS parameters"
+
+ def __init__(self):
+ super().__init__()
+ self.test_name = "HACKFEST3v3-"
+ self.commands = {'1': ['ls -lrt /home/ubuntu/first-touch-1'], '2': ['ls -lrt /home/ubuntu/first-touch-2']}
+ self.descriptor_edit = {
+ "vnfd0": yaml.load(
+ """
+ scaling-group-descriptor:
+ - name: "scale_dataVM"
+ max-instance-count: 10
+ scaling-policy:
+ - name: "auto_cpu_util_above_threshold"
+ scaling-type: "automatic"
+ threshold-time: 0
+ cooldown-time: 60
+ scaling-criteria:
+ - name: "cpu_util_above_threshold"
+ scale-in-threshold: 15
+ scale-in-relational-operation: "LE"
+ scale-out-threshold: 60
+ scale-out-relational-operation: "GE"
+ vnf-monitoring-param-ref: "monitor1"
+ vdu:
+ - vdu-id-ref: dataVM
+ count: 1
+ scaling-config-action:
+ - trigger: post-scale-out
+ vnf-config-primitive-name-ref: touch
+ - trigger: pre-scale-in
+ vnf-config-primitive-name-ref: touch
+ vdu:
+ "$id: dataVM":
+ monitoring-param:
+ - id: "dataVM_cpu_util"
+ nfvi-metric: "cpu_utilization"
+
+ monitoring-param:
+ - id: "monitor1"
+ name: "monitor1"
+ aggregation-type: AVERAGE
+ vdu-monitoring-param:
+ vdu-ref: "dataVM"
+ vdu-monitoring-param-ref: "dataVM_cpu_util"
+ vnf-configuration:
+ initial-config-primitive:
+ "$[1]":
+ parameter:
+ "$[0]":
+ value: "<touch-filename>" # default-value: /home/ubuntu/first-touch
+ config-primitive:
+ "$[0]":
+ parameter:
+ "$[0]":
+ default-value: "<touch-filename2>"
+ """)
+ }
+ self.ns_params = {
+ "additionalParamsForVnf": [
+ {"member-vnf-index": "1", "additionalParams": {"touch-filename": "/home/ubuntu/first-touch-1",
+ "touch-filename2": "/home/ubuntu/second-touch-1"}},
+ {"member-vnf-index": "2", "additionalParams": {"touch-filename": "/home/ubuntu/first-touch-2",
+ "touch-filename2": "/home/ubuntu/second-touch-2"}},
+ ]
+ }
+
+ def additional_operations(self, engine, test_osm, manual_check):
+ super().additional_operations(engine, test_osm, manual_check)
+ if not test_osm:
+ return
+
+ # 2 perform scale out
+ payload = '{scaleType: SCALE_VNF, scaleVnfData: {scaleVnfType: SCALE_OUT, scaleByStepData: ' \
+ '{scaling-group-descriptor: scale_dataVM, member-vnf-index: "1"}}}'
+ engine.test("Execute scale action over NS", "POST",
+ "/nslcm/v1/ns_instances/{}/scale".format(self.ns_id), headers_yaml, payload,
+ 201, r_headers_yaml_location_nslcmop, "yaml")
+ nslcmop2_scale_out = engine.last_id
+ engine.wait_operation_ready("ns", nslcmop2_scale_out, timeout_deploy)
+ if manual_check:
+ input('NS scale out done. Check that file /home/ubuntu/second-touch-1 is present and new VM is created')
+ if test_osm:
+ commands = {'1': ['ls -lrt /home/ubuntu/second-touch-1', ]}
+ self.test_ns(engine, test_osm, commands=commands)
+ # TODO check automatic connection to scaled VM
+
+ # 2 perform scale in
+ payload = '{scaleType: SCALE_VNF, scaleVnfData: {scaleVnfType: SCALE_IN, scaleByStepData: ' \
+ '{scaling-group-descriptor: scale_dataVM, member-vnf-index: "1"}}}'
+ engine.test("Execute scale action over NS", "POST",
+ "/nslcm/v1/ns_instances/{}/scale".format(self.ns_id), headers_yaml, payload,
+ 201, r_headers_yaml_location_nslcmop, "yaml")
+ nslcmop2_scale_in = engine.last_id
+ engine.wait_operation_ready("ns", nslcmop2_scale_in, timeout_deploy)
+ if manual_check:
+ input('NS scale in done. Check that file /home/ubuntu/second-touch-1 is updated and new VM is deleted')
+ # TODO check automatic
+
+
+class TestDeploySimpleCharm(TestDeploy):
+ description = "Deploy hackfest-4 hackfest_simplecharm example"
+
+ def __init__(self):
+ super().__init__()
+ self.test_name = "HACKFEST-SIMPLE"
+ self.descriptor_url = "https://osm-download.etsi.org/ftp/osm-4.0-four/4th-hackfest/packages/"
+ self.vnfd_filenames = ("hackfest_simplecharm_vnf.tar.gz",)
+ self.nsd_filename = "hackfest_simplecharm_ns.tar.gz"
+ self.uses_configuration = True
+ self.commands = {'1': [''], '2': ['ls -lrt /home/ubuntu/first-touch', ]}
+ self.users = {'1': "ubuntu", '2': "ubuntu"}
+ self.passwords = {'1': "osm4u", '2': "osm4u"}
+
+
+class TestDeploySimpleCharm2(TestDeploySimpleCharm):
+ description = "Deploy hackfest-4 hackfest_simplecharm example changing naming to contain dots on ids and " \
+ "vnf-member-index"
+
+ def __init__(self):
+ super().__init__()
+ self.test_name = "HACKFEST-SIMPLE2-"
+ self.qforce = "?FORCE=True"
+ self.descriptor_edit = {
+ "vnfd0": {
+ "id": "hackfest.simplecharm.vnf"
+ },
+
+ "nsd": {
+ "id": "hackfest.simplecharm.ns",
+ "constituent-vnfd": {
+ "$[0]": {"vnfd-id-ref": "hackfest.simplecharm.vnf", "member-vnf-index": "$1"},
+ "$[1]": {"vnfd-id-ref": "hackfest.simplecharm.vnf", "member-vnf-index": "$2"},
+ },
+ "vld": {
+ "$[0]": {
+ "vnfd-connection-point-ref": {"$[0]": {"member-vnf-index-ref": "$1",
+ "vnfd-id-ref": "hackfest.simplecharm.vnf"},
+ "$[1]": {"member-vnf-index-ref": "$2",
+ "vnfd-id-ref": "hackfest.simplecharm.vnf"}},
+ },
+ "$[1]": {
+ "vnfd-connection-point-ref": {"$[0]": {"member-vnf-index-ref": "$1",
+ "vnfd-id-ref": "hackfest.simplecharm.vnf"},
+ "$[1]": {"member-vnf-index-ref": "$2",
+ "vnfd-id-ref": "hackfest.simplecharm.vnf"}},
+ },
+ }
+ }
+ }
+
+