Add LCM APIs for DownloadNeSw and ActivateNeSw actions 47/99147/1
authorEnbo Wang <wangenbo@huawei.com>
Wed, 4 Dec 2019 13:14:48 +0000 (21:14 +0800)
committerEnbo Wang <wangenbo@huawei.com>
Wed, 4 Dec 2019 13:14:48 +0000 (21:14 +0800)
Add two LCM APIs of DownloadNeSw and ActivateNeSw for PNF Software Upgrade.

Change-Id: I5a8f143c2d7d54fd96772eeb1d31b2d2e8bfb523
Issue-ID: SDNC-856
Signed-off-by: Enbo Wang <wangenbo@huawei.com>
lcm/model/src/main/resources/lcm.20180329.json
lcm/model/src/main/yang/lcm.yang
lcm/provider/src/main/java/org/onap/ccsdk/sli/northbound/LcmProvider.java
lcm/provider/src/test/java/org/onap/ccsdk/sli/northbound/TestLcmProvider.java
lcm/provider/src/test/resources/graphs/lcm/LCM_activate-ne-sw.xml [new file with mode: 0644]
lcm/provider/src/test/resources/graphs/lcm/LCM_download-ne-sw.xml [new file with mode: 0644]
lcm/provider/src/test/resources/graphs/lcm/graph.versions

index 291e18f..2e9eabe 100644 (file)
         "description": "An operation to upgrade the target VNF to a new version and expected that the VNF is in a quiesced status .",
         "operationId": "upgrade-software"
       }
+    },
+    "/operations/LCM:download-ne-sw": {
+      "post": {
+        "consumes": [
+          "application/json",
+          "application/xml"
+        ],
+        "produces": [
+          "application/json",
+          "application/xml"
+        ],
+        "parameters": [
+          {
+            "in": "body",
+            "name": "body",
+            "required": false,
+            "schema": {
+              "$ref": "#/definitions/(download-ne-sw)input-TOP"
+            }
+          }
+        ],
+        "responses": {
+          "200": {
+            "description": "No response was specified",
+            "schema": {
+              "$ref": "#/definitions/(download-ne-sw)output-TOP"
+            }
+          }
+        },
+        "description": "An operation to download NE software.",
+        "operationId": "download-ne-sw"
+      }
+    },
+    "/operations/LCM:activate-ne-sw": {
+      "post": {
+        "consumes": [
+          "application/json",
+          "application/xml"
+        ],
+        "produces": [
+          "application/json",
+          "application/xml"
+        ],
+        "parameters": [
+          {
+            "in": "body",
+            "name": "body",
+            "required": false,
+            "schema": {
+              "$ref": "#/definitions/(activate-ne-sw)input-TOP"
+            }
+          }
+        ],
+        "responses": {
+          "200": {
+            "description": "No response was specified",
+            "schema": {
+              "$ref": "#/definitions/(activate-ne-sw)output-TOP"
+            }
+          }
+        },
+        "description": "An operation to activate NE software.",
+        "operationId": "activate-ne-sw"
+      }
     }
   },
   "definitions": {
       },
       "type": "object"
     },
+    "(download-ne-sw)input": {
+      "properties": {
+        "LCM:action": {
+          "$ref": "#/definitions/Optional.empty"
+        },
+        "LCM:action-identifiers": {
+          "description": "A block containing the action arguments. These are used to specify\\nthe object upon which APP-C LCM command is to operate",
+          "items": {
+            "$ref": "#/definitions/LCM(config)action-identifiers"
+          },
+          "type": "object"
+        },
+        "LCM:common-header": {
+          "description": "A common header for all APP-C requests",
+          "items": {
+            "$ref": "#/definitions/LCM(config)common-header"
+          },
+          "type": "object"
+        },
+        "LCM:payload": {
+          "$ref": "#/definitions/Optional.empty"
+        }
+      },
+      "required": [
+        "LCM:action",
+        "LCM:payload"
+      ],
+      "type": "object"
+    },
+    "(download-ne-sw)input-TOP": {
+      "properties": {
+        "LCM:input": {
+          "items": {
+            "$ref": "#/definitions/(download-ne-sw)input"
+          },
+          "type": "object"
+        }
+      },
+      "type": "object"
+    },
+    "(download-ne-sw)output": {
+      "properties": {
+        "LCM:common-header": {
+          "description": "A common header for all APP-C requests",
+          "items": {
+            "$ref": "#/definitions/LCM(config)common-header"
+          },
+          "type": "object"
+        },
+        "LCM:payload": {
+          "$ref": "#/definitions/Optional.empty"
+        },
+        "LCM:status": {
+          "description": "The specific response codes are to be aligned with SDC reference doc\\n(main table removed to avoid duplication and digression from main table).\\nSee SDC and ECOMP Distribution Consumer Interface Agreement",
+          "items": {
+            "$ref": "#/definitions/LCM(config)status"
+          },
+          "type": "object"
+        }
+      },
+      "required": [
+        "LCM:payload"
+      ],
+      "type": "object"
+    },
+    "(download-ne-sw)output-TOP": {
+      "properties": {
+        "LCM:output": {
+          "items": {
+            "$ref": "#/definitions/(download-ne-sw)output"
+          },
+          "type": "object"
+        }
+      },
+      "type": "object"
+    },
+    "(activate-ne-sw)input": {
+      "properties": {
+        "LCM:action": {
+          "$ref": "#/definitions/Optional.empty"
+        },
+        "LCM:action-identifiers": {
+          "description": "A block containing the action arguments. These are used to specify\\nthe object upon which APP-C LCM command is to operate",
+          "items": {
+            "$ref": "#/definitions/LCM(config)action-identifiers"
+          },
+          "type": "object"
+        },
+        "LCM:common-header": {
+          "description": "A common header for all APP-C requests",
+          "items": {
+            "$ref": "#/definitions/LCM(config)common-header"
+          },
+          "type": "object"
+        },
+        "LCM:payload": {
+          "$ref": "#/definitions/Optional.empty"
+        }
+      },
+      "required": [
+        "LCM:action",
+        "LCM:payload"
+      ],
+      "type": "object"
+    },
+    "(activate-ne-sw)input-TOP": {
+      "properties": {
+        "LCM:input": {
+          "items": {
+            "$ref": "#/definitions/(activate-ne-sw)input"
+          },
+          "type": "object"
+        }
+      },
+      "type": "object"
+    },
+    "(activate-ne-sw)output": {
+      "properties": {
+        "LCM:common-header": {
+          "description": "A common header for all APP-C requests",
+          "items": {
+            "$ref": "#/definitions/LCM(config)common-header"
+          },
+          "type": "object"
+        },
+        "LCM:payload": {
+          "$ref": "#/definitions/Optional.empty"
+        },
+        "LCM:status": {
+          "description": "The specific response codes are to be aligned with SDC reference doc\\n(main table removed to avoid duplication and digression from main table).\\nSee SDC and ECOMP Distribution Consumer Interface Agreement",
+          "items": {
+            "$ref": "#/definitions/LCM(config)status"
+          },
+          "type": "object"
+        }
+      },
+      "required": [
+        "LCM:payload"
+      ],
+      "type": "object"
+    },
+    "(activate-ne-sw)output-TOP": {
+      "properties": {
+        "LCM:output": {
+          "items": {
+            "$ref": "#/definitions/(activate-ne-sw)output"
+          },
+          "type": "object"
+        }
+      },
+      "type": "object"
+    },
     "LCM(config)action-identifiers": {
       "properties": {
         "LCM:service-instance-id": {
index cbb772f..55af115 100644 (file)
@@ -114,6 +114,8 @@ module LCM {
             enum "DistributeTraffic";
             enum "UpgradePreCheck";
             enum "UpgradeSoftware";
+            enum "DownloadNeSw";
+            enum "ActivateNeSw";
             enum "UpgradePostCheck";
             enum "UpgradeBackup";
             enum "UpgradeBackout";
@@ -311,6 +313,12 @@ module LCM {
                 type string;
                 mandatory false;
             }
+            leaf pnf-id {
+                description "identifies the PNF to which this action is to be applied.";
+                type string;
+                mandatory false;
+            }
+
         }
     }
 
@@ -591,6 +599,60 @@ module LCM {
         }
     }
 
+    /**********************************************************************************
+     * Define the downloadNeSw operation
+     **********************************************************************************/
+    rpc download-ne-sw {
+        description "An operation to download NE software";
+        input {
+            uses common-header;
+            leaf action {
+                type action;
+                mandatory true;
+            }
+            uses action-identifiers;
+            leaf payload {
+                type payload;
+                mandatory true;
+           }
+        }
+        output {
+            uses common-header;
+            uses status;
+            leaf payload {
+                type payload;
+                mandatory true;
+            }
+        }
+    }
+
+    /**********************************************************************************
+     * Define the activateNeSw operation
+     **********************************************************************************/
+    rpc activate-ne-sw {
+        description "An operation to activate NE software";
+        input {
+            uses common-header;
+            leaf action {
+                type action;
+                mandatory true;
+            }
+            uses action-identifiers;
+            leaf payload {
+                type payload;
+                mandatory true;
+           }
+        }
+        output {
+            uses common-header;
+            uses status;
+            leaf payload {
+                type payload;
+                mandatory true;
+            }
+        }
+    }
+
     /**********************************************************************************
      * Define the VNF UpgradePostCheck service
      **********************************************************************************/
index 0074dfc..6fd4943 100644 (file)
@@ -760,6 +760,54 @@ public class LcmProvider implements AutoCloseable, LCMService {
                return Futures.immediateFuture(rpcResult);
        }
 
+       @Override
+       public ListenableFuture<RpcResult<DownloadNeSwOutput>> downloadNeSw(DownloadNeSwInput input) {
+               DownloadNeSwInputBuilder iBuilder = new DownloadNeSwInputBuilder(input);
+               DownloadNeSwOutputBuilder oBuilder = new DownloadNeSwOutputBuilder();
+
+               try {
+                       CommonLcmFields retval = callDG("download-ne-sw", iBuilder.build());
+                       oBuilder.setStatus(retval.getStatusBuilder().build());
+                       oBuilder.setCommonHeader(retval.getCommonHeaderBuilder().build());
+                       if (retval.getPayload() != null) {
+                               oBuilder.setPayload(retval.getPayload());
+                       }
+               } catch (LcmRpcInvocationException e) {
+                       LOG.debug(exceptionMessage, e);
+                       oBuilder.setCommonHeader(e.getCommonHeader());
+                       oBuilder.setStatus(e.getStatus());
+               }
+
+               RpcResult<DownloadNeSwOutput> rpcResult =
+                               RpcResultBuilder.<DownloadNeSwOutput> status(true).withResult(oBuilder.build()).build();
+               // return error
+               return Futures.immediateFuture(rpcResult);
+       }
+
+       @Override
+       public ListenableFuture<RpcResult<ActivateNeSwOutput>> activateNeSw(ActivateNeSwInput input) {
+               ActivateNeSwInputBuilder iBuilder = new ActivateNeSwInputBuilder(input);
+               ActivateNeSwOutputBuilder oBuilder = new ActivateNeSwOutputBuilder();
+
+               try {
+                       CommonLcmFields retval = callDG("activate-ne-sw", iBuilder.build());
+                       oBuilder.setStatus(retval.getStatusBuilder().build());
+                       oBuilder.setCommonHeader(retval.getCommonHeaderBuilder().build());
+                       if (retval.getPayload() != null) {
+                               oBuilder.setPayload(retval.getPayload());
+                       }
+               } catch (LcmRpcInvocationException e) {
+                       LOG.debug(exceptionMessage, e);
+                       oBuilder.setCommonHeader(e.getCommonHeader());
+                       oBuilder.setStatus(e.getStatus());
+               }
+
+               RpcResult<ActivateNeSwOutput> rpcResult =
+                               RpcResultBuilder.<ActivateNeSwOutput> status(true).withResult(oBuilder.build()).build();
+               // return error
+               return Futures.immediateFuture(rpcResult);
+       }
+
        @Override
        public ListenableFuture<RpcResult<StopOutput>> stop(StopInput input) {
                StopInputBuilder iBuilder = new StopInputBuilder(input);
index 8e82cca..e0d8e57 100644 (file)
@@ -106,6 +106,10 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.
 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.UpgradePreCheckOutput;
 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.UpgradeSoftwareInputBuilder;
 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.UpgradeSoftwareOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.DownloadNeSwInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.DownloadNeSwOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.ActivateNeSwInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.ActivateNeSwOutput;
 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.ZULU;
 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.action.identifiers.ActionIdentifiersBuilder;
 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.northbound.lcm.rev180329.common.header.CommonHeaderBuilder;
@@ -1150,6 +1154,74 @@ public class TestLcmProvider {
                }
        }
 
+       @Test
+       public void testDownloadNeSw() {
+               DownloadNeSwInputBuilder builder = new DownloadNeSwInputBuilder();
+
+               CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder();
+               hdrBuilder.setApiVer("1");
+               hdrBuilder.setFlags(null);
+               hdrBuilder.setOriginatorId("jUnit");
+               hdrBuilder.setRequestId("123");
+               hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date())));
+               builder.setCommonHeader(hdrBuilder.build());
+
+               ActionIdentifiersBuilder aBuilder = new ActionIdentifiersBuilder();
+               aBuilder.setServiceInstanceId("SVCID-123");
+               aBuilder.setVfModuleId("vf-module-1");
+               aBuilder.setVnfcName("my-vnfc");
+               aBuilder.setVnfId("123");
+               aBuilder.setVserverId("123");
+               builder.setActionIdentifiers(aBuilder.build());
+
+               builder.setAction(Action.DownloadNeSw);
+               builder.setPayload(mock(Payload.class));
+
+
+               try {
+                       DownloadNeSwOutput results = provider.downloadNeSw(builder.build()).get().getResult();
+                       LOG.info("DownloadNeSw returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage());
+                       assert(results.getStatus().getCode() == 400);
+               } catch (InterruptedException | ExecutionException e) {
+                       LOG.error("Caught exception", e);
+                       fail("DownloadNeSw threw exception");
+               }
+       }
+
+       @Test
+       public void testActivateNeSw() {
+               ActivateNeSwInputBuilder builder = new ActivateNeSwInputBuilder();
+
+               CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder();
+               hdrBuilder.setApiVer("1");
+               hdrBuilder.setFlags(null);
+               hdrBuilder.setOriginatorId("jUnit");
+               hdrBuilder.setRequestId("123");
+               hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date())));
+               builder.setCommonHeader(hdrBuilder.build());
+
+               ActionIdentifiersBuilder aBuilder = new ActionIdentifiersBuilder();
+               aBuilder.setServiceInstanceId("SVCID-123");
+               aBuilder.setVfModuleId("vf-module-1");
+               aBuilder.setVnfcName("my-vnfc");
+               aBuilder.setVnfId("123");
+               aBuilder.setVserverId("123");
+               builder.setActionIdentifiers(aBuilder.build());
+
+               builder.setAction(Action.ActivateNeSw);
+               builder.setPayload(mock(Payload.class));
+
+
+               try {
+                       ActivateNeSwOutput results = provider.activateNeSw(builder.build()).get().getResult();
+                       LOG.info("ActivateNeSw returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage());
+                       assert(results.getStatus().getCode() == 400);
+               } catch (InterruptedException | ExecutionException e) {
+                       LOG.error("Caught exception", e);
+                       fail("ActivateNeSw threw exception");
+               }
+       }
+
        @Test
        public void testStop() {
                StopInputBuilder builder = new StopInputBuilder();
diff --git a/lcm/provider/src/test/resources/graphs/lcm/LCM_activate-ne-sw.xml b/lcm/provider/src/test/resources/graphs/lcm/LCM_activate-ne-sw.xml
new file mode 100644 (file)
index 0000000..99f74b6
--- /dev/null
@@ -0,0 +1,30 @@
+<!--
+  ============LICENSE_START=======================================================
+  openECOMP : SDN-C
+  ================================================================================
+  Copyright (C) 2017 AT&T Intellectual Property. All rights
+                                                       reserved.
+  ================================================================================
+  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.
+  ============LICENSE_END=========================================================
+  -->
+
+<service-logic xmlns="http://www.onap.org/sdnc/svclogic"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd"
+       module='LCM' version='1.0.0'>
+       <method rpc='activate-ne-sw' mode='sync'>
+               <set>
+                       <parameter name='status.code' value='400' />
+                       <parameter name='status.message' value='SUCCESS' />
+               </set>
+       </method>
+</service-logic>
diff --git a/lcm/provider/src/test/resources/graphs/lcm/LCM_download-ne-sw.xml b/lcm/provider/src/test/resources/graphs/lcm/LCM_download-ne-sw.xml
new file mode 100644 (file)
index 0000000..fd586cc
--- /dev/null
@@ -0,0 +1,30 @@
+<!--
+  ============LICENSE_START=======================================================
+  openECOMP : SDN-C
+  ================================================================================
+  Copyright (C) 2017 AT&T Intellectual Property. All rights
+                                                       reserved.
+  ================================================================================
+  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.
+  ============LICENSE_END=========================================================
+  -->
+
+<service-logic xmlns="http://www.onap.org/sdnc/svclogic"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd"
+       module='LCM' version='1.0.0'>
+       <method rpc='download-ne-sw' mode='sync'>
+               <set>
+                       <parameter name='status.code' value='400' />
+                       <parameter name='status.message' value='SUCCESS' />
+               </set>
+       </method>
+</service-logic>
index 233aa45..466be55 100644 (file)
@@ -30,6 +30,8 @@ LCM resume-traffic 1.0.0 sync
 LCM distribute-traffic 1.0.0 sync
 LCM upgrade-pre-check 1.0.0 sync
 LCM upgrade-software 1.0.0 sync
+LCM download-ne-sw 1.0.0 sync
+LCM activate-ne-sw 1.0.0 sync
 LCM upgrade-post-check 1.0.0 sync
 LCM upgrade-backup 1.0.0 sync
 LCM upgrade-backout 1.0.0 sync