Merge "Bug 263 fixed"
[osm/devops.git] / src / generate_descriptor_pkg.sh
index ae0d7e1..a09fb6a 100755 (executable)
@@ -65,7 +65,6 @@ INTF_TYPE='VIRTIO'
 VCPU=2
 MEMORY=4096
 STORAGE=10
-CLOUD_INIT='#cloud-config '
 INTERFACES=1
 
 function usage() {
@@ -99,7 +98,7 @@ Usage:
 
             --vendor : Vendor name for descriptor. Default OSM
 
-            --interface-type : Interface type [VIRTIO|SR-IOV|PCI-PASSTHROUGH|E1000|OM-MGMT]
+            --interface-type : Interface type [VIRTIO|SR-IOV|PCI-PASSTHROUGH|E1000]
                                Default VIRTIO
 
           VM Flavour options:
@@ -119,7 +118,7 @@ Usage:
             --cloud-init : Cloud init script. Will be ignored if
                            cloud-init-file is specified
 
-            --interfaces : Number of external interfaces. Default 1.
+            --interfaces : Number of external interfaces in additon to OM-MGMT. Default 1.
 
         End of create descriptor specific options
 
@@ -152,6 +151,18 @@ get_pci() {
    printf '%02x' $((10 + $1)) | tr '[:upper:]' '[:lower:]'
 }
 
+function write_readme() {
+    dir=$1
+    file=${dir}/README
+    date=$(date)
+
+    cat >$file <<EOF
+Descriptor created by OSM descriptor package generated
+Created on $date
+EOF
+
+}
+
 function write_vnfd_tmpl() {
     name=$(basename $1)
     desc_file="${name}.yaml"
@@ -175,6 +186,8 @@ vnfd:vnfd-catalog:
 
         # Atleast one VDU need to be specified
         vdu:
+        # Additional VDUs can be created by copying the
+        # VDU descriptor below
         -   id: ${name}-VM
             name: ${name}-VM
             description: ${name}-VM
@@ -198,7 +211,7 @@ EOF
             # Cloud init file
             cloud-init-file: '${cif}'
 EOF
-    else
+    elif [[ -n ${CLOUD_INIT} ]]; then
         cat >>$desc_file <<EOF
             # Cloud init to use
             cloud-init: '${CLOUD_INIT}'
@@ -212,16 +225,26 @@ EOF
             # There can be multiple interfaces defined
 EOF
 
+    # Add mgmt interface
+    cat >>$desc_file <<EOF
+            -   name: eth0
+                virtual-interface:
+                    type: VIRTIO
+                    bandwidth: '0'
+                    vpci: '0000:00:0a.0'
+                vnfd-connection-point-ref: eth0
+EOF
+
     # Add external interfaces
     for i in `seq 1 ${INTERFACES}`; do
-        eth=$(($i - 1))
+        eth=$(($i))
         pci=$(get_pci $eth)
         cat >>$desc_file <<EOF
             -   name: eth${eth}
                 virtual-interface:
                     type: ${INTF_TYPE}
                     bandwidth: '0'
-                    vpci: 0000:00:${pci}.0
+                    vpci: '0000:00:${pci}.0'
                 vnfd-connection-point-ref: eth${eth}
 EOF
     done
@@ -232,14 +255,45 @@ EOF
         connection-point:
 EOF
 
-    for i in `seq 1 ${INTERFACES}`; do
-        eth=$(($i - 1))
+    for i in `seq 0 ${INTERFACES}`; do
+        eth=$(($i))
         cat >>$desc_file <<EOF
             -   name: eth${eth}
                 type: ${CP_TYPE}
 EOF
     done
 
+    cat >>$desc_file <<EOF
+
+        # Uncomment and update below to enable juju
+        # charm configuration for the VNF
+        # vnf-configuration:
+        #     juju:
+        #         charm: <charm name>
+        #     service-primitive:
+        #     -   name: config
+        #         parameter:
+        #         -   name: <config parameter>
+        #             data-type: [STRING|INTEGER]
+        #             mandatory: [true|false]
+        #             default-value: <value>
+        #     -   name: <action name>
+        #         parameter:
+        #         -   name: <action parameter>
+        #             data-type: [STRING|INTEGER]
+        #             mandatory: [true|false]
+        #             default-value: <value>
+        #     initial-config-primitive:
+        #     -   name: config
+        #         parameter:
+        #         -   name: <config name>
+        #             value: <value>
+        #     -   name: <action name>
+        #         parameter:
+        #         -   name: <action parameter>
+        #             value: <value>
+EOF
+
     if [ $VERBOSE == true ]; then
         echo "INFO: Created $desc_file"
     fi
@@ -278,15 +332,39 @@ EOF
         # Networks for the VNFs
 EOF
 
+    # Add management VLD
+    cat >>$desc_file <<EOF
+            -   id: ${name}_vld0
+                name: management
+                short-name: management
+                type: ELAN
+                mgmt-network: 'true'
+                # vim-network-name: <update>
+                # provider-network:
+                #     overlay-type: VLAN
+                #     segmentation_id: <update>
+                vnfd-connection-point-ref:
+                # Specify the constituent VNFs
+                # member-vnf-index-ref - entry from constituent vnf
+                # vnfd-id-ref - VNFD id
+                # vnfd-connection-point-ref - connection point name in the VNFD
+                -   nsd:member-vnf-index-ref: 1
+                    nsd:vnfd-id-ref: ${vnfd}
+                    # NOTE: Validate the entry below
+                    nsd:vnfd-connection-point-ref: eth0
+EOF
+
+    # Add rest of VLDs
     for i in `seq 1 ${INTERFACES}`; do
-        eth=$(($i - 1))
+        eth=$(($i))
         cat >>$desc_file <<EOF
             -   id: ${name}_vld${i}
                 name: ${name}_vld${i}
+                short-name: ${name}_vld${i}
                 type: ELAN
+                # vim-network-name: <update>
                 # provider-network:
                 #     overlay-type: VLAN
-                #     physical-network: <update>
                 #     segmentation_id: <update>
                 vnfd-connection-point-ref:
                 # Specify the constituent VNFs
@@ -443,6 +521,8 @@ function generate_package(){
         write_nsd_tmpl $dir $vnfd
     fi
 
+    write_readme $dir
+
     if [ $ARCHIVE == true ]; then
         # Create archive of the package
         cd $dest_dir