nsd:vendor: RIFT.io
nsd:version: '1.0'
nsd:description: RIFT.io sample ping pong network service
- nsd:config-parameter-map:
- - nsd:config-parameter-request:
- nsd:config-parameter-request-ref: pong_ip
- nsd:member-vnf-index-ref: '1'
- nsd:config-parameter-source:
- nsd:config-parameter-source-ref: service_ip
- nsd:member-vnf-index-ref: '2'
- nsd:id: '1'
- - nsd:config-parameter-request:
- nsd:config-parameter-request-ref: pong_port
- nsd:member-vnf-index-ref: '1'
- nsd:config-parameter-source:
- nsd:config-parameter-source-ref: service_port
- nsd:member-vnf-index-ref: '2'
- nsd:id: '2'
nsd:constituent-vnfd:
- nsd:member-vnf-index: '1'
nsd:vnfd-id-ref: rift_ping_vnf
nsd:initial-config-primitive:
- nsd:name: start traffic
nsd:parameter:
- - nsd:name: userid
- nsd:value: rift
+ - nsd:name: port
+ nsd:value: 5555
nsd:seq: '1'
nsd:user-defined-script: start_traffic.py
nsd:input-parameter-xpath:
def start_traffic(yaml_cfg, logger):
'''Use curl and set admin status to enable on pong and ping vnfs'''
- def enable_service(mgmt_ip, port, vnf_type):
- curl_cmd = 'curl -D /dev/stdout -H "Accept: application/vnd.yang.data' \
+ curl_fmt = 'curl -D /dev/stdout -H "Accept: application/vnd.yang.data' \
'+xml" -H "Content-Type: application/vnd.yang.data+json" ' \
- '-X POST -d "{{\\"enable\\":true}}" http://{mgmt_ip}:' \
- '{mgmt_port}/api/v1/{vnf_type}/adminstatus/state'. \
- format(
- mgmt_ip=mgmt_ip,
- mgmt_port=port,
- vnf_type=vnf_type)
+ '-X POST -d "{{ {data} }}" http://{mgmt_ip}:' \
+ '{mgmt_port}/api/v1/{vnf_type}/{url}'
+
+ def setup_service(mgmt_ip, port, vnf_type, service_ip, service_port):
+ data = '\\"ip\\":\\"{}\\", \\"port\\":5555'.format(service_ip)
+ curl_cmd = curl_fmt.format(
+ mgmt_ip=mgmt_ip,
+ mgmt_port=port,
+ vnf_type=vnf_type,
+ data=data,
+ url='server'
+ )
+
+ logger.debug("Executing cmd: %s", curl_cmd)
+ proc = subprocess.run(curl_cmd, shell=True,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+
+ logger.debug("Process: {}".format(proc))
+
+ return proc.returncode
+
+ def enable_service(mgmt_ip, port, vnf_type):
+ curl_cmd = curl_fmt.format(
+ mgmt_ip=mgmt_ip,
+ mgmt_port=port,
+ vnf_type=vnf_type,
+ data='\\"enable\\":true',
+ url='adminstatus/state'
+ )
logger.debug("Executing cmd: %s", curl_cmd)
proc = subprocess.run(curl_cmd, shell=True,
return proc.returncode
+ # Get port from user parameter
+ service_port = yaml_cfg['parameter']['port']
+
+ service_ip = None
# Enable pong service first
for index, vnfr in yaml_cfg['vnfr'].items():
logger.debug("VNFR {}: {}".format(index, vnfr))
+ def get_cp_ip(cp_name):
+ for cp in vnfr['connection_point']:
+ if cp['name'].endswith(cp_name):
+ return cp['ip_address']
+
# Check if it is pong vnf
if 'pong_vnf' in vnfr['name']:
vnf_type = 'pong'
- port = 18889
- rc = enable_service(vnfr['mgmt_ip_address'], port, vnf_type)
+ mgmt_ip = vnfr['mgmt_ip_address']
+ port = vnfr['mgmt_port']
+ service_ip = get_cp_ip('cp1')
+
+ max_tries = 60
+ tries = 0
+ while tries < max_tries:
+ rc = setup_service(mgmt_ip, port, vnf_type, service_ip, service_port)
+ tries += 1
+ if rc != 0:
+ logger.error("Setup service for pong failed ({}): {}".
+ format(tries, rc))
+ if rc != 7:
+ return rc
+ else:
+ time.sleep(1) # Sleep for 1 seconds
+
+ rc = enable_service(mgmt_ip, port, vnf_type)
if rc != 0:
logger.error("Enable service for pong failed: {}".
format(rc))
# Check if it is pong vnf
if 'ping_vnf' in vnfr['name']:
vnf_type = 'ping'
- port = 18888
- rc = enable_service(vnfr['mgmt_ip_address'], port, vnf_type)
+ mgmt_ip = vnfr['mgmt_ip_address']
+ port = vnfr['mgmt_port']
+ if service_ip is None:
+ logger.error("Did not find pong ip!!")
+ return 1
+
+ max_tries = 30
+ tries = 0
+ while tries < max_tries:
+ rc = setup_service(mgmt_ip, port, vnf_type, service_ip, service_port)
+ tries += 1
+ if rc != 0:
+ logger.error("Setup service for ping failed ({}): {}".
+ format(tries, rc))
+ if rc != 7:
+ return rc
+ else:
+ time.sleep(1) # Sleep for 1 seconds
+
+ rc = enable_service(mgmt_ip, port, vnf_type)
+ if rc != 0:
+ logger.error("Enable service for ping failed: {}".
+ format(rc))
break
return rc
vnfd:vnfd-catalog:
vnfd:vnfd:
- - vnfd:id: rift_ping_vnf
- vnfd:name: ping_vnf
- vnfd:short-name: ping_vnf
- vnfd:logo: rift_logo.png
- vnfd:vendor: RIFT.io
- vnfd:version: '1.0'
- vnfd:description: This is an example RIFT.ware VNF
- vnfd:config-parameter:
- vnfd:config-parameter-request:
- - vnfd:description: IP on which Pong service is listening
- vnfd:name: pong_ip
- vnfd:parameter:
- - vnfd:config-primitive-name-ref: set-server
- vnfd:config-primitive-parameter-ref: server-ip
- - vnfd:description: Port on which Pong service is listening
- vnfd:name: pong_port
- vnfd:parameter:
- - vnfd:config-primitive-name-ref: set-server
- vnfd:config-primitive-parameter-ref: server-port
- vnfd:config-parameter-source:
- - vnfd:attribute: ../../../mgmt-interface, ip-address
- vnfd:description: Management IP address
- vnfd:name: mgmt_ip
- vnfd:parameter:
- - vnfd:config-primitive-name-ref: config
- vnfd:config-primitive-parameter-ref: ssh-hostname
- - vnfd:description: SSH username
- vnfd:name: username
- vnfd:parameter:
- - vnfd:config-primitive-name-ref: config
- vnfd:config-primitive-parameter-ref: ssh-username
- vnfd:value: fedora
- - vnfd:attribute: ../../../mgmt-interface/ssh-key, private-key-file
- vnfd:description: SSH private key file
- vnfd:name: ssh_key
- vnfd:parameter:
- - vnfd:config-primitive-name-ref: config
- vnfd:config-primitive-parameter-ref: ssh-private-key
- - vnfd:description: Rate of packet generation
- vnfd:name: rate
- vnfd:parameter:
- - vnfd:config-primitive-name-ref: set-rate
- vnfd:config-primitive-parameter-ref: rate
- vnfd:value: '5'
- vnfd:connection-point:
- - vnfd:name: ping_vnfd/cp0
- vnfd:type: VPORT
- - vnfd:name: ping_vnfd/cp1
- vnfd:type: VPORT
- vnfd:http-endpoint:
- - vnfd:path: api/v1/ping/stats
- vnfd:polling_interval_secs: '2'
- vnfd:port: '18888'
- vnfd:mgmt-interface:
- vnfd:dashboard-params:
- vnfd:path: api/v1/ping/stats
- vnfd:port: '18888'
- vnfd:port: '18888'
- rw-vnfd:ssh-key: 'true'
- vnfd:vdu-id: iovdu_0
- vnfd:monitoring-param:
- - vnfd:description: no of ping requests
- vnfd:group-tag: Group1
- vnfd:http-endpoint-ref: api/v1/ping/stats
- vnfd:id: '1'
- vnfd:json-query-method: NAMEKEY
- vnfd:name: ping-request-tx-count
- vnfd:units: packets
- vnfd:value-type: INT
- vnfd:widget-type: COUNTER
- - vnfd:description: no of ping responses
- vnfd:group-tag: Group1
- vnfd:http-endpoint-ref: api/v1/ping/stats
- vnfd:id: '2'
- vnfd:json-query-method: NAMEKEY
- vnfd:name: ping-response-rx-count
- vnfd:units: packets
- vnfd:value-type: INT
- vnfd:widget-type: COUNTER
- vnfd:placement-groups:
- - vnfd:member-vdus:
- - vnfd:member-vdu-ref: iovdu_0
- vnfd:name: Eris
- vnfd:requirement: Place this VM on the Kuiper belt object Eris
- vnfd:strategy: COLOCATION
- vnfd:vdu:
- - vnfd:count: '1'
- vnfd:external-interface:
- - vnfd:name: eth0
- vnfd:virtual-interface:
- vnfd:type: VIRTIO
- vnfd:vnfd-connection-point-ref: ping_vnfd/cp0
- - vnfd:name: eth1
- vnfd:virtual-interface:
- vnfd:type: VIRTIO
- vnfd:vnfd-connection-point-ref: ping_vnfd/cp1
- vnfd:id: iovdu_0
- vnfd:image: Fedora-x86_64-20-20131211.1-sda-ping.qcow2
- vnfd:image-checksum: a6ffaa77f949a9e4ebb082c6147187cf
- vnfd:name: iovdu_0
- vnfd:vm-flavor:
- vnfd:memory-mb: '512'
- vnfd:storage-gb: '4'
- vnfd:vcpu-count: '1'
- vnfd:vnf-configuration:
- vnfd:config-primitive:
- - vnfd:name: start
- - vnfd:name: stop
- - vnfd:name: restart
- - vnfd:name: config
- vnfd:parameter:
- - vnfd:data-type: STRING
- vnfd:name: ssh-hostname
- - vnfd:data-type: STRING
- vnfd:name: ssh-username
- - vnfd:data-type: STRING
- vnfd:name: ssh-private-key
- - vnfd:data-type: STRING
- vnfd:default-value: ping
- vnfd:name: mode
- vnfd:read-only: 'true'
- - vnfd:name: set-server
- vnfd:parameter:
- - vnfd:data-type: STRING
- vnfd:name: server-ip
- - vnfd:data-type: INTEGER
- vnfd:name: server-port
- - vnfd:name: set-rate
- vnfd:parameter:
- - vnfd:data-type: INTEGER
- vnfd:default-value: '5'
- vnfd:name: rate
- - vnfd:name: start-traffic
- - vnfd:name: stop-traffic
- vnfd:initial-config-primitive:
- - vnfd:config-primitive-ref: config
- vnfd:seq: '1'
- - vnfd:config-primitive-ref: start
- vnfd:seq: '2'
- - vnfd:config-primitive-ref: set-server
- vnfd:seq: '3'
- - vnfd:config-primitive-ref: set-rate
- vnfd:seq: '4'
- vnfd:juju:
- vnfd:charm: pingpong
+ - id: rift_ping_vnf
+ name: ping_vnf
+ short-name: ping_vnf
+ logo: rift_logo.png
+ vendor: RIFT.io
+ version: '1.0'
+ description: This is an example RIFT.ware VNF
+ connection-point:
+ - name: ping_vnfd/cp0
+ type: VPORT
+ - name: ping_vnfd/cp1
+ type: VPORT
+ http-endpoint:
+ - path: api/v1/ping/stats
+ polling_interval_secs: '2'
+ port: '18888'
+ mgmt-interface:
+ dashboard-params:
+ path: api/v1/ping/stats
+ port: '18888'
+ port: '18888'
+ vdu-id: iovdu_0
+ placement-groups:
+ - member-vdus:
+ - member-vdu-ref: iovdu_0
+ name: Eris
+ requirement: Place this VM on the Kuiper belt object Eris
+ strategy: COLOCATION
+ vdu:
+ - cloud-init-file: ping_cloud_init.cfg
+ count: '1'
+ external-interface:
+ - name: eth0
+ virtual-interface:
+ type: VIRTIO
+ vnfd-connection-point-ref: ping_vnfd/cp0
+ - name: eth1
+ virtual-interface:
+ type: VIRTIO
+ vnfd-connection-point-ref: ping_vnfd/cp1
+ id: iovdu_0
+ image: Fedora-x86_64-20-20131211.1-sda-ping.qcow2
+ image-checksum: a6ffaa77f949a9e4ebb082c6147187cf
+ name: iovdu_0
+ vm-flavor:
+ memory-mb: '512'
+ storage-gb: '4'
+ vcpu-count: '1'
+ vnf-configuration:
+ config-attributes:
+ config-delay: 10
+ service-primitive:
+ - name: start
+ - name: stop
+ - name: restart
+ - name: config
+ parameter:
+ - data-type: STRING
+ default-value: <rw_mgmt_ip>
+ name: ssh-hostname
+ - data-type: STRING
+ default-value: fedora
+ name: ssh-username
+ - data-type: STRING
+ default-value: fedora
+ name: ssh-password
+ - data-type: STRING
+ name: ssh-private-key
+ - data-type: STRING
+ default-value: ping
+ name: mode
+ read-only: 'true'
+ - name: set-server
+ parameter:
+ - data-type: STRING
+ name: server-ip
+ - data-type: INTEGER
+ name: server-port
+ - name: set-rate
+ parameter:
+ - data-type: INTEGER
+ default-value: '5'
+ name: rate
+ - name: start-traffic
+ - name: stop-traffic
+ initial-config-primitive:
+ - name: config
+ parameter:
+ - name: ssh-hostname
+ value: <rw_mgmt_ip>
+ - name: ssh-username
+ value: fedora
+ - name: ssh-password
+ value: fedora
+ - name: mode
+ value: ping
+ seq: '1'
+ - name: start
+ seq: '2'
+ juju:
+ charm: pingpong
#
vnfd:vnfd-catalog:
- vnfd:vnfd:
- - vnfd:id: rift_pong_vnf
- vnfd:name: pong_vnf
- vnfd:short-name: pong_vnf
- vnfd:logo: rift_logo.png
- vnfd:vendor: RIFT.io
- vnfd:version: '1.0'
- vnfd:description: This is an example RIFT.ware VNF
- vnfd:config-parameter:
- vnfd:config-parameter-source:
- - vnfd:attribute: ../../../mgmt-interface, ip-address
- vnfd:description: Management IP address
- vnfd:name: mgmt_ip
- vnfd:parameter:
- - vnfd:config-primitive-name-ref: config
- vnfd:config-primitive-parameter-ref: ssh-hostname
- - vnfd:description: SSH username
- vnfd:name: username
- vnfd:parameter:
- - vnfd:config-primitive-name-ref: config
- vnfd:config-primitive-parameter-ref: ssh-username
- vnfd:value: fedora
- - vnfd:attribute: ../../../mgmt-interface/ssh-key, private-key-file
- vnfd:description: SSH private key file
- vnfd:name: ssh_key
- vnfd:parameter:
- - vnfd:config-primitive-name-ref: config
- vnfd:config-primitive-parameter-ref: ssh-private-key
- - vnfd:attribute: ../../../connection-point[name='pong_vnfd/cp1'], ip-address
- vnfd:description: IP on which Pong service is listening
- vnfd:name: service_ip
- vnfd:parameter:
- - vnfd:config-primitive-name-ref: set-server
- vnfd:config-primitive-parameter-ref: server-ip
- - vnfd:description: Port on which server listens for incoming data packets
- vnfd:name: service_port
- vnfd:parameter:
- - vnfd:config-primitive-name-ref: set-server
- vnfd:config-primitive-parameter-ref: server-port
- vnfd:value: '5555'
- vnfd:connection-point:
- - vnfd:name: pong_vnfd/cp0
- vnfd:type: VPORT
- - vnfd:name: pong_vnfd/cp1
- vnfd:type: VPORT
- vnfd:http-endpoint:
- - vnfd:path: api/v1/pong/stats
- vnfd:polling_interval_secs: '2'
- vnfd:port: '18889'
- vnfd:mgmt-interface:
- vnfd:dashboard-params:
- vnfd:path: api/v1/pong/stats
- vnfd:port: '18889'
- vnfd:port: '18889'
- rw-vnfd:ssh-key: 'true'
- vnfd:vdu-id: iovdu_0
- vnfd:monitoring-param:
- - vnfd:description: no of ping requests
- vnfd:group-tag: Group1
- vnfd:http-endpoint-ref: api/v1/pong/stats
- vnfd:id: '1'
- vnfd:json-query-method: NAMEKEY
- vnfd:name: ping-request-rx-count
- vnfd:units: packets
- vnfd:value-type: INT
- vnfd:widget-type: COUNTER
- - vnfd:description: no of ping responses
- vnfd:group-tag: Group1
- vnfd:http-endpoint-ref: api/v1/pong/stats
- vnfd:id: '2'
- vnfd:json-query-method: NAMEKEY
- vnfd:name: ping-response-tx-count
- vnfd:units: packets
- vnfd:value-type: INT
- vnfd:widget-type: COUNTER
- vnfd:placement-groups:
- - vnfd:member-vdus:
- - vnfd:member-vdu-ref: iovdu_0
- vnfd:name: Weywot
- vnfd:requirement: Place this VM on the Kuiper belt object Weywot
- vnfd:strategy: COLOCATION
- vnfd:vdu:
- - vnfd:count: '1'
- vnfd:external-interface:
- - vnfd:name: eth0
- vnfd:virtual-interface:
- vnfd:type: VIRTIO
- vnfd:vnfd-connection-point-ref: pong_vnfd/cp0
- - vnfd:name: eth1
- vnfd:virtual-interface:
- vnfd:type: VIRTIO
- vnfd:vnfd-connection-point-ref: pong_vnfd/cp1
- vnfd:id: iovdu_0
- vnfd:image: Fedora-x86_64-20-20131211.1-sda-pong.qcow2
- vnfd:image-checksum: 977484d95575f80ef8399c9cf1d45ebd
- vnfd:name: iovdu_0
- vnfd:vm-flavor:
- vnfd:memory-mb: '512'
- vnfd:storage-gb: '4'
- vnfd:vcpu-count: '1'
- vnfd:vnf-configuration:
- vnfd:config-primitive:
- - vnfd:name: start
- - vnfd:name: stop
- - vnfd:name: restart
- - vnfd:name: config
- vnfd:parameter:
- - vnfd:data-type: STRING
- vnfd:name: ssh-hostname
- - vnfd:data-type: STRING
- vnfd:name: ssh-username
- - vnfd:data-type: STRING
- vnfd:name: ssh-private-key
- - vnfd:data-type: STRING
- vnfd:default-value: pong
- vnfd:name: mode
- vnfd:read-only: 'true'
- - vnfd:name: set-server
- vnfd:parameter:
- - vnfd:data-type: STRING
- vnfd:name: server-ip
- - vnfd:data-type: INTEGER
- vnfd:name: server-port
- - vnfd:name: start-traffic
- - vnfd:name: stop-traffic
- vnfd:initial-config-primitive:
- - vnfd:config-primitive-ref: config
- vnfd:seq: '1'
- - vnfd:config-primitive-ref: start
- vnfd:seq: '2'
- - vnfd:config-primitive-ref: set-server
- vnfd:seq: '3'
- vnfd:juju:
- vnfd:charm: pingpong
+ vnfd:
+ - id: rift_pong_vnf
+ name: pong_vnf
+ short-name: pong_vnf
+ logo: rift_logo.png
+ vendor: RIFT.io
+ version: '1.0'
+ description: This is an example RIFT.ware VNF
+ connection-point:
+ - name: pong_vnfd/cp0
+ type: VPORT
+ - name: pong_vnfd/cp1
+ type: VPORT
+ http-endpoint:
+ - path: api/v1/pong/stats
+ polling_interval_secs: '2'
+ port: '18889'
+ mgmt-interface:
+ dashboard-params:
+ path: api/v1/pong/stats
+ port: '18889'
+ port: '18889'
+ vdu-id: iovdu_0
+ placement-groups:
+ - member-vdus:
+ - member-vdu-ref: iovdu_0
+ name: Weywot
+ requirement: Place this VM on the Kuiper belt object Weywot
+ strategy: COLOCATION
+ vdu:
+ - cloud-init-file: pong_cloud_init.cfg
+ count: '1'
+ external-interface:
+ - name: eth0
+ virtual-interface:
+ type: VIRTIO
+ vnfd-connection-point-ref: pong_vnfd/cp0
+ - name: eth1
+ virtual-interface:
+ type: VIRTIO
+ vnfd-connection-point-ref: pong_vnfd/cp1
+ id: iovdu_0
+ image: Fedora-x86_64-20-20131211.1-sda-pong.qcow2
+ image-checksum: 977484d95575f80ef8399c9cf1d45ebd
+ name: iovdu_0
+ vm-flavor:
+ memory-mb: '512'
+ storage-gb: '4'
+ vcpu-count: '1'
+ vnf-configuration:
+ config-attributes:
+ config-delay: 10
+ service-primitive:
+ - name: start
+ - name: stop
+ - name: restart
+ - name: config
+ parameter:
+ - data-type: STRING
+ default-value: <rw_mgmt_ip>
+ name: ssh-hostname
+ - data-type: STRING
+ default-value: fedora
+ name: ssh-username
+ - data-type: STRING
+ default-value: fedora
+ name: ssh-password
+ - data-type: STRING
+ name: ssh-private-key
+ - data-type: STRING
+ default-value: pong
+ name: mode
+ read-only: 'true'
+ - name: set-server
+ parameter:
+ - data-type: STRING
+ name: server-ip
+ - data-type: INTEGER
+ name: server-port
+ - name: start-traffic
+ - name: stop-traffic
+ initial-config-primitive:
+ - name: config
+ parameter:
+ - name: ssh-hostname
+ value: <rw_mgmt_ip>
+ - name: ssh-username
+ value: fedora
+ - name: ssh-password
+ value: fedora
+ - name: mode
+ value: pong
+ seq: '1'
+ - name: start
+ seq: '2'
+ juju:
+ charm: pingpong