aboutsummaryrefslogtreecommitdiffstats
path: root/samples/vnf_samples/vnf_descriptors/vfw_vnf.yaml
blob: dfc0e678f42747d104086c42fb54ea9949bb90f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

vnfd:vnfd-catalog:
    vnfd:
    -   id: FWApproxVnf
        name: FWVnfSshIntel
        short-name: vFWVnf
        description: FW approximation using DPDK
        mgmt-interface:
            vdu-id: aclvnf-baremetal
            {% if user is defined %}
            user: '{{user}}'  # Value filled by vnfdgen
            {% endif %}
            {% if password is defined %}
            password: '{{password}}'  # Value filled by vnfdgen
            {% endif %}
            {% if ip is defined %}
            ip: '{{ip}}'  # Value filled by vnfdgen
            {% endif %}
            {% if host is defined %}
            host: '{{host}}'  # Value filled by vnfdgen
            {% endif %}
            {% if key_filename is defined %}
            key_filename: '{{key_filename}}'  # Value filled by vnfdgen
            {% endif %}
        vdu:
        -   id: aclvnf-baremetal
            name: aclvnf-baremetal
            description: ACL approximation using DPDK
            vm-flavor:
                vcpu-count: '4'
                memory-mb: '4096'
            routing_table: {{ routing_table }}
            nd_route_tbl: {{ nd_route_tbl }}
        benchmark:
            kpi:
                - packets_in
                - packets_fwd
                - packets_dropped
ss="k">def runner_on_failed(self, host, res, ignore_errors=False): task_error(host, res) def runner_on_ok(self, host, res): pass def runner_on_skipped(self, host, item=None): pass def runner_on_unreachable(self, host, res): pass def runner_on_no_hosts(self): pass def runner_on_async_poll(self, host, res, jid, clock): pass def runner_on_async_ok(self, host, res, jid): pass def runner_on_async_failed(self, host, res, jid): task_error(host, res) def playbook_on_start(self): pass def playbook_on_notify(self, host, handler): pass def playbook_on_no_hosts_matched(self): pass def playbook_on_no_hosts_remaining(self): pass def playbook_on_task_start(self, name, is_conditional): pass def playbook_on_vars_prompt(self, varname, private=True, prompt=None, encrypt=None, confirm=False, salt_size=None, salt=None, default=None): pass def playbook_on_setup(self): pass def playbook_on_import_for_host(self, host, imported_file): pass def playbook_on_not_import_for_host(self, host, missing_file): pass def playbook_on_play_start(self, name): pass def playbook_on_stats(self, stats): logging.info("playbook_on_stats enter") hosts = sorted(stats.processed.keys()) host_vars = self.playbook.inventory.get_variables(hosts[0]) cluster_name = host_vars['cluster_name'] failures = False unreachable = False for host in hosts: summary = stats.summarize(host) if summary['failures'] > 0: failures = True if summary['unreachable'] > 0: unreachable = True if failures or unreachable: for host in hosts: notify_host("localhost", host, "error") return for host in hosts: clusterhost_name = host + "." + cluster_name notify_host("localhost", clusterhost_name, "succ") def raise_for_status(resp): if resp.status < 200 or resp.status > 300: raise RuntimeError("%s, %s, %s" % (resp.status, resp.reason, resp.read())) def auth(conn): credential = {} credential['email'] = "admin@huawei.com" credential['password'] = "admin" url = "/api/users/token" headers = {"Content-type": "application/json", "Accept": "*/*"} conn.request("POST", url, json.dumps(credential), headers) resp = conn.getresponse() raise_for_status(resp) return json.loads(resp.read())["token"] def notify_host(compass_host, host, status): if status == "succ": body = {"ready": True} url = "/api/clusterhosts/%s/state_internal" % host elif status == "error": body = {"state": "ERROR"} host = host.strip("host") url = "/api/clusterhosts/%s/state" % host else: logging.error("notify_host: host %s with status %s is not supported" \ % (host, status)) return headers = {"Content-type": "application/json", "Accept": "*/*"} conn = httplib.HTTPConnection(compass_host, 80) token = auth(conn) headers["X-Auth-Token"] = token logging.info("host=%s,url=%s,body=%s,headers=%s" % (compass_host,url,json.dumps(body),headers)) conn.request("POST", url, json.dumps(body), headers) resp = conn.getresponse() try: raise_for_status(resp) logging.info("notify host status success!!! status=%s, body=%s" % (resp.status, resp.read())) except Exception as e: logging.error("http request failed %s" % str(e)) raise finally: conn.close() if __name__ == "__main__": if len(sys.argv) != 3: logging.error("params: host, status is need") sys.exit(1) host = sys.argv[1] status = sys.argv[2] notify_host(host, status)