diff options
9 files changed, 3064 insertions, 1121 deletions
diff --git a/generic-resource-api/model/src/main/yang/GENERIC-RESOURCE-API.yang b/generic-resource-api/model/src/main/yang/GENERIC-RESOURCE-API.yang index 2a607cbe..78923516 100644 --- a/generic-resource-api/model/src/main/yang/GENERIC-RESOURCE-API.yang +++ b/generic-resource-api/model/src/main/yang/GENERIC-RESOURCE-API.yang @@ -61,6 +61,12 @@ module GENERIC-RESOURCE-API { container vnf-data {
uses vnf-operation-information;
uses vnf-topology;
+ container vnf-network-collections {
+ uses vnf-network-collection;
+ }
+ container vnf-sub-interface-groups {
+ uses vnf-sub-interface-group;
+ }
container vnf-provided-allotted-resources {
leaf-list vnf-provided-ar-id {
description "List of allotted resources using capacity from this vnf";
@@ -98,6 +104,29 @@ module GENERIC-RESOURCE-API { uses allotted-resource-info;
}
}
+ container provided-configurations {
+ list provided-configuration {
+ key "configuration-id";
+ uses configuration-info;
+ }
+ }
+ container vnfc-instance-groups {
+ uses vnfc-instance-group;
+ }
+ container network-instance-groups {
+ uses network-instance-group;
+ }
+ container forwarding-paths {
+ list forwarding-path {
+ key "forwarding-path-id";
+ leaf forwarding-path-id {
+ description "Generated by SDNC";
+ type string;
+ mandatory true;
+ }
+ uses forwarding-path-information;
+ }
+ }
}
}
grouping service-status {
@@ -134,6 +163,7 @@ module GENERIC-RESOURCE-API { enum "delete";
enum "unassign";
enum "deactivate";
+ enum "create";
}
}
leaf response-timestamp {
@@ -225,6 +255,10 @@ module GENERIC-RESOURCE-API { leaf network-type {
type string;
}
+ leaf from-preload {
+ description "Indicates if source is preload data";
+ type boolean;
+ }
uses onap-model-information;
}
}
@@ -237,6 +271,10 @@ module GENERIC-RESOURCE-API { container network-input-parameters {
uses param;
}
+ leaf network-instance-group-id {
+ description "When network has instance-group role in service model";
+ type string;
+ }
}
}
grouping network-topology {
@@ -262,12 +300,14 @@ module GENERIC-RESOURCE-API { leaf network-type {
type string;
}
+ leaf network-instance-group-id {
+ description "When network is part of network instance-Group-data & instance Group in A&AI";
+ type string;
+ }
leaf network-technology {
- description "should we keep this?";
type string;
}
leaf eipam-v4-address-plan {
- description "??";
type string;
}
leaf eipam-v6-address-plan {
@@ -292,6 +332,81 @@ module GENERIC-RESOURCE-API { }
}
}
+ grouping network-instance-group {
+ list network-instance-group {
+ key "network-instance-group-id";
+ leaf network-instance-group-id {
+ description "Also a Key in Network Instance Group in A&AI";
+ type string;
+ mandatory true;
+ }
+ leaf network-instance-group-function {
+ type string;
+ }
+ leaf service-instance-id {
+ type string;
+ }
+ uses onap-model-information;
+ container subnet-assignment-policy {
+ leaf subnet-use {
+ description "Current valid values - unique, shared (default)";
+ type string;
+ }
+ }
+ container vpn-binding-policy {
+ leaf vpn-binding {
+ type string;
+ }
+ leaf vpn-name {
+ type string;
+ }
+ leaf vpn-type {
+ type string;
+ }
+ leaf vpn-platform {
+ type string;
+ }
+ leaf global-route-target {
+ type string;
+ }
+ leaf route-target-role {
+ type string;
+ }
+ }
+ uses subnets;
+ leaf subnet-key-value {
+ description "key-value provided to EIPAM when creating shared subnet";
+ type string;
+ }
+ container networks {
+ list network {
+ key "network-id";
+ leaf network-id {
+ description "Index into network-topology-identifier structure";
+ type string;
+ mandatory true;
+ }
+ uses vpn-bindings;
+ leaf vlan-tag-id {
+ type uint32;
+ }
+ leaf network-status {
+ description "assigned, unassigned";
+ type string;
+ }
+ container customer-bonding-requests {
+ list customer-bonding-request {
+ key "configuration-id";
+ leaf configuration-id {
+ description "e.g. vlan network receptor configuration id";
+ type string;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
grouping network-level-oper-status {
container network-level-oper-status {
uses oper-status-data;
@@ -310,7 +425,9 @@ module GENERIC-RESOURCE-API { type string;
}
leaf vnf-type {
- description "vnf-model-id in Pats model?in Pats vnf submodule, contained within vnf-instance-topology-identifier grouping (along with vnf-name and vnf-instance-id)";
+ type string;
+ }
+ leaf vnf-name {
type string;
}
uses onap-model-information;
@@ -319,11 +436,9 @@ module GENERIC-RESOURCE-API { grouping vnf-request-input {
container vnf-request-input {
leaf request-version {
- description "keep this? e.g. 1702";
type string;
}
leaf vnf-name {
- description "in Pats vnf submodule, contained within vnf-instance-topology-identifier (along with vnf-model-id and vnf-instance-id)";
type string;
}
uses region-identifier;
@@ -333,6 +448,13 @@ module GENERIC-RESOURCE-API { uses vnf-network-data;
}
}
+ list vnf-network-instance-group-ids {
+ key "vnf-network-instance-group-id";
+ leaf vnf-network-instance-group-id {
+ description "List of vnf network-instance-group";
+ type string;
+ }
+ }
container vnf-input-parameters {
uses param;
}
@@ -347,6 +469,10 @@ module GENERIC-RESOURCE-API { container vnf-parameters-data {
uses param;
}
+ leaf sdnc-generated-cloud-resources {
+ description "Indicate if source is sdnc generated cloud param";
+ type boolean;
+ }
}
}
grouping vnf-topology-identifier-structure {
@@ -380,7 +506,7 @@ module GENERIC-RESOURCE-API { grouping vnf-resource-assignments {
container vnf-resource-assignments {
leaf vnf-status {
- description "Do we need this?Orchestration status from AAI - to be set by SDNCWill not be used for vIPR.";
+ description "Orchestration status from AAI - to be set by SDNC";
type string;
}
container availability-zones {
@@ -425,7 +551,19 @@ module GENERIC-RESOURCE-API { }
container subnets-data {
list subnet-data {
- key "ip-version";
+ key "sdnc-subnet-id";
+ leaf sdnc-subnet-id {
+ description "Unique SDNC generated UUID of the subnet. Key into A&AI instance.This maps to ipv4-key-subnet-id and ipv6-key-subnet-id in VNF-API";
+ type string;
+ }
+ leaf subnet-role {
+ description "Subnet Role for the subnet";
+ type string;
+ }
+ leaf subnet-name {
+ description "Populated for preload only";
+ type string;
+ }
leaf ip-version {
description "Should be ipv4 or ipv6";
type string;
@@ -434,6 +572,13 @@ module GENERIC-RESOURCE-API { description "subnet UUID to be passed into the HEAT template";
type string;
}
+ leaf dhcp-enabled {
+ description "Indicator to use this subnet for DHCP ";
+ type enumeration {
+ enum "Y";
+ enum "N";
+ }
+ }
}
}
}
@@ -458,6 +603,10 @@ module GENERIC-RESOURCE-API { leaf vf-module-type {
type string;
}
+ leaf from-preload {
+ description "Indicates if source is preload data";
+ type boolean;
+ }
uses onap-model-information;
}
}
@@ -485,6 +634,10 @@ module GENERIC-RESOURCE-API { container vf-module-parameters {
uses param;
}
+ leaf sdnc-generated-cloud-resources {
+ description "Indicate if source is sdnc-generated-cloud-resources.When true, the parameters are literal HEAT template parameter names;When false, the parameters need to be converted to HEAT format";
+ type boolean;
+ }
}
}
grouping vf-module-topology-identifier {
@@ -498,7 +651,6 @@ module GENERIC-RESOURCE-API { type string;
}
leaf vf-module-type {
- description "In Pats model referred to as model-id";
type string;
}
}
@@ -506,7 +658,7 @@ module GENERIC-RESOURCE-API { grouping vf-module-assignments {
container vf-module-assignments {
leaf vf-module-status {
- description "Do we need this?Orchestration status from AAI - to be set by SDNCNot being used for vIPR.";
+ description "Orchestration status from AAI - to be set by SDNC";
type string;
}
container vms {
@@ -515,6 +667,7 @@ module GENERIC-RESOURCE-API { uses vm-topology-data;
}
}
+ uses vlan-vnfc-instance-groups;
}
}
grouping vm-topology-data {
@@ -535,10 +688,18 @@ module GENERIC-RESOURCE-API { }
container vm-names {
leaf-list vm-name {
- description "ordered-by: user";
type string;
ordered-by user;
}
+ list vnfc-names {
+ key "vnfc-name";
+ leaf vnfc-name {
+ type string;
+ }
+ container vnfc-networks {
+ uses vnfc-network-data;
+ }
+ }
}
container vm-networks {
list vm-network {
@@ -547,6 +708,83 @@ module GENERIC-RESOURCE-API { }
}
}
+ grouping vnfc-network-data {
+ list vnfc-network-data {
+ key "vnfc-network-role";
+ leaf vnfc-network-role {
+ description "e.g. dummy net - parent port network role ";
+ type string;
+ mandatory true;
+ }
+ leaf vnfc-type {
+ description "Vm-type e.g. FW,";
+ type string;
+ }
+ container vnfc-ports {
+ list vnfc-port {
+ key "vnfc-port-id";
+ leaf vnfc-port-id {
+ description "Port(s) with a given network-role are assigned vnfc-port-id from series - 01, 02, 03 ...Example: VM with two ports with network-role =X and another 2 ports with network-role=Y vnfc-port-ids:01 - 1st port with network-role=X02 - 2nd port with network-role=X01 - 1st port with network-role=Y02 - 2nd port with network-role=Y";
+ type string;
+ mandatory true;
+ }
+ leaf common-sub-interface-role {
+ description "If sub-interfaces have common interface role (network role)";
+ type string;
+ }
+ container vnic-sub-interfaces {
+ uses sub-interface-network-data;
+ }
+ }
+ }
+ list vnfc-subnet {
+ key "vnfc-subnet-role";
+ leaf vnfc-subnet-role {
+ description "Default value if subnet role is not defined.";
+ type string;
+ mandatory true;
+ }
+ list vnfc-ip-assignments {
+ key "vnfc-address-family";
+ leaf vnfc-address-family {
+ description "indicates if this is IpV4 or IpV6";
+ type enumeration {
+ enum "ipv4";
+ enum "ipv6";
+ }
+ }
+ leaf vnfc-subnet-dhcp {
+ description "Indicator to use DHCP for IP assignment. Unless dhcp=N, we wouldnt have any IPs here, since they would not be SDNC assigned ";
+ type enumeration {
+ enum "Y";
+ enum "N";
+ }
+ }
+ leaf vnfc-subnet-ip-count {
+ description "The number of IP addresses to be assigned per vnfc for this subnet role";
+ type uint8;
+ }
+ list vnfc-subnet-ip {
+ key "vnfc-ip-address";
+ leaf vnfc-ip-address {
+ description "Either IpV4 IP or IpV6 IP addresses should be present";
+ type inet:ip-address;
+ }
+ leaf vnfc-client-key {
+ type string;
+ }
+ leaf ip-type {
+ description "Capture what type of IP this is, if is virtual IP (AKA, floating IP) or Fixed IP. ";
+ type enumeration {
+ enum "FIXED";
+ enum "VIP";
+ }
+ }
+ }
+ }
+ }
+ }
+ }
grouping vm-network-data {
leaf network-role {
description "network (identified by role) that this VM connects to. Should also be included in the vnf-networks for the containing VNF";
@@ -576,7 +814,7 @@ module GENERIC-RESOURCE-API { }
container network-ips {
leaf-list network-ip {
- description "List of assigned ip addresses of type ip-version on a network. Is there a way to specify format to indicate ipv4 or ipv6 format?";
+ description "List of assigned ip addresses of type ip-version on a network";
type string;
ordered-by user;
}
@@ -650,6 +888,511 @@ module GENERIC-RESOURCE-API { type string;
}
}
+ grouping forwarding-path-operation-information {
+ uses sdnc-request-header;
+ uses request-information;
+ uses service-information;
+ uses forwarding-path-request-input;
+ }
+ grouping forwarding-path-request-input {
+ container forwarding-path-request-input {
+ list forwarding-paths {
+ key "forwarding-path-name";
+ leaf forwarding-path-name {
+ description "Forwarding-path-name from tosca-model. ";
+ type string;
+ mandatory true;
+ }
+ uses onap-model-information;
+ }
+ }
+ }
+ grouping forwarding-path-information {
+ leaf forwarding-path-name {
+ description "Fowarding-path name from TOSCA model, or name generated by SDNC";
+ type string;
+ }
+ leaf forwarding-path-type {
+ description "Based on MySQL Forwarding_Path tables path_type value from related TOSCA model";
+ type enumeration {
+ enum "VNF";
+ enum "Service";
+ }
+ }
+ uses onap-model-information;
+ container service-paths {
+ list service-path {
+ key "service-path-instance-id";
+ uses service-path-information;
+ }
+ }
+ }
+ grouping service-path-information {
+ leaf service-path-instance-id {
+ description "Service path instance ID generated by SDNC. Identifies a service-path-instance within a forwarding-path definition";
+ type string;
+ }
+ leaf service-path-instance-name {
+ description "A unique name generated by SDNC ( forwarding-path-name + service-path-instance-id )";
+ type string;
+ }
+ leaf version {
+ description "Only one version of the service-path-instance data will be available in MD-SAL. version will be updated when the service-path-instance is reevaluated ";
+ type string;
+ }
+ list service {
+ key "service-instance-id";
+ leaf service-instance-id {
+ description "service-instance-id of each service-instance in the service-path-instance";
+ type string;
+ }
+ leaf service-path-sequence-id {
+ description "e.g. S1S2S3S5seq id=1 S1-S2seq id=2 S2S3seq id=3 S3S5Incremental integer value";
+ type uint32;
+ }
+ container vnfs {
+ list vnf {
+ key "vnf-instance-id";
+ uses vnf-path-information;
+ }
+ }
+ }
+ }
+ grouping vnf-path-information {
+ leaf vnf-instance-id {
+ description "VNF instance ID in the path";
+ type string;
+ }
+ leaf vnf-path-sequence-id {
+ description "Sequence ID at the VNF instance levele.g. e.g. V1V2V3V5V6seq id=1 V1-V2seq id=2 V2V3seq id=3 V3V5seq id=4 V5V6incremental integer value.";
+ type uint32;
+ }
+ leaf left-network-name {
+ description "Every VNF instance in the path is connected to one or two VNFs.";
+ type string;
+ }
+ leaf left-network-role {
+ type string;
+ }
+ leaf right-network-name {
+ type string;
+ }
+ leaf right-network-role {
+ type string;
+ }
+ container vf-module-instance {
+ leaf vf-module-id {
+ type string;
+ }
+ leaf vf-module-name {
+ type string;
+ }
+ }
+ }
+ grouping forwarding-path-level-oper-status {
+ container forwarding-path-level-oper-status {
+ uses oper-status-data;
+ }
+ }
+ grouping configuration-info {
+ leaf configuration-id {
+ type string;
+ }
+ leaf configuration-type {
+ description "Not an enum, but expected values are port-mirror-configuration, , vlan-network-receptor";
+ type string;
+ }
+ leaf configuration-sub-type {
+ description "Not an enum, but expected values are vprobe and pprobe";
+ type string;
+ }
+ leaf configuration-topology-link {
+ description "Pointer to the configurations topology";
+ type string;
+ }
+ }
+ grouping vnfc-instance-group {
+ list vnfc-instance-group {
+ key "instance-group-role nfc-naming-code configuration-id";
+ leaf instance-group-role {
+ description "i.e.TSBC_VNFC_group";
+ type string;
+ mandatory true;
+ }
+ leaf nfc-naming-code {
+ description "Set to nfc-naming-code from A&AI";
+ type string;
+ mandatory true;
+ }
+ leaf configuration-id {
+ type string;
+ mandatory true;
+ }
+ leaf group-type {
+ description " port-mirror-source or port-mirror-dest";
+ type string;
+ }
+ uses vnfc-objects;
+ }
+ }
+ grouping vnfc-objects {
+ container vnfc-objects {
+ list vnfc-object {
+ key "vnfc-key";
+ leaf vnfc-key {
+ type string;
+ }
+ leaf vnfc-name {
+ description "Vnfc name as key in A&AI";
+ type string;
+ }
+ leaf vm-type {
+ type string;
+ }
+ leaf vnf-id {
+ type string;
+ }
+ leaf vserver-name {
+ type string;
+ }
+ leaf vserver-id {
+ type string;
+ }
+ container vnics {
+ list vnic {
+ key "vnic-port-name";
+ leaf vnic-port-name {
+ type string;
+ }
+ leaf vnic-port-id {
+ type string;
+ }
+ container capacity {
+ leaf vnic-capacity {
+ type uint32;
+ }
+ leaf used-capacity {
+ description "Updated for destination port when source port is mapped/unmapped.";
+ type uint32;
+ }
+ }
+ container vnic-ip-addresses {
+ uses ip-addresses;
+ }
+ }
+ }
+ }
+ }
+ }
+ grouping vnfcs {
+ container vnfcs {
+ list vnfc {
+ key "vnfc-name";
+ leaf vnfc-name {
+ description "Vnfc name as key in A&AI";
+ type string;
+ }
+ leaf vserver-name {
+ type string;
+ }
+ leaf vserver-id {
+ type string;
+ }
+ uses vnics;
+ }
+ }
+ }
+ grouping vnics {
+ container vnics {
+ list vnic {
+ key "vnic-port-name";
+ leaf vnic-port-name {
+ type string;
+ }
+ leaf vnic-port-id {
+ type string;
+ }
+ uses sub-interfaces;
+ }
+ }
+ }
+ grouping sub-interfaces {
+ container sub-interfaces {
+ list sub-interface {
+ key "sub-interface-port-name";
+ leaf sub-interface-port-name {
+ type string;
+ }
+ leaf sub-interface-port-id {
+ type string;
+ }
+ container sub-interface-ip-addresses {
+ uses ip-addresses;
+ }
+ uses vlan-tags;
+ container sub-interface-network {
+ leaf network-name {
+ type string;
+ }
+ leaf network-id {
+ type string;
+ }
+ }
+ leaf sub-interface-status {
+ description "NULL, unassigned, assigned";
+ type string;
+ }
+ }
+ }
+ }
+ grouping vlan-tags {
+ container vlan-tags {
+ leaf vlan-interface {
+ description "A&AI Key";
+ type string;
+ }
+ leaf upper-tag-id {
+ type uint32;
+ }
+ leaf lower-tag-id {
+ type uint32;
+ }
+ }
+ }
+ grouping vlan-vnfc-instance-groups {
+ container vlan-vnfc-instance-groups {
+ list vlan-vnfc-instance-group {
+ key "instance-group-id";
+ leaf instance-group-id {
+ description "A&AI ID";
+ type string;
+ mandatory true;
+ }
+ leaf instance-group-function {
+ type string;
+ }
+ leaf vnf-id {
+ type string;
+ }
+ container vnfcs {
+ list vnfc {
+ key "vnfc-name";
+ leaf vnfc-name {
+ type string;
+ }
+ uses vnic-groups;
+ }
+ }
+ }
+ }
+ }
+ grouping vnic-groups {
+ container vnic-groups {
+ list vnic-group {
+ key "vnic-interface-role";
+ leaf vnic-interface-role {
+ description "Same as network-role of network where vnic is connected";
+ type string;
+ mandatory true;
+ }
+ leaf network-instance-group-function {
+ description "network-instance-Group-function for network collection where vnics with vnic-interface-role will connect";
+ type string;
+ }
+ leaf vlan-assignment-policy-name {
+ description "Policy name in ASDC model & policy definition in Policy Engine";
+ type string;
+ }
+ leaf vlan-tag-index-next {
+ description "Next tag to be assigned";
+ type uint32;
+ }
+ container vlan-common-ip-addresses {
+ uses ip-addresses;
+ }
+ container vlan-vnics {
+ list vlan-vnic {
+ key "vnic-port-id";
+ leaf vnic-port-id {
+ type string;
+ mandatory true;
+ }
+ container vnic-sub-interfaces {
+ uses sub-interface-network-data;
+ }
+ }
+ }
+ }
+ }
+ }
+ grouping vnf-network-collection {
+ list vnf-network-collection {
+ key "network-instance-group-function";
+ leaf network-instance-group-function {
+ description "Network Instance-Group function in A&AI";
+ type string;
+ mandatory true;
+ }
+ leaf network-instance-group-id {
+ description "Network Instance-Group id in A&AI";
+ type string;
+ }
+ leaf network-collection-service-instance-id {
+ description "Service-instance-id of service that created the network collection";
+ type string;
+ }
+ leaf network-collection-customization-uuid {
+ description "network-collection-customization-uuid stored in Network IsntanceGroup.customization-uuid in A&AI";
+ type string;
+ }
+ container vnf-floating-ip {
+ uses ip-addresses;
+ }
+ }
+ }
+ grouping vnf-sub-interface-group {
+ list vnf-sub-interface-group {
+ key "vnfc-instance-group-function network-instance-group-function parent-port-role";
+ leaf vnfc-instance-group-function {
+ type string;
+ mandatory true;
+ }
+ leaf network-instance-group-function {
+ type string;
+ mandatory true;
+ }
+ leaf parent-port-role {
+ type string;
+ mandatory true;
+ }
+ uses vnfcs;
+ container customer-bonding-requests {
+ list customer-bonding-request {
+ key "configuration-id";
+ leaf configuration-id {
+ description "e.g. vlan network receptor configuration id";
+ type string;
+ }
+ }
+ }
+ }
+ }
+ grouping sub-interface-network-data {
+ list sub-interface-network-data {
+ key "network-id";
+ leaf network-id {
+ description "Subinterface network id (UUID in A&AI)";
+ type string;
+ mandatory true;
+ }
+ leaf network-name {
+ description "Subinterface network name";
+ type uint32;
+ }
+ leaf vlan-tag-id {
+ description "Vlan tag assigned to subinterface port";
+ type uint32;
+ }
+ leaf network-role {
+ description "e.g. untrusted ";
+ type string;
+ }
+ leaf network-role-tag {
+ description "Assuming HEAT template network role tag parameter - not used";
+ type string;
+ }
+ container network-information-items {
+ list network-information-item {
+ key "ip-version";
+ leaf ip-version {
+ description "Use ipv4 or ipv6";
+ type string;
+ }
+ leaf use-dhcp {
+ description "Indicator to use DHCP on this network for this VM - set to N for Vlan tagging";
+ type enumeration {
+ enum "Y";
+ enum "N";
+ }
+ }
+ leaf ip-count {
+ description "The number of ip addresses to be assigned per vm for this network role";
+ type uint8;
+ }
+ container network-ips {
+ leaf-list network-ip {
+ description "List of assigned ip addresses of type ip-version on a network.";
+ type inet:ip-address;
+ ordered-by user;
+ }
+ }
+ }
+ }
+ container floating-ips {
+ leaf-list floating-ip-v4 {
+ description "Floating ipv4 for VMs of a given type on this network";
+ type inet:ip-address;
+ ordered-by user;
+ }
+ leaf-list floating-ip-v6 {
+ description "Floating ipv6 for VMs of a given type on this network";
+ type inet:ipv6-address;
+ ordered-by user;
+ }
+ }
+ }
+ }
+ grouping vnf-cloud-param {
+ leaf service-instance-id {
+ type string;
+ }
+ leaf service-instance-name {
+ type string;
+ }
+ list vnf {
+ key "vnf-id";
+ leaf vnf-id {
+ type string;
+ }
+ leaf vnf-name {
+ type string;
+ }
+ uses param;
+ list vf-module {
+ key "vf-module-id";
+ leaf vf-module-id {
+ type string;
+ }
+ uses param;
+ }
+ }
+ }
+ grouping vnf-get-resource-request-input-data {
+ list vnf {
+ key "vnf-id";
+ leaf vnf-id {
+ type string;
+ }
+ list vf-module {
+ key "vf-module-id";
+ leaf vf-module-id {
+ type string;
+ }
+ }
+ }
+ }
+ grouping pnf-information {
+ container pnf-information {
+ leaf pnf-name {
+ description "Key for A&AI query";
+ type string;
+ }
+ leaf pnf-type {
+ type string;
+ }
+ uses onap-model-information;
+ }
+ }
grouping contrail-route-operation-information {
uses sdnc-request-header;
uses request-information;
@@ -798,6 +1541,235 @@ module GENERIC-RESOURCE-API { }
}
}
+ grouping port-mirror-topology-operation-information {
+ uses sdnc-request-header;
+ uses request-information;
+ uses service-information;
+ uses configuration-information;
+ uses port-mirror-configuration-request-input;
+ }
+ grouping port-mirror-configuration-request-input {
+ container port-mirror-configuration-request-input {
+ container source-port {
+ uses port-info;
+ leaf source-port-id {
+ description "needed for srv-action=disable/enable";
+ type string;
+ }
+ }
+ container dest-port {
+ uses port-info;
+ }
+ uses region-identifier;
+ container port-mirror-configuration-input-parameters {
+ uses param;
+ }
+ }
+ }
+ grouping port-info {
+ leaf service-instance-id {
+ description "May not be need.";
+ type string;
+ }
+ uses pnf-information;
+ uses vnf-information;
+ }
+ grouping port-mirror-configuration-topology {
+ container port-mirror-configuration-topology {
+ uses configuration-identifiers;
+ uses onap-model-information;
+ uses port-mirror-configuration-assignments;
+ container port-mirror-configuration-parameters {
+ uses param;
+ }
+ }
+ }
+ grouping port-mirror-configuration-assignments {
+ container port-mirror-configuration-assignments {
+ container contrail-vmi-params {
+ uses param;
+ }
+ leaf vnics-group-id {
+ type string;
+ }
+ leaf owning-entity {
+ type string;
+ }
+ leaf tenant-context {
+ description "From tenant object in A&AI";
+ type string;
+ }
+ leaf tenant {
+ description "Tenant name from A&AI for source VNF";
+ type string;
+ }
+ leaf tenant-id {
+ description "tenant-id from A&AI for source VNF";
+ type string;
+ }
+ leaf dest-tenant {
+ description "Tenant name from A&AI for destination VNF";
+ type string;
+ }
+ leaf dest-tenant-id {
+ description "tenant-id from A&AI for destination VNF";
+ type string;
+ }
+ leaf cloud-region-id {
+ type string;
+ }
+ leaf cloud-owner {
+ type string;
+ }
+ leaf dest-network-fqdn {
+ type string;
+ }
+ leaf source-network-fqdn {
+ type string;
+ }
+ leaf source-capacity {
+ description "Source port pps (packets per second) rating from tosca model";
+ type uint32;
+ }
+ leaf source-vnf-id {
+ type string;
+ }
+ leaf dest-vnf-id {
+ description "For vProbe";
+ type string;
+ }
+ leaf dest-pnf-name {
+ description "For pProbe";
+ type string;
+ }
+ leaf dest-p-interface {
+ description "For pProbe; from policy manager";
+ type string;
+ }
+ leaf dest-pnf-port-policy-name {
+ description "For pProbe; from tosca model";
+ type string;
+ }
+ leaf probe-type {
+ description "vprobe or pprobe; derived from configuration-information.configuration-sub-type";
+ type string;
+ }
+ leaf route-allotted-resource-id {
+ description "For vProbe";
+ type string;
+ }
+ container source-vnfc-instance-group-id {
+ leaf service-instance-id {
+ type string;
+ }
+ leaf nfc-naming-code {
+ type string;
+ }
+ leaf instance-group-role {
+ type string;
+ }
+ leaf configuration-id {
+ type string;
+ }
+ }
+ container dest-vnfc-instance-group-id {
+ leaf service-instance-id {
+ type string;
+ }
+ leaf nfc-naming-code {
+ type string;
+ }
+ leaf instance-group-role {
+ type string;
+ }
+ leaf configuration-id {
+ type string;
+ }
+ }
+ container source-to-dest-maps {
+ list source-to-dest-map {
+ key "source-port-id";
+ leaf source-port-id {
+ type string;
+ mandatory true;
+ }
+ leaf source-port-name {
+ type string;
+ }
+ leaf source-vserver-id {
+ type string;
+ }
+ leaf dest-vserver-id {
+ type string;
+ }
+ leaf dest-port-id {
+ type string;
+ }
+ leaf dest-port-name {
+ type string;
+ }
+ leaf link-name {
+ type string;
+ }
+ container dest-ip-addresses {
+ uses ip-addresses;
+ }
+ }
+ }
+ }
+ }
+ grouping gc-topology-operation-information {
+ uses sdnc-request-header;
+ uses request-information;
+ uses service-information;
+ uses configuration-information;
+ uses gc-request-input;
+ }
+ grouping gc-request-input {
+ container gc-request-input {
+ leaf vnf-id {
+ type string;
+ }
+ container input-parameters {
+ uses param;
+ }
+ }
+ }
+ grouping vnr-parameters {
+ container vnr-parameters {
+ leaf vnf-id {
+ type string;
+ }
+ leaf vnf-service-instance-id {
+ type string;
+ }
+ leaf network-collection-service-instance-id {
+ description "service instance id that created network-collection";
+ type string;
+ }
+ leaf network-instance-group-id {
+ type string;
+ }
+ leaf network-id {
+ type string;
+ }
+ leaf vnfc-instance-group-function {
+ type string;
+ }
+ leaf network-instance-group-function {
+ type string;
+ }
+ leaf parent-port-role {
+ type string;
+ }
+ leaf upper-tag-id {
+ type uint32;
+ }
+ leaf lower-tag-id {
+ type uint32;
+ }
+ }
+ }
grouping tunnelxconn-operation-information {
uses sdnc-request-header;
uses request-information;
@@ -880,7 +1852,6 @@ module GENERIC-RESOURCE-API { }
}
}
-
grouping connection-attachment-operation-information {
uses sdnc-request-header;
uses request-information;
@@ -996,6 +1967,95 @@ module GENERIC-RESOURCE-API { }
}
}
+ grouping configuration-information {
+ container configuration-information {
+ leaf configuration-id {
+ type string;
+ }
+ leaf configuration-name {
+ type string;
+ }
+ leaf configuration-type {
+ description "Not an enum, but expected values are port-mirror-configuration, vlan-network-receptor";
+ type string;
+ }
+ leaf configuration-sub-type {
+ description "e.g. vprobe and pprobe when configuration-type=port-mirror-configuration";
+ type string;
+ }
+ uses onap-model-information;
+ }
+ }
+ grouping configuration-identifiers {
+ container configuration-identifiers {
+ leaf configuration-id {
+ type string;
+ }
+ leaf configuration-name {
+ type string;
+ }
+ leaf configuration-type {
+ description "Not an enum, but expected values are port-mirror-configuration.";
+ type string;
+ }
+ leaf configuration-sub-type {
+ description " vprobe and pprobe";
+ type string;
+ }
+ leaf parent-service-instance-id {
+ description "Service-instance-id of the parent service to which this resource belongs.";
+ type string;
+ }
+ }
+ }
+ grouping configuration-oper-status {
+ container configuration-oper-status {
+ uses oper-status-data;
+ }
+ }
+ grouping configuration-status {
+ container configuration-status {
+ leaf response-code {
+ type string;
+ }
+ leaf response-message {
+ type string;
+ }
+ leaf final-indicator {
+ type string;
+ }
+ leaf request-status {
+ type enumeration {
+ enum "synccomplete";
+ enum "asynccomplete";
+ enum "notifycomplete";
+ }
+ }
+ leaf action {
+ description "value would one of possible request-actions; match the list in service-data oper-status";
+ type string;
+ }
+ leaf rpc-name {
+ type string;
+ }
+ leaf rpc-action {
+ description "this is the svc-action from the incoming request";
+ type enumeration {
+ enum "assign";
+ enum "activate";
+ enum "create";
+ enum "disable";
+ enum "enable";
+ enum "delete";
+ enum "unassign";
+ enum "deactivate";
+ }
+ }
+ leaf response-timestamp {
+ type string;
+ }
+ }
+ }
grouping topology-response-common {
leaf svc-request-id {
description "the request id from the request message for which this is the responseKeep as M";
@@ -1021,7 +2081,7 @@ module GENERIC-RESOURCE-API { type string;
}
leaf svc-action {
- description "Enumerated listThis is the rpcAction";
+ description "This is the rpcAction";
type enumeration {
enum "reserve";
enum "assign";
@@ -1033,6 +2093,9 @@ module GENERIC-RESOURCE-API { enum "deactivate";
enum "unassign";
enum "create";
+ enum "disable";
+ enum "enable";
+ enum "update";
}
}
leaf svc-notification-url {
@@ -1083,6 +2146,18 @@ module GENERIC-RESOURCE-API { enum "ActivateSiteInstance";
enum "DeactivateSiteInstance";
enum "DeleteSiteInstance";
+ enum "CreatePortMirrorConfigurationInstance";
+ enum "DeletePortMirrorConfigurationInstance";
+ enum "ChangePortMirrorConfigurationInstance";
+ enum "CreateGenericConfigurationInstance";
+ enum "DeleteGenericConfigurationInstance";
+ enum "PreloadVfModuleRequest";
+ enum "DeletePreloadVfModuleRequest";
+ enum "PreloadNetworkRequest";
+ enum "DeletePreloadNetworkRequest";
+ enum "CreateForwardingPathInstance";
+ enum "DeleteForwardingPathInstance";
+ enum "UpdateForwardingPathInstance";
}
}
leaf source {
@@ -1167,6 +2242,43 @@ module GENERIC-RESOURCE-API { leaf value {
type string;
}
+ container resource-resolution-data {
+ list resource-key {
+ key "name";
+ leaf name {
+ type string;
+ }
+ leaf value {
+ type string;
+ }
+ }
+ leaf status {
+ description "SUCCESS, FAILED, or PENDING - RA returned data as capability";
+ type string;
+ }
+ leaf capability-name {
+ description "Resource assignment resolution Capability name";
+ type string;
+ }
+ }
+ }
+ }
+ grouping ip-addresses {
+ container ip-addresses {
+ leaf ipv4-address {
+ type inet:ip-address;
+ }
+ leaf ipv6-address {
+ type inet:ip-address;
+ }
+ leaf vipv4-address {
+ description "Virtual v4";
+ type inet:ip-address;
+ }
+ leaf vipv6-address {
+ description "Virtual v6";
+ type inet:ip-address;
+ }
}
}
grouping instance-reference {
@@ -1199,6 +2311,7 @@ module GENERIC-RESOURCE-API { enum "unassign";
enum "deactivate";
enum "create";
+ enum "changeassign";
}
}
leaf last-action {
@@ -1237,6 +2350,18 @@ module GENERIC-RESOURCE-API { enum "ActivateSiteInstance";
enum "DeactivateSiteInstance";
enum "DeleteSiteInstance";
+ enum "CreatePortMirrorConfigurationInstance";
+ enum "DeletePortMirrorConfigurationInstance";
+ enum "ChangePortMirrorConfigurationInstance";
+ enum "CreateGenericConfigurationInstance";
+ enum "DeleteGenericConfigurationInstance";
+ enum "PreloadVfModuleRequest";
+ enum "DeletePreloadVfModuleRequest";
+ enum "PreloadNetworkRequest";
+ enum "DeletePreloadNetworkRequest";
+ enum "CreateForwardingPathInstance";
+ enum "DeleteForwardingPathInstance";
+ enum "UpdateForwardingPathInstance";
}
}
leaf last-svc-request-id {
@@ -1244,7 +2369,6 @@ module GENERIC-RESOURCE-API { type string;
}
leaf last-order-status {
- description "fieldused by generic-resource-api";
type enumeration {
enum "Active";
enum "PendingAssignment";
@@ -1293,6 +2417,21 @@ module GENERIC-RESOURCE-API { uses instance-reference;
}
}
+ grouping getpathsegment-response-information {
+ container getpathsegment-response-information {
+ uses instance-reference;
+ }
+ }
+ grouping port-mirror-response-information {
+ container port-mirror-response-information {
+ uses instance-reference;
+ }
+ }
+ grouping gc-response-information {
+ container gc-response-information {
+ uses instance-reference;
+ }
+ }
grouping tunnelxconn-response-information {
container tunnelxconn-response-information {
uses instance-reference;
@@ -1309,266 +2448,46 @@ module GENERIC-RESOURCE-API { }
}
grouping preload-model-information {
- list vnf-preload-list {
- key "vnf-name vnf-type";
- leaf vnf-name {
+ list preload-list {
+ key "preload-id preload-type";
+ leaf preload-id {
description "vf-module-name or network name";
type string;
mandatory true;
}
- leaf vnf-type {
- description "vf-module-type or network type";
+ leaf preload-type {
+ description "network or vf-module";
type string;
mandatory true;
}
uses preload-data;
}
}
- grouping vnf-topology-response-body {
- leaf svc-request-id {
- type string;
- }
- leaf response-code {
- type string;
- }
- leaf response-message {
- type string;
- }
- leaf ack-final-indicator {
- type string;
- }
- }
grouping preload-data {
container preload-data {
- uses vnf-topology-information;
- uses network-topology-information;
- uses oper-status;
- }
- }
- grouping vnf-topology-information {
- container vnf-topology-information {
- uses vnf-topology-identifier;
- uses vnf-assignments;
- uses vnf-parameters;
+ uses preload-vf-module-topology-information;
+ uses preload-network-topology-information;
+ uses preload-oper-status;
}
}
- grouping vnf-topology-identifier {
- container vnf-topology-identifier {
- leaf service-type {
- type string;
- }
- leaf service-id {
- type string;
- }
- leaf vnf-name {
- description "vf-module-name";
- type string;
- }
- leaf vnf-type {
- description "vf-module-type";
- type string;
- }
- leaf generic-vnf-name {
- type string;
- }
- leaf generic-vnf-type {
- type string;
- }
- leaf generic-vnf-id {
- type string;
- }
- }
- }
- grouping vnf-assignments {
- container vnf-assignments {
- leaf vnf-status {
- description "Orchestration Status from AAI - to be set by SDNC";
- type string;
- }
- list availability-zones {
- key "availability-zone";
- leaf availability-zone {
- description "Openstack availability zone name or UUID";
- type string;
- }
- }
- list vnf-networks {
- key "network-role";
- uses vnf-network;
- uses sriov-vlan-filter-list;
- }
- uses vm-topology;
- }
- }
- grouping vm-topology {
- list vnf-vms {
- key "vm-type";
- leaf vm-type {
- type string;
- mandatory true;
- }
- leaf vm-count {
- type uint8;
- }
- list vm-names {
- key "vm-name";
- leaf vm-name {
- type string;
- }
- }
- list vm-networks {
- key "network-role";
- uses vm-network;
- }
- }
- }
- grouping vnf-network {
- leaf network-role {
- description "A Network Role to which a VNF must connect";
- type string;
- mandatory true;
- }
- leaf network-name {
- description "Unique Neutron UUID of an instance of the network role ";
- type string;
- }
- leaf neutron-id {
- description "Unique Neutron UUID of an instance of the network role ";
- type string;
- }
- leaf network-id {
- description "Unique Neutron UUID of an instance of the network role ";
- type string;
- }
- leaf subnet-id {
- description "ipv4 subnet UUID to be passed into the HEAT template";
- type string;
- }
- leaf subnet-name {
- description "ipv4 subnet-name that corresponds to the ipv4 subnet-id";
- type string;
- }
- leaf contrail-network-fqdn {
- description "contrail network policy object";
- type string;
- }
- leaf ipv6-subnet-id {
- description "ipv6 subnet UUID to be passed into the HEAT template";
- type string;
- }
- leaf ipv6-subnet-name {
- description "ipv6 subnet-name that corresponds to the ipv6 subnet-id";
- type string;
- }
- }
- grouping sriov-vlan-filter-list {
- list sriov-vlan-filter-list {
- key "sriov-vlan-filter";
- leaf sriov-vlan-filter {
- type string;
- }
- }
- }
- grouping vm-network {
- leaf network-role {
- description "network (identified by role) that this VM connects to. Should also be included in the vnf-networks for the containing VNF";
- type string;
- }
- leaf use-dhcp {
- description "Indicator to use DHCP on this network for this VM";
- type enumeration {
- enum "Y";
- enum "N";
- }
- }
- leaf ip-count {
- description "The number of ip addresses to be assigned per vm for this network role";
- type uint8;
- }
- list network-ips {
- key "ip-address";
- leaf ip-address {
- description "List of assigned ipv4 addresses on a network";
- type inet:ip-address;
- }
- }
- list network-ips-v6 {
- key "ip-address-ipv6";
- leaf ip-address-ipv6 {
- description "List of assigned ipv6 addresses on a network";
- type inet:ipv6-address;
- }
- }
- list network-macs {
- key "mac-address";
- leaf mac-address {
- description "List of network assignments for this VM (one per network)";
- type string;
- }
- }
- leaf floating-ip {
- description "Floating ipv4 for VMs of a given type on this network";
- type inet:ip-address;
- }
- leaf floating-ip-v6 {
- description "Floating ipv6 for VMs of a given type on this network";
- type inet:ipv6-address;
- }
- list interface-route-prefixes {
- key "interface-route-prefix-cidr";
- leaf interface-route-prefix-cidr {
- description "route prefixes (CIDRs) in ip/cidr format to be provided to MSO in vnf-topology as a list of static routes";
- type string;
- mandatory true;
- }
- leaf interface-route-prefix {
- description "route prefixes (CIDRs) to be provided to MSO in vnf-topology as a list of static routes";
- type inet:ip-address;
- }
- }
- }
- grouping vnf-parameters {
- list vnf-parameters {
- key "vnf-parameter-name";
- leaf vnf-parameter-name {
- description "The name of an arbitrary instance-specific vnf-parameters";
- type string;
- }
- leaf vnf-parameter-value {
- description "The value of an arbitrary instance-specific vnf-parameters ";
- type string;
- }
+ grouping preload-vf-module-topology-information {
+ container preload-vf-module-topology-information {
+ uses vnf-topology-identifier-structure;
+ uses vnf-resource-assignments;
+ uses vf-module-topology;
}
}
- grouping network-topology-information {
- container network-topology-information {
- uses network-topology-identifier;
+ grouping preload-network-topology-information {
+ container preload-network-topology-information {
+ uses network-topology-identifier-structure;
uses subnets;
uses vpn-bindings;
uses network-policy;
uses route-table-reference;
+ uses host-routes;
uses provider-network-information;
}
}
- grouping network-topology-identifier {
- container network-topology-identifier {
- leaf service-type {
- type string;
- }
- leaf network-name {
- type string;
- }
- leaf network-role {
- type string;
- }
- leaf network-type {
- type string;
- }
- leaf network-technology {
- type string;
- }
- }
- }
grouping subnets {
list subnets {
key "start-address";
@@ -1596,9 +2515,22 @@ module GENERIC-RESOURCE-API { leaf dhcp-end-address {
type string;
}
+ leaf addr-from-start {
+ description "Default is N";
+ type enumeration {
+ enum "Y";
+ enum "N";
+ }
+ }
leaf subnet-name {
type string;
}
+ leaf subnet-role {
+ type string;
+ }
+ leaf subnet-sequence {
+ type uint8;
+ }
}
}
grouping vpn-bindings {
@@ -1607,9 +2539,19 @@ module GENERIC-RESOURCE-API { leaf vpn-binding-id {
type string;
}
+ leaf vpn-name {
+ type string;
+ }
leaf global-route-target {
type string;
}
+ leaf route-target-role {
+ type string;
+ }
+ leaf aic-zone {
+ description "AIC Zone the route target associated with";
+ type string;
+ }
}
}
grouping network-policy {
@@ -1645,12 +2587,24 @@ module GENERIC-RESOURCE-API { leaf is-shared-network {
type boolean;
}
- leaf is-external-network {
+ leaf is-external-network {
type boolean;
}
}
- grouping oper-status {
- container oper-status {
+ grouping host-routes {
+ list host-routes {
+ key "route-prefix";
+ leaf route-prefix {
+ type string;
+ }
+ leaf next-hop {
+ description "Could be ip-address or hostname or service-instance";
+ type string;
+ }
+ }
+ }
+ grouping preload-oper-status {
+ container preload-oper-status {
leaf order-status {
type enumeration {
enum "Active";
@@ -1662,23 +2616,11 @@ module GENERIC-RESOURCE-API { }
}
leaf last-action {
- description "this is preload request actions";
type enumeration {
- enum "VNFActivateRequest";
- enum "ChangeVNFActivateRequest";
- enum "VnfInstanceActivateRequest";
- enum "ChangeVnfInstanceActivateRequest";
- enum "VfModuleActivateRequest";
- enum "ChangeVfModuleActivateRequest";
- enum "DisconnectVNFRequest";
- enum "DisconnectVnfInstanceRequest";
- enum "DisconnectVfModuleRequest";
- enum "PreloadVNFRequest";
- enum "DeletePreloadVNFRequest";
- enum "PreloadVnfInstanceRequest";
- enum "DeletePreloadVnfInstanceRequest";
enum "PreloadVfModuleRequest";
enum "DeletePreloadVfModuleRequest";
+ enum "PreloadNetworkRequest";
+ enum "DeletePreloadNetworkRequest";
}
}
leaf last-svc-request-id {
@@ -1708,6 +2650,34 @@ module GENERIC-RESOURCE-API { }
}
}
+ grouping preload-topology-response-body {
+ leaf svc-request-id {
+ type string;
+ }
+ leaf response-code {
+ type string;
+ }
+ leaf response-message {
+ type string;
+ }
+ leaf ack-final-indicator {
+ type string;
+ }
+ }
+ rpc generic-configuration-notification {
+ input {
+ uses sdnc-request-header;
+ uses request-information;
+ uses service-information;
+ uses configuration-information;
+ uses topology-response-common;
+ leaf configuration-topology-link {
+ description "Returns URL to generic-configuration-topology ";
+ type string;
+ }
+ uses vnr-parameters;
+ }
+ }
container services {
uses service-model-infrastructure;
}
@@ -1808,6 +2778,39 @@ module GENERIC-RESOURCE-API { uses allotted-resource-status;
}
}
+ container port-mirror-configurations {
+ list port-mirror-configuration {
+ key "configuration-id";
+ leaf configuration-id {
+ type string;
+ mandatory true;
+ }
+ container configuration-data {
+ container configuration-operation-information {
+ uses port-mirror-topology-operation-information;
+ }
+ uses port-mirror-configuration-topology;
+ uses configuration-oper-status;
+ }
+ uses configuration-status;
+ }
+ }
+ container generic-configurations {
+ list gc-configuration {
+ key "configuration-id";
+ leaf configuration-id {
+ type string;
+ mandatory true;
+ }
+ container configuration-data {
+ container configuration-operation-information {
+ uses gc-topology-operation-information;
+ }
+ uses configuration-oper-status;
+ }
+ uses configuration-status;
+ }
+ }
rpc service-topology-operation {
input {
uses service-operation-information;
@@ -1888,27 +2891,95 @@ module GENERIC-RESOURCE-API { uses service-response-information;
}
}
- container preload-vnfs {
+ rpc policy-update-notify-operation {
+ input {
+ leaf policy-name {
+ type string;
+ mandatory true;
+ }
+ leaf version-id {
+ description "Map JSON versionNo to version-id";
+ type string;
+ mandatory true;
+ }
+ leaf update-type {
+ type string;
+ mandatory true;
+ }
+ }
+ output {
+ leaf error-code {
+ type string;
+ }
+ leaf error-msg {
+ type string;
+ }
+ }
+ }
+ rpc getpathsegment-topology-operation {
+ input {
+ uses forwarding-path-operation-information;
+ }
+ output {
+ uses topology-response-common;
+ uses getpathsegment-response-information;
+ uses service-response-information;
+ }
+ }
+ rpc port-mirror-topology-operation {
+ input {
+ uses port-mirror-topology-operation-information;
+ }
+ output {
+ uses topology-response-common;
+ uses port-mirror-response-information;
+ uses service-response-information;
+ }
+ }
+ rpc generic-configuration-topology-operation {
+ input {
+ uses gc-topology-operation-information;
+ }
+ output {
+ uses topology-response-common;
+ uses gc-response-information;
+ uses service-response-information;
+ }
+ }
+ rpc vnf-get-resource-request {
+ input {
+ uses sdnc-request-header;
+ uses request-information;
+ uses service-information;
+ uses vnf-get-resource-request-input-data;
+ }
+ output {
+ container vnf-get-resource-response-information {
+ uses vnf-cloud-param;
+ }
+ }
+ }
+ container preload-information {
uses preload-model-information;
}
- rpc preload-vnf-topology-operation {
+ rpc preload-vf-module-topology-operation {
input {
uses sdnc-request-header;
uses request-information;
- uses vnf-topology-information;
+ uses preload-vf-module-topology-information;
}
output {
- uses vnf-topology-response-body;
+ uses preload-topology-response-body;
}
}
rpc preload-network-topology-operation {
input {
uses sdnc-request-header;
uses request-information;
- uses network-topology-information;
+ uses preload-network-topology-information;
}
output {
- uses vnf-topology-response-body;
+ uses preload-topology-response-body;
}
}
diff --git a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java index 7f67f40f..02217b54 100644 --- a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java +++ b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java @@ -12,6 +12,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; + import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; @@ -34,20 +35,38 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.re import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ContrailRouteTopologyOperationOutput; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ContrailRouteTopologyOperationOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GENERICRESOURCEAPIService; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationNotificationInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationNotificationInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationTopologyOperationInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationTopologyOperationInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationTopologyOperationOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationTopologyOperationOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GetpathsegmentTopologyOperationInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GetpathsegmentTopologyOperationInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GetpathsegmentTopologyOperationOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GetpathsegmentTopologyOperationOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInput; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutput; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PolicyUpdateNotifyOperationInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PolicyUpdateNotifyOperationInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PolicyUpdateNotifyOperationOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PolicyUpdateNotifyOperationOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PortMirrorTopologyOperationInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PortMirrorTopologyOperationInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PortMirrorTopologyOperationOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PortMirrorTopologyOperationOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadInformation; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadInformationBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationInput; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationOutput; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationInput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationOutput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfs; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfsBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationInput; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationOutput; @@ -66,6 +85,10 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.re import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationOutput; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfGetResourceRequestInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfGetResourceRequestInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfGetResourceRequestOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfGetResourceRequestOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInput; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutput; @@ -73,12 +96,14 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.re import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.brg.response.information.BrgResponseInformationBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.connection.attachment.response.information.ConnectionAttachmentResponseInformationBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.contrail.route.response.information.ContrailRouteResponseInformationBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.gc.response.information.GcResponseInformationBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.response.information.NetworkResponseInformationBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.port.mirror.response.information.PortMirrorResponseInformationBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.data.PreloadData; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.data.PreloadDataBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.model.information.VnfPreloadList; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.model.information.VnfPreloadListBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.model.information.VnfPreloadListKey; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.model.information.PreloadList; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.model.information.PreloadListBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.model.information.PreloadListKey; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction; @@ -93,6 +118,8 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.re import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.status.ServiceStatus.RpcAction; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.status.ServiceStatusBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.tunnelxconn.response.information.TunnelxconnResponseInformationBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.response.information.VfModuleResponseInformationBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.response.information.VnfResponseInformationBuilder; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -101,35 +128,37 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Defines a base implementation for your provider. This class extends from a helper class which provides storage for - * the most commonly used components of the MD-SAL. Additionally the base class provides some basic logging and + * Defines a base implementation for your provider. This class extends from a + * helper class which provides storage for the most commonly used components of + * the MD-SAL. Additionally the base class provides some basic logging and * initialization / clean up methods. * - * To use this, copy and paste (overwrite) the following method into the TestApplicationProviderModule class which is - * auto generated under src/main/java in this project (created only once during first compilation): + * To use this, copy and paste (overwrite) the following method into the + * TestApplicationProviderModule class which is auto generated under + * src/main/java in this project (created only once during first compilation): * * <pre> * * @Override * public java.lang.AutoCloseable createInstance() { * - * // final GENERIC-RESOURCE-APIProvider provider = new - * // GENERIC-RESOURCE-APIProvider(); - * final GenericResourceApiProvider provider = new GenericResourceApiProvider(); - * provider.setDataBroker(getDataBrokerDependency()); - * provider.setNotificationService(getNotificationServiceDependency()); - * provider.setRpcRegistry(getRpcRegistryDependency()); - * provider.initialize(); - * return new AutoCloseable() { + * // final GENERIC-RESOURCE-APIProvider provider = new + * // GENERIC-RESOURCE-APIProvider(); + * final GenericResourceApiProvider provider = new GenericResourceApiProvider(); + * provider.setDataBroker(getDataBrokerDependency()); + * provider.setNotificationService(getNotificationServiceDependency()); + * provider.setRpcRegistry(getRpcRegistryDependency()); + * provider.initialize(); + * return new AutoCloseable() { * - * @Override - * public void close() throws Exception { - * // TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE - * // BROKER/NOTIFICATION - * // SERVIE/RPC REGISTRY - * provider.close(); - * } - * }; + * @Override + * public void close() throws Exception { + * // TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE + * // BROKER/NOTIFICATION + * // SERVIE/RPC REGISTRY + * provider.close(); + * } + * }; * } * * </pre> @@ -150,6 +179,9 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC private static final String ERROR_MESSAGE_PARAM = "error-message"; private static final String ACK_FINAL_PARAM = "ack-final"; private static final String SERVICE_OBJECT_PATH_PARAM = "service-object-path"; + private static final String NETWORK_OBJECT_PATH_PARAM = "network-object-path"; + private static final String VNF_OBJECT_PATH_PARAM = "vnf-object-path"; + private static final String VF_MODULE_OBJECT_PATH_PARAM = "vf-module-object-path"; private static final String UPDATING_MDSAL_ERROR_MESSAGE = "Caught Exception updating MD-SAL for {} [{}] \n"; private static final String UPDATING_MDSAL_ERROR_MESSAGE_2 = "Caught Exception updating MD-SAL for {} [{},{}] \n"; private static final String RETURNED_FAILED_MESSAGE = "Returned FAILED for {} [{}] {}"; @@ -164,6 +196,8 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC protected static final String INVALID_INPUT_ERROR_MESSAGE = "invalid input: the service-instance does not have any service data in SDNC"; private static final String ALLOTTED_RESOURCE_ID_PARAM = "allotted-resource-id"; private static final String ERROR_NETWORK_ID = "error"; + private static final String BACKGROUND_THREAD_STARTED_MESSAGE = "Start background thread"; + private static final String BACKGROUND_THREAD_INFO = "Background thread: input conf_id is {}"; private final Logger log = LoggerFactory.getLogger(GenericResourceApiProvider.class); private final ExecutorService executor; @@ -174,12 +208,8 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC protected RpcProviderRegistry rpcRegistry; protected BindingAwareBroker.RpcRegistration<GENERICRESOURCEAPIService> rpcRegistration; - public GenericResourceApiProvider( - DataBroker dataBroker, - NotificationPublishService notificationPublishService, - RpcProviderRegistry rpcProviderRegistry, - GenericResourceApiSvcLogicServiceClient client - ) { + public GenericResourceApiProvider(DataBroker dataBroker, NotificationPublishService notificationPublishService, + RpcProviderRegistry rpcProviderRegistry, GenericResourceApiSvcLogicServiceClient client) { log.info("Creating provider for {}", APP_NAME); executor = Executors.newFixedThreadPool(1); setDataBroker(dataBroker); @@ -259,15 +289,15 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC // Create the service-instance container t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Services.class), - new ServicesBuilder().build()); + new ServicesBuilder().build()); t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Services.class), - new ServicesBuilder().build()); + new ServicesBuilder().build()); - // Create the PreloadVnfs container - t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(PreloadVnfs.class), - new PreloadVnfsBuilder().build()); - t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(PreloadVnfs.class), - new PreloadVnfsBuilder().build()); + // Create the PreloadInformation container + t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(PreloadInformation.class), + new PreloadInformationBuilder().build()); + t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(PreloadInformation.class), + new PreloadInformationBuilder().build()); try { CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = t.submit(); @@ -280,7 +310,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC } private void setServiceStatus(ServiceStatusBuilder serviceStatusBuilder, String errorCode, String errorMessage, - String ackFinal) { + String ackFinal) { serviceStatusBuilder.setResponseCode(errorCode); serviceStatusBuilder.setResponseMessage(errorMessage); serviceStatusBuilder.setFinalIndicator(ackFinal); @@ -296,24 +326,27 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC private void setServiceStatus(ServiceStatusBuilder serviceStatusBuilder, SdncRequestHeader requestHeader) { if (requestHeader != null && requestHeader.getSvcAction() != null) { switch (requestHeader.getSvcAction()) { - case Assign: - serviceStatusBuilder.setRpcAction(RpcAction.Assign); - break; - case Unassign: - serviceStatusBuilder.setRpcAction(RpcAction.Unassign); - break; - case Activate: - serviceStatusBuilder.setRpcAction(RpcAction.Activate); - break; - case Deactivate: - serviceStatusBuilder.setRpcAction(RpcAction.Deactivate); - break; - case Delete: - serviceStatusBuilder.setRpcAction(RpcAction.Delete); - break; - default: - log.error("Unknown SvcAction: {}", requestHeader.getSvcAction()); - break; + case Assign: + serviceStatusBuilder.setRpcAction(RpcAction.Assign); + break; + case Unassign: + serviceStatusBuilder.setRpcAction(RpcAction.Unassign); + break; + case Activate: + serviceStatusBuilder.setRpcAction(RpcAction.Activate); + break; + case Deactivate: + serviceStatusBuilder.setRpcAction(RpcAction.Deactivate); + break; + case Delete: + serviceStatusBuilder.setRpcAction(RpcAction.Delete); + break; + case Create: + serviceStatusBuilder.setRpcAction(RpcAction.Create); + break; + default: + log.error("Unknown SvcAction: {}", requestHeader.getSvcAction()); + break; } } } @@ -325,10 +358,8 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC private void getServiceData(String siid, ServiceDataBuilder serviceDataBuilder, LogicalDatastoreType type) { // See if any data exists yet for this siid, if so grab it. - InstanceIdentifier<Service> serviceInstanceIdentifier = InstanceIdentifier - .builder(Services.class) - .child(Service.class, new ServiceKey(siid)) - .build(); + InstanceIdentifier<Service> serviceInstanceIdentifier = InstanceIdentifier.builder(Services.class) + .child(Service.class, new ServiceKey(siid)).build(); ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction(); Optional<Service> data = Optional.absent(); @@ -352,6 +383,10 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC serviceDataBuilder.setVnfs(serviceData.getVnfs()); serviceDataBuilder.setProvidedAllottedResources(serviceData.getProvidedAllottedResources()); serviceDataBuilder.setConsumedAllottedResources(serviceData.getConsumedAllottedResources()); + serviceDataBuilder.setNetworkInstanceGroups(serviceData.getNetworkInstanceGroups()); + serviceDataBuilder.setVnfcInstanceGroups(serviceData.getVnfcInstanceGroups()); + serviceDataBuilder.setForwardingPaths(serviceData.getForwardingPaths()); + serviceDataBuilder.setProvidedConfigurations(serviceData.getProvidedConfigurations()); // service-instance-id needs to be set } else { log.info("No service-data found in MD-SAL ({}) for [{}]", type, siid); @@ -361,68 +396,17 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC } } - private void getPreloadData(String vnfName, String vnfType, PreloadDataBuilder preloadDataBuilder) { - // default to config - getPreloadData(vnfName, vnfType, preloadDataBuilder, LogicalDatastoreType.CONFIGURATION); - } - - private void getPreloadData(String preloadName, String preloadType, PreloadDataBuilder preloadDataBuilder, - LogicalDatastoreType type) { - // See if any data exists yet for this name/type, if so grab it. - InstanceIdentifier<VnfPreloadList> preloadInstanceIdentifier = InstanceIdentifier - .builder(PreloadVnfs.class) - .child(VnfPreloadList.class, new VnfPreloadListKey(preloadName, preloadType)) - .build(); - - ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction(); - Optional<VnfPreloadList> data = Optional.absent(); - try { - data = readTx.read(type, preloadInstanceIdentifier).get(); - } catch (InterruptedException | ExecutionException e) { - log.error("Caught Exception reading MD-SAL ({}) for [{},{}] ", type, preloadName, preloadType, e); - } - - if (data != null && data.isPresent()) { - PreloadData preloadData = data.get().getPreloadData(); - if (preloadData != null) { - log.info("Read MD-SAL ({}) data for [{},{}] PreloadData: {}", type, preloadName, preloadType, - preloadData); - preloadDataBuilder.setVnfTopologyInformation(preloadData.getVnfTopologyInformation()); - preloadDataBuilder.setNetworkTopologyInformation(preloadData.getNetworkTopologyInformation()); - preloadDataBuilder.setOperStatus(preloadData.getOperStatus()); - } else { - log.info("No preload-data found in MD-SAL ({}) for [{},{}] ", type, preloadName, preloadType); - } - } else { - log.info("No data found in MD-SAL ({}) for [{},{}] ", type, preloadName, preloadType); - } - } - private void saveService(final Service entry, boolean merge, LogicalDatastoreType storeType) { // Each entry will be identifiable by a unique key, we have to create that // identifier - InstanceIdentifier<Service> path = InstanceIdentifier - .builder(Services.class) - .child(Service.class, entry.getKey()) - .build(); - - trySaveEntry(entry, merge, storeType, path); - } - - private void savePreloadList(final VnfPreloadList entry, boolean merge, LogicalDatastoreType storeType) { - - // Each entry will be identifiable by a unique key, we have to create that - // identifier - InstanceIdentifier<VnfPreloadList> path = InstanceIdentifier - .builder(PreloadVnfs.class) - .child(VnfPreloadList.class, entry.getKey()) - .build(); + InstanceIdentifier<Service> path = InstanceIdentifier.builder(Services.class) + .child(Service.class, entry.getKey()).build(); trySaveEntry(entry, merge, storeType, path); } private <T extends DataObject> void trySaveEntry(T entry, boolean merge, LogicalDatastoreType storeType, - InstanceIdentifier<T> path) { + InstanceIdentifier<T> path) { int tries = 2; while (true) { try { @@ -442,8 +426,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC } private <T extends DataObject> void save(T entry, boolean merge, LogicalDatastoreType storeType, - InstanceIdentifier<T> path) - throws TransactionCommitFailedException { + InstanceIdentifier<T> path) throws TransactionCommitFailedException { WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); if (merge) { tx.merge(storeType, path, entry); @@ -457,10 +440,8 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC private void deleteService(final Service entry, LogicalDatastoreType storeType) { // Each entry will be identifiable by a unique key, we have to create // that identifier - InstanceIdentifier<Service> path = InstanceIdentifier - .builder(Services.class) - .child(Service.class, entry.getKey()) - .build(); + InstanceIdentifier<Service> path = InstanceIdentifier.builder(Services.class) + .child(Service.class, entry.getKey()).build(); tryDeleteEntry(storeType, path); } @@ -485,7 +466,115 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC } private void delete(LogicalDatastoreType storeType, InstanceIdentifier<Service> path) - throws TransactionCommitFailedException { + throws TransactionCommitFailedException { + WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); + tx.delete(storeType, path); + tx.submit().checkedGet(); + log.debug("DataStore delete succeeded"); + } + + private void getPreloadData(String vnf_name, String vnf_type, PreloadDataBuilder preloadDataBuilder) { + // default to config + getPreloadData(vnf_name, vnf_type, preloadDataBuilder, LogicalDatastoreType.CONFIGURATION); + } + + private void getPreloadData(String preloadName, String preloadType, PreloadDataBuilder preloadDataBuilder, + LogicalDatastoreType type) { + // See if any data exists yet for this name/type, if so grab it. + InstanceIdentifier preloadInstanceIdentifier = InstanceIdentifier + .<PreloadInformation>builder(PreloadInformation.class) + .child(PreloadList.class, new PreloadListKey(preloadName, preloadType)).build(); + ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction(); + Optional<PreloadList> data = null; + try { + data = (Optional<PreloadList>) readTx.read(type, preloadInstanceIdentifier).get(); + } catch (InterruptedException | ExecutionException e) { + log.error("Caught Exception reading MD-SAL ({}) for [{},{}] ", type, preloadName, preloadType, e); + } + + if (data != null && data.isPresent()) { + PreloadData preloadData = data.get().getPreloadData(); + if (preloadData != null) { + log.info("Read MD-SAL ({}) data for [{},{}] PreloadData: {}", type, preloadName, preloadType, + preloadData); + preloadDataBuilder + .setPreloadVfModuleTopologyInformation(preloadData.getPreloadVfModuleTopologyInformation()); + preloadDataBuilder + .setPreloadNetworkTopologyInformation(preloadData.getPreloadNetworkTopologyInformation()); + preloadDataBuilder.setPreloadOperStatus(preloadData.getPreloadOperStatus()); + } else { + log.info("No preload-data found in MD-SAL ({}) for [{},{}] ", type, preloadName, preloadType); + } + } else { + log.info("No data found in MD-SAL ({}) for [{},{}] ", type, preloadName, preloadType); + } + } + + private void savePreloadList(final PreloadList entry, boolean merge, LogicalDatastoreType storeType) + throws IllegalStateException { + + // Each entry will be identifiable by a unique key, we have to create that + // identifier + InstanceIdentifier.InstanceIdentifierBuilder<PreloadList> preloadListBuilder = InstanceIdentifier + .<PreloadInformation>builder(PreloadInformation.class).child(PreloadList.class, entry.getKey()); + InstanceIdentifier<PreloadList> path = preloadListBuilder.build(); + int tries = 2; + while (true) { + try { + WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); + if (merge) { + tx.merge(storeType, path, entry); + } else { + tx.put(storeType, path, entry); + } + tx.submit().checkedGet(); + log.debug("Update DataStore succeeded"); + break; + } catch (final TransactionCommitFailedException e) { + if (e instanceof OptimisticLockFailedException) { + if (--tries <= 0) { + log.debug("Got OptimisticLockFailedException on last try - failing "); + throw new IllegalStateException(e); + } + log.debug("Got OptimisticLockFailedException - trying again "); + } else { + log.debug("Update DataStore failed"); + throw new IllegalStateException(e); + } + } + } + } + + private void deletePreloadList(final PreloadList entry, LogicalDatastoreType storeType) { + // Each entry will be identifiable by a unique key, we have to create + // that identifier + InstanceIdentifier<PreloadList> path = InstanceIdentifier.builder(PreloadInformation.class) + .child(PreloadList.class, entry.getKey()).build(); + + tryDeletePreloadListEntry(storeType, path); + } + + private void tryDeletePreloadListEntry(LogicalDatastoreType storeType, InstanceIdentifier<PreloadList> path) { + int tries = 2; + while (true) { + try { + deletePreloadList(storeType, path); + break; + } catch (OptimisticLockFailedException e) { + if (--tries <= 0) { + log.debug("Got OptimisticLockFailedException on last try - failing "); + throw new IllegalStateException(e); + } + log.debug("Got OptimisticLockFailedException - trying again "); + } catch (TransactionCommitFailedException ex) { + log.debug("Update DataStore failed"); + throw new IllegalStateException(ex); + } + } + } + + private void deletePreloadList(LogicalDatastoreType storeType, InstanceIdentifier<PreloadList> path) + throws TransactionCommitFailedException { WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); tx.delete(storeType, path); tx.submit().checkedGet(); @@ -494,7 +583,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC @Override public Future<RpcResult<ServiceTopologyOperationOutput>> serviceTopologyOperation( - ServiceTopologyOperationInput input) { + ServiceTopologyOperationInput input) { final String svcOperation = "service-topology-operation"; ServiceData serviceData; @@ -512,9 +601,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setAckFinalIndicator("Y"); RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder - .<ServiceTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -534,23 +621,20 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader()); setServiceStatus(serviceStatusBuilder, input.getRequestInformation()); - /* + /* * // setup a service-data object builder // ACTION service-topology-operation - * // INPUT: // USES uses service-operation-information // OUTPUT: // uses - * topology-response-common; // uses service-response-information; - */ + * // INPUT: // USES uses service-operation-information // OUTPUT: // uses + * topology-response-common; // uses service-response-information; + */ log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input); ServiceTopologyOperationInputBuilder inputBuilder = new ServiceTopologyOperationInputBuilder(input); GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); - log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, - operDataBuilder.build()); + log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build()); GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder); // Call SLI sync method - // Get SvcLogicService reference - ResponseObject responseObject = new ResponseObject("200", ""); String ackFinal = "Y"; String serviceObjectPath = null; @@ -583,9 +667,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder - .<ServiceTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -617,9 +699,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder - .<ServiceTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -632,27 +712,26 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder - .<ServiceTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - private void trySetResponseMessage(ServiceTopologyOperationOutputBuilder responseBuilder, ResponseObject error) { - if (!error.getMessage().isEmpty()) { - responseBuilder.setResponseMessage(error.getMessage()); + private void trySetResponseMessage(ServiceTopologyOperationOutputBuilder responseBuilder, + ResponseObject responseObject) { + if (responseObject.getMessage() != null) { + responseBuilder.setResponseMessage(responseObject.getMessage()); } } private boolean hasInvalidServiceId(ServiceTopologyOperationInput input) { return input == null || input.getServiceInformation() == null - || input.getServiceInformation().getServiceInstanceId() == null - || input.getServiceInformation().getServiceInstanceId().length() == 0; + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0; } private void trySetSvcRequestId(ServiceTopologyOperationInput input, - ServiceTopologyOperationOutputBuilder responseBuilder) { + ServiceTopologyOperationOutputBuilder responseBuilder) { if (input.getSdncRequestHeader() != null) { responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId()); } @@ -668,7 +747,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC } private Properties tryGetProperties(String svcOperation, Properties parms, ServiceDataBuilder serviceDataBuilder, - ResponseObject responseObject) { + ResponseObject responseObject) { try { if (svcLogicClient.hasGraph(APP_NAME, svcOperation, null, "sync")) { try { @@ -692,9 +771,8 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC } private boolean failed(ResponseObject error) { - return - !error.getStatusCode().isEmpty() && !("0".equals(error.getStatusCode()) || "200" - .equals(error.getStatusCode())); + return !error.getStatusCode().isEmpty() + && !("0".equals(error.getStatusCode()) || "200".equals(error.getStatusCode())); } private boolean isValidRequest(ServiceTopologyOperationInput input) { @@ -714,13 +792,12 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC VnfTopologyOperationOutputBuilder responseBuilder = new VnfTopologyOperationOutputBuilder(); if (hasInvalidServiceId(input)) { - log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation); responseBuilder.setResponseCode("404"); responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM); responseBuilder.setAckFinalIndicator("Y"); RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()).build(); + .withResult(responseBuilder.build()).build(); // return error return Futures.immediateFuture(rpcResult); } @@ -736,14 +813,13 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setResponseMessage("invalid input, null or empty vnf-id"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder - .<VnfTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } + String vnfId = input.getVnfInformation().getVnfId(); ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder(); getServiceData(siid, serviceDataBuilder); @@ -775,27 +851,23 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC VnfTopologyOperationInputBuilder inputBuilder = new VnfTopologyOperationInputBuilder(input); GenericResourceApiUtil.toProperties(properties, inputBuilder.build()); - log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, - operDataBuilder.build()); + log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build()); GenericResourceApiUtil.toProperties(properties, OPERATIONAL_DATA_PARAM, operDataBuilder); // Call SLI sync method - // Get SvcLogicService reference ResponseObject responseObject = new ResponseObject("200", ""); String ackFinal = "Y"; String serviceObjectPath = null; + String vnfObjectPath = null; Properties respProps = tryGetProperties(svcOperation, properties, serviceDataBuilder, responseObject); if (respProps != null) { responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); - - //FIXME if needed - /*before was "vfn-object-path", but it didn't make sense, since everywhere else, - when extracting service object path the "service-object-path" property is used*/ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM); + vnfObjectPath = respProps.getProperty(VNF_OBJECT_PATH_PARAM); } setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal); @@ -818,10 +890,8 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC } log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); - RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder - .<VnfTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); // return error return Futures.immediateFuture(rpcResult); @@ -841,7 +911,6 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC if (isValidRequest(input) && input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) { // Only update operational tree on Assign - log.info(UPDATING_TREE_INFO_MESSAGE); saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); } @@ -851,6 +920,11 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC serviceResponseInformationBuilder.setObjectPath(serviceObjectPath); responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build()); + VnfResponseInformationBuilder vnfResponseInformationBuilder = new VnfResponseInformationBuilder(); + vnfResponseInformationBuilder.setInstanceId(vnfId); + vnfResponseInformationBuilder.setObjectPath(vnfObjectPath); + responseBuilder.setVnfResponseInformation(vnfResponseInformationBuilder.build()); + } catch (Exception e) { log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); responseBuilder.setResponseCode("500"); @@ -858,10 +932,8 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setAckFinalIndicator("Y"); log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); - RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder - .<VnfTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -873,25 +945,23 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid); log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build()); - RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder - .<VnfTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); // return success return Futures.immediateFuture(rpcResult); } - private void trySetResponseMessage(VnfTopologyOperationOutputBuilder responseBuilder, ResponseObject error) { - if (!error.getMessage().isEmpty()) { - responseBuilder.setResponseMessage(error.getMessage()); + private void trySetResponseMessage(VnfTopologyOperationOutputBuilder responseBuilder, + ResponseObject responseObject) { + if (responseObject.getMessage() != null) { + responseBuilder.setResponseMessage(responseObject.getMessage()); } } private void trySaveService(VnfTopologyOperationInput input, ServiceBuilder serviceBuilder) { - if (isValidRequest(input) && - (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete) || - input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) { + if (isValidRequest(input) && (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete) + || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) { // Only update operational tree on activate or delete log.info(UPDATING_TREE_INFO_MESSAGE); @@ -901,17 +971,17 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC private boolean hasInvalidVnfId(VnfTopologyOperationInput input) { return input.getVnfInformation() == null || input.getVnfInformation().getVnfId() == null - || input.getVnfInformation().getVnfId().length() == 0; + || input.getVnfInformation().getVnfId().length() == 0; } private boolean hasInvalidServiceId(VnfTopologyOperationInput input) { return input == null || input.getServiceInformation() == null - || input.getServiceInformation().getServiceInstanceId() == null - || input.getServiceInformation().getServiceInstanceId().length() == 0; + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0; } private void trySetSvcRequestId(VnfTopologyOperationInput input, - VnfTopologyOperationOutputBuilder responseBuilder) { + VnfTopologyOperationOutputBuilder responseBuilder) { if (input.getSdncRequestHeader() != null) { responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId()); } @@ -923,7 +993,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC @Override public Future<RpcResult<VfModuleTopologyOperationOutput>> vfModuleTopologyOperation( - VfModuleTopologyOperationInput input) { + VfModuleTopologyOperationInput input) { final String svcOperation = "vf-module-topology-operation"; ServiceData serviceData; @@ -941,9 +1011,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setAckFinalIndicator("Y"); RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder - .<VfModuleTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); // return error return Futures.immediateFuture(rpcResult); @@ -955,7 +1023,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setResponseMessage("invalid input, null or empty vnf-id"); responseBuilder.setAckFinalIndicator("Y"); RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder - .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -966,15 +1034,15 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setAckFinalIndicator("Y"); RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder - .<VfModuleTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } // Grab the service instance ID from the input buffer String siid = input.getServiceInformation().getServiceInstanceId(); + String vnfId = input.getVnfInformation().getVnfId(); + String vfModuleId = input.getVfModuleInformation().getVfModuleId(); trySetSvcRequestId(input, responseBuilder); @@ -1009,28 +1077,25 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC VfModuleTopologyOperationInputBuilder inputBuilder = new VfModuleTopologyOperationInputBuilder(input); GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); - log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, - operDataBuilder.build()); + log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build()); GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder); // Call SLI sync method - // Get SvcLogicService reference ResponseObject responseObject = new ResponseObject("200", ""); String ackFinal = "Y"; String serviceObjectPath = null; + String vnfObjectPath = null; + String vfModuleObjectPath = null; Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, responseObject); if (respProps != null) { responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); - - - //FIXME if needed - /*before was "vf-module-object-path", but it didnt make sense, since everywhere else, - when extracting service object path the "service-object-path" property is used*/ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM); + vnfObjectPath = respProps.getProperty(VNF_OBJECT_PATH_PARAM); + vfModuleObjectPath = respProps.getProperty(VF_MODULE_OBJECT_PATH_PARAM); } setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal); @@ -1053,9 +1118,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder - .<VfModuleTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); // return error return Futures.immediateFuture(rpcResult); @@ -1080,6 +1143,16 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC serviceResponseInformationBuilder.setObjectPath(serviceObjectPath); responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build()); + VnfResponseInformationBuilder vnfResponseInformationBuilder = new VnfResponseInformationBuilder(); + vnfResponseInformationBuilder.setInstanceId(vnfId); + vnfResponseInformationBuilder.setObjectPath(vnfObjectPath); + responseBuilder.setVnfResponseInformation(vnfResponseInformationBuilder.build()); + + VfModuleResponseInformationBuilder vfModuleResponseInformationBuilder = new VfModuleResponseInformationBuilder(); + vfModuleResponseInformationBuilder.setInstanceId(vfModuleId); + vfModuleResponseInformationBuilder.setObjectPath(vfModuleObjectPath); + responseBuilder.setVfModuleResponseInformation(vfModuleResponseInformationBuilder.build()); + } catch (Exception e) { log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); responseBuilder.setResponseCode("500"); @@ -1088,9 +1161,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder - .<VfModuleTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1103,24 +1174,22 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder - .<VfModuleTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); // return success return Futures.immediateFuture(rpcResult); } - private void trySetResponseMessage(VfModuleTopologyOperationOutputBuilder responseBuilder, ResponseObject error) { - if (!error.getMessage().isEmpty()) { - responseBuilder.setResponseMessage(error.getMessage()); + private void trySetResponseMessage(VfModuleTopologyOperationOutputBuilder responseBuilder, + ResponseObject responseObject) { + if (responseObject.getMessage() != null) { + responseBuilder.setResponseMessage(responseObject.getMessage()); } } private void trySaveService(VfModuleTopologyOperationInput input, ServiceBuilder serviceBuilder) { - if (isValidRequest(input) && - (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) || - input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) { + if (isValidRequest(input) && (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) + || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) { // Only update operational tree on activate or delete log.info(UPDATING_TREE_INFO_MESSAGE); @@ -1129,7 +1198,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC } private void trySetSvcRequestId(VfModuleTopologyOperationInput input, - VfModuleTopologyOperationOutputBuilder responseBuilder) { + VfModuleTopologyOperationOutputBuilder responseBuilder) { if (input.getSdncRequestHeader() != null) { responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId()); } @@ -1137,18 +1206,18 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC private boolean hasInvalidVfModuleId(VfModuleTopologyOperationInput input) { return input.getVfModuleInformation() == null || input.getVfModuleInformation().getVfModuleId() == null - || input.getVfModuleInformation().getVfModuleId().length() == 0; + || input.getVfModuleInformation().getVfModuleId().length() == 0; } private boolean hasInvalidVnfId(VfModuleTopologyOperationInput input) { return input.getVnfInformation() == null || input.getVnfInformation().getVnfId() == null - || input.getVnfInformation().getVnfId().length() == 0; + || input.getVnfInformation().getVnfId().length() == 0; } private boolean hasInvalidServiceId(VfModuleTopologyOperationInput input) { return input == null || input.getServiceInformation() == null - || input.getServiceInformation().getServiceInstanceId() == null - || input.getServiceInformation().getServiceInstanceId().length() == 0; + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0; } private boolean isValidRequest(VfModuleTopologyOperationInput input) { @@ -1157,7 +1226,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC @Override public Future<RpcResult<NetworkTopologyOperationOutput>> networkTopologyOperation( - NetworkTopologyOperationInput input) { + NetworkTopologyOperationInput input) { final String svcOperation = "network-topology-operation"; ServiceData serviceData; @@ -1192,7 +1261,6 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); // Call SLI sync method - // Get SvcLogicService reference ResponseObject responseObject = new ResponseObject("200", ""); String ackFinal = "Y"; @@ -1207,7 +1275,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); networkId = respProps.getProperty("networkId"); serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM); - networkObjectPath = respProps.getProperty("network-object-path"); + networkObjectPath = respProps.getProperty(NETWORK_OBJECT_PATH_PARAM); } if (failed(responseObject)) { @@ -1218,9 +1286,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder - .<NetworkTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1258,9 +1324,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder - .<NetworkTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1273,30 +1337,28 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder - .<NetworkTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - private void trySetResponseMessage(NetworkTopologyOperationOutputBuilder responseBuilder, ResponseObject error) { - if (!error.getMessage().isEmpty()) { - responseBuilder.setResponseMessage(error.getMessage()); + private void trySetResponseMessage(NetworkTopologyOperationOutputBuilder responseBuilder, + ResponseObject responseObject) { + if (responseObject.getMessage() != null) { + responseBuilder.setResponseMessage(responseObject.getMessage()); } } private void trySetSvcRequestId(NetworkTopologyOperationInput input, - NetworkTopologyOperationOutputBuilder responseBuilder) { + NetworkTopologyOperationOutputBuilder responseBuilder) { if (input.getSdncRequestHeader() != null) { responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId()); } } private void trySaveService(NetworkTopologyOperationInput input, ServiceBuilder serviceBuilder) { - if (isValidRequest(input) && - (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate) || - input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Create))) { + if (isValidRequest(input) && (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate) + || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Create))) { // Only update operational tree on Activate log.info(UPDATING_TREE_INFO_MESSAGE); saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); @@ -1305,22 +1367,19 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC private boolean hasInvalidServiceId(NetworkTopologyOperationInput input) { return input == null || input.getServiceInformation() == null - || input.getServiceInformation().getServiceInstanceId() == null - || input.getServiceInformation().getServiceInstanceId().length() == 0; + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0; } private Future<RpcResult<NetworkTopologyOperationOutput>> buildRpcResultFuture( - NetworkTopologyOperationOutputBuilder responseBuilder, String responseMessage) { + NetworkTopologyOperationOutputBuilder responseBuilder, String responseMessage) { responseBuilder.setResponseCode("404"); - responseBuilder - .setResponseMessage(responseMessage); + responseBuilder.setResponseMessage(responseMessage); responseBuilder.setAckFinalIndicator("Y"); RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder - .<NetworkTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1331,7 +1390,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC @Override public Future<RpcResult<ContrailRouteTopologyOperationOutput>> contrailRouteTopologyOperation( - ContrailRouteTopologyOperationInput input) { + ContrailRouteTopologyOperationInput input) { final String svcOperation = "contrail-route-topology-operation"; ServiceData serviceData; @@ -1366,33 +1425,31 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC GenericResourceApiUtil.toProperties(properties, inputBuilder.build()); // Call SLI sync method - // Get SvcLogicService reference - ResponseObject error = new ResponseObject("200", ""); + + ResponseObject responseObject = new ResponseObject("200", ""); String ackFinal = "Y"; String allottedResourceId = ERROR_NETWORK_ID; String serviceObjectPath = null; String contrailRouteObjectPath = null; - Properties respProps = tryGetProperties(svcOperation, properties, serviceDataBuilder, error); + Properties respProps = tryGetProperties(svcOperation, properties, serviceDataBuilder, responseObject); if (respProps != null) { - error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); - error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); + responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); + responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM); serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM); contrailRouteObjectPath = respProps.getProperty("contrail-route-object-path"); } - if (failed(error)) { - responseBuilder.setResponseCode(error.getStatusCode()); - responseBuilder.setResponseMessage(error.getMessage()); + if (failed(responseObject)) { + responseBuilder.setResponseCode(responseObject.getStatusCode()); + responseBuilder.setResponseMessage(responseObject.getMessage()); responseBuilder.setAckFinalIndicator(ackFinal); log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder - .<ContrailRouteTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1429,39 +1486,34 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder - .<ContrailRouteTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } // Update succeeded - responseBuilder.setResponseCode(error.getStatusCode()); + responseBuilder.setResponseCode(responseObject.getStatusCode()); responseBuilder.setAckFinalIndicator(ackFinal); - trySetResponseMessage(responseBuilder, error); + trySetResponseMessage(responseBuilder, responseObject); log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid); log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder - .<ContrailRouteTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } private void trySetResponseMessage(ContrailRouteTopologyOperationOutputBuilder responseBuilder, - ResponseObject error) { - if (!error.getMessage().isEmpty()) { - responseBuilder.setResponseMessage(error.getMessage()); + ResponseObject responseObject) { + if (responseObject.getMessage() != null) { + responseBuilder.setResponseMessage(responseObject.getMessage()); } } private void trySaveService(ContrailRouteTopologyOperationInput input, ServiceBuilder serviceBuilder) { - if (isValidRequest(input) && - (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) || - input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) { + if (isValidRequest(input) && (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) + || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) { // Only update operational tree on activate or delete log.info(UPDATING_TREE_INFO_MESSAGE); saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); @@ -1469,7 +1521,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC } private void trySetSvcRequestId(ContrailRouteTopologyOperationInput input, - ContrailRouteTopologyOperationOutputBuilder responseBuilder) { + ContrailRouteTopologyOperationOutputBuilder responseBuilder) { if (input.getSdncRequestHeader() != null) { responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId()); } @@ -1477,21 +1529,18 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC private boolean hasInvalidServiceId(ContrailRouteTopologyOperationInput input) { return input == null || input.getServiceInformation() == null - || input.getServiceInformation().getServiceInstanceId() == null - || input.getServiceInformation().getServiceInstanceId().length() == 0; + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0; } - private Future<RpcResult<ContrailRouteTopologyOperationOutput>> - buildRpcResultFuture(ContrailRouteTopologyOperationOutputBuilder responseBuilder, String responseMessage) { - + private Future<RpcResult<ContrailRouteTopologyOperationOutput>> buildRpcResultFuture( + ContrailRouteTopologyOperationOutputBuilder responseBuilder, String responseMessage) { responseBuilder.setResponseCode("404"); responseBuilder.setResponseMessage(responseMessage); responseBuilder.setAckFinalIndicator("Y"); RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder - .<ContrailRouteTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1502,7 +1551,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC @Override public Future<RpcResult<SecurityZoneTopologyOperationOutput>> securityZoneTopologyOperation( - SecurityZoneTopologyOperationInput input) { + SecurityZoneTopologyOperationInput input) { final String svcOperation = "security-zone-topology-operation"; ServiceData serviceData; @@ -1536,7 +1585,6 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); // Call SLI sync method - // Get SvcLogicService reference Properties respProps = null; @@ -1582,9 +1630,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder - .<SecurityZoneTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1622,9 +1668,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder - .<SecurityZoneTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1637,24 +1681,21 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build()); RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder - .<SecurityZoneTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } private void trySetResponseMessage(SecurityZoneTopologyOperationOutputBuilder responseBuilder, - ResponseObject error) { - if (!error.getMessage().isEmpty()) { - responseBuilder.setResponseMessage(error.getMessage()); + ResponseObject responseObject) { + if (responseObject.getMessage() != null) { + responseBuilder.setResponseMessage(responseObject.getMessage()); } } private void trySaveService(SecurityZoneTopologyOperationInput input, ServiceBuilder serviceBuilder) { - if (isValidRequest(input) && - (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) || - input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) { + if (isValidRequest(input) && (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) + || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) { // Only update operational tree on activate or delete log.info(UPDATING_TREE_INFO_MESSAGE); saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); @@ -1662,7 +1703,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC } private void trySetSvcRequestId(SecurityZoneTopologyOperationInput input, - SecurityZoneTopologyOperationOutputBuilder responseBuilder) { + SecurityZoneTopologyOperationOutputBuilder responseBuilder) { if (input.getSdncRequestHeader() != null) { responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId()); } @@ -1674,21 +1715,19 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC private boolean hasInvalidServiceId(SecurityZoneTopologyOperationInput input) { return input == null || input.getServiceInformation() == null - || input.getServiceInformation().getServiceInstanceId() == null - || input.getServiceInformation().getServiceInstanceId().length() == 0; + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0; } - private Future<RpcResult<SecurityZoneTopologyOperationOutput>> - buildRpcResultFuture(SecurityZoneTopologyOperationOutputBuilder responseBuilder, String responseMessage) { + private Future<RpcResult<SecurityZoneTopologyOperationOutput>> buildRpcResultFuture( + SecurityZoneTopologyOperationOutputBuilder responseBuilder, String responseMessage) { responseBuilder.setResponseCode("404"); responseBuilder.setResponseMessage(responseMessage); responseBuilder.setAckFinalIndicator("Y"); RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder - .<SecurityZoneTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1697,108 +1736,6 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null; } - @Override - public Future<RpcResult<TunnelxconnTopologyOperationOutput>> tunnelxconnTopologyOperation( - TunnelxconnTopologyOperationInput input) { - - final String svcOperation = "tunnelxconn-topology-operation"; - Properties parms = new Properties(); - log.info(CALLED_STR, svcOperation); - - // create a new response object - TunnelxconnTopologyOperationOutputBuilder responseBuilder = new TunnelxconnTopologyOperationOutputBuilder(); - if (hasInvalidServiceId(input)) { - log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation); - responseBuilder.setResponseCode("404"); - responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM); - responseBuilder.setAckFinalIndicator("Y"); - - RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder - .<TunnelxconnTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); - - return Futures.immediateFuture(rpcResult); - } - String siid = input.getServiceInformation().getServiceInstanceId(); - log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input); - TunnelxconnTopologyOperationInputBuilder inputBuilder = new TunnelxconnTopologyOperationInputBuilder(input); - GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); - - // Call SLI sync method - // Get SvcLogicService reference - ResponseObject responseObject = new ResponseObject("200", ""); - String ackFinal = "Y"; - String allottedResourceId = ERROR_NETWORK_ID; - String serviceObjectPath = null; - String tunnelxconnObjectPath = null; - Properties respProps = tryGetProperties(svcOperation, parms, responseObject); - - if (respProps != null) { - responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); - responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); - ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); - allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM); - serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM); - tunnelxconnObjectPath = respProps.getProperty("tunnelxconn-object-path"); - } - - if (failed(responseObject)) { - responseBuilder.setResponseCode(responseObject.getStatusCode()); - responseBuilder.setResponseMessage(responseObject.getMessage()); - responseBuilder.setAckFinalIndicator(ackFinal); - - log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); - - RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder - .<TunnelxconnTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); - - return Futures.immediateFuture(rpcResult); - } - - // Got success from SLI - try { - TunnelxconnResponseInformationBuilder tunnelxconnResponseInformationBuilder = new TunnelxconnResponseInformationBuilder(); - tunnelxconnResponseInformationBuilder.setInstanceId(allottedResourceId); - tunnelxconnResponseInformationBuilder.setObjectPath(tunnelxconnObjectPath); - responseBuilder.setTunnelxconnResponseInformation(tunnelxconnResponseInformationBuilder.build()); - - ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder(); - serviceResponseInformationBuilder.setInstanceId(siid); - serviceResponseInformationBuilder.setObjectPath(serviceObjectPath); - responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build()); - - } catch (IllegalStateException e) { - log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); - responseBuilder.setResponseCode("500"); - responseBuilder.setResponseMessage(e.toString()); - responseBuilder.setAckFinalIndicator("Y"); - log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); - - RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder - .<TunnelxconnTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); - - return Futures.immediateFuture(rpcResult); - } - - // Update succeeded - responseBuilder.setResponseCode(responseObject.getStatusCode()); - responseBuilder.setAckFinalIndicator(ackFinal); - trySetResponseMessage(responseBuilder, responseObject); - log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid); - log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build()); - - RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder - .<TunnelxconnTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); - - return Futures.immediateFuture(rpcResult); - } private boolean hasInvalidServiceId(ConnectionAttachmentTopologyOperationInput input) { return input == null || input.getServiceInformation() == null @@ -1982,17 +1919,112 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC return Futures.immediateFuture(rpcResult); } + @Override + public Future<RpcResult<TunnelxconnTopologyOperationOutput>> tunnelxconnTopologyOperation( + TunnelxconnTopologyOperationInput input) { + + final String svcOperation = "tunnelxconn-topology-operation"; + Properties parms = new Properties(); + log.info(CALLED_STR, svcOperation); + + // create a new response object + TunnelxconnTopologyOperationOutputBuilder responseBuilder = new TunnelxconnTopologyOperationOutputBuilder(); + if (hasInvalidServiceId(input)) { + log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation); + responseBuilder.setResponseCode("404"); + responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM); + responseBuilder.setAckFinalIndicator("Y"); + + RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder + .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + + return Futures.immediateFuture(rpcResult); + } + String siid = input.getServiceInformation().getServiceInstanceId(); + log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input); + TunnelxconnTopologyOperationInputBuilder inputBuilder = new TunnelxconnTopologyOperationInputBuilder(input); + GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); + + // Call SLI sync method + + ResponseObject responseObject = new ResponseObject("200", ""); + String ackFinal = "Y"; + String allottedResourceId = ERROR_NETWORK_ID; + String serviceObjectPath = null; + String tunnelxconnObjectPath = null; + Properties respProps = tryGetProperties(svcOperation, parms, responseObject); + + if (respProps != null) { + responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); + responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); + ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); + allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM); + serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM); + tunnelxconnObjectPath = respProps.getProperty("tunnelxconn-object-path"); + } + + if (failed(responseObject)) { + responseBuilder.setResponseCode(responseObject.getStatusCode()); + responseBuilder.setResponseMessage(responseObject.getMessage()); + responseBuilder.setAckFinalIndicator(ackFinal); + + log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); + + RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder + .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + + return Futures.immediateFuture(rpcResult); + } + + // Got success from SLI + try { + TunnelxconnResponseInformationBuilder tunnelxconnResponseInformationBuilder = new TunnelxconnResponseInformationBuilder(); + tunnelxconnResponseInformationBuilder.setInstanceId(allottedResourceId); + tunnelxconnResponseInformationBuilder.setObjectPath(tunnelxconnObjectPath); + responseBuilder.setTunnelxconnResponseInformation(tunnelxconnResponseInformationBuilder.build()); + + ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder(); + serviceResponseInformationBuilder.setInstanceId(siid); + serviceResponseInformationBuilder.setObjectPath(serviceObjectPath); + responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build()); + + } catch (IllegalStateException e) { + log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); + responseBuilder.setResponseCode("500"); + responseBuilder.setResponseMessage(e.getMessage()); + responseBuilder.setAckFinalIndicator("Y"); + log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); + + RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder + .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + + return Futures.immediateFuture(rpcResult); + } + + // Update succeeded + responseBuilder.setResponseCode(responseObject.getStatusCode()); + responseBuilder.setAckFinalIndicator(ackFinal); + trySetResponseMessage(responseBuilder, responseObject); + log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid); + log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build()); + + RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder + .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + + return Futures.immediateFuture(rpcResult); + } + private void trySetResponseMessage(TunnelxconnTopologyOperationOutputBuilder responseBuilder, - ResponseObject error) { - if (!error.getMessage().isEmpty()) { - responseBuilder.setResponseMessage(error.getMessage()); + ResponseObject responseObject) { + if (responseObject.getMessage() != null) { + responseBuilder.setResponseMessage(responseObject.getMessage()); } } private boolean hasInvalidServiceId(TunnelxconnTopologyOperationInput input) { return input == null || input.getServiceInformation() == null - || input.getServiceInformation().getServiceInstanceId() == null - || input.getServiceInformation().getServiceInstanceId().length() == 0; + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0; } private Properties tryGetProperties(String svcOperation, Properties parms, ResponseObject responseObject) { @@ -2034,10 +2066,8 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder - .<BrgTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -2049,33 +2079,31 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); // Call SLI sync method - // Get SvcLogicService reference - ResponseObject error = new ResponseObject("200", ""); + + ResponseObject responseObject = new ResponseObject("200", ""); String ackFinal = "Y"; String allottedResourceId = ERROR_NETWORK_ID; String serviceObjectPath = null; String brgObjectPath = null; - Properties respProps = tryGetProperties(svcOperation, parms, error); + Properties respProps = tryGetProperties(svcOperation, parms, responseObject); if (respProps != null) { - error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); - error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); + responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); + responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM); serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM); brgObjectPath = respProps.getProperty("brg-object-path"); } - if (failed(error)) { - responseBuilder.setResponseCode(error.getStatusCode()); - responseBuilder.setResponseMessage(error.getMessage()); + if (failed(responseObject)) { + responseBuilder.setResponseCode(responseObject.getStatusCode()); + responseBuilder.setResponseMessage(responseObject.getMessage()); responseBuilder.setAckFinalIndicator(ackFinal); log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); - RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder - .<BrgTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -2096,169 +2124,511 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC } catch (IllegalStateException e) { log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); responseBuilder.setResponseCode("500"); - responseBuilder.setResponseMessage(e.toString()); + responseBuilder.setResponseMessage(e.getMessage()); responseBuilder.setAckFinalIndicator("Y"); log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); - RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder - .<BrgTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } // Update succeeded - responseBuilder.setResponseCode(error.getStatusCode()); + responseBuilder.setResponseCode(responseObject.getStatusCode()); responseBuilder.setAckFinalIndicator(ackFinal); - trySetResponseMessage(responseBuilder, error); + trySetResponseMessage(responseBuilder, responseObject); log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid); log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build()); - RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder - .<BrgTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - private void trySetResponseMessage(BrgTopologyOperationOutputBuilder responseBuilder, ResponseObject error) { - if (!error.getMessage().isEmpty()) { - responseBuilder.setResponseMessage(error.getMessage()); + private void trySetResponseMessage(BrgTopologyOperationOutputBuilder responseBuilder, + ResponseObject responseObject) { + if (responseObject.getMessage() != null) { + responseBuilder.setResponseMessage(responseObject.getMessage()); } } private boolean hasInvalidServiceId(BrgTopologyOperationInput input) { return input == null || input.getServiceInformation() == null - || input.getServiceInformation().getServiceInstanceId() == null - || input.getServiceInformation().getServiceInstanceId().length() == 0; + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0; + } + + private String resolveAckFinal(ResponseObject responseObject, Properties respProps) { + if (respProps != null) { + responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); + responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); + return respProps.getProperty(ACK_FINAL_PARAM, "Y"); + } + return "Y"; } @Override - public Future<RpcResult<PreloadVnfTopologyOperationOutput>> preloadVnfTopologyOperation( - PreloadVnfTopologyOperationInput input) { + public Future<RpcResult<PreloadNetworkTopologyOperationOutput>> preloadNetworkTopologyOperation( + PreloadNetworkTopologyOperationInput input) { - final String svcOperation = "preload-vnf-topology-operation"; - Properties parms = new Properties(); + final String svcOperation = "preload-network-topology-operation"; + PreloadData preloadData; + Properties properties = new Properties(); log.info(CALLED_STR, svcOperation); // create a new response object - PreloadVnfTopologyOperationOutputBuilder responseBuilder = new PreloadVnfTopologyOperationOutputBuilder(); - - if (hasInvalidVnfTopology(input)) { + PreloadNetworkTopologyOperationOutputBuilder responseBuilder = new PreloadNetworkTopologyOperationOutputBuilder(); - log.debug("exiting {} because of null input", svcOperation); + if (hasInvalidPreloadNetwork(input)) { + log.debug("exiting {} because of null or empty preload-network-topology-information", svcOperation); responseBuilder.setResponseCode("403"); - responseBuilder.setResponseMessage("invalid input: input is null"); + responseBuilder.setResponseMessage("invalid input, null or empty preload-network-topology-information"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder - .<PreloadVnfTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - // Grab the name and type from the input buffer - String preloadName = input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfName(); - String preloadType = input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfType(); + // Grab the preload ID from the input buffer + String preloadId = input.getPreloadNetworkTopologyInformation().getNetworkTopologyIdentifierStructure() + .getNetworkName(); + String preloadType = "network"; + + trySetSvcRequestId(input, responseBuilder); + + PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder(); + getPreloadData(preloadId, preloadType, preloadDataBuilder); + + PreloadDataBuilder operDataBuilder = new PreloadDataBuilder(); + getPreloadData(preloadId, preloadType, operDataBuilder, LogicalDatastoreType.OPERATIONAL); + + // + // setup a preload-data object builder + // ACTION preload-network-topology-operation + // INPUT: + // uses sdnc-request-header; + // uses request-information; + // uses preload-network-topology-information; + // OUTPUT: + // uses preload-topology-response-body; + // + // container preload-data + // uses preload-network-topology-information; + // uses preload-oper-status; + + log.info(ADDING_INPUT_DATA_LOG, svcOperation, preloadId, input); + PreloadNetworkTopologyOperationInputBuilder inputBuilder = new PreloadNetworkTopologyOperationInputBuilder( + input); + GenericResourceApiUtil.toProperties(properties, inputBuilder.build()); + log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, preloadId, input); + GenericResourceApiUtil.toProperties(properties, OPERATIONAL_DATA_PARAM, operDataBuilder); + + // Call SLI sync method + ResponseObject responseObject = new ResponseObject("200", ""); + String ackFinal = "Y"; + Properties respProps = tryGetProperties(svcOperation, properties, preloadDataBuilder, responseObject); + + if (respProps != null) { + responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); + responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); + ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); + } + + if (failed(responseObject)) { + responseBuilder.setResponseCode(responseObject.getStatusCode()); + responseBuilder.setResponseMessage(responseObject.getMessage()); + responseBuilder.setAckFinalIndicator(ackFinal); + log.error(RETURNED_FAILED_MESSAGE, svcOperation, preloadId, responseBuilder.build()); + RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } - // Make sure we have a preload_name and preload_type - if (invalidPreloadData(preloadName, preloadType)) { - log.debug("exiting {} vnf-name or vnf-type is null or empty", svcOperation); + // Got success from SLI + try { + preloadData = preloadDataBuilder.build(); + log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, preloadId, preloadData); + + // preload-list object + PreloadListBuilder preloadListBuilder = new PreloadListBuilder(); + preloadListBuilder.setPreloadId(preloadId); + preloadListBuilder.setPreloadType(preloadType); + preloadListBuilder.setPreloadData(preloadData); + + savePreloadList(preloadListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); + log.info(UPDATING_TREE_INFO_MESSAGE); + savePreloadList(preloadListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); + + tryDeletePreload(input, preloadListBuilder); + } catch (Exception e) { + log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, preloadId, e); + responseBuilder.setResponseCode("500"); + responseBuilder.setResponseMessage(e.getMessage()); + responseBuilder.setAckFinalIndicator("Y"); + log.error(RETURNED_FAILED_MESSAGE, svcOperation, preloadId, responseBuilder.build()); + RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PreloadNetworkTopologyOperationOutput>status(false).withResult(responseBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + // Update succeeded + responseBuilder.setResponseCode(responseObject.getStatusCode()); + responseBuilder.setAckFinalIndicator(ackFinal); + trySetResponseMessage(responseBuilder, responseObject); + log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, preloadId); + log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, preloadId, responseBuilder.build()); + + RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + private boolean hasInvalidPreloadNetwork(PreloadNetworkTopologyOperationInput input) { + return input == null || input.getPreloadNetworkTopologyInformation() == null + || input.getPreloadNetworkTopologyInformation().getNetworkTopologyIdentifierStructure() == null; + } + + private boolean hasInvalidPreloadId(String preloadId) { + return preloadId == null || preloadId.length() == 0; + } + + private void trySetSvcRequestId(PreloadNetworkTopologyOperationInput input, + PreloadNetworkTopologyOperationOutputBuilder responseBuilder) { + if (input.getSdncRequestHeader() != null) { + responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId()); + } + } + + private Properties tryGetProperties(String svcOperation, Properties parms, PreloadDataBuilder preloadDataBuilder, + ResponseObject responseObject) { + try { + if (svcLogicClient.hasGraph(APP_NAME, svcOperation, null, "sync")) { + try { + return svcLogicClient.execute(APP_NAME, svcOperation, null, "sync", preloadDataBuilder, parms); + } catch (Exception e) { + log.error(SERVICE_LOGIC_EXECUTION_ERROR_MESSAGE, svcOperation, e); + responseObject.setMessage(e.getMessage()); + responseObject.setStatusCode("500"); + } + } else { + responseObject.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'"); + responseObject.setStatusCode("503"); + } + } catch (Exception e) { + responseObject.setMessage(e.getMessage()); + responseObject.setStatusCode("500"); + log.error(SERVICE_LOGIC_SEARCH_ERROR_MESSAGE, e); + } + + return null; + } + + private void trySetResponseMessage(PreloadNetworkTopologyOperationOutputBuilder responseBuilder, + ResponseObject responseObject) { + if (responseObject.getMessage() != null) { + if (!responseObject.getMessage().isEmpty()) { + responseBuilder.setResponseMessage(responseObject.getMessage()); + } + } + } + + private void tryDeletePreload(PreloadNetworkTopologyOperationInput input, PreloadListBuilder preloadListBuilder) { + if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete)) { + log.info("Delete from both CONFIGURATION and OPERATIONAL tree."); + deletePreloadList(preloadListBuilder.build(), LogicalDatastoreType.OPERATIONAL); + deletePreloadList(preloadListBuilder.build(), LogicalDatastoreType.CONFIGURATION); + } + } + + @Override + public Future<RpcResult<PreloadVfModuleTopologyOperationOutput>> preloadVfModuleTopologyOperation( + PreloadVfModuleTopologyOperationInput input) { + + final String svcOperation = "preload-vf-module-topology-operation"; + PreloadData preloadData; + Properties properties = new Properties(); + + log.info(CALLED_STR, svcOperation); + // create a new response object + PreloadVfModuleTopologyOperationOutputBuilder responseBuilder = new PreloadVfModuleTopologyOperationOutputBuilder(); + + if (hasInvalidPreloadVfModule(input)) { + log.debug( + "exiting {} because of null or empty preload-vf-module-topology-information.vf-module-topology.vf-module-topology-identifier.vf-module-name", + svcOperation); responseBuilder.setResponseCode("403"); - responseBuilder.setResponseMessage("invalid input: vnf-name or vnf-type is null or empty"); + responseBuilder.setResponseMessage( + "invalid input, null or empty preload-vf-module-topology-information.vf-module-topology.vf-module-topology-identifier.vf-module-name"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder - .<PreloadVnfTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PreloadVfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } + // Grab the preload ID from the input buffer + String preloadId = input.getPreloadVfModuleTopologyInformation().getVfModuleTopology() + .getVfModuleTopologyIdentifier().getVfModuleName(); + String preloadType = "vf-module"; + trySetSvcRequestId(input, responseBuilder); PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder(); - getPreloadData(preloadName, preloadType, preloadDataBuilder); + getPreloadData(preloadId, preloadType, preloadDataBuilder); PreloadDataBuilder operDataBuilder = new PreloadDataBuilder(); - getPreloadData(preloadName, preloadType, operDataBuilder, LogicalDatastoreType.OPERATIONAL); + getPreloadData(preloadId, preloadType, operDataBuilder, LogicalDatastoreType.OPERATIONAL); + // // setup a preload-data object builder - // ACTION preload-vnf-topology-operation + // ACTION preload-vf-module-topology-operation // INPUT: - // USES sdnc-request-header; - // USES request-information; - // uses vnf-topology-information; + // uses sdnc-request-header; + // uses request-information; + // uses preload-vnf-topology-information; // OUTPUT: - // USES vnf-topology-response-body; + // uses preload-topology-response-body; // // container preload-data - // uses vnf-topology-information; - // uses network-topology-information; - // uses oper-status; + // uses preload-vf-module-topology-information; + // uses preload-oper-status; + + log.info(ADDING_INPUT_DATA_LOG, svcOperation, preloadId, input); + PreloadVfModuleTopologyOperationInputBuilder inputBuilder = new PreloadVfModuleTopologyOperationInputBuilder( + input); + GenericResourceApiUtil.toProperties(properties, inputBuilder.build()); + log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, preloadId, input); + GenericResourceApiUtil.toProperties(properties, OPERATIONAL_DATA_PARAM, operDataBuilder); + + // Call SLI sync method + ResponseObject responseObject = new ResponseObject("200", ""); + String ackFinal = "Y"; + Properties respProps = tryGetProperties(svcOperation, properties, preloadDataBuilder, responseObject); + + if (respProps != null) { + responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); + responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); + ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); + } - log.info("Adding INPUT data for {} [{},{}] input: {}", svcOperation, preloadName, preloadType, input); - PreloadVnfTopologyOperationInputBuilder inputBuilder = new PreloadVnfTopologyOperationInputBuilder(input); + if (failed(responseObject)) { + responseBuilder.setResponseCode(responseObject.getStatusCode()); + responseBuilder.setResponseMessage(responseObject.getMessage()); + responseBuilder.setAckFinalIndicator(ackFinal); + log.error(RETURNED_FAILED_MESSAGE, svcOperation, preloadId, responseBuilder.build()); + RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PreloadVfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + // Got success from SLI + try { + preloadData = preloadDataBuilder.build(); + log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, preloadId, preloadData); + + // preload-list object + PreloadListBuilder preloadListBuilder = new PreloadListBuilder(); + preloadListBuilder.setPreloadId(preloadId); + preloadListBuilder.setPreloadType(preloadType); + preloadListBuilder.setPreloadData(preloadData); + + savePreloadList(preloadListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); + log.info(UPDATING_TREE_INFO_MESSAGE); + savePreloadList(preloadListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); + + tryDeletePreload(input, preloadListBuilder); + + } catch (Exception e) { + log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, preloadId, e); + responseBuilder.setResponseCode("500"); + responseBuilder.setResponseMessage(e.getMessage()); + responseBuilder.setAckFinalIndicator("Y"); + log.error(RETURNED_FAILED_MESSAGE, svcOperation, preloadId, responseBuilder.build()); + RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PreloadVfModuleTopologyOperationOutput>status(false).withResult(responseBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + // Update succeeded + responseBuilder.setResponseCode(responseObject.getStatusCode()); + responseBuilder.setAckFinalIndicator(ackFinal); + trySetResponseMessage(responseBuilder, responseObject); + log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, preloadId); + log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, preloadId, responseBuilder.build()); + + RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PreloadVfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + private boolean hasInvalidPreloadVfModule(PreloadVfModuleTopologyOperationInput input) { + return input == null || input.getPreloadVfModuleTopologyInformation() == null + || input.getPreloadVfModuleTopologyInformation().getVfModuleTopology() == null + || input.getPreloadVfModuleTopologyInformation().getVfModuleTopology() + .getVfModuleTopologyIdentifier() == null + || input.getPreloadVfModuleTopologyInformation().getVfModuleTopology().getVfModuleTopologyIdentifier() + .getVfModuleName() == null; + } + + private void trySetSvcRequestId(PreloadVfModuleTopologyOperationInput input, + PreloadVfModuleTopologyOperationOutputBuilder responseBuilder) { + if (input.getSdncRequestHeader() != null) { + responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId()); + } + } + + private void trySetResponseMessage(PreloadVfModuleTopologyOperationOutputBuilder responseBuilder, + ResponseObject responseObject) { + if (responseObject.getMessage() != null) { + if (!responseObject.getMessage().isEmpty()) { + responseBuilder.setResponseMessage(responseObject.getMessage()); + } + } + } + + private void tryDeletePreload(PreloadVfModuleTopologyOperationInput input, PreloadListBuilder preloadListBuilder) { + if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete)) { + log.info("Delete from both CONFIGURATION and OPERATIONAL tree."); + deletePreloadList(preloadListBuilder.build(), LogicalDatastoreType.OPERATIONAL); + deletePreloadList(preloadListBuilder.build(), LogicalDatastoreType.CONFIGURATION); + } + } + + @Override + public Future<RpcResult<GenericConfigurationTopologyOperationOutput>> genericConfigurationTopologyOperation( + GenericConfigurationTopologyOperationInput input) { + + final String svcOperation = "generic-configuration-topology-operation"; + ServiceData serviceData; + ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder(); + Properties parms = new Properties(); + + log.info(CALLED_STR, svcOperation); + // create a new response object + GenericConfigurationTopologyOperationOutputBuilder responseBuilder = new GenericConfigurationTopologyOperationOutputBuilder(); + + if (hasInvalidService(input)) { + log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation); + responseBuilder.setResponseCode("404"); + responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM); + responseBuilder.setAckFinalIndicator("Y"); + + RpcResult<GenericConfigurationTopologyOperationOutput> rpcResult = RpcResultBuilder + .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build()) + .build(); + + return Futures.immediateFuture(rpcResult); + } + + // Grab the service instance ID from the input buffer + String siid = input.getServiceInformation().getServiceInstanceId(); + + trySetSvcRequestId(input, responseBuilder); + + if (hasInvalidConfigurationIdOrType(input)) { + log.debug("exiting {} because of null or empty configuration-id or configuration-type", svcOperation); + responseBuilder.setResponseCode("404"); + responseBuilder.setResponseMessage("invalid input, null or empty configuration-id or configuration-type"); + responseBuilder.setAckFinalIndicator("Y"); + RpcResult<GenericConfigurationTopologyOperationOutput> rpcResult = RpcResultBuilder + .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build()) + .build(); + return Futures.immediateFuture(rpcResult); + } + + // Grab the configuration ID from the input buffer + String configId = input.getConfigurationInformation().getConfigurationId(); + + ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder(); + getServiceData(siid, serviceDataBuilder); + + ServiceDataBuilder operDataBuilder = new ServiceDataBuilder(); + getServiceData(siid, operDataBuilder, LogicalDatastoreType.OPERATIONAL); + + // Set the serviceStatus based on input + setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader()); + setServiceStatus(serviceStatusBuilder, input.getRequestInformation()); + + log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input); + GenericConfigurationTopologyOperationInputBuilder inputBuilder = new GenericConfigurationTopologyOperationInputBuilder( + input); GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); - log.info("Adding OPERATIONAL data for {} [{},{}] operational-data: {}", svcOperation, preloadName, - preloadType, operDataBuilder.build()); + + log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build()); GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder); // Call SLI sync method - // Get SvcLogicService reference + ResponseObject responseObject = new ResponseObject("200", ""); - Properties respProps = tryGetProperties(svcOperation, parms, responseObject); - String ackFinal = resolveAckFinal(responseObject, respProps); + String ackFinal = "Y"; + String serviceObjectPath = ""; + Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, responseObject); - if (failed(responseObject)) { + if (respProps != null) { + responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); + responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); + ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); + serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM); + } + setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal); + serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete); + serviceStatusBuilder.setRpcName(svcOperation); + + if (failed(responseObject)) { responseBuilder.setResponseCode(responseObject.getStatusCode()); responseBuilder.setResponseMessage(responseObject.getMessage()); responseBuilder.setAckFinalIndicator(ackFinal); - VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder(); - preloadVnfListBuilder.setVnfName(preloadName); - preloadVnfListBuilder.setVnfType(preloadType); - preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build()); - log.error("Returned FAILED for {} [{},{}] error code: '{}', Reason: '{}'", svcOperation, preloadName, - preloadType, responseObject.getStatusCode(), responseObject.getMessage()); + ServiceBuilder serviceBuilder = new ServiceBuilder(); + serviceBuilder.setServiceInstanceId(siid); + serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); try { - savePreloadList(preloadVnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); + saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); } catch (Exception e) { - log.error(UPDATING_MDSAL_ERROR_MESSAGE_2, svcOperation, preloadName, - preloadType, e); + log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); } - log.debug("Sending Success rpc result due to external error"); + log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); - RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder - .<PreloadVnfTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + RpcResult<GenericConfigurationTopologyOperationOutput> rpcResult = RpcResultBuilder + .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build()) + .build(); return Futures.immediateFuture(rpcResult); } // Got success from SLI try { - updatePreloadData(svcOperation, preloadName, preloadType, preloadDataBuilder); + serviceData = serviceDataBuilder.build(); + + // service object + ServiceBuilder serviceBuilder = new ServiceBuilder(); + serviceBuilder.setServiceData(serviceData); + serviceBuilder.setServiceInstanceId(siid); + serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); + saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); + + ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder(); + serviceResponseInformationBuilder.setInstanceId(siid); + serviceResponseInformationBuilder.setObjectPath(serviceObjectPath); + responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build()); + GcResponseInformationBuilder gcResponseInformationBuilder = new GcResponseInformationBuilder(); + gcResponseInformationBuilder.setInstanceId(configId); + responseBuilder.setGcResponseInformation(gcResponseInformationBuilder.build()); + } catch (Exception e) { - log.error(UPDATING_MDSAL_ERROR_MESSAGE_2, svcOperation, preloadName, preloadType, - e); + log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); responseBuilder.setResponseCode("500"); responseBuilder.setResponseMessage(e.getMessage()); responseBuilder.setAckFinalIndicator("Y"); - log.error("Returned FAILED for {} [{},{}] {}", svcOperation, preloadName, preloadType, - responseBuilder.build()); - - RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder - .<PreloadVnfTopologyOperationOutput>status(false) - .withResult(responseBuilder.build()) - .build(); + RpcResult<GenericConfigurationTopologyOperationOutput> rpcResult = RpcResultBuilder + .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build()) + .build(); return Futures.immediateFuture(rpcResult); } @@ -2267,192 +2637,502 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setResponseCode(responseObject.getStatusCode()); responseBuilder.setAckFinalIndicator(ackFinal); trySetResponseMessage(responseBuilder, responseObject); + log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid); + log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build()); - log.info("Updated MD-SAL for {} [{},{}]", svcOperation, preloadName, preloadType); - log.info("Returned SUCCESS for {} [{},{}] {}", svcOperation, preloadName, preloadType, - responseBuilder.build()); - - RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder - .<PreloadVnfTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + RpcResult<GenericConfigurationTopologyOperationOutput> rpcResult = RpcResultBuilder + .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - private String resolveAckFinal(ResponseObject responseObject, Properties respProps) { + private boolean hasInvalidService(GenericConfigurationTopologyOperationInput input) { + return input == null || input.getServiceInformation() == null + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0; + } + + private void trySetSvcRequestId(GenericConfigurationTopologyOperationInput input, + GenericConfigurationTopologyOperationOutputBuilder responseBuilder) { + if (input.getSdncRequestHeader() != null) { + responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId()); + } + } + + private boolean hasInvalidConfigurationIdOrType(GenericConfigurationTopologyOperationInput input) { + return input.getConfigurationInformation() == null + || input.getConfigurationInformation().getConfigurationId() == null + || input.getConfigurationInformation().getConfigurationType() == null; + } + + private void trySetResponseMessage(GenericConfigurationTopologyOperationOutputBuilder responseBuilder, + ResponseObject responseObject) { + if (responseObject.getMessage() != null) { + if (!responseObject.getMessage().isEmpty()) { + responseBuilder.setResponseMessage(responseObject.getMessage()); + } + } + } + + @Override + public Future<RpcResult<Void>> genericConfigurationNotification(GenericConfigurationNotificationInput input) { + + final String svcOperation = "generic-configuration-notification"; + ServiceData serviceData; + ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder(); + Properties parms = new Properties(); + + log.info(CALLED_STR, svcOperation); + + // Grab the service instance ID from the input buffer + String siid = input.getServiceInformation().getServiceInstanceId(); + + ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder(); + getServiceData(siid, serviceDataBuilder); + + ServiceDataBuilder operDataBuilder = new ServiceDataBuilder(); + getServiceData(siid, operDataBuilder, LogicalDatastoreType.OPERATIONAL); + + // Set the serviceStatus based on input + setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader()); + setServiceStatus(serviceStatusBuilder, input.getRequestInformation()); + + log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input); + GenericConfigurationNotificationInputBuilder inputBuilder = new GenericConfigurationNotificationInputBuilder( + input); + GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); + + log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build()); + GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder); + + // Call SLI sync method + + ResponseObject responseObject = new ResponseObject("200", ""); + String ackFinal = "Y"; + Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, responseObject); + if (respProps != null) { responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); - return respProps.getProperty(ACK_FINAL_PARAM, "Y"); + ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); } - return "Y"; + + setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal); + serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete); + serviceStatusBuilder.setRpcName(svcOperation); + + if (failed(responseObject)) { + ServiceBuilder serviceBuilder = new ServiceBuilder(); + serviceBuilder.setServiceInstanceId(siid); + serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); + try { + saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); + } catch (Exception e) { + log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); + } + + RpcResult<Void> rpcResult = RpcResultBuilder.<Void>status(true).build(); + + return Futures.immediateFuture(rpcResult); + } + + // Got success from SLI + try { + serviceData = serviceDataBuilder.build(); + + // service object + ServiceBuilder serviceBuilder = new ServiceBuilder(); + serviceBuilder.setServiceData(serviceData); + serviceBuilder.setServiceInstanceId(siid); + serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); + saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); + + ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder(); + serviceResponseInformationBuilder.setInstanceId(siid); + + } catch (Exception e) { + log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); + RpcResult<Void> rpcResult = RpcResultBuilder.<Void>status(true).build(); + + return Futures.immediateFuture(rpcResult); + } + + // Update succeeded + log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid); + + RpcResult<Void> rpcResult = RpcResultBuilder.<Void>status(true).build(); + + return Futures.immediateFuture(rpcResult); } - private void trySetResponseMessage(PreloadVnfTopologyOperationOutputBuilder responseBuilder, ResponseObject error) { - if (!error.getMessage().isEmpty()) { - responseBuilder.setResponseMessage(error.getMessage()); + @Override + public Future<RpcResult<GetpathsegmentTopologyOperationOutput>> getpathsegmentTopologyOperation( + GetpathsegmentTopologyOperationInput input) { + + final String svcOperation = "getpathsegment-topology-operation"; + ServiceData serviceData; + ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder(); + Properties parms = new Properties(); + + log.info(CALLED_STR, svcOperation); + // create a new response object + GetpathsegmentTopologyOperationOutputBuilder responseBuilder = new GetpathsegmentTopologyOperationOutputBuilder(); + + if (hasInvalidService(input)) { + log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation); + responseBuilder.setResponseCode("404"); + responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM); + responseBuilder.setAckFinalIndicator("Y"); + + RpcResult<GetpathsegmentTopologyOperationOutput> rpcResult = RpcResultBuilder + .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + + return Futures.immediateFuture(rpcResult); } + + // Grab the service instance ID from the input buffer + String siid = input.getServiceInformation().getServiceInstanceId(); + + trySetSvcRequestId(input, responseBuilder); + + if (hasInvalidOnapModelInformation(input)) { + log.debug("exiting {} because no model-uuid provided", svcOperation); + responseBuilder.setResponseCode("404"); + responseBuilder.setResponseMessage("invalid input, no model-uuid provided"); + responseBuilder.setAckFinalIndicator("Y"); + RpcResult<GetpathsegmentTopologyOperationOutput> rpcResult = RpcResultBuilder + .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder(); + getServiceData(siid, serviceDataBuilder); + + ServiceDataBuilder operDataBuilder = new ServiceDataBuilder(); + getServiceData(siid, operDataBuilder, LogicalDatastoreType.OPERATIONAL); + + // Set the serviceStatus based on input + setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader()); + setServiceStatus(serviceStatusBuilder, input.getRequestInformation()); + + log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input); + GetpathsegmentTopologyOperationInputBuilder inputBuilder = new GetpathsegmentTopologyOperationInputBuilder( + input); + GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); + + log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build()); + GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder); + + // Call SLI sync method + + ResponseObject responseObject = new ResponseObject("200", ""); + String ackFinal = "Y"; + String serviceObjectPath = null; + Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, responseObject); + + if (respProps != null) { + responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); + responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); + ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); + serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM); + } + + setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal); + serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete); + serviceStatusBuilder.setRpcName(svcOperation); + + if (failed(responseObject)) { + responseBuilder.setResponseCode(responseObject.getStatusCode()); + responseBuilder.setResponseMessage(responseObject.getMessage()); + responseBuilder.setAckFinalIndicator(ackFinal); + + ServiceBuilder serviceBuilder = new ServiceBuilder(); + serviceBuilder.setServiceInstanceId(siid); + serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); + try { + saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); + } catch (Exception e) { + log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); + } + log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); + + RpcResult<GetpathsegmentTopologyOperationOutput> rpcResult = RpcResultBuilder + .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + + return Futures.immediateFuture(rpcResult); + } + + // Got success from SLI + try { + serviceData = serviceDataBuilder.build(); + log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, serviceData); + + // service object + ServiceBuilder serviceBuilder = new ServiceBuilder(); + serviceBuilder.setServiceData(serviceData); + serviceBuilder.setServiceInstanceId(siid); + serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); + saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); + + ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder(); + serviceResponseInformationBuilder.setInstanceId(siid); + serviceResponseInformationBuilder.setObjectPath(serviceObjectPath); + responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build()); + + } catch (Exception e) { + log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); + responseBuilder.setResponseCode("500"); + responseBuilder.setResponseMessage(e.getMessage()); + responseBuilder.setAckFinalIndicator("Y"); + RpcResult<GetpathsegmentTopologyOperationOutput> rpcResult = RpcResultBuilder + .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + + return Futures.immediateFuture(rpcResult); + } + + // Update succeeded + responseBuilder.setResponseCode(responseObject.getStatusCode()); + responseBuilder.setAckFinalIndicator(ackFinal); + trySetResponseMessage(responseBuilder, responseObject); + log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid); + log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build()); + + RpcResult<GetpathsegmentTopologyOperationOutput> rpcResult = RpcResultBuilder + .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + + return Futures.immediateFuture(rpcResult); + } + + private boolean hasInvalidService(GetpathsegmentTopologyOperationInput input) { + return input == null || input.getServiceInformation() == null + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0; } - private void trySetSvcRequestId(PreloadVnfTopologyOperationInput input, - PreloadVnfTopologyOperationOutputBuilder responseBuilder) { + private void trySetSvcRequestId(GetpathsegmentTopologyOperationInput input, + GetpathsegmentTopologyOperationOutputBuilder responseBuilder) { if (input.getSdncRequestHeader() != null) { responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId()); } } - private boolean hasInvalidVnfTopology(PreloadVnfTopologyOperationInput input) { - return input == null || input.getVnfTopologyInformation() == null - || input.getVnfTopologyInformation().getVnfTopologyIdentifier() == null; + private boolean hasInvalidOnapModelInformation(GetpathsegmentTopologyOperationInput input) { + return input.getServiceInformation() == null || input.getServiceInformation().getOnapModelInformation() == null + || input.getServiceInformation().getOnapModelInformation().getModelUuid() == null; } - private void updatePreloadData(String svcOperation, String preloadName, String preloadType, - PreloadDataBuilder preloadDataBuilder) { - PreloadData preloadData; - preloadData = preloadDataBuilder.build(); - log.info("Updating MD-SAL for {} [{},{}] preloadData: {}", svcOperation, preloadName, preloadType, - preloadData); - // svc-configuration-list - VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder(); - preloadVnfListBuilder.setVnfName(preloadName); - preloadVnfListBuilder.setVnfType(preloadType); - preloadVnfListBuilder.setPreloadData(preloadData); - - // merge flag sets to false to allow it to be overwritten (not appended) - savePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); - log.info(UPDATING_TREE_INFO_MESSAGE); - savePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); + private void trySetResponseMessage(GetpathsegmentTopologyOperationOutputBuilder responseBuilder, + ResponseObject responseObject) { + if (responseObject.getMessage() != null) { + if (!responseObject.getMessage().isEmpty()) { + responseBuilder.setResponseMessage(responseObject.getMessage()); + } + } } @Override - public Future<RpcResult<PreloadNetworkTopologyOperationOutput>> preloadNetworkTopologyOperation( - PreloadNetworkTopologyOperationInput input) { + public Future<RpcResult<PolicyUpdateNotifyOperationOutput>> policyUpdateNotifyOperation( + PolicyUpdateNotifyOperationInput input) { - final String svcOperation = "preload-network-topology-operation"; + final String svcOperation = "policy-update-notify-operation"; Properties parms = new Properties(); log.info(CALLED_STR, svcOperation); + // create a new response object - PreloadNetworkTopologyOperationOutputBuilder responseBuilder = new PreloadNetworkTopologyOperationOutputBuilder(); + PolicyUpdateNotifyOperationOutputBuilder responseBuilder = new PolicyUpdateNotifyOperationOutputBuilder(); + + // Make sure we have a valid input + if (hasInvalidInput(input)) { + log.debug("exiting {} because policy name, update type, or version id was not provided", svcOperation); + responseBuilder.setErrorCode("404"); + responseBuilder.setErrorMsg("Invalid input, missing input data"); + RpcResult<PolicyUpdateNotifyOperationOutput> rpcResult = RpcResultBuilder + .<PolicyUpdateNotifyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } - if (hasInvalidNetworkTopology(input)) { + log.info("Adding INPUT data for {} input: {}", svcOperation, input); + PolicyUpdateNotifyOperationInputBuilder inputBuilder = new PolicyUpdateNotifyOperationInputBuilder(input); + GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); - log.debug("exiting {} because of null input", svcOperation); - responseBuilder.setResponseCode("403"); - responseBuilder.setResponseMessage("input is null"); - responseBuilder.setAckFinalIndicator("Y"); + // Call SLI sync method + ResponseObject responseObject = new ResponseObject("200", ""); + String ackFinal = "Y"; + String serviceObjectPath = null; + Properties respProps = tryGetProperties(svcOperation, parms, responseObject); - RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder - .<PreloadNetworkTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + if (respProps != null) { + responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); + responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); + ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); + serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM); + } + + if (failed(responseObject)) { + responseBuilder.setErrorCode(responseObject.getStatusCode()); + responseBuilder.setErrorMsg(responseObject.getMessage()); + log.error(RETURNED_FAILED_MESSAGE, svcOperation, "policy update", responseBuilder.build()); + + RpcResult<PolicyUpdateNotifyOperationOutput> rpcResult = RpcResultBuilder + .<PolicyUpdateNotifyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - // Grab the name and type from the input buffer - String preloadName = input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkName(); - String preloadType = input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkType(); + // Got success from SLI + responseBuilder.setErrorCode(responseObject.getStatusCode()); + if (responseObject.getMessage() != null) { + responseBuilder.setErrorMsg(responseObject.getMessage()); + } + log.info("Returned SUCCESS for " + svcOperation + responseBuilder.build()); + RpcResult<PolicyUpdateNotifyOperationOutput> rpcResult = RpcResultBuilder + .<PolicyUpdateNotifyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + // return success + return Futures.immediateFuture(rpcResult); + } - // Make sure we have a preload_name and preload_type - if (invalidPreloadData(preloadName, preloadType)) { - log.debug("exiting {} because of invalid preload-name or preload-type", svcOperation); - responseBuilder.setResponseCode("403"); - responseBuilder.setResponseMessage("invalid input: network-name or network-type is null or empty"); - responseBuilder.setAckFinalIndicator("Y"); + private boolean hasInvalidInput(PolicyUpdateNotifyOperationInput input) { + return (input.getPolicyName() == null) || (input.getUpdateType() == null) || (input.getVersionId() == null); + } - RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder - .<PreloadNetworkTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + @Override + public Future<RpcResult<PortMirrorTopologyOperationOutput>> portMirrorTopologyOperation( + final PortMirrorTopologyOperationInput input) { + + final String svcOperation = "port-mirror-topology-operation"; + ServiceData serviceData = null; + ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder(); + Properties properties = new Properties(); + + log.info(CALLED_STR, svcOperation); + + // create a new response object + PortMirrorTopologyOperationOutputBuilder responseBuilder = new PortMirrorTopologyOperationOutputBuilder(); + if (hasInvalidService(input)) { + log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation); + responseBuilder.setResponseCode("404"); + responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM); + responseBuilder.setAckFinalIndicator("Y"); + RpcResult<PortMirrorTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + // return error + return Futures.immediateFuture(rpcResult); + } + + if (hasInvalidConfigurationId(input)) { + log.debug("exiting {} because of null or empty configuration-id", svcOperation); + responseBuilder.setResponseCode("404"); + responseBuilder.setResponseMessage("invalid input, null or empty configuration-id"); + responseBuilder.setAckFinalIndicator("Y"); + RpcResult<PortMirrorTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } + // Grab the service instance ID from the input buffer + String siid = input.getServiceInformation().getServiceInstanceId(); + trySetSvcRequestId(input, responseBuilder); - PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder(); - getPreloadData(preloadName, preloadType, preloadDataBuilder); + ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder(); + getServiceData(siid, serviceDataBuilder); - PreloadDataBuilder operDataBuilder = new PreloadDataBuilder(); - getPreloadData(preloadName, preloadType, operDataBuilder, LogicalDatastoreType.OPERATIONAL); + ServiceDataBuilder operDataBuilder = new ServiceDataBuilder(); + getServiceData(siid, operDataBuilder, LogicalDatastoreType.OPERATIONAL); - // - // setup a preload-data object builder - // ACTION preload-network-topology-operation - // INPUT: - // USES sdnc-request-header; - // USES request-information; - // uses network-topology-information; - // OUTPUT: - // USES vnf-topology-response-body; - // - // container preload-data - // uses vnf-topology-information; - // uses network-topology-information; - // uses oper-status; + // Set the serviceStatus based on input + setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader()); + setServiceStatus(serviceStatusBuilder, input.getRequestInformation()); - log.info("Adding INPUT data for {} [{},{}] input: {}", svcOperation, preloadName, preloadType, input); - PreloadNetworkTopologyOperationInputBuilder inputBuilder = new PreloadNetworkTopologyOperationInputBuilder( - input); - GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); - log.info("Adding OPERATIONAL data for {} [{},{}] operational-data: {}", svcOperation, preloadName, - preloadType, operDataBuilder.build()); - GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder); + log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input); + PortMirrorTopologyOperationInputBuilder inputBuilder = new PortMirrorTopologyOperationInputBuilder(input); + GenericResourceApiUtil.toProperties(properties, inputBuilder.build()); + + log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build()); + GenericResourceApiUtil.toProperties(properties, OPERATIONAL_DATA_PARAM, operDataBuilder); // Call SLI sync method - // Get SvcLogicService reference ResponseObject responseObject = new ResponseObject("200", ""); - Properties respProps = tryGetProperties(svcOperation, parms, responseObject); + String ackFinal = "Y"; + String serviceObjectPath = null; + String portMirrorObjectPath = null; + Properties respProps = tryGetProperties(svcOperation, properties, serviceDataBuilder, responseObject); - String ackFinal = resolveAckFinal(responseObject, respProps); + if (respProps != null) { + responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); + responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); + ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); + serviceObjectPath = respProps.getProperty("service-object-path"); + portMirrorObjectPath = respProps.getProperty("port-mirror-object-path"); + } - if (failed(responseObject)) { + setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal); + serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete); + serviceStatusBuilder.setRpcName(svcOperation); + if (failed(responseObject)) { responseBuilder.setResponseCode(responseObject.getStatusCode()); responseBuilder.setResponseMessage(responseObject.getMessage()); responseBuilder.setAckFinalIndicator(ackFinal); - VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder(); - preloadVnfListBuilder.setVnfName(preloadName); - preloadVnfListBuilder.setVnfType(preloadType); - preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build()); - log.error("Returned FAILED for {} [{},{}] error code: '{}', Reason: '{}'", svcOperation, preloadName, - preloadType, responseObject.getStatusCode(), responseObject.getMessage()); + ServiceBuilder serviceBuilder = new ServiceBuilder(); + serviceBuilder.setServiceInstanceId(siid); + serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); try { - savePreloadList(preloadVnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); + saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); } catch (Exception e) { - log.error(UPDATING_MDSAL_ERROR_MESSAGE_2, svcOperation, preloadName, - preloadType, e); - + log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); } - log.debug("Sending Success rpc result due to external error"); + log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); - RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder - .<PreloadNetworkTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + RpcResult<PortMirrorTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + // return error return Futures.immediateFuture(rpcResult); } // Got success from SLI try { - updatePreloadData(svcOperation, preloadName, preloadType, preloadDataBuilder); + serviceData = serviceDataBuilder.build(); + log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, serviceData); + + // service object + ServiceBuilder serviceBuilder = new ServiceBuilder(); + serviceBuilder.setServiceData(serviceData); + serviceBuilder.setServiceInstanceId(siid); + serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); + saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); + + if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) { + // Only update operational tree on activate or delete + if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) + || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) { + log.info(UPDATING_TREE_INFO_MESSAGE); + saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); + } + } + + ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder(); + serviceResponseInformationBuilder.setInstanceId(siid); + serviceResponseInformationBuilder.setObjectPath(serviceObjectPath); + responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build()); + PortMirrorResponseInformationBuilder portMirrorResponseInformationBuilder = new PortMirrorResponseInformationBuilder(); + portMirrorResponseInformationBuilder + .setInstanceId(input.getConfigurationInformation().getConfigurationId()); + portMirrorResponseInformationBuilder.setObjectPath(portMirrorObjectPath); + responseBuilder.setPortMirrorResponseInformation(portMirrorResponseInformationBuilder.build()); + } catch (Exception e) { - log.error(UPDATING_MDSAL_ERROR_MESSAGE_2, svcOperation, preloadName, preloadType, e); + log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); responseBuilder.setResponseCode("500"); responseBuilder.setResponseMessage(e.getMessage()); responseBuilder.setAckFinalIndicator("Y"); - log.error("Returned FAILED for {} [{},{}] {}", svcOperation, preloadName, preloadType, - responseBuilder.build()); - - RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder - .<PreloadNetworkTopologyOperationOutput>status(false) - .withResult(responseBuilder.build()) - .build(); - + log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); + RpcResult<PortMirrorTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -2460,40 +3140,234 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setResponseCode(responseObject.getStatusCode()); responseBuilder.setAckFinalIndicator(ackFinal); trySetResponseMessage(responseBuilder, responseObject); + log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid); + log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build()); - log.info("Updated MD-SAL for {} [{},{}]", svcOperation, preloadName, preloadType); - log.info("Returned SUCCESS for {} [{},{}] {}", svcOperation, preloadName, preloadType, - responseBuilder.build()); + RpcResult<PortMirrorTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); - RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder - .<PreloadNetworkTopologyOperationOutput>status(true) - .withResult(responseBuilder.build()) - .build(); + if (ackFinal.equals("N")) { + // Spawn background thread to invoke the Async DG + Runnable backgroundThread = new Runnable() { + public void run() { + log.info(BACKGROUND_THREAD_STARTED_MESSAGE); + processAsyncPortMirrorTopologyOperation(input); + } + }; + new Thread(backgroundThread).start(); + } + // return success return Futures.immediateFuture(rpcResult); } - private void trySetResponseMessage(PreloadNetworkTopologyOperationOutputBuilder responseBuilder, - ResponseObject error) { - if (!error.getMessage().isEmpty()) { - responseBuilder.setResponseMessage(error.getMessage()); - } + private boolean hasInvalidService(PortMirrorTopologyOperationInput input) { + return input == null || input.getServiceInformation() == null + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0; } - private void trySetSvcRequestId(PreloadNetworkTopologyOperationInput input, - PreloadNetworkTopologyOperationOutputBuilder responseBuilder) { + private boolean hasInvalidConfigurationId(PortMirrorTopologyOperationInput input) { + return input.getConfigurationInformation() == null + || input.getConfigurationInformation().getConfigurationId() == null + || input.getConfigurationInformation().getConfigurationId().length() == 0; + } + + private void trySetSvcRequestId(PortMirrorTopologyOperationInput input, + PortMirrorTopologyOperationOutputBuilder responseBuilder) { if (input.getSdncRequestHeader() != null) { responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId()); } } - private boolean invalidPreloadData(String preloadName, String preloadType) { - return preloadName == null || preloadName.length() == 0 || preloadType == null || preloadType.length() == 0; + private void trySetResponseMessage(PortMirrorTopologyOperationOutputBuilder responseBuilder, + ResponseObject responseObject) { + if (responseObject.getMessage() != null) { + if (!responseObject.getMessage().isEmpty()) { + responseBuilder.setResponseMessage(responseObject.getMessage()); + } + } } - private boolean hasInvalidNetworkTopology(PreloadNetworkTopologyOperationInput input) { - return input == null || input.getNetworkTopologyInformation() == null - || input.getNetworkTopologyInformation().getNetworkTopologyIdentifier() == null; + public void processAsyncPortMirrorTopologyOperation(PortMirrorTopologyOperationInput input) { + log.info(BACKGROUND_THREAD_INFO, input.getConfigurationInformation().getConfigurationId()); + + final String svcOperation = "port-mirror-topology-operation-async"; + ServiceData serviceData = null; + ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder(); + Properties parms = new Properties(); + + log.info(CALLED_STR, svcOperation); + + // Grab the service instance ID from the input buffer + String siid = input.getServiceInformation().getServiceInstanceId(); + + ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder(); + getServiceData(siid, serviceDataBuilder); + + ServiceDataBuilder operDataBuilder = new ServiceDataBuilder(); + getServiceData(siid, operDataBuilder, LogicalDatastoreType.OPERATIONAL); + + // Set the serviceStatus based on input + setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader()); + setServiceStatus(serviceStatusBuilder, input.getRequestInformation()); + + log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input); + PortMirrorTopologyOperationInputBuilder inputBuilder = new PortMirrorTopologyOperationInputBuilder(input); + GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); + + log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build()); + GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder); + + // Call SLI sync method + ResponseObject responseObject = new ResponseObject("200", ""); + String ackFinal = "Y"; + String serviceObjectPath = null; + Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, responseObject); + + if (respProps != null) { + responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); + responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); + ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); + } + + setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal); + serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete); + serviceStatusBuilder.setRpcName(svcOperation); + + if (failed(responseObject)) { + ServiceBuilder serviceBuilder = new ServiceBuilder(); + serviceBuilder.setServiceInstanceId(siid); + serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); + try { + saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); + } catch (Exception e) { + log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); + } + + // return error + return; + } + + // Got success from SLI + try { + serviceData = serviceDataBuilder.build(); + log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, serviceData); + + // service object + ServiceBuilder serviceBuilder = new ServiceBuilder(); + serviceBuilder.setServiceData(serviceData); + serviceBuilder.setServiceInstanceId(siid); + serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); + saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); + + if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) { + // Only update operational tree on activate or delete + if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) + || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) { + log.info(UPDATING_TREE_INFO_MESSAGE); + saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); + } + } + + ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder(); + serviceResponseInformationBuilder.setInstanceId(siid); + serviceResponseInformationBuilder.setObjectPath(serviceObjectPath); + + } catch (Exception e) { + log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e); + return; + } + + // Update succeeded + log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid); + + return; + } + + @Override + public Future<RpcResult<VnfGetResourceRequestOutput>> vnfGetResourceRequest(VnfGetResourceRequestInput input) { + + final String svcOperation = "vnf-get-resource-request"; + ServiceData serviceData; + ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder(); + Properties parms = new Properties(); + + log.info(CALLED_STR, svcOperation); + // create a new response object + VnfGetResourceRequestOutputBuilder responseBuilder = new VnfGetResourceRequestOutputBuilder(); + + if (hasInvalidService(input)) { + log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation); + RpcResult<VnfGetResourceRequestOutput> rpcResult = RpcResultBuilder + .<VnfGetResourceRequestOutput>status(true).withResult(responseBuilder.build()).build(); + // return error + return Futures.immediateFuture(rpcResult); + } + + // Grab the service instance ID from the input buffer + String siid = input.getServiceInformation().getServiceInstanceId(); + + ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder(); + getServiceData(siid, serviceDataBuilder); + + ServiceDataBuilder operDataBuilder = new ServiceDataBuilder(); + getServiceData(siid, operDataBuilder, LogicalDatastoreType.OPERATIONAL); + + // Set the serviceStatus based on input + setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader()); + setServiceStatus(serviceStatusBuilder, input.getRequestInformation()); + + log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input); + VnfGetResourceRequestInputBuilder inputBuilder = new VnfGetResourceRequestInputBuilder(input); + GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); + + log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build()); + GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder); + + // Call SLI sync method + + ResponseObject responseObject = new ResponseObject("200", ""); + String ackFinal = "Y"; + String serviceObjectPath = null; + Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, responseObject); + + if (respProps != null) { + responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM)); + responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM)); + ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y"); + serviceObjectPath = respProps.getProperty("service-object-path"); + } + + setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal); + serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete); + serviceStatusBuilder.setRpcName(svcOperation); + + if (failed(responseObject)) { + log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build()); + RpcResult<VnfGetResourceRequestOutput> rpcResult = RpcResultBuilder + .<VnfGetResourceRequestOutput>status(true).withResult(responseBuilder.build()).build(); + // return error + return Futures.immediateFuture(rpcResult); + } + + // Got success from SLI + log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build()); + + if (respProps != null) { + GenericResourceApiUtil.toBuilder(respProps, responseBuilder); + } + + RpcResult<VnfGetResourceRequestOutput> rpcResult = RpcResultBuilder.<VnfGetResourceRequestOutput>status(true) + .withResult(responseBuilder.build()).build(); + + // return success + return Futures.immediateFuture(rpcResult); } + private boolean hasInvalidService(VnfGetResourceRequestInput input) { + return input == null || input.getServiceInformation() == null + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0; + } } diff --git a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiUtil.java b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiUtil.java index 04d0b6fe..424547c1 100644 --- a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiUtil.java +++ b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiUtil.java @@ -60,36 +60,20 @@ public class GenericResourceApiUtil extends MdsalHelper { new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.request.input.network.request.input.NetworkInputParametersBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.response.information.NetworkResponseInformationBuilder u10 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.response.information.NetworkResponseInformationBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.topology.identifier.NetworkTopologyIdentifierBuilder u11 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.topology.identifier.NetworkTopologyIdentifierBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.topology.identifier.structure.NetworkTopologyIdentifierStructureBuilder u12 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.topology.identifier.structure.NetworkTopologyIdentifierStructureBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.topology.information.NetworkTopologyInformationBuilder u13 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.topology.information.NetworkTopologyInformationBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.topology.NetworkTopologyBuilder u14 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.topology.NetworkTopologyBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInputBuilder u15 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInputBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutputBuilder u16 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutputBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.oper.status.OperStatusBuilder u17 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.oper.status.OperStatusBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.param.ParamBuilder u18 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.param.ParamBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.data.PreloadDataBuilder u19 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.data.PreloadDataBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.model.information.VnfPreloadListBuilder u20 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.model.information.VnfPreloadListBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationInputBuilder u21 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationInputBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationOutputBuilder u22 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationOutputBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfsBuilder u23 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfsBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationInputBuilder u24 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationInputBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationOutputBuilder u25 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationOutputBuilder(); + org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadInformationBuilder u23 = + new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadInformationBuilder(); + org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationInputBuilder u24 = + new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationInputBuilder(); + org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationOutputBuilder u25 = + new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationOutputBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformationBuilder u26 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformationBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.route.table.reference.RouteTableReferenceBuilder u27 = @@ -146,16 +130,12 @@ public class GenericResourceApiUtil extends MdsalHelper { new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationOutputBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.topology.ServiceTopologyBuilder u53 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.topology.ServiceTopologyBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sriov.vlan.filter.list.SriovVlanFilterListBuilder u54 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sriov.vlan.filter.list.SriovVlanFilterListBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.subnets.SubnetsBuilder u55 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.subnets.SubnetsBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.assignments.VfModuleAssignmentsBuilder u56 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.assignments.VfModuleAssignmentsBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.assignments.vf.module.assignments.VmsBuilder u57 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.assignments.vf.module.assignments.VmsBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.assignments.vf.module.assignments.vms.VmBuilder u58 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.assignments.vf.module.assignments.vms.VmBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.information.VfModuleInformationBuilder u59 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.information.VfModuleInformationBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.level.oper.status.VfModuleLevelOperStatusBuilder u60 = @@ -198,50 +178,12 @@ public class GenericResourceApiUtil extends MdsalHelper { new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.network.data.SriovParametersBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.network.data.sriov.parameters.HeatVlanFiltersBuilder u79 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.network.data.sriov.parameters.HeatVlanFiltersBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.network.InterfaceRoutePrefixesBuilder u80 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.network.InterfaceRoutePrefixesBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.network.NetworkIpsBuilder u81 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.network.NetworkIpsBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.network.NetworkIpsV6Builder u82 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.network.NetworkIpsV6Builder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.network.NetworkMacsBuilder u83 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.network.NetworkMacsBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.topology.data.VmNamesBuilder u84 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.topology.data.VmNamesBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.topology.data.VmNetworksBuilder u85 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.topology.data.VmNetworksBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.topology.data.vm.networks.VmNetworkBuilder u86 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.topology.data.vm.networks.VmNetworkBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.topology.VnfVmsBuilder u87 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.topology.VnfVmsBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.topology.vnf.vms.VmNamesBuilder u88 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.topology.vnf.vms.VmNamesBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.topology.vnf.vms.VmNetworksBuilder u89 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vm.topology.vnf.vms.VmNetworksBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.assignments.vnf.assignments.AvailabilityZonesBuilder u90 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.assignments.vnf.assignments.AvailabilityZonesBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.assignments.VnfAssignmentsBuilder u91 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.assignments.VnfAssignmentsBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.assignments.vnf.assignments.VnfNetworksBuilder u92 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.assignments.vnf.assignments.VnfNetworksBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.information.VnfInformationBuilder u93 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.information.VnfInformationBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.level.oper.status.VnfLevelOperStatusBuilder u94 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.level.oper.status.VnfLevelOperStatusBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.network.data.SubnetsDataBuilder u95 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.network.data.SubnetsDataBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.network.data.subnets.data.SubnetDataBuilder u96 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.network.data.subnets.data.SubnetDataBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.parameters.VnfParametersBuilder u97 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.parameters.VnfParametersBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.request.input.VnfRequestInputBuilder u98 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.request.input.VnfRequestInputBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.request.input.vnf.request.input.VnfInputParametersBuilder u99 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.request.input.vnf.request.input.VnfInputParametersBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.request.input.vnf.request.input.VnfNetworksBuilder u100 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.request.input.vnf.request.input.VnfNetworksBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.request.input.vnf.request.input.vnf.networks.VnfNetworkBuilder u101 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.request.input.vnf.request.input.vnf.networks.VnfNetworkBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.resource.assignments.vnf.resource.assignments.AvailabilityZonesBuilder u102 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.resource.assignments.vnf.resource.assignments.AvailabilityZonesBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.resource.assignments.VnfResourceAssignmentsBuilder u103 = @@ -254,19 +196,9 @@ public class GenericResourceApiUtil extends MdsalHelper { new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.response.information.VnfResponseInformationBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.identifier.structure.VnfTopologyIdentifierStructureBuilder u107 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.identifier.structure.VnfTopologyIdentifierStructureBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.identifier.VnfTopologyIdentifierBuilder u108 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.identifier.VnfTopologyIdentifierBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.information.VnfTopologyInformationBuilder u109 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.information.VnfTopologyInformationBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInputBuilder u110 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInputBuilder(); org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutputBuilder u111 = new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutputBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.VnfTopologyBuilder u112 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.VnfTopologyBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.vnf.topology.VnfParametersDataBuilder u113 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.vnf.topology.VnfParametersDataBuilder(); - org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vpn.bindings.VpnBindingsBuilder u114 = - new org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vpn.bindings.VpnBindingsBuilder(); } } diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadNetworkTopologyRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadNetworkTopologyRPCTest.java index b05f1b27..6e0f1a2e 100644 --- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadNetworkTopologyRPCTest.java +++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadNetworkTopologyRPCTest.java @@ -7,8 +7,8 @@ import static org.onap.sdnc.northbound.GenericResourceApiProvider.APP_NAME; import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE; import static org.onap.sdnc.northbound.util.MDSALUtil.build; import static org.onap.sdnc.northbound.util.MDSALUtil.exec; -import static org.onap.sdnc.northbound.util.MDSALUtil.networkTopologyIdentifierBuilder; -import static org.onap.sdnc.northbound.util.MDSALUtil.networkTopologyInformationBuilder; +import static org.onap.sdnc.northbound.util.MDSALUtil.networkTopologyIdentifierStructureBuilder; +import static org.onap.sdnc.northbound.util.MDSALUtil.preloadNetworkTopologyInformationBuilder; import static org.onap.sdnc.northbound.util.MDSALUtil.preloadNetworkTopologyOperationInput; import static org.onap.sdnc.northbound.util.MDSALUtil.preloadNetworkTopologyOperationOutput; import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation; @@ -41,7 +41,7 @@ public class PreloadNetworkTopologyRPCTest extends GenericResourceApiProviderTes } @Test - public void should_fail_when_invalid_vnf_topology() throws Exception { + public void should_fail_when_invalid_network_topology() throws Exception { PreloadNetworkTopologyOperationInput input = build(preloadNetworkTopologyOperationInput()); @@ -49,25 +49,7 @@ public class PreloadNetworkTopologyRPCTest extends GenericResourceApiProviderTes exec(genericResourceApiProvider::preloadNetworkTopologyOperation, input, RpcResult::getResult); assertEquals("403", output.getResponseCode()); - assertEquals("input is null", output.getResponseMessage()); - assertEquals("Y", output.getAckFinalIndicator()); - } - - - @Test - public void should_fail_when_invalid_preload_data() throws Exception { - - PreloadNetworkTopologyOperationInput input = build(preloadNetworkTopologyOperationInput() - .setNetworkTopologyInformation(build(networkTopologyInformationBuilder() - .setNetworkTopologyIdentifier(build(networkTopologyIdentifierBuilder() - .setNetworkName("test-network-name"))))) - ); - - PreloadNetworkTopologyOperationOutput output = - exec(genericResourceApiProvider::preloadNetworkTopologyOperation, input, RpcResult::getResult); - - assertEquals("403", output.getResponseCode()); - assertEquals("invalid input: network-name or network-type is null or empty", output.getResponseMessage()); + assertEquals("invalid input, null or empty preload-network-topology-information", output.getResponseMessage()); assertEquals("Y", output.getAckFinalIndicator()); } @@ -76,11 +58,11 @@ public class PreloadNetworkTopologyRPCTest extends GenericResourceApiProviderTes public void should_fail_when_client_execution_failed() throws Exception { svcClient.mockHasGraph(true); - svcClient.mockExecuteWoServiceData(new RuntimeException("test exception")); + svcClient.mockExecuteWoServiceDataPreload(new RuntimeException("test exception")); PreloadNetworkTopologyOperationInput input = build(preloadNetworkTopologyOperationInput() - .setNetworkTopologyInformation(build(networkTopologyInformationBuilder() - .setNetworkTopologyIdentifier(build(networkTopologyIdentifierBuilder() + .setPreloadNetworkTopologyInformation(build(preloadNetworkTopologyInformationBuilder() + .setNetworkTopologyIdentifierStructure(build(networkTopologyIdentifierStructureBuilder() .setNetworkName("test-network-name") .setNetworkType("test-network-type"))))) ); @@ -99,8 +81,8 @@ public class PreloadNetworkTopologyRPCTest extends GenericResourceApiProviderTes svcClient.mockHasGraph(false); PreloadNetworkTopologyOperationInput input = build(preloadNetworkTopologyOperationInput() - .setNetworkTopologyInformation(build(networkTopologyInformationBuilder() - .setNetworkTopologyIdentifier(build(networkTopologyIdentifierBuilder() + .setPreloadNetworkTopologyInformation(build(preloadNetworkTopologyInformationBuilder() + .setNetworkTopologyIdentifierStructure(build(networkTopologyIdentifierStructureBuilder() .setNetworkName("test-network-name") .setNetworkType("test-network-type"))))) ); @@ -127,8 +109,8 @@ public class PreloadNetworkTopologyRPCTest extends GenericResourceApiProviderTes genericResourceApiProvider.setDataBroker(spyDataBroker); PreloadNetworkTopologyOperationInput input = build(preloadNetworkTopologyOperationInput() - .setNetworkTopologyInformation(build(networkTopologyInformationBuilder() - .setNetworkTopologyIdentifier(build(networkTopologyIdentifierBuilder() + .setPreloadNetworkTopologyInformation(build(preloadNetworkTopologyInformationBuilder() + .setNetworkTopologyIdentifierStructure(build(networkTopologyIdentifierStructureBuilder() .setNetworkName("test-network-name") .setNetworkType("test-network-type"))))) ); @@ -149,8 +131,8 @@ public class PreloadNetworkTopologyRPCTest extends GenericResourceApiProviderTes svcClient.mockExecute(svcResultProp); PreloadNetworkTopologyOperationInput input = build(preloadNetworkTopologyOperationInput() - .setNetworkTopologyInformation(build(networkTopologyInformationBuilder() - .setNetworkTopologyIdentifier(build(networkTopologyIdentifierBuilder() + .setPreloadNetworkTopologyInformation(build(preloadNetworkTopologyInformationBuilder() + .setNetworkTopologyIdentifierStructure(build(networkTopologyIdentifierStructureBuilder() .setNetworkName("test-network-name") .setNetworkType("test-network-type"))))) .setSdncRequestHeader(build(sdncRequestHeader() diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadVnfTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadVnfTopologyOperationRPCTest.java index 8a854a91..8ab5e1f7 100644 --- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadVnfTopologyOperationRPCTest.java +++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadVnfTopologyOperationRPCTest.java @@ -7,12 +7,14 @@ import static org.onap.sdnc.northbound.GenericResourceApiProvider.APP_NAME; import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE; import static org.onap.sdnc.northbound.util.MDSALUtil.build; import static org.onap.sdnc.northbound.util.MDSALUtil.exec; -import static org.onap.sdnc.northbound.util.MDSALUtil.preloadVnfTopologyOperationInput; -import static org.onap.sdnc.northbound.util.MDSALUtil.preloadVnfTopologyOperationOutput; +import static org.onap.sdnc.northbound.util.MDSALUtil.preloadVfModuleTopologyOperationInput; +import static org.onap.sdnc.northbound.util.MDSALUtil.preloadVfModuleTopologyOperationOutput; import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation; import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader; -import static org.onap.sdnc.northbound.util.MDSALUtil.vnfTopologyIdentifierBuilder; -import static org.onap.sdnc.northbound.util.MDSALUtil.vnfTopologyInformationBuilder; +import static org.onap.sdnc.northbound.util.MDSALUtil.vnfTopologyIdentifierStructureBuilder; +import static org.onap.sdnc.northbound.util.MDSALUtil.preloadVfModuleTopologyInformationBuilder; +import static org.onap.sdnc.northbound.util.MDSALUtil.vfModuleTopologyBuilder; +import static org.onap.sdnc.northbound.util.MDSALUtil.vfModuleTopologyIdentifierBuilder; import org.junit.Before; import org.junit.Test; @@ -23,8 +25,8 @@ import org.onap.sdnc.northbound.util.PropBuilder; import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationInput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationOutput; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -32,7 +34,7 @@ import org.opendaylight.yangtools.yang.common.RpcResult; @RunWith(MockitoJUnitRunner.class) public class PreloadVnfTopologyOperationRPCTest extends GenericResourceApiProviderTest { - private static final String SVC_OPERATION = "preload-vnf-topology-operation"; + private static final String SVC_OPERATION = "preload-vf-module-topology-operation"; @Before public void setUp() throws Exception { @@ -43,13 +45,13 @@ public class PreloadVnfTopologyOperationRPCTest extends GenericResourceApiProvid @Test public void should_fail_when_invalid_vnf_topology() throws Exception { - PreloadVnfTopologyOperationInput input = build(preloadVnfTopologyOperationInput()); + PreloadVfModuleTopologyOperationInput input = build(preloadVfModuleTopologyOperationInput()); - PreloadVnfTopologyOperationOutput output = - exec(genericResourceApiProvider::preloadVnfTopologyOperation, input, RpcResult::getResult); + PreloadVfModuleTopologyOperationOutput output = + exec(genericResourceApiProvider::preloadVfModuleTopologyOperation, input, RpcResult::getResult); assertEquals("403", output.getResponseCode()); - assertEquals("invalid input: input is null", output.getResponseMessage()); + assertEquals("invalid input, null or empty preload-vf-module-topology-information.vf-module-topology.vf-module-topology-identifier.vf-module-name", output.getResponseMessage()); assertEquals("Y", output.getAckFinalIndicator()); } @@ -57,17 +59,17 @@ public class PreloadVnfTopologyOperationRPCTest extends GenericResourceApiProvid @Test public void should_fail_when_invalid_preload_data() throws Exception { - PreloadVnfTopologyOperationInput input = build(preloadVnfTopologyOperationInput() - .setVnfTopologyInformation(build(vnfTopologyInformationBuilder() - .setVnfTopologyIdentifier(build(vnfTopologyIdentifierBuilder() + PreloadVfModuleTopologyOperationInput input = build(preloadVfModuleTopologyOperationInput() + .setPreloadVfModuleTopologyInformation(build(preloadVfModuleTopologyInformationBuilder() + .setVnfTopologyIdentifierStructure(build(vnfTopologyIdentifierStructureBuilder() .setVnfName("test-vnf-name"))))) ); - PreloadVnfTopologyOperationOutput output = - exec(genericResourceApiProvider::preloadVnfTopologyOperation, input, RpcResult::getResult); + PreloadVfModuleTopologyOperationOutput output = + exec(genericResourceApiProvider::preloadVfModuleTopologyOperation, input, RpcResult::getResult); assertEquals("403", output.getResponseCode()); - assertEquals("invalid input: vnf-name or vnf-type is null or empty", output.getResponseMessage()); + assertEquals("invalid input, null or empty preload-vf-module-topology-information.vf-module-topology.vf-module-topology-identifier.vf-module-name", output.getResponseMessage()); assertEquals("Y", output.getAckFinalIndicator()); } @@ -76,17 +78,29 @@ public class PreloadVnfTopologyOperationRPCTest extends GenericResourceApiProvid public void should_fail_when_client_execution_failed() throws Exception { svcClient.mockHasGraph(true); - svcClient.mockExecuteWoServiceData(new RuntimeException("test exception")); - - PreloadVnfTopologyOperationInput input = build(preloadVnfTopologyOperationInput() - .setVnfTopologyInformation(build(vnfTopologyInformationBuilder() - .setVnfTopologyIdentifier(build(vnfTopologyIdentifierBuilder() - .setVnfName("test-vnf-name") - .setVnfType("test-vnf-type"))))) - ); - - PreloadVnfTopologyOperationOutput output = - exec(genericResourceApiProvider::preloadVnfTopologyOperation, input, RpcResult::getResult); + svcClient.mockExecuteWoServiceDataPreload(new RuntimeException("test exception")); + + PreloadVfModuleTopologyOperationInput input = build(preloadVfModuleTopologyOperationInput() + .setPreloadVfModuleTopologyInformation(build(preloadVfModuleTopologyInformationBuilder() + .setVnfTopologyIdentifierStructure(build(vnfTopologyIdentifierStructureBuilder() + .setVnfName("test-vnf-name") + .setVnfType("test-vnf-type"))) + .setVfModuleTopology(build(vfModuleTopologyBuilder() + .setVfModuleTopologyIdentifier(build(vfModuleTopologyIdentifierBuilder() + .setVfModuleName("vf-module-name")) + ))))) + .setSdncRequestHeader(build(sdncRequestHeader() + .setSvcRequestId("test-svc-request-id") + .setSvcAction(SvcAction.Assign) + )) + .setRequestInformation(build(requestInformation() + .setRequestId("test-request-id") + .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance) + )) + ); + + PreloadVfModuleTopologyOperationOutput output = + exec(genericResourceApiProvider::preloadVfModuleTopologyOperation, input, RpcResult::getResult); assertEquals("500", output.getResponseCode()); assertEquals("test exception", output.getResponseMessage()); @@ -98,15 +112,27 @@ public class PreloadVnfTopologyOperationRPCTest extends GenericResourceApiProvid svcClient.mockHasGraph(false); - PreloadVnfTopologyOperationInput input = build(preloadVnfTopologyOperationInput() - .setVnfTopologyInformation(build(vnfTopologyInformationBuilder() - .setVnfTopologyIdentifier(build(vnfTopologyIdentifierBuilder() - .setVnfName("test-vnf-name") - .setVnfType("test-vnf-type"))))) - ); - - PreloadVnfTopologyOperationOutput output = - exec(genericResourceApiProvider::preloadVnfTopologyOperation, input, RpcResult::getResult); + PreloadVfModuleTopologyOperationInput input = build(preloadVfModuleTopologyOperationInput() + .setPreloadVfModuleTopologyInformation(build(preloadVfModuleTopologyInformationBuilder() + .setVnfTopologyIdentifierStructure(build(vnfTopologyIdentifierStructureBuilder() + .setVnfName("test-vnf-name") + .setVnfType("test-vnf-type"))) + .setVfModuleTopology(build(vfModuleTopologyBuilder() + .setVfModuleTopologyIdentifier(build(vfModuleTopologyIdentifierBuilder() + .setVfModuleName("vf-module-name")) + ))))) + .setSdncRequestHeader(build(sdncRequestHeader() + .setSvcRequestId("test-svc-request-id") + .setSvcAction(SvcAction.Assign) + )) + .setRequestInformation(build(requestInformation() + .setRequestId("test-request-id") + .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance) + )) + ); + + PreloadVfModuleTopologyOperationOutput output = + exec(genericResourceApiProvider::preloadVfModuleTopologyOperation, input, RpcResult::getResult); assertEquals("503", output.getResponseCode()); assertEquals(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + SVC_OPERATION + "'", output.getResponseMessage()); @@ -126,15 +152,27 @@ public class PreloadVnfTopologyOperationRPCTest extends GenericResourceApiProvid when(spyDataBroker.newWriteOnlyTransaction()).thenReturn(mockWriteTransaction); genericResourceApiProvider.setDataBroker(spyDataBroker); - PreloadVnfTopologyOperationInput input = build(preloadVnfTopologyOperationInput() - .setVnfTopologyInformation(build(vnfTopologyInformationBuilder() - .setVnfTopologyIdentifier(build(vnfTopologyIdentifierBuilder() - .setVnfName("test-vnf-name") - .setVnfType("test-vnf-type"))))) - ); - - PreloadVnfTopologyOperationOutput output = - exec(genericResourceApiProvider::preloadVnfTopologyOperation, input, RpcResult::getResult); + PreloadVfModuleTopologyOperationInput input = build(preloadVfModuleTopologyOperationInput() + .setPreloadVfModuleTopologyInformation(build(preloadVfModuleTopologyInformationBuilder() + .setVnfTopologyIdentifierStructure(build(vnfTopologyIdentifierStructureBuilder() + .setVnfName("test-vnf-name") + .setVnfType("test-vnf-type"))) + .setVfModuleTopology(build(vfModuleTopologyBuilder() + .setVfModuleTopologyIdentifier(build(vfModuleTopologyIdentifierBuilder() + .setVfModuleName("vf-module-name")) + ))))) + .setSdncRequestHeader(build(sdncRequestHeader() + .setSvcRequestId("test-svc-request-id") + .setSvcAction(SvcAction.Assign) + )) + .setRequestInformation(build(requestInformation() + .setRequestId("test-request-id") + .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance) + )) + ); + + PreloadVfModuleTopologyOperationOutput output = + exec(genericResourceApiProvider::preloadVfModuleTopologyOperation, input, RpcResult::getResult); assertEquals("500", output.getResponseCode()); assertEquals("test exception", output.getResponseMessage()); @@ -148,11 +186,15 @@ public class PreloadVnfTopologyOperationRPCTest extends GenericResourceApiProvid PropBuilder svcResultProp = svcClient.createExecuteOKResult(); svcClient.mockExecute(svcResultProp); - PreloadVnfTopologyOperationInput input = build(preloadVnfTopologyOperationInput() - .setVnfTopologyInformation(build(vnfTopologyInformationBuilder() - .setVnfTopologyIdentifier(build(vnfTopologyIdentifierBuilder() + PreloadVfModuleTopologyOperationInput input = build(preloadVfModuleTopologyOperationInput() + .setPreloadVfModuleTopologyInformation(build(preloadVfModuleTopologyInformationBuilder() + .setVnfTopologyIdentifierStructure(build(vnfTopologyIdentifierStructureBuilder() .setVnfName("test-vnf-name") - .setVnfType("test-vnf-type"))))) + .setVnfType("test-vnf-type"))) + .setVfModuleTopology(build(vfModuleTopologyBuilder() + .setVfModuleTopologyIdentifier(build(vfModuleTopologyIdentifierBuilder() + .setVfModuleName("vf-module-name")) + ))))) .setSdncRequestHeader(build(sdncRequestHeader() .setSvcRequestId("test-svc-request-id") .setSvcAction(SvcAction.Assign) @@ -163,19 +205,19 @@ public class PreloadVnfTopologyOperationRPCTest extends GenericResourceApiProvid )) ); - PreloadVnfTopologyOperationOutput output = - exec(genericResourceApiProvider::preloadVnfTopologyOperation, input, RpcResult::getResult); + PreloadVfModuleTopologyOperationOutput output = + exec(genericResourceApiProvider::preloadVfModuleTopologyOperation, input, RpcResult::getResult); assertEquals("200", output.getResponseCode()); assertEquals("Y", output.getAckFinalIndicator()); - PreloadVnfTopologyOperationOutput expectedOutput = createExpectedOutput(svcResultProp, input); + PreloadVfModuleTopologyOperationOutput expectedOutput = createExpectedOutput(svcResultProp, input); assertEquals(expectedOutput, output); } - private PreloadVnfTopologyOperationOutput createExpectedOutput(PropBuilder svcResultProp, - PreloadVnfTopologyOperationInput input) { - return build(preloadVnfTopologyOperationOutput() + private PreloadVfModuleTopologyOperationOutput createExpectedOutput(PropBuilder svcResultProp, + PreloadVfModuleTopologyOperationInput input) { + return build(preloadVfModuleTopologyOperationOutput() .setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId()) .setResponseCode(svcResultProp.get(svcClient.errorCode)) .setAckFinalIndicator(svcResultProp.get(svcClient.ackFinal)) diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VfModuleTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VfModuleTopologyOperationRPCTest.java index facf71d6..2cadbfeb 100644 --- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VfModuleTopologyOperationRPCTest.java +++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VfModuleTopologyOperationRPCTest.java @@ -12,6 +12,8 @@ import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation; import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader; import static org.onap.sdnc.northbound.util.MDSALUtil.serviceInformationBuilder; import static org.onap.sdnc.northbound.util.MDSALUtil.serviceResponseInformation; +import static org.onap.sdnc.northbound.util.MDSALUtil.vnfResponseInformation; +import static org.onap.sdnc.northbound.util.MDSALUtil.vfModuleResponseInformation; import static org.onap.sdnc.northbound.util.MDSALUtil.vfModuleInformationBuilder; import static org.onap.sdnc.northbound.util.MDSALUtil.vfModuleTopologyOperationInput; import static org.onap.sdnc.northbound.util.MDSALUtil.vfModuleTopologyOperationOutput; @@ -225,8 +227,16 @@ public class VfModuleTopologyOperationRPCTest extends GenericResourceApiProvider .setResponseMessage(propBuilder.get(svcClient.errorMessage)) .setServiceResponseInformation(build(serviceResponseInformation() .setInstanceId(input.getServiceInformation().getServiceInstanceId()) - .setObjectPath(propBuilder.get(svcClient.serviceObjectPath)) - )) + .setObjectPath(propBuilder.get(svcClient.serviceObjectPath))) + ) + .setVnfResponseInformation(build(vnfResponseInformation() + .setInstanceId(input.getVnfInformation().getVnfId()) + .setObjectPath(propBuilder.get(svcClient.vnfObjectPath))) + ) + .setVfModuleResponseInformation(build(vfModuleResponseInformation() + .setInstanceId(input.getVfModuleInformation().getVfModuleId()) + .setObjectPath(propBuilder.get(svcClient.vfModuleObjectPath))) + ) ); } } diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VnfTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VnfTopologyOperationRPCTest.java index 645cbf29..7e657dc3 100644 --- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VnfTopologyOperationRPCTest.java +++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VnfTopologyOperationRPCTest.java @@ -198,6 +198,10 @@ public class VnfTopologyOperationRPCTest extends GenericResourceApiProviderTest .setInstanceId(vnfTopologyOperationInput.getServiceInformation().getServiceInstanceId()) .setObjectPath(svcResultProp.get(svcClient.serviceObjectPath)) )) + .setVnfResponseInformation(build(vnfResponseInformation() + .setInstanceId(vnfTopologyOperationInput.getVnfInformation().getVnfId()) + .setObjectPath(svcResultProp.get(svcClient.vnfObjectPath)) + )) ); } } diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/GenericResourceApiSvcLogicServiceClientMockUtil.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/GenericResourceApiSvcLogicServiceClientMockUtil.java index 784717d9..36c6c7ff 100644 --- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/GenericResourceApiSvcLogicServiceClientMockUtil.java +++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/GenericResourceApiSvcLogicServiceClientMockUtil.java @@ -29,6 +29,7 @@ import static org.onap.sdnc.northbound.util.PropBuilder.propBuilder; import java.util.Properties; import org.onap.sdnc.northbound.GenericResourceApiSvcLogicServiceClient; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.data.PreloadDataBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.ServiceDataBuilder; @@ -44,18 +45,17 @@ public class GenericResourceApiSvcLogicServiceClientMockUtil { private final String VERSION = null; private String scvOperation = null; - public final String errorCode = "error-code"; public final String errorMessage = "error-message"; public final String ackFinal = "ack-final"; public final String serviceObjectPath = "service-object-path"; public final String networkObjectPath = "network-object-path"; + public final String vnfObjectPath = "vnf-object-path"; + public final String vfModuleObjectPath = "vf-module-object-path"; public final String networkId = "networkId"; - private final GenericResourceApiSvcLogicServiceClient mockGenericResourceApiSvcLogicServiceClient; - public GenericResourceApiSvcLogicServiceClientMockUtil( GenericResourceApiSvcLogicServiceClient mockGenericResourceApiSvcLogicServiceClient) { this.mockGenericResourceApiSvcLogicServiceClient = mockGenericResourceApiSvcLogicServiceClient; @@ -98,8 +98,9 @@ public class GenericResourceApiSvcLogicServiceClientMockUtil { .set(ackFinal, "Y") .set(serviceObjectPath, "serviceObjectPath: XYZ") .set(networkObjectPath, "networkObjectPath: XYZ") + .set(vnfObjectPath, "vnfObjectPath: XYZ") + .set(vfModuleObjectPath, "vfModuleObjectPath: XYZ") .set(networkId, "networkId: XYZ"); - } @@ -161,5 +162,19 @@ public class GenericResourceApiSvcLogicServiceClientMockUtil { ).thenThrow(exception); } + public void mockExecuteWoServiceDataPreload(RuntimeException exception) throws Exception { + when( + mockGenericResourceApiSvcLogicServiceClient + .execute( + eq(MODULE), + eq(scvOperation), + eq(VERSION), + eq(MODE), + isA(PreloadDataBuilder.class), + isA(Properties.class) + ) + ).thenThrow(exception); + } + } diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java index 4b970475..9ed690ca 100644 --- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java +++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java @@ -34,8 +34,8 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.re import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationInputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationOutputBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationInputBuilder; @@ -51,8 +51,9 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.re import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.contrail.route.response.information.ContrailRouteResponseInformationBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.information.NetworkInformationBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.response.information.NetworkResponseInformationBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.topology.identifier.NetworkTopologyIdentifierBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.topology.information.NetworkTopologyInformationBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.topology.identifier.structure.NetworkTopologyIdentifierStructureBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.network.topology.information.PreloadNetworkTopologyInformationBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.vf.module.topology.information.PreloadVfModuleTopologyInformationBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformationBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeaderBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.security.zone.response.information.SecurityZoneResponseInformationBuilder; @@ -64,10 +65,12 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.re import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.status.ServiceStatusBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.tunnelxconn.response.information.TunnelxconnResponseInformationBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.information.VfModuleInformationBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.response.information.VfModuleResponseInformationBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.topology.VfModuleTopologyBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.topology.identifier.VfModuleTopologyIdentifierBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.information.VnfInformationBuilder; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.response.information.VnfResponseInformationBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.identifier.VnfTopologyIdentifierBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.information.VnfTopologyInformationBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.identifier.structure.VnfTopologyIdentifierStructureBuilder; import org.opendaylight.yangtools.concepts.Builder; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -99,12 +102,12 @@ import org.opendaylight.yangtools.yang.common.RpcResult; */ public class MDSALUtil { - public static PreloadVnfTopologyOperationInputBuilder preloadVnfTopologyOperationInput() { - return new PreloadVnfTopologyOperationInputBuilder(); + public static PreloadVfModuleTopologyOperationInputBuilder preloadVfModuleTopologyOperationInput() { + return new PreloadVfModuleTopologyOperationInputBuilder(); } - public static PreloadVnfTopologyOperationOutputBuilder preloadVnfTopologyOperationOutput() { - return new PreloadVnfTopologyOperationOutputBuilder(); + public static PreloadVfModuleTopologyOperationOutputBuilder preloadVfModuleTopologyOperationOutput() { + return new PreloadVfModuleTopologyOperationOutputBuilder(); } public static PreloadNetworkTopologyOperationInputBuilder preloadNetworkTopologyOperationInput() { @@ -184,7 +187,7 @@ public class MDSALUtil { public static ServiceResponseInformationBuilder serviceResponseInformation() { return new ServiceResponseInformationBuilder(); } - + public static SecurityZoneResponseInformationBuilder securityZoneResponseInformation() { return new SecurityZoneResponseInformationBuilder(); } @@ -205,24 +208,20 @@ public class MDSALUtil { return new VnfResponseInformationBuilder(); } - public static ServiceInformationBuilder serviceInformationBuilder() { - return new ServiceInformationBuilder(); - } - - public static VnfTopologyInformationBuilder vnfTopologyInformationBuilder() { - return new VnfTopologyInformationBuilder(); + public static VfModuleResponseInformationBuilder vfModuleResponseInformation() { + return new VfModuleResponseInformationBuilder(); } - public static NetworkTopologyInformationBuilder networkTopologyInformationBuilder() { - return new NetworkTopologyInformationBuilder(); + public static ServiceInformationBuilder serviceInformationBuilder() { + return new ServiceInformationBuilder(); } - public static NetworkTopologyIdentifierBuilder networkTopologyIdentifierBuilder(){ - return new NetworkTopologyIdentifierBuilder(); + public static PreloadNetworkTopologyInformationBuilder preloadNetworkTopologyInformationBuilder() { + return new PreloadNetworkTopologyInformationBuilder(); } - public static VnfTopologyIdentifierBuilder vnfTopologyIdentifierBuilder() { - return new VnfTopologyIdentifierBuilder(); + public static NetworkTopologyIdentifierStructureBuilder networkTopologyIdentifierStructureBuilder(){ + return new NetworkTopologyIdentifierStructureBuilder(); } public static VnfInformationBuilder vnfInformationBuilder() { @@ -237,12 +236,10 @@ public class MDSALUtil { return new ServiceBuilder(); } - public static ServiceDataBuilder serviceData() { return new ServiceDataBuilder(); } - public static ServiceStatusBuilder serviceStatus() { return new ServiceStatusBuilder(); } @@ -259,6 +256,22 @@ public class MDSALUtil { return new NetworkTopologyOperationOutputBuilder(); } + public static VnfTopologyIdentifierStructureBuilder vnfTopologyIdentifierStructureBuilder() { + return new VnfTopologyIdentifierStructureBuilder(); + } + + public static PreloadVfModuleTopologyInformationBuilder preloadVfModuleTopologyInformationBuilder() { + return new PreloadVfModuleTopologyInformationBuilder(); + } + + public static VfModuleTopologyBuilder vfModuleTopologyBuilder() { + return new VfModuleTopologyBuilder(); + } + + public static VfModuleTopologyIdentifierBuilder vfModuleTopologyIdentifierBuilder() { + return new VfModuleTopologyIdentifierBuilder(); + } + public static NetworkResponseInformationBuilder networkResponseInformation() { return new NetworkResponseInformationBuilder(); } |