From: Martial COULIBALY Date: Thu, 19 Oct 2017 14:47:21 +0000 (+0200) Subject: ServiceHandler Update X-Git-Tag: v0.2.0~84 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=transportpce.git;a=commitdiff_plain;h=e909d17392274b7af0e8e6d99f80fd021f4ed7a4 ServiceHandler Update this commit includes : - Debugging error process failure due to function writeOrDelete. - solving the following javadoc warning 'IllegalCatch : Catching "Exception" is not allowed'. - Modifiy all RPCs to wait for stubpce and stubrenderer notification success or failure before launching other actions. - Correct major errors on RPC serviceReconfigure. - Correct all CDP errors from serviceHandler and Stubpce maven project. - Modfify servicehandler.yang to only have modified notification with and RPC use rpc-response-status-ex from org-openroadm-common-service-path-types. ServiceHandler will now get his RPCs from org-openroadm-service.yang. - useless blank removed - correct javadoc warnnings - move stubpce and stubrenderer to tests folder - add dependency 'Version update to 1.6 of the service-path model'. Change-Id: Icb580c1446f55734cbf56139386d9bd9c8a29ae3 Signed-off-by: Martial COULIBALY Signed-off-by: Olivier RENAIS --- diff --git a/api/src/main/yang/service_path/transportpce-common-service-path-types@2017-04-26.yang b/api/src/main/yang/service_path/transportpce-common-service-path-types@2017-04-26.yang index 8d1f9b6dd..b0bf7f28d 100644 --- a/api/src/main/yang/service_path/transportpce-common-service-path-types@2017-04-26.yang +++ b/api/src/main/yang/service_path/transportpce-common-service-path-types@2017-04-26.yang @@ -10,11 +10,11 @@ module transportpce-common-service-path-types { } import transportpce-routing-constraints { prefix transportpce-routing-constraints; - revision-date 2017-04-26; + revision-date 2017-04-26; } import transportpce-pathDescription { prefix transportpce-pathDescription; - revision-date 2017-04-26; + revision-date 2017-04-26; } import org-openroadm-common-types { prefix org-openroadm-common-types; diff --git a/api/src/main/yang/service_path/transportpce-common-service-path-types@2017-10-16.yang b/api/src/main/yang/service_path/transportpce-common-service-path-types@2017-10-16.yang index b0561e000..316c768d3 100644 --- a/api/src/main/yang/service_path/transportpce-common-service-path-types@2017-10-16.yang +++ b/api/src/main/yang/service_path/transportpce-common-service-path-types@2017-10-16.yang @@ -10,11 +10,11 @@ module transportpce-common-service-path-types { } import transportpce-routing-constraints { prefix transportpce-routing-constraints; - revision-date 2017-10-17; + revision-date 2017-10-17; } import transportpce-pathDescription { prefix transportpce-pathDescription; - revision-date 2017-10-17; + revision-date 2017-10-17; } import org-openroadm-common-types { prefix org-openroadm-common-types; @@ -61,16 +61,17 @@ module transportpce-common-service-path-types { ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE"; - + revision 2017-04-26 { description "Version 1.5"; } + revision 2017-10-16 { description "Version 1.6"; } - + typedef service-path-notification-types { type enumeration { enum "path-computation-request" { @@ -112,11 +113,13 @@ module transportpce-common-service-path-types { "Successful, Failed or Pending"; } + leaf status-message { type string; description "Gives a more detailed reason for failure"; } + } grouping response-parameters-sp { diff --git a/api/src/main/yang/service_path/transportpce-pathDescription@2017-10-17.yang b/api/src/main/yang/service_path/transportpce-pathDescription@2017-10-17.yang index 62de99393..f265b4db8 100644 --- a/api/src/main/yang/service_path/transportpce-pathDescription@2017-10-17.yang +++ b/api/src/main/yang/service_path/transportpce-pathDescription@2017-10-17.yang @@ -45,6 +45,7 @@ module transportpce-pathDescription { description "Version 1.5"; } + revision 2017-10-17 { description "Version 1.6"; diff --git a/api/src/main/yang/service_path/transportpce-pce.yang b/api/src/main/yang/service_path/transportpce-pce.yang index 0652d3e97..53c356ded 100644 --- a/api/src/main/yang/service_path/transportpce-pce.yang +++ b/api/src/main/yang/service_path/transportpce-pce.yang @@ -20,6 +20,9 @@ module transportpce-pce { prefix transportpce-pathDescription; revision-date 2017-10-17; } + import transportpce-pathDescription { + prefix transportpce-pathDescription; + } organization "transportPCE"; @@ -116,7 +119,7 @@ notification service-path-rpc-result { uses transportpce-common-service-path-types:rpc-response-status-ex; uses org-openroadm-common-service-types:service-notification-result; } - + grouping stubpce-path-description { leaf path-name { type string; @@ -136,5 +139,4 @@ notification service-path-rpc-result { uses stubpce-path-description; } } - } diff --git a/api/src/main/yang/service_path/transportpce-routing-constraints@2017-10-17.yang b/api/src/main/yang/service_path/transportpce-routing-constraints@2017-10-17.yang index 66b369033..a235bbbdb 100644 --- a/api/src/main/yang/service_path/transportpce-routing-constraints@2017-10-17.yang +++ b/api/src/main/yang/service_path/transportpce-routing-constraints@2017-10-17.yang @@ -40,6 +40,7 @@ module transportpce-routing-constraints { description "Version 1.5"; } + revision 2017-10-17 { description "Version 1.6"; diff --git a/api/src/main/yang/service_path/transportpce-service-path@2017-04-26.yang b/api/src/main/yang/service_path/transportpce-service-path@2017-04-26.yang index de321f354..dd517b4b0 100644 --- a/api/src/main/yang/service_path/transportpce-service-path@2017-04-26.yang +++ b/api/src/main/yang/service_path/transportpce-service-path@2017-04-26.yang @@ -7,7 +7,7 @@ module transportpce-servicepath { } import transportpce-routing-constraints { prefix transportpce-routing-constraints; - revision-date 2017-04-26; + revision-date 2017-04-26; } import org-openroadm-common-types { prefix org-openroadm-common-types; @@ -20,11 +20,11 @@ module transportpce-servicepath { } import transportpce-common-service-path-types { prefix transportpce-common-service-path-types; - revision-date 2017-04-26; + revision-date 2017-04-26; } import transportpce-pathDescription { prefix transportpce-pathDescription; - revision-date 2017-04-26; + revision-date 2017-04-26; } import org-openroadm-topology { prefix org-openroadm-topology; diff --git a/api/src/main/yang/service_path/transportpce-service-path@2017-10-17.yang b/api/src/main/yang/service_path/transportpce-service-path@2017-10-17.yang index 373adfdab..aea37409f 100644 --- a/api/src/main/yang/service_path/transportpce-service-path@2017-10-17.yang +++ b/api/src/main/yang/service_path/transportpce-service-path@2017-10-17.yang @@ -48,6 +48,7 @@ module transportpce-servicepath { description "Version 1.5"; } + revision 2017-10-17 { description "Version 1.6"; diff --git a/api/src/main/yang/servicehandler.yang b/api/src/main/yang/servicehandler.yang new file mode 100644 index 000000000..c6832b0c3 --- /dev/null +++ b/api/src/main/yang/servicehandler.yang @@ -0,0 +1,68 @@ +module servicehandler { + namespace "http://org/opendaylight/transportpce/servicehandler"; + prefix "org-opendaylight-transportpce-servicehandler"; + + import org-openroadm-common-types { + prefix org-openroadm-common-types; + revision-date 2016-10-14; + } + import org-openroadm-common-service-types { + prefix org-openroadm-common-service-types; + } + import transportpce-common-service-path-types { + prefix org-openroadm-common-service-path-types; + revision-date 2017-04-26; + } + + organization + "Open ROADM MSA"; + contact + "OpenROADM.org"; + description + "YANG definitions of services. + Copyright © 2017 Orange, Inc. and others. All rights reserved. + + This model is derived from the OpenROADM service definition that includes the following notice: + + + Copyright of the Members of the Open ROADM MSA Agreement dated (c) 2016, + AT&T Intellectual Property. All other rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + * Neither the Members of the Open ROADM MSA Agreement nor the names of its + contributors may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE MEMBERS OF THE OPEN ROADM MSA AGREEMENT ''AS IS'' + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT THE MEMBERS OF THE OPEN ROADM MSA AGREEMENT BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE"; + + revision 2017-09-30 { + description + "Version 1.2"; + } + + notification service-rpc-result-sh{ + description + "This Notification indicates result of service RPC"; + leaf notification-type { + type org-openroadm-common-service-types:service-notification-types; + } + uses org-openroadm-common-service-path-types:rpc-response-status-ex; + uses org-openroadm-common-service-types:service-notification-result; + } +} diff --git a/api/src/main/yang/servicehandler@2016-10-14.yang b/api/src/main/yang/servicehandler@2016-10-14.yang deleted file mode 100644 index 4a42ee37e..000000000 --- a/api/src/main/yang/servicehandler@2016-10-14.yang +++ /dev/null @@ -1,593 +0,0 @@ -module servicehandler { - namespace "http://org/opendaylight/transportpce/servicehandler"; - prefix "org-opendaylight-transportpce-servicehandler"; - - import ietf-yang-types { - prefix yang; - } - import org-openroadm-routing-constraints { - prefix org-openroadm-routing-constraints; - revision-date 2016-10-14; - } - import org-openroadm-common-types { - prefix org-openroadm-common-types; - revision-date 2016-10-14; - } - - import org-openroadm-resource-types { - prefix org-openroadm-resource-types; - } - import org-openroadm-common-service-types { - prefix org-openroadm-common-service-types; - } - import transportpce-common-service-path-types { - prefix org-openroadm-common-service-path-types; - revision-date 2017-04-26; - } - - - organization - "Open ROADM MSA"; - contact - "OpenROADM.org"; - description - "YANG definitions of services. - Copyright © 2017 Orange, Inc. and others. All rights reserved. - - This model is derived from the OpenROADM service definition that includes the following notice: - - - Copyright of the Members of the Open ROADM MSA Agreement dated (c) 2016, - AT&T Intellectual Property. All other rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation and/or - other materials provided with the distribution. - * Neither the Members of the Open ROADM MSA Agreement nor the names of its - contributors may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE MEMBERS OF THE OPEN ROADM MSA AGREEMENT ''AS IS'' - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT THE MEMBERS OF THE OPEN ROADM MSA AGREEMENT BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE"; - - revision 2016-10-14 { - description - "Version 1.2"; - } - - rpc service-create { - input { - leaf service-name { - type string; - description - "Identifier for the service to be created in - the ROADM network, e.g., CLFI, CLCI, etc. This is reported against the service, but may not get reflected in the service in the network."; - mandatory true; - } - leaf common-id { - type string; - description - "To be used by the ROADM controller to identify the routing constraints received from planning application (PED)."; - } - uses org-openroadm-common-service-types:sdnc-request-header; - leaf connection-type { - type org-openroadm-common-service-types:connection-type; - mandatory true; - } - container service-a-end { - uses org-openroadm-common-service-types:service-endpoint; - } - container service-z-end { - uses org-openroadm-common-service-types:service-endpoint; - } - uses org-openroadm-routing-constraints:routing-constraints; - uses org-openroadm-common-service-types:service-information; - } - output { - uses org-openroadm-common-service-types:configuration-response-common; - uses org-openroadm-common-service-types:response-parameters; - } - description - "Whether this request passed initial validation and was accepted for processing. Once the request completes processing, a - service-rpc-result Notification shall be sent."; - } - - rpc service-feasibility-check { - input { - leaf common-id { - type string; - mandatory true; - description - "To be used by the ROADM controller to identify the routing - constraints received from planning application (PED)."; - } - uses org-openroadm-common-service-types:sdnc-request-header; - leaf connection-type { - type org-openroadm-common-service-types:connection-type; - } - container service-a-end { - uses org-openroadm-common-service-types:service-endpoint; - } - container service-z-end { - uses org-openroadm-common-service-types:service-endpoint; - } - uses org-openroadm-routing-constraints:routing-constraints; - uses org-openroadm-common-service-types:service-information; - } - output { - uses org-openroadm-common-service-types:configuration-response-common; - uses org-openroadm-common-service-types:response-parameters; - container service-a-end { - uses org-openroadm-common-service-types:service-endpoint; - list equipment-required { - description - "List of required equipment, including equipment type and quantity"; - key "eqipment-identifier"; - leaf eqipment-identifier { - type string; - } - leaf equipment-type { - type string; - } - leaf equipment-quantity { - type uint32; - } - } - } - container service-z-end { - uses org-openroadm-common-service-types:service-endpoint; - list equipment-required { - description - "List of required equipment, including equipment type and quantity"; - key "eqipment-identifier"; - leaf eqipment-identifier { - type string; - } - leaf equipment-type { - type string; - } - leaf equipment-quantity { - type uint32; - } - } - } - list intermediate-sites { - key "clli"; - uses org-openroadm-common-service-types:service-endpoint; - list equipment-required { - description - "List of required equipment, including equipment type and quantity"; - key "eqipment-identifier"; - leaf eqipment-identifier { - type string; - } - leaf equipment-type { - type string; - } - leaf equipment-quantity { - type uint32; - } - } - } - } - description - "Whether a service was possible to be created, and if so - the routing constraints match and the a and z end connection that have - to match"; - } - - rpc service-delete { - input { - uses org-openroadm-common-service-types:sdnc-request-header; - container service-delete-req-info { - leaf service-name { - type string; - description - "Identifier for the service to be deleted in - the ROADM network, e.g., CLFI, CLCI, etc."; - mandatory true; - } - leaf due-date { - type yang:date-and-time; - description - "date and time service to be turned down. If missing, now."; - } - leaf tail-retention { - type enumeration { - enum "yes" { - value 1; - description - "tails are left intact "; - } - enum "no" { - value 2; - description - "tails are deleted"; - } - } - mandatory true; - } - } - } - output { - uses org-openroadm-common-service-types:configuration-response-common; - } - description - "Whether this request passed initial validation and was accepted for processing. Once the request completes processing, a - service-rpc-result Notification shall be sent. Once the service has been deleted, it no longer will appear in the service list"; - } - - rpc equipment-notification { - input { - uses org-openroadm-common-service-types:sdnc-request-header; - leaf equiptment-id { - type string; - mandatory true; - } - leaf equipment-name { - type string; - } - leaf equipemt-type { - type string; - mandatory true; - } - leaf equipment-vendor { - type string; - mandatory true; - } - leaf equipment-customer { - type string; - } - leaf equipment-clli { - type string; - mandatory true; - } - leaf equipment-ip { - type string; - } - leaf controller-id { - type string; - mandatory true; - } - } - output { - uses org-openroadm-common-service-types:configuration-response-common; - } - } - - rpc temp-service-create { - input { - leaf common-id { - type string; - description - "To be used by the ROADM controller to identify the routing constraints received from planning application (PED)."; - mandatory true; - } - uses org-openroadm-common-service-types:sdnc-request-header; - leaf connection-type { - type org-openroadm-common-service-types:connection-type; - mandatory true; - } - container service-a-end { - uses org-openroadm-common-service-types:service-endpoint; - } - container service-z-end { - uses org-openroadm-common-service-types:service-endpoint; - } - uses org-openroadm-routing-constraints:routing-constraints; - uses org-openroadm-common-service-types:service-information; - } - output { - uses org-openroadm-common-service-types:configuration-response-common; - uses org-openroadm-common-service-types:response-parameters; - } - } - - rpc temp-service-delete { - input { - leaf common-id { - type string; - mandatory true; - } - } - output { - uses org-openroadm-common-service-types:configuration-response-common; - } - } - - rpc service-roll { - input { - leaf service-name { - type string; - mandatory true; - description - "Identifier for the service to be rolled in - the ROADM network, e.g., CLFI, CLCI, etc."; - } - leaf due-date { - type yang:date-and-time; - description - "date and time service to be rolled"; - } - } - output { - //uses org-openroadm-common-types:rpc-response-status; - uses org-openroadm-common-service-path-types:rpc-response-status-ex; - } - } - - rpc service-reconfigure { - input { - leaf service-name { - type string; - mandatory true; - description - "Existing identifier for the service to be - reconfigured in the ROADM network, e.g., CLFI, CLCI, etc."; - } - leaf new-service-name { - type string; - description - "New identifier for the service to be - reconfigured in the ROADM network, e.g., CLFI, CLCI, etc."; - } - leaf common-id { - type string; - description - "To be used by the ROADM controller to identify the routing - constraints received from planning application (PED)."; - } - /**Add by Martial **/ - leaf notification-url { - type string; - } - leaf connection-type { - type org-openroadm-common-service-types:connection-type; - } - container service-a-end { - uses org-openroadm-common-service-types:service-endpoint; - } - container service-z-end { - uses org-openroadm-common-service-types:service-endpoint; - } - uses org-openroadm-routing-constraints:routing-constraints; - uses org-openroadm-common-service-types:service-information; - } - output { - //uses org-openroadm-common-types:rpc-response-status; - uses org-openroadm-common-service-path-types:rpc-response-status-ex; - } - description - "Whether this request passed initial validation and was accepted for processing. Once the request completes processing, a - service-rpc-result Notification shall be sent."; - } - - rpc service-restoration { - input { - leaf service-name { - type string; - mandatory true; - description - "Identifier for the service to be restored in - the ROADM network, e.g., CLFI, CLCI, etc."; - } - /**Add by Martial **/ - leaf notification-url { - type string; - } - leaf option { - type enumeration { - enum "permanent" { - value 1; - description - "A spare regen can be used to restore the - service permanently without reverting back to the - original regen"; - } - enum "temporary" { - value 2; - description - "a spare regen can be used to restore the - service temporarily. The service needs to be reverted - back to the original regen transponder"; - } - } - mandatory true; - } - } - output { - //uses org-openroadm-common-types:rpc-response-status; - uses org-openroadm-common-service-path-types:rpc-response-status-ex; - } - description - "Whether this request passed initial validation and was accepted for processing. Once the request completes processing, a - service-rpc-result Notification shall be sent."; - } - - rpc service-reversion { - input { - leaf service-name { - type string; - mandatory true; - description - "Identifier for the service to be reverted - in the ROADM network, e.g., CLFI, CLCI, etc. "; - } - leaf due-date { - type yang:date-and-time; - description - "date and time service to be reverted"; - } - } - output { - //uses org-openroadm-common-types:rpc-response-status; - uses org-openroadm-common-service-path-types:rpc-response-status-ex; - } - description - "Whether this request passed initial validation and was accepted for processing. Once the request completes processing, a - service-rpc-result Notification shall be sent."; - } - - rpc service-reroute { - input { - leaf service-name { - type string; - mandatory true; - description - "Identifier for the service to be re-routed in - the ROADM network, e.g., CLFI, CLCI, etc."; - } - } - output { - //uses org-openroadm-common-types:rpc-response-status; - uses org-openroadm-common-service-path-types:rpc-response-status-ex; - uses org-openroadm-routing-constraints:routing-constraints; - } - description - "Whether this request was validated and processed correct. If sucessful, it return the proposed new route. - If acceptable, this request should be followed by a service-reroute-confirm to complete the reroute operation."; - } - - rpc service-reroute-confirm { - input { - leaf service-name { - type string; - mandatory true; - description - "Identifier for the service to be re-routed in - the ROADM network, e.g., CLFI, CLCI, etc."; - } - uses org-openroadm-routing-constraints:routing-constraints; - } - output { - //uses org-openroadm-common-types:rpc-response-status; - uses org-openroadm-common-service-path-types:rpc-response-status-ex; - } - description - "Whether this request passed initial validation and was accepted for processing. Once the request completes processing, a - service-rpc-result Notification shall be sent."; - } - - rpc network-re-optimization { - input { - leaf service-name { - type string; - description - "Identifier for the service in the ROADM network, - e.g., CLFI, CLCI, etc. whose path is to be checked by the RNC - for re-optimization"; - } - leaf a-end { - type string; - description - "Services whose A-ends are terminated at the - specified office location are to be checked by the RNC for - re-optimization"; - } - leaf z-end { - type string; - description - "Services whose Z-ends are terminated at the - specified office location are to be checked by the RNC for - re-optimization "; - } - leaf pass-through { - type string; - description - "Services that are pass-through (either via - regen or express) at the specified office location are to - be checked by the RNC for re-optimization"; - } - leaf customer-code { - type string; - description - "Services that belong to the specified customer - are to be checked by the RNC for re-optimization "; - } - } - output { - //uses org-openroadm-common-types:rpc-response-status; - uses org-openroadm-common-service-path-types:rpc-response-status-ex; - leaf optimization-candidate { - type string; - } - } - } - - container service-list { - description - "List of service. Can only be created, deleted, modified, etc. using special RPCs."; - list services { - key "service-name"; - uses org-openroadm-common-service-types:service; - } - } - - container temp-service-list { - description - "List of temporary services Can only be created, deleted, modified, etc. using special RPCs."; - list services { - key "common-id"; - uses org-openroadm-common-service-types:service { - refine "service-name" { - mandatory false; - } - } - } - } - - notification service-rpc-result { - description - "This Notification indicates result of service RPC"; - leaf notification-type { - type org-openroadm-common-service-types:service-notification-types; - } - //uses org-openroadm-common-types:rpc-response-status; - uses org-openroadm-common-service-path-types:rpc-response-status-ex; - uses org-openroadm-common-service-types:service-notification-result; - } - - notification service-traffic-flow { - description - "This Notification indicates that traffic is flowing again on the service after an administrative action has completed"; - leaf service-name { - type string; - description - "Identifier for the service being reported on"; - mandatory true; - } - leaf actual-date { - type yang:date-and-time; - description - "Actual date and time traffic started flowing"; - } - } - - notification service-notification { - description - "This Notification that a service has been added, modified or removed. - A resourceCreation notification shall contain the created service in its entirety. - A resourceMofified notification shall contain just the modified field, plus the service identifier - A resourceDeleted notification shall just contain the service identifier"; - leaf notificationType { - type org-openroadm-resource-types:resource-notification-type; - description - "Whether this notification indicates a service creation, service modification or service deletion."; - } - uses org-openroadm-common-service-types:service; - } - -} diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/CheckCoherencyHardSoft.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/CheckCoherencyHardSoft.java index 5bc4333fe..da7329cfe 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/CheckCoherencyHardSoft.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/CheckCoherencyHardSoft.java @@ -14,16 +14,17 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Class to check coherency between hard and soft constraints. - * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange + * Class to check coherency between hard and soft constraints. + * + * @author Martial Coulibaly on behalf of Orange * */ public class CheckCoherencyHardSoft { - /* Logging. */ + /** Logging. */ private static final Logger LOG = LoggerFactory.getLogger(CheckCoherencyHardSoft.class); - /* Hard Constraints. */ + /** Hard Constraints. */ private HardConstraints hard; - /* Soft Constraints. */ + /** Soft Constraints. */ private SoftConstraints soft; public CheckCoherencyHardSoft(HardConstraints hard, SoftConstraints soft) { @@ -39,7 +40,7 @@ public class CheckCoherencyHardSoft { public boolean check() { boolean result = false; if (hard != null && soft != null) { - /* + /** * Check coherency with hard/soft constraints * hard/soft include/exclude coherency * diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/LoggingFuturesCallBack.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/LoggingFuturesCallBack.java index ddc37bdca..557a6878e 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/LoggingFuturesCallBack.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/LoggingFuturesCallBack.java @@ -12,8 +12,9 @@ import com.google.common.util.concurrent.FutureCallback; import org.slf4j.Logger; /** - * Class to log future logging from datastore actions (write, modify and delete..). - * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange + * Class to log future logging from datastore actions (write,modify and delete..). + * + * @author Martial Coulibaly on behalf of Orange */ public class LoggingFuturesCallBack implements FutureCallback { diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingPCRequest.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingPCRequest.java index 081ac68f6..c9f75cf64 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingPCRequest.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingPCRequest.java @@ -19,24 +19,32 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceCreateInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceFeasibilityCheckInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceReconfigureInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.service.list.Services; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveInput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveInputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveOutputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestInput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestInputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.StubpceService; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.computation.request.input.ServiceAEnd; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.computation.request.input.ServiceAEndBuilder; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.computation.request.input.ServiceZEnd; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.path.computation.request.input.ServiceZEndBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceEndpoint; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeaderBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.RoutingConstraintsSp.PceMetric; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.HardConstraints; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing.constraints.sp.SoftConstraints; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirection; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirectionBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirection; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirectionBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.handler.header.ServiceHandlerHeaderBuilder; import org.opendaylight.yangtools.yang.common.RpcResult; @@ -44,26 +52,28 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * Class for Mapping and Sending PCE requests : - * - path-computation-request - * - cancelCresource-reserve. - * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange + * class for Mapping and Sending PCE requests : - path-computation-request - + * cancel-resource-reserve. + * + * @author Martial Coulibaly on behalf of Orange * */ public class MappingAndSendingPCRequest { - /* Logging. */ + /** Logging. */ private static final Logger LOG = LoggerFactory.getLogger(MappingAndSendingPCRequest.class); - /* Permit to call PCE RPCs. */ + /** Permit to call PCE RPCs. */ private StubpceService service; - /* define procedure success (or not ). */ + /** define procedure success (or not ). */ private Boolean success; - /* permit to call bundle service (PCE, Renderer, Servicehandler. */ + /** permit to call bundle service (PCE, Renderer, Servicehandler. */ private RpcProviderRegistry rpcRegistry; PathComputationRequestInput pathComputationRequestInput = null; CancelResourceReserveInput cancelResourceReserveInput = null; HardConstraints hard = null; SoftConstraints soft = null; - /* store all error messages. */ + private ServiceAEnd serviceAEndSp; + private ServiceZEnd serviceZEndSp; + /** store all error messages. */ private String error; private final ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(5)); @@ -79,21 +89,25 @@ public class MappingAndSendingPCRequest { */ public MappingAndSendingPCRequest(RpcProviderRegistry rpcRegistry, ServiceReconfigureInput serviceReconfigureInput, Boolean resvResource) { - this.rpcRegistry = rpcRegistry; + this.setRpcRegistry(rpcRegistry); if (rpcRegistry != null) { service = rpcRegistry.getRpcService(StubpceService.class); } - SdncRequestHeader head = new SdncRequestHeaderBuilder().build(); + endpointToEndpointStubpce(serviceReconfigureInput.getServiceAEnd(), serviceReconfigureInput.getServiceZEnd()); + SdncRequestHeader head = new SdncRequestHeaderBuilder() + .setRequestId("reconfigure_" + serviceReconfigureInput.getServiceName()) + .setRpcAction(RpcActions.ServiceReconfigure) + .build(); MappingConstraints map = new MappingConstraints(serviceReconfigureInput.getHardConstraints(), serviceReconfigureInput.getSoftConstraints()); map.serviceToServicePathConstarints(); - /* + /** * mappingPCRequest(serviceReconfigureInput.getNewServiceName(), * serviceReconfigureInput.getHardConstraints(), * serviceReconfigureInput.getSoftConstraints(),head ,resvResource); */ - mappingPCRequest(serviceReconfigureInput.getNewServiceName(), map.getServicePathHardConstraints(), - map.getServicePathSoftConstraints(), head, resvResource); + mappingPCRequest(serviceReconfigureInput.getNewServiceName(),serviceAEndSp, serviceZEndSp, + map.getServicePathHardConstraints(), map.getServicePathSoftConstraints(), head, resvResource); setSuccess(false); setError(""); } @@ -111,15 +125,18 @@ public class MappingAndSendingPCRequest { */ public MappingAndSendingPCRequest(RpcProviderRegistry rpcRegistry, ServiceFeasibilityCheckInput serviceFeasibilityCheckInput, Boolean resvResource) { - this.rpcRegistry = rpcRegistry; + this.setRpcRegistry(rpcRegistry); if (rpcRegistry != null) { service = rpcRegistry.getRpcService(StubpceService.class); } + endpointToEndpointStubpce(serviceFeasibilityCheckInput.getServiceAEnd(), + serviceFeasibilityCheckInput.getServiceZEnd()); MappingConstraints map = new MappingConstraints(serviceFeasibilityCheckInput.getHardConstraints(), serviceFeasibilityCheckInput.getSoftConstraints()); map.serviceToServicePathConstarints(); - mappingPCRequest("no name", map.getServicePathHardConstraints(), map.getServicePathSoftConstraints(), - serviceFeasibilityCheckInput.getSdncRequestHeader(), resvResource); + mappingPCRequest("no name",serviceAEndSp, serviceZEndSp, map.getServicePathHardConstraints(), + map.getServicePathSoftConstraints(), serviceFeasibilityCheckInput.getSdncRequestHeader(), + resvResource); setSuccess(false); setError(""); } @@ -136,15 +153,17 @@ public class MappingAndSendingPCRequest { */ public MappingAndSendingPCRequest(RpcProviderRegistry rpcRegistry, ServiceCreateInput serviceCreateInput, Boolean resvResource) { - this.rpcRegistry = rpcRegistry; + this.setRpcRegistry(rpcRegistry); if (rpcRegistry != null) { service = rpcRegistry.getRpcService(StubpceService.class); } + endpointToEndpointStubpce(serviceCreateInput.getServiceAEnd(), serviceCreateInput.getServiceZEnd()); MappingConstraints map = new MappingConstraints(serviceCreateInput.getHardConstraints(), serviceCreateInput.getSoftConstraints()); map.serviceToServicePathConstarints(); - mappingPCRequest(serviceCreateInput.getServiceName(), map.getServicePathHardConstraints(), - map.getServicePathSoftConstraints(), serviceCreateInput.getSdncRequestHeader(), resvResource); + mappingPCRequest(serviceCreateInput.getServiceName(),serviceAEndSp, serviceZEndSp, + map.getServicePathHardConstraints(), map.getServicePathSoftConstraints(), + serviceCreateInput.getSdncRequestHeader(), resvResource); setSuccess(false); setError(""); } @@ -161,24 +180,65 @@ public class MappingAndSendingPCRequest { * Boolean to reserve resource */ public MappingAndSendingPCRequest(RpcProviderRegistry rpcRegistry, Services input, Boolean resvResource) { - this.rpcRegistry = rpcRegistry; + this.setRpcRegistry(rpcRegistry); if (rpcRegistry != null) { service = rpcRegistry.getRpcService(StubpceService.class); } + endpointToEndpointStubpce(input.getServiceAEnd(), input.getServiceZEnd()); MappingConstraints map = new MappingConstraints(input.getHardConstraints(), input.getSoftConstraints()); map.serviceToServicePathConstarints(); - mappingPCRequest(input.getServiceName(), map.getServicePathHardConstraints(), + mappingPCRequest(input.getServiceName(),serviceAEndSp, serviceZEndSp, map.getServicePathHardConstraints(), map.getServicePathSoftConstraints(), input.getSdncRequestHeader(), resvResource); setSuccess(false); setError(""); } + + public void endpointToEndpointStubpce(ServiceEndpoint serviceAEnd, ServiceEndpoint serviceZEnd) { + LOG.info("Mapping Service Endpoint to Service Endpoint Stubpce"); + TxDirection txDirection = null; + RxDirection rxDirection = null; + if (serviceAEnd != null && serviceZEnd != null) { + txDirection = new TxDirectionBuilder() + .setPort(serviceAEnd.getTxDirection().getPort()) + .build(); + rxDirection = new RxDirectionBuilder() + .setPort(serviceAEnd.getRxDirection().getPort()) + .build(); + serviceAEndSp = new ServiceAEndBuilder() + .setClli(serviceAEnd.getClli()) + .setNodeId(serviceAEnd.getNodeId()) + .setServiceFormat(serviceAEnd.getServiceFormat()) + .setServiceRate(serviceAEnd.getServiceRate()) + .setTxDirection(txDirection) + .setRxDirection(rxDirection) + .build(); + + txDirection = new TxDirectionBuilder() + .setPort(serviceZEnd.getTxDirection().getPort()) + .build(); + rxDirection = new RxDirectionBuilder() + .setPort(serviceZEnd.getRxDirection().getPort()) + .build(); + serviceZEndSp = new ServiceZEndBuilder() + .setClli(serviceZEnd.getClli()) + .setNodeId(serviceZEnd.getNodeId()) + .setServiceFormat(serviceZEnd.getServiceFormat()) + .setServiceRate(serviceZEnd.getServiceRate()) + .setTxDirection(txDirection) + .setRxDirection(rxDirection) + .build(); + } + } + /** * Build pathComputationRequestInput or cancelResourceReserveInput with * input parameters (serviceReconfigureInput or serviceFeasibilityCheckInput. * * @param String * serviceName + * @param zend Service ZEnd + * @param aend Service AEnd * @param HardConstraints * hardConstraints * @param SoftConstraints @@ -188,9 +248,10 @@ public class MappingAndSendingPCRequest { * @param Boolean * resvResource */ - private void mappingPCRequest(String serviceName, HardConstraints hardConstraints, SoftConstraints softConstraints, - org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header - .SdncRequestHeader sdncRequestHeader, Boolean resvResource) { + private void mappingPCRequest(String serviceName, ServiceAEnd aend, ServiceZEnd zend, + HardConstraints hardConstraints, SoftConstraints softConstraints, org.opendaylight.yang.gen.v1.http.org + .openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader sdncRequestHeader, + Boolean resvResource) { LOG.info("Mapping ServiceCreateInput or ServiceFeasibilityCheckInput or serviceReconfigureInput " + "to PCE requests"); @@ -213,35 +274,38 @@ public class MappingAndSendingPCRequest { serviceHandlerHeader.setRequestId(sdncRequestHeader.getRequestId()); } - /* PathComputationRequestInput build */ - pathComputationRequestInput = new PathComputationRequestInputBuilder().setServiceName(serviceName) - .setResourceReserve(resvResource).setServiceHandlerHeader(serviceHandlerHeader.build()) - .setHardConstraints(pceHardConstraints).setSoftConstraints(pceSoftConstraints) + /** PathComputationRequestInput build */ + pathComputationRequestInput = new PathComputationRequestInputBuilder() + .setServiceName(serviceName) + .setResourceReserve(resvResource) + .setServiceHandlerHeader(serviceHandlerHeader.build()) + .setServiceAEnd(aend) + .setServiceZEnd(zend) + .setHardConstraints(pceHardConstraints) + .setSoftConstraints(pceSoftConstraints) .setPceMetric(PceMetric.TEMetric).build(); - /* CancelResourceReserveInput build */ + /** CancelResourceReserveInput build */ cancelResourceReserveInput = new CancelResourceReserveInputBuilder().setServiceName(serviceName) .setServiceHandlerHeader(serviceHandlerHeader.build()).build(); } + /** * Send cancelResourceReserve request to PCE. * - * @return CancelResourceReserveOutput data response from PCE + * @return Boolean true if success, false else */ - public ListenableFuture cancelResourceReserve() { + public ListenableFuture cancelResourceReserve() { setSuccess(false); - return executor.submit(new Callable() { - + return executor.submit(new Callable() { @Override - public CancelResourceReserveOutput call() throws Exception { - CancelResourceReserveOutput output = null; + public Boolean call() throws Exception { + Boolean output = false; if (cancelResourceReserveInput != null) { - RpcResult pceOutputResult = null; Future> pceOutputFuture = service .cancelResourceReserve(cancelResourceReserveInput); - try { pceOutputResult = pceOutputFuture.get(); } catch (InterruptedException | CancellationException | ExecutionException e) { @@ -253,9 +317,7 @@ public class MappingAndSendingPCRequest { if (pceOutputResult != null && pceOutputResult.isSuccessful()) { LOG.info("PCE replied to CancelResource request !"); - CancelResourceReserveOutput pceOutput = pceOutputResult.getResult(); - output = new CancelResourceReserveOutputBuilder() - .setConfigurationResponseCommon(pceOutput.getConfigurationResponseCommon()).build(); + output = true; setSuccess(true); } } else { @@ -267,55 +329,35 @@ public class MappingAndSendingPCRequest { } - public Boolean getSuccess() { - return success; - } - - public void setSuccess(Boolean success) { - this.success = success; - } - - public String getError() { - return error; - } - - public void setError(String error) { - this.error = error; - } - /** * Send pathComputationRequest request to PCE. * - * @return PathComputationRequestOutput data response from PCE + * @return Boolean true if success, false else */ - public ListenableFuture pathComputationRequest() { + public ListenableFuture pathComputationRequest() { LOG.info("In pathComputationRequest ..."); setSuccess(false); - return executor.submit(new Callable() { + return executor.submit(new Callable() { @Override - public PathComputationRequestOutput call() throws Exception { + public Boolean call() throws Exception { RpcResult pceOutputResult = null; - PathComputationRequestOutput output = null; + Boolean output = false; if (pathComputationRequestInput != null) { + LOG.info("pathComputationRequestInput : " + pathComputationRequestInput.toString()); Future> pceOutputFuture = service .pathComputationRequest(pathComputationRequestInput); try { - pceOutputResult = pceOutputFuture.get();// wait to get - // the result + pceOutputResult = pceOutputFuture.get(); } catch (InterruptedException | CancellationException | ExecutionException e) { setError("Did not receive the expected response from pce to pathComputationRequest RPC " + e.toString()); LOG.error(error); pceOutputFuture.cancel(true); } - if (pceOutputResult != null && pceOutputResult.isSuccessful()) { setSuccess(true); + output = true; LOG.info("PCE replied to pathComputation request !"); - PathComputationRequestOutput pceOutput = pceOutputResult.getResult(); - output = new PathComputationRequestOutputBuilder() - .setConfigurationResponseCommon(pceOutput.getConfigurationResponseCommon()) - .setResponseParameters(pceOutput.getResponseParameters()).build(); } } else { LOG.info("pathComputationRequestInput parameter not valid !"); @@ -323,6 +365,45 @@ public class MappingAndSendingPCRequest { return output; } }); + } + + public Boolean getSuccess() { + return success; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public String getError() { + return error; + } + + public void setError(String error) { + this.error = error; + } + + public RpcProviderRegistry getRpcRegistry() { + return rpcRegistry; + } + + public void setRpcRegistry(RpcProviderRegistry rpcRegistry) { + this.rpcRegistry = rpcRegistry; + } + + public ServiceAEnd getServiceAEndSp() { + return serviceAEndSp; + } + + public void setServiceAEndSp(ServiceAEnd serviceAEndSp) { + this.serviceAEndSp = serviceAEndSp; + } + + public ServiceZEnd getServiceZEndSp() { + return serviceZEndSp; + } + public void setServiceZEndSp(ServiceZEnd serviceZEndSp) { + this.serviceZEndSp = serviceZEndSp; } } diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingSIRequest.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingSIRequest.java index 3e91980e2..691b156c5 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingSIRequest.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingAndSendingSIRequest.java @@ -11,8 +11,6 @@ package org.opendaylight.transportpce.servicehandler; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; @@ -20,40 +18,23 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceCreateInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceReconfigureInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.service.list.Services; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteInput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteInputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceDeleteOutputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestInput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestInputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererService; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.PathDescription; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.PathDescriptionBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceAEnd; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceAEndBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceZEnd; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.service.implementation.request.input.ServiceZEndBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceFormat; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.Port; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.PortBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirection; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.AToZDirectionBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ZToADirection; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ZToADirectionBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZ; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.atoz.direction.AToZKey; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToA; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToABuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.path.description.ztoa.direction.ZToAKey; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.Resource; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426.pce.resource.ResourceBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirection; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.RxDirectionBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.service.endpoint.sp.TxDirection; @@ -74,15 +55,15 @@ import org.slf4j.LoggerFactory; * */ public class MappingAndSendingSIRequest { - /* Logging. */ + /** Logging. */ private static final Logger LOG = LoggerFactory.getLogger(MappingAndSendingSIRequest.class); - /* Permit to call Renderer RPCs. */ + /** Permit to call Renderer RPCs. */ private StubrendererService service; - /* define procedure success (or not ). */ + /** define procedure success (or not ). */ private Boolean success = false; - /* permit to call bundle service (PCE, Renderer, Servicehandler. */ + /** permit to call bundle service (PCE, Renderer, Servicehandler. */ private RpcProviderRegistry rpcRegistry; - /* store all error messages. */ + /** store all error messages. */ private String error; ServiceImplementationRequestInput serviceImplementationRequestInput = null; ServiceDeleteInput serviceDeleteInput = null; @@ -100,21 +81,22 @@ public class MappingAndSendingSIRequest { */ public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry, ServiceCreateInput serviceCreateInput,PathComputationRequestOutput pathComputationOutput) { - this.rpcRegistry = rpcRegistry; + this.setRpcRegistry(rpcRegistry); if (rpcRegistry != null) { service = rpcRegistry.getRpcService(StubrendererService.class); } setSuccess(false); setError(""); - /* Building ServiceImplementationRequestInput / ServiceDeleteInput serviceDeleteInput. */ + /** Building ServiceImplementationRequestInput / ServiceDeleteInput serviceDeleteInput. */ ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder(); if (serviceCreateInput.getSdncRequestHeader() != null) { serviceHandlerHeader.setRequestId(serviceCreateInput.getSdncRequestHeader().getRequestId()); } - //.build(); + mappingSIRequest(pathComputationOutput, serviceHandlerHeader, serviceCreateInput.getServiceAEnd(), + serviceCreateInput.getServiceZEnd(), serviceCreateInput.getServiceName()); + /* - /*ServiceAEnd Build */ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014 .service.create.input.ServiceAEnd tempA = serviceCreateInput.getServiceAEnd(); @@ -126,34 +108,6 @@ public class MappingAndSendingSIRequest { .service.types.rev161014.service.port.Port tempAPortTx = serviceCreateInput.getServiceAEnd().getTxDirection().getPort(); - /*Port portARx = new PortBuilder() - .setPortDeviceName(tempAPortRx.getPortDeviceName()) - .setPortName(tempAPortRx.getPortName()) - .setPortRack(tempAPortRx.getPortRack()) - .setPortShelf(tempAPortRx.getPortShelf()) - .setPortSlot(tempAPortRx.getPortSlot()) - .setPortSubSlot(tempAPortRx.getPortSubSlot()) - .setPortType(tempAPortRx.getPortType()) - .build(); - - Port portATx = new PortBuilder() - .setPortDeviceName(tempAPortTx.getPortDeviceName()) - .setPortName(tempAPortTx.getPortName()) - .setPortRack(tempAPortTx.getPortRack()) - .setPortShelf(tempAPortTx.getPortShelf()) - .setPortSlot(tempAPortTx.getPortSlot()) - .setPortSubSlot(tempAPortTx.getPortSubSlot()) - .setPortType(tempAPortTx.getPortType()) - .build(); - - RxDirection rxDirectionAEnd = new RxDirectionBuilder() - .setPort(portARx ) - .build(); - - TxDirection txDirectionAEnd = new TxDirectionBuilder() - .setPort(portATx ) - .build();*/ - RxDirection rxDirectionAEnd = getRxDirection(tempAPortRx); TxDirection txDirectionAEnd = getTxDirection(tempAPortTx); @@ -167,7 +121,6 @@ public class MappingAndSendingSIRequest { .setTxDirection(txDirectionAEnd) .build(); - /* ServiceZEnd Build */ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014 .service.create.input.ServiceZEnd tempZ = serviceCreateInput.getServiceZEnd(); @@ -179,34 +132,6 @@ public class MappingAndSendingSIRequest { .service.types.rev161014.service.port.Port tempZPortTx = serviceCreateInput.getServiceZEnd().getTxDirection().getPort(); - /*Port portZRx = new PortBuilder() - .setPortDeviceName(tempZPortRx.getPortDeviceName()) - .setPortName(tempZPortRx.getPortName()) - .setPortRack(tempZPortRx.getPortRack()) - .setPortShelf(tempZPortRx.getPortShelf()) - .setPortSlot(tempZPortRx.getPortSlot()) - .setPortSubSlot(tempZPortRx.getPortSubSlot()) - .setPortType(tempZPortRx.getPortType()) - .build(); - - Port portZTx = new PortBuilder() - .setPortDeviceName(tempZPortTx.getPortDeviceName()) - .setPortName(tempZPortTx.getPortName()) - .setPortRack(tempZPortTx.getPortRack()) - .setPortShelf(tempZPortTx.getPortShelf()) - .setPortSlot(tempZPortTx.getPortSlot()) - .setPortSubSlot(tempZPortTx.getPortSubSlot()) - .setPortType(tempZPortTx.getPortType()) - .build(); - - RxDirection rxDirectionZEnd = new RxDirectionBuilder() - .setPort(portZRx ) - .build(); - - TxDirection txDirectionZEnd = new TxDirectionBuilder() - .setPort(portZTx ) - .build();*/ - RxDirection rxDirectionZEnd = getRxDirection(tempZPortRx); TxDirection txDirectionZEnd = getTxDirection(tempZPortTx); @@ -220,8 +145,6 @@ public class MappingAndSendingSIRequest { .setTxDirection(txDirectionZEnd) .build(); - - /* ServiceImplementationRequestInput Build*/ org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types .rev170426.response.parameters.sp.response.parameters.PathDescription tmp = null; try { @@ -239,7 +162,10 @@ public class MappingAndSendingSIRequest { .setServiceName(serviceCreateInput.getServiceName()) .setServiceAEnd(serviceAEnd) .setServiceZEnd(serviceZEnd) - .build(); + .build();*/ + + mappingSIRequest(pathComputationOutput, serviceHandlerHeader, serviceCreateInput.getServiceAEnd(), + serviceCreateInput.getServiceZEnd(), serviceCreateInput.getServiceName()); } /** @@ -253,17 +179,20 @@ public class MappingAndSendingSIRequest { public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry, ServiceReconfigureInput serviceReconfigureInput,PathComputationRequestOutput pathComputationOutput) { - this.rpcRegistry = rpcRegistry; + this.setRpcRegistry(rpcRegistry); if (rpcRegistry != null) { service = rpcRegistry.getRpcService(StubrendererService.class); } setSuccess(false); setError(""); - /* Building ServiceImplementationRequestInput / ServiceDeleteInput serviceDeleteInput .*/ - ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder(); + /** Building ServiceImplementationRequestInput / ServiceDeleteInput serviceDeleteInput .*/ + ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder() + .setRequestId("reconfigure_" + serviceReconfigureInput.getNewServiceName()); + mappingSIRequest(pathComputationOutput, serviceHandlerHeader, serviceReconfigureInput.getServiceAEnd(), + serviceReconfigureInput.getServiceZEnd(), serviceReconfigureInput.getNewServiceName()); - /*ServiceAEnd Build .*/ + /* org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014 .service.reconfigure.input.ServiceAEnd tempA = serviceReconfigureInput.getServiceAEnd(); @@ -275,34 +204,6 @@ public class MappingAndSendingSIRequest { .service.types.rev161014.service.port.Port tempAPortTx = serviceReconfigureInput.getServiceAEnd().getTxDirection().getPort(); - /*Port portARx = new PortBuilder() - .setPortDeviceName(tempAPortRx.getPortDeviceName()) - .setPortName(tempAPortRx.getPortName()) - .setPortRack(tempAPortRx.getPortRack()) - .setPortShelf(tempAPortRx.getPortShelf()) - .setPortSlot(tempAPortRx.getPortSlot()) - .setPortSubSlot(tempAPortRx.getPortSubSlot()) - .setPortType(tempAPortRx.getPortType()) - .build(); - - Port portATx = new PortBuilder() - .setPortDeviceName(tempAPortTx.getPortDeviceName()) - .setPortName(tempAPortTx.getPortName()) - .setPortRack(tempAPortTx.getPortRack()) - .setPortShelf(tempAPortTx.getPortShelf()) - .setPortSlot(tempAPortTx.getPortSlot()) - .setPortSubSlot(tempAPortTx.getPortSubSlot()) - .setPortType(tempAPortTx.getPortType()) - .build(); - - RxDirection rxDirectionAEnd = new RxDirectionBuilder() - .setPort(portARx ) - .build(); - - TxDirection txDirectionAEnd = new TxDirectionBuilder() - .setPort(portATx ) - .build();*/ - RxDirection rxDirectionAEnd = getRxDirection(tempAPortRx); TxDirection txDirectionAEnd = getTxDirection(tempAPortTx); @@ -316,7 +217,6 @@ public class MappingAndSendingSIRequest { .setTxDirection(txDirectionAEnd) .build(); - /* ServiceZEnd Build .*/ org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014 .service.reconfigure.input.ServiceZEnd tempZ = serviceReconfigureInput.getServiceZEnd(); @@ -328,33 +228,6 @@ public class MappingAndSendingSIRequest { .service.types.rev161014.service.port.Port tempZPortTx = serviceReconfigureInput.getServiceZEnd().getTxDirection().getPort(); - /*Port portZRx = new PortBuilder() - .setPortDeviceName(tempZPortRx.getPortDeviceName()) - .setPortName(tempZPortRx.getPortName()) - .setPortRack(tempZPortRx.getPortRack()) - .setPortShelf(tempZPortRx.getPortShelf()) - .setPortSlot(tempZPortRx.getPortSlot()) - .setPortSubSlot(tempZPortRx.getPortSubSlot()) - .setPortType(tempZPortRx.getPortType()) - .build(); - - Port portZTx = new PortBuilder() - .setPortDeviceName(tempZPortTx.getPortDeviceName()) - .setPortName(tempZPortTx.getPortName()) - .setPortRack(tempZPortTx.getPortRack()) - .setPortShelf(tempZPortTx.getPortShelf()) - .setPortSlot(tempZPortTx.getPortSlot()) - .setPortSubSlot(tempZPortTx.getPortSubSlot()) - .setPortType(tempZPortTx.getPortType()) - .build(); - - RxDirection rxDirectionZEnd = new RxDirectionBuilder() - .setPort(portZRx ) - .build(); - - TxDirection txDirectionZEnd = new TxDirectionBuilder() - .setPort(portZTx ) - .build();*/ RxDirection rxDirectionZEnd = getRxDirection(tempZPortRx); TxDirection txDirectionZEnd = getTxDirection(tempZPortTx); @@ -368,9 +241,6 @@ public class MappingAndSendingSIRequest { .setTxDirection(txDirectionZEnd) .build(); - - /* ServiceImplementationRequestInput Build.*/ - org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types .rev170426.response.parameters.sp.response.parameters.PathDescription tmp = null; try { @@ -389,7 +259,7 @@ public class MappingAndSendingSIRequest { .setServiceAEnd(serviceAEnd) .setServiceZEnd(serviceZEnd) .build(); - LOG.info("ServiceImplementationRequestInput : " + serviceImplementationRequestInput.toString()); + LOG.info("ServiceImplementationRequestInput : " + serviceImplementationRequestInput.toString());*/ } @@ -402,45 +272,47 @@ public class MappingAndSendingSIRequest { * @param serviceName Service name */ public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,String requestId, String serviceName) { - this.rpcRegistry = rpcRegistry; + this.setRpcRegistry(rpcRegistry); if (rpcRegistry != null) { service = rpcRegistry.getRpcService(StubrendererService.class); } setSuccess(false); setError(""); - /* ServiceDeleteInput Build .*/ + /** ServiceDeleteInput Build .*/ ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder(); if (requestId != null) { serviceHandlerHeader.setRequestId(requestId); } serviceDeleteInput = new ServiceDeleteInputBuilder() - .setServiceHandlerHeader(serviceHandlerHeader.build()) - .setServiceName(serviceName) - .build(); + .setServiceHandlerHeader(serviceHandlerHeader.build()) + .setServiceName(serviceName) + .build(); } - /* + /** * MappingAndSendingSIRequest Class constructor * for modify Service in ODL Datastore. * * @param rpcRegistry RpcProviderRegistry * @param services Services + * @param pathComputationOutput PathComputationRequestOutput */ - public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,Services services) { - this.rpcRegistry = rpcRegistry; + public MappingAndSendingSIRequest(RpcProviderRegistry rpcRegistry,Services services, + PathComputationRequestOutput pathComputationOutput) { + this.setRpcRegistry(rpcRegistry); if (rpcRegistry != null) { service = rpcRegistry.getRpcService(StubrendererService.class); } setSuccess(false); setError(""); - /* Building ServiceImplementationRequestInput / ServiceDeleteInput serviceDeleteInput .*/ + /** Building ServiceImplementationRequestInput / ServiceDeleteInput serviceDeleteInput .*/ ServiceHandlerHeaderBuilder serviceHandlerHeader = new ServiceHandlerHeaderBuilder(); - - /*ServiceAEnd Build .*/ - org.opendaylight.yang.gen.v1.http.org.openroadm.common.service + mappingSIRequest(pathComputationOutput, serviceHandlerHeader, services.getServiceAEnd(), + services.getServiceZEnd(), services.getServiceName()); + /*org.opendaylight.yang.gen.v1.http.org.openroadm.common.service .types.rev161014.service.ServiceAEnd tempA = services.getServiceAEnd(); org.opendaylight.yang.gen.v1.http.org.openroadm.common @@ -462,8 +334,6 @@ public class MappingAndSendingSIRequest { .setRxDirection(rxDirectionAEnd) .setTxDirection(txDirectionAEnd) .build(); - - /* ServiceZEnd Build .*/ org.opendaylight.yang.gen.v1.http.org.openroadm.common.service .types.rev161014.service.ServiceZEnd tempZ = services.getServiceZEnd(); @@ -484,115 +354,100 @@ public class MappingAndSendingSIRequest { .setRxDirection(rxDirectionZEnd) .setTxDirection(txDirectionZEnd) .build(); - - - /* ServiceImplementationRequestInput Build.*/ - - - List atozList = new ArrayList(); - List ztoaList = new ArrayList(); - - for (org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZ - tmp : services.getTopology().getAToZ()) { - - AToZKey key = new AToZKey(tmp.getKey().getId()); - Resource atozresource = new ResourceBuilder() - .build(); - AToZ atoz = new AToZBuilder() - .setId(tmp.getId()) - .setKey(key) - .setResource(atozresource) - .build(); - atozList.add(atoz); + org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types + .rev170426.response.parameters.sp.response.parameters.PathDescription tmp = null; + try { + tmp = pathComputationOutput.getResponseParameters().getPathDescription(); + } catch (NullPointerException e) { + LOG.error("PathDescription is null : " + e.toString()); } - - for (org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToA - tmp : services.getTopology().getZToA()) { - ZToAKey key = new ZToAKey(tmp.getKey().getId()); - Resource ztoaresource = new ResourceBuilder() - .build(); - ZToA ztoa = new ZToABuilder() - .setId(tmp.getId()) - .setKey(key) - .setResource(ztoaresource) - .build(); - ztoaList.add(ztoa); + PathDescriptionBuilder pathDescription = new PathDescriptionBuilder(); + if (tmp != null) { + pathDescription = new PathDescriptionBuilder(tmp); } - AToZDirection atozdirection = new AToZDirectionBuilder() - .setAToZ(atozList) - .build(); - - ZToADirection ztoadirection = new ZToADirectionBuilder() - .setZToA(ztoaList) - .build(); - - - PathDescription pathDescription = new PathDescriptionBuilder() - .setAToZDirection(atozdirection) - .setZToADirection(ztoadirection) - .build(); - serviceImplementationRequestInput = new ServiceImplementationRequestInputBuilder() - .setPathDescription(pathDescription) + .setPathDescription(pathDescription.build()) .setServiceHandlerHeader(serviceHandlerHeader.build()) .setServiceName(services.getServiceName()) .setServiceAEnd(serviceAEnd) .setServiceZEnd(serviceZEnd) .build(); - LOG.info("ServiceImplementationRequestInput : " + serviceImplementationRequestInput.toString()); + LOG.info("ServiceImplementationRequestInput : " + serviceImplementationRequestInput.toString());*/ } /** - * Create RxDirection with Port - * information. + *Build serviceImplementationRequestInput with + *input parameters from ServiceCreateInput or + *Services or serviceReconfigureInput. * - * @param tempPort Port - * @return RxDirection + * @param pathComputationOutput PathComputationRequestOutput + * @param serviceHandlerHeader ServiceHandlerHeaderBuilder + * @param aend Beginning ServiceEndpoint + * @param zend Ending ServiceEndpoint + * @param serviceName Service Name */ - public RxDirection getRxDirection(org.opendaylight.yang.gen.v1.http.org.openroadm.common - .service.types.rev161014.service.port.Port tempPort) { - Port port = new PortBuilder() - .setPortDeviceName(tempPort.getPortDeviceName()) - .setPortName(tempPort.getPortName()) - .setPortRack(tempPort.getPortRack()) - .setPortShelf(tempPort.getPortShelf()) - .setPortSlot(tempPort.getPortSlot()) - .setPortSubSlot(tempPort.getPortSubSlot()) - .setPortType(tempPort.getPortType()) - .build(); + private void mappingSIRequest(PathComputationRequestOutput pathComputationOutput, + ServiceHandlerHeaderBuilder serviceHandlerHeader, org.opendaylight.yang.gen .v1.http.org.openroadm.common + .service.types.rev161014.ServiceEndpoint aend , org.opendaylight.yang.gen.v1.http.org.openroadm.common + .service.types.rev161014.ServiceEndpoint zend, String serviceName) { + LOG.info("Mapping ServiceCreateInput or Services or serviceReconfigureInput to SIR requests"); + /** ServiceAEnd Build. */ + RxDirection rxDirectionAEnd = new RxDirectionBuilder() + .setPort(aend.getRxDirection().getPort()) + .build(); + TxDirection txDirectionAEnd = new TxDirectionBuilder() + .setPort(aend.getTxDirection().getPort()) + .build(); - RxDirection result = new RxDirectionBuilder() - .setPort(port) - .build(); + ServiceAEnd serviceAEnd = new ServiceAEndBuilder() + .setClli(aend.getClli()) + .setNodeId(aend.getNodeId()) + .setServiceFormat(ServiceFormat.valueOf(aend.getServiceFormat().getName())) + .setServiceRate(aend.getServiceRate()) + .setRxDirection(rxDirectionAEnd) + .setTxDirection(txDirectionAEnd) + .build(); - return result; - } + /** ServiceZEnd Build. */ + RxDirection rxDirectionZEnd = new RxDirectionBuilder() + .setPort(zend.getRxDirection().getPort()) + .build(); - /* - * Create TxDirection with Port - * information. - * - * @param tempPort Port - * @return TxDirection TxDirection - */ - public TxDirection getTxDirection(org.opendaylight.yang.gen.v1.http.org.openroadm.common - .service.types.rev161014.service.port.Port tempPort) { - Port port = new PortBuilder() - .setPortDeviceName(tempPort.getPortDeviceName()) - .setPortName(tempPort.getPortName()) - .setPortRack(tempPort.getPortRack()) - .setPortShelf(tempPort.getPortShelf()) - .setPortSlot(tempPort.getPortSlot()) - .setPortSubSlot(tempPort.getPortSubSlot()) - .setPortType(tempPort.getPortType()) - .build(); + TxDirection txDirectionZEnd = new TxDirectionBuilder() + .setPort(zend.getTxDirection().getPort()) + .build(); + + ServiceZEnd serviceZEnd = new ServiceZEndBuilder() + .setClli(zend.getClli()) + .setNodeId(zend.getNodeId()) + .setServiceFormat(ServiceFormat.valueOf(zend.getServiceFormat().getName())) + .setServiceRate(zend.getServiceRate()) + .setRxDirection(rxDirectionZEnd) + .setTxDirection(txDirectionZEnd) + .build(); - TxDirection result = new TxDirectionBuilder() - .setPort(port) - .build(); - return result; + /** ServiceImplementationRequestInput Build. */ + org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types + .rev170426.response.parameters.sp.response.parameters.PathDescription tmp = null; + try { + tmp = pathComputationOutput.getResponseParameters().getPathDescription(); + } catch (NullPointerException e) { + LOG.error("PathDescription is null : " + e.toString()); + } + PathDescriptionBuilder pathDescription = new PathDescriptionBuilder(); + if (tmp != null) { + pathDescription = new PathDescriptionBuilder(tmp); + } + serviceImplementationRequestInput = new ServiceImplementationRequestInputBuilder() + .setPathDescription(pathDescription.build()) + .setServiceHandlerHeader(serviceHandlerHeader.build()) + .setServiceName(serviceName) + .setServiceAEnd(serviceAEnd) + .setServiceZEnd(serviceZEnd) + .build(); + } /** @@ -600,13 +455,12 @@ public class MappingAndSendingSIRequest { * * @return ServiceImplementationRequestOutput data response from Renderer */ - public ListenableFuture serviceImplementation() { + public ListenableFuture serviceImplementation() { setSuccess(false); - return executor.submit(new Callable() { - + return executor.submit(new Callable() { @Override - public ServiceImplementationRequestOutput call() throws Exception { - ServiceImplementationRequestOutput output = null; + public Boolean call() throws Exception { + Boolean output = null; if (serviceImplementationRequestInput != null) { RpcResult rendererOutputResult = null; Future> rendererOutputFuture = @@ -623,10 +477,7 @@ public class MappingAndSendingSIRequest { if (rendererOutputResult != null && rendererOutputResult.isSuccessful()) { LOG.info("Renderer replied to serviceImplementation Request !"); setSuccess(true); - ServiceImplementationRequestOutput rendererOutput = rendererOutputResult.getResult(); - output = new ServiceImplementationRequestOutputBuilder() - .setConfigurationResponseCommon(rendererOutput.getConfigurationResponseCommon()) - .build(); + output = true; setSuccess(true); } } else { @@ -644,18 +495,16 @@ public class MappingAndSendingSIRequest { * * @return ServiceDeleteOutput data response from Renderer */ - public ListenableFuture serviceDelete() { + public ListenableFuture serviceDelete() { setSuccess(false); - return executor.submit(new Callable() { - + return executor.submit(new Callable() { @Override - public ServiceDeleteOutput call() throws Exception { - ServiceDeleteOutput output = null; + public Boolean call() throws Exception { + Boolean output = null; if (serviceDeleteInput != null) { RpcResult rendererOutputResult = null; Future> rendererOutputFuture = service.serviceDelete(serviceDeleteInput); - try { rendererOutputResult = rendererOutputFuture.get();//wait to get the result } catch (InterruptedException | CancellationException | ExecutionException e) { @@ -668,11 +517,7 @@ public class MappingAndSendingSIRequest { if (rendererOutputResult != null && rendererOutputResult.isSuccessful()) { LOG.info("Renderer replied to serviceDelete Request!"); setSuccess(true); - ServiceDeleteOutput rendererOutput = rendererOutputResult.getResult(); - output = new ServiceDeleteOutputBuilder() - .setConfigurationResponseCommon(rendererOutput.getConfigurationResponseCommon()) - .build(); - setSuccess(true); + output = true; } } return output; @@ -698,4 +543,12 @@ public class MappingAndSendingSIRequest { this.error = error; } + public RpcProviderRegistry getRpcRegistry() { + return rpcRegistry; + } + + public void setRpcRegistry(RpcProviderRegistry rpcRegistry) { + this.rpcRegistry = rpcRegistry; + } + } diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingConstraints.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingConstraints.java index cf3a09aa9..ed5199428 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingConstraints.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/MappingConstraints.java @@ -9,6 +9,7 @@ package org.opendaylight.transportpce.servicehandler; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.Constraints; import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.CoRoutingOrGeneral; import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.CoRouting; import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.General; @@ -18,6 +19,7 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161 import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.constraints.co.routing.or.general.general.Latency; import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.HardConstraints; import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraints; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.ConstraintsSp; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.co.routing.CoRoutingBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.general.DiversityBuilder; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.constraints.sp.co.routing.or.general.general.ExcludeBuilder; @@ -37,7 +39,7 @@ import org.slf4j.LoggerFactory; * */ public class MappingConstraints { - /* Logging. */ + /** Logging. */ private static final Logger LOG = LoggerFactory.getLogger(MappingConstraints.class); private HardConstraints serviceHardConstraints; private SoftConstraints serviceSoftConstraints; @@ -73,15 +75,116 @@ public class MappingConstraints { setServicePathSoftConstraints(soft); } + /** + *get all constraints informations + *from service constraints to map to + *servicePath constraints. + * + * @param input HardConstraints or SoftConstraints + * @return ConstraintsSp HardConstraintsSp or HardConstraintsSp + */ + private ConstraintsSp getConstraints(T input) { + CoRoutingOrGeneral coRoutingOrGeneral = null; + HardConstraintsBuilder tempHard = new HardConstraintsBuilder(); + SoftConstraintsBuilder tempSoft = new SoftConstraintsBuilder(); + if (input != null && input instanceof Constraints) { + Constraints constraints = (Constraints)input; + coRoutingOrGeneral = constraints.getCoRoutingOrGeneral(); + General tmpGeneral = null; + CoRouting tmpCoRouting = null; + if (coRoutingOrGeneral != null) { + org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints + .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder finalGeneral = + new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints + .rev170426.constraints.sp.co.routing.or.general.GeneralBuilder(); + org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints + .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder finalCoRouting = + new org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints + .rev170426.constraints.sp.co.routing.or.general.CoRoutingBuilder(); + if (coRoutingOrGeneral instanceof General) { + tmpGeneral = (General) coRoutingOrGeneral; + if (tmpGeneral != null) { + Diversity tmpDiversity = tmpGeneral.getDiversity(); + if (tmpDiversity != null) { + finalGeneral.setDiversity( + new DiversityBuilder() + .setExistingService(tmpDiversity.getExistingService()) + .setExistingServiceApplicability( + new ExistingServiceApplicabilityBuilder() + .setClli(tmpDiversity.getExistingServiceApplicability().isSite()) + .setNode(tmpDiversity.getExistingServiceApplicability().isNode()) + .setSrlg(tmpDiversity.getExistingServiceApplicability().isSrlg()) + .build()) + .build()); + } + Exclude tmpExclude = tmpGeneral.getExclude(); + if (tmpExclude != null) { + finalGeneral.setExclude( + new ExcludeBuilder() + .setSupportingServiceName(tmpExclude.getSupportingServiceName()) + .setClli(tmpExclude.getSite()) + .setNodeId(tmpExclude.getNodeId()) + //.setAffinity(value) + //.setSRLG(value) + .build()); + } + Include tmpInclude = tmpGeneral.getInclude(); + if (tmpInclude != null) { + finalGeneral.setInclude( + new IncludeBuilder() + //.setOrderedHops() + .build()); + } + Latency tmpLatency = tmpGeneral.getLatency(); + if (tmpLatency != null) { + finalGeneral.setLatency( + new LatencyBuilder() + .setMaxLatency(tmpLatency.getMaxLatency()) + .build()); + } + } + tempHard.setCoRoutingOrGeneral(finalGeneral.build()) + .setCustomerCode(constraints.getCustomerCode()); + tempSoft.setCoRoutingOrGeneral(finalGeneral.build()) + .setCustomerCode(constraints.getCustomerCode()); + } else if (coRoutingOrGeneral instanceof CoRouting) { + tmpCoRouting = (CoRouting)coRoutingOrGeneral; + if (tmpCoRouting != null) { + org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014 + .constraints.co.routing.or.general.co.routing.CoRouting tmpCoRoutingCoRouting = + tmpCoRouting.getCoRouting(); + if (tmpCoRoutingCoRouting != null) { + finalCoRouting.setCoRouting( + new CoRoutingBuilder() + .setExistingService(tmpCoRoutingCoRouting.getExistingService()) + .build()); + } + } + tempHard.setCoRoutingOrGeneral(finalCoRouting.build()) + .setCustomerCode(constraints.getCustomerCode()); + tempSoft.setCoRoutingOrGeneral(finalCoRouting.build()) + .setCustomerCode(constraints.getCustomerCode()); + } + } + } + if (input instanceof HardConstraints) { + return tempHard.build(); + } else if (input instanceof SoftConstraints) { + return tempSoft.build(); + } else { + return null; + } + } + /** * map hard/soft constraints from Service 1.2 * to ServicePath 1.4. */ public void serviceToServicePathConstarints() { LOG.info("Mapping Service Constraints to ServicePath Constraints"); - CoRoutingOrGeneral coRoutingOrGeneral = null; + //CoRoutingOrGeneral coRoutingOrGeneral = null; if (serviceHardConstraints != null) { - HardConstraintsBuilder tempHard = new HardConstraintsBuilder(); + /*HardConstraintsBuilder tempHard = new HardConstraintsBuilder(); coRoutingOrGeneral = serviceHardConstraints.getCoRoutingOrGeneral(); General tmpGeneral = null; CoRouting tmpCoRouting = null; @@ -158,9 +261,17 @@ public class MappingConstraints { } } - servicePathHardConstraints = tempHard.build(); + servicePathHardConstraints = tempHard.build();*/ + + org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints + .rev170426.routing.constraints.sp.HardConstraints tempHard = (org.opendaylight.yang.gen + .v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing + .constraints.sp.HardConstraints) getConstraints(serviceHardConstraints); + if (tempHard != null) { + servicePathHardConstraints = tempHard; + } } else if (serviceSoftConstraints != null) { - SoftConstraintsBuilder tempSoft = new SoftConstraintsBuilder(); + /*oftConstraintsBuilder tempSoft = new SoftConstraintsBuilder(); coRoutingOrGeneral = serviceSoftConstraints.getCoRoutingOrGeneral(); General tmpGeneral = null; CoRouting tmpCoRouting = null; @@ -237,7 +348,14 @@ public class MappingConstraints { } } - servicePathSoftConstraints = tempSoft.build(); + servicePathSoftConstraints = tempSoft.build();*/ + org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints + .rev170426.routing.constraints.sp.SoftConstraints tempSoft = (org.opendaylight.yang.gen + .v1.http.org.transportpce.b.c._interface.routing.constraints.rev170426.routing + .constraints.sp.SoftConstraints) getConstraints(serviceSoftConstraints); + if (tempSoft != null) { + servicePathSoftConstraints = tempSoft; + } } } diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServicehandlerCompliancyCheck.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServicehandlerCompliancyCheck.java index 0af2ad526..2fd8343ff 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServicehandlerCompliancyCheck.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServicehandlerCompliancyCheck.java @@ -21,17 +21,17 @@ import org.slf4j.LoggerFactory; * */ public class ServicehandlerCompliancyCheck { - /* Logging. */ + /** Logging. */ private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerCompliancyCheck.class); - /* SdncRequestHeader. */ + /** SdncRequestHeader. */ private SdncRequestHeader sndcRequestHeader; - /* Service Name. */ + /** Service Name. */ private String serviceName; - /* Type of connection : service / infrastructure / roadm-line. */ + /** Type of connection : service / infrastructure / roadm-line. */ private ConnectionType conType; - /* type of service : service-create / service-delete ... */ + /** type of service : service-create / service-delete ... */ private RpcActions action; - /* Response message from procedure. */ + /** Response message from procedure. */ private String message; /** diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServicehandlerTxRxCheck.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServicehandlerTxRxCheck.java index b385b14ff..85c71d20b 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServicehandlerTxRxCheck.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/ServicehandlerTxRxCheck.java @@ -23,13 +23,13 @@ import org.slf4j.LoggerFactory; * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange */ public class ServicehandlerTxRxCheck { - /* Logging. */ + /** Logging. */ private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerTxRxCheck.class); - /* ServiceEndpoint. */ + /** ServiceEndpoint. */ private ServiceEndpoint serviceEnd; - /* Response message from procedure. */ + /** Response message from procedure. */ private String message; - /* type serviceEndpoint : serviceAEnd / serviceZEnd. */ + /** type serviceEndpoint : serviceAEnd / serviceZEnd. */ private String service = null; /** diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java index fea237842..1fa5d4e04 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerImpl.java @@ -10,19 +10,12 @@ package org.opendaylight.transportpce.servicehandler.impl; import com.google.common.base.Optional; -import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import java.io.DataOutputStream; -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutionException; @@ -34,87 +27,75 @@ import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.transportpce.servicehandler.CheckCoherencyHardSoft; -import org.opendaylight.transportpce.servicehandler.LoggingFuturesCallBack; import org.opendaylight.transportpce.servicehandler.MappingAndSendingPCRequest; import org.opendaylight.transportpce.servicehandler.MappingAndSendingSIRequest; import org.opendaylight.transportpce.servicehandler.ServicehandlerCompliancyCheck; import org.opendaylight.transportpce.servicehandler.ServicehandlerTxRxCheck; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.EquipmentNotificationInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.EquipmentNotificationOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.NetworkReOptimizationInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.NetworkReOptimizationOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceCreateInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceCreateOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceCreateOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceDeleteInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceDeleteOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceDeleteOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceFeasibilityCheckInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceFeasibilityCheckOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceFeasibilityCheckOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceList; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceListBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceReconfigureInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceReconfigureOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceReconfigureOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceRerouteConfirmInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceRerouteConfirmOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceRerouteInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceRerouteOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceRestorationInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceRestorationOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceRestorationOutputBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceReversionInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceReversionOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceRollInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceRollOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceRpcResult; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServiceRpcResultBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServicehandlerService; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.TempServiceCreateInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.TempServiceCreateOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.TempServiceDeleteInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.TempServiceDeleteOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.service.feasibility.check.output.IntermediateSites; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.service.feasibility.check.output.IntermediateSitesBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.service.list.Services; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.service.list.ServicesBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.service.list.ServicesKey; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.CancelResourceReserveOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceRpcResultSh; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev170930.ServiceRpcResultShBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestOutputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.ServicePathRpcResult; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.StubpceListener; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceImplementationRequestOutput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.ServiceRpcResultSp; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererListener; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceFormat; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceEndpoint; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceNotificationTypes; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommon; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.configuration.response.common.ConfigurationResponseCommonBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.response.parameters.ResponseParameters; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.response.parameters.ResponseParametersBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceAEnd; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceAEndBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceZEnd; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.ServiceZEndBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.Topology; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.TopologyBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.RxDirection; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.RxDirectionBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.TxDirection; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.TxDirectionBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.lgx.Lgx; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.lgx.LgxBuilder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.Port; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.PortBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.LifecycleState; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.OpticTypes; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.RpcStatus; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.HardConstraints; +import org.opendaylight.yang.gen.v1.http.org.openroadm.routing.constrains.rev161014.routing.constraints.SoftConstraints; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.EquipmentNotificationInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.EquipmentNotificationOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.NetworkReOptimizationInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.NetworkReOptimizationOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.OrgOpenroadmServiceService; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceCreateOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceDeleteOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceFeasibilityCheckOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceList; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceListBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReconfigureOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteConfirmInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteConfirmOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRerouteOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRestorationInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRestorationOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRestorationOutputBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReversionInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceReversionOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRollInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.ServiceRollOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceCreateOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteInput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.TempServiceDeleteOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.Services; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesBuilder; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.service.list.ServicesKey; import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZ; import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.AToZKey; @@ -122,7 +103,10 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topolo import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToABuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.topology.rev161014.topology.ZToAKey; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.RpcStatusEx; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.ServicePathNotificationTypes; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.response.parameters.sp.response.parameters.PathDescription; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.response.parameters.sp.response.parameters.PathDescriptionBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.rpc.result.sp.PathTopology; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev170426.service.rpc.result.sp.PathTopologyBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; @@ -133,26 +117,26 @@ import org.slf4j.LoggerFactory; /** * Class to implement ServicehandlerService and ServicehandlerListener. * - * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange - * + * @author Martial Coulibaly on behalf of Orange */ -public class ServicehandlerImpl implements ServicehandlerService, StubpceListener, StubrendererListener, AutoCloseable { - /* Logging. */ +public class ServicehandlerImpl implements OrgOpenroadmServiceService,StubpceListener, + StubrendererListener,AutoCloseable { + /** Logging. */ private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerImpl.class); - /* Permit to access database. */ + /** Permit to access database. */ private DataBroker db; - /* check service sdnc-request-header compliancy. */ + /** check service sdnc-request-header compliancy. */ private ServicehandlerCompliancyCheck compliancyCheck; - /* check missing info on Tx/Rx for A/Z end. */ + /** check missing info on Tx/Rx for A/Z end. */ private ServicehandlerTxRxCheck txrxCheck; - /* check coherency between hard & sof constraints. */ + /** check coherency between hard and soft constraints. */ private CheckCoherencyHardSoft checkCoherencyHardSoft; - /* + /** * Map and Send PCE requests : - * path-computation-request/cancel-resource-reserve. */ private MappingAndSendingPCRequest mappingAndSendingPCRequest; - /* + /** * Map and Send Service Implemention requests : - service * implementation/service delete. */ @@ -168,66 +152,736 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene private String notificationUrl = ""; private RpcActions action; + private PathDescription pathDescription; + private PathTopology pathTopology; + private ServiceCreateInput serviceCreateInput; + private ServiceDeleteInput serviceDeleteInput; + private ServiceReconfigureInput serviceReconfigureInput; + private Services service; + private ServiceFeasibilityCheckInput serviceFeasibilityCheckInput; + public ServicehandlerImpl(DataBroker databroker, RpcProviderRegistry rpcRegistry, NotificationPublishService notificationPublishService) { this.db = databroker; this.rpcRegistry = rpcRegistry; this.notificationPublishService = notificationPublishService; executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(5)); + serviceCreateInput = null; + setServiceDeleteInput(null); + setServiceReconfigureInput(null); initializeDataTree(db); } - @Override - public Future> serviceCreate(ServiceCreateInput input) { - LOG.info("RPC service creation received"); - action = RpcActions.ServiceCreate; - boolean commonId = true; - boolean coherencyHardSoft = false; - ServiceRpcResult notification = null; - notificationUrl = null;// input.getSdncRequestHeader().getnotificationUrl(); - LOG.info("notificationUrl : " + notificationUrl); + /** + * delete service from + * datastore after receiving + * Stubrenderer notification. + * + */ + private void deleteServiceFromDatastore() { + String serviceName = null; + if (serviceDeleteInput != null) { + LOG.info("deleteServiceFromDatastore came from RPC serviceDelete"); + serviceName = serviceDeleteInput.getServiceDeleteReqInfo().getServiceName(); + } else if (service != null) { + LOG.info("deleteServiceFromDatastore came from RPC serviceRestoration"); + serviceName = service.getServiceName(); + } + if (serviceName != null) { + LOG.info("deleting service '" + serviceName + "'from datastore ..."); + ServiceRpcResultSh notification = null; + String message = ""; + /** + * Service delete confirmed deleting service from + * database + */ + if (writeOrModifyOrDeleteServiceList(serviceName, null, + null,1) == null) { + /** Service delete. */ + message = "Service deleted from database"; + } else { + message = "deleting service from database failed !"; + } + LOG.info(message); + notification = new ServiceRpcResultShBuilder() + .setNotificationType(ServiceNotificationTypes.ServiceDeleteResult) + .setServiceName(serviceDeleteInput.getServiceDeleteReqInfo().getServiceName()) + .setStatus(RpcStatusEx.Successful).setStatusMessage(message).build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + } else { + LOG.error("Parameter 'ServiceName' fro deleteServiceFromDatastore is null !"); + } + } - ResponseParametersBuilder responseParameters = new ResponseParametersBuilder(); - ConfigurationResponseCommon configurationResponseCommon; + + /** + *Put Service status to up + *and add topology information + *after receiving Stubrenderer + *service implementation + *notification. + * + * @param input ServiceCreateInput or + */ + private void updateServiceStatus(T input) { + LOG.info("Updating Service Status ..."); + ServiceRpcResultSh notification = null; String message = ""; - String responseCode = ""; + String serviceName = null; + ServiceNotificationTypes notif = null; + if (input instanceof ServiceCreateInput) { + LOG.info("Updating Service Status came from RPC serviceCreateInput ..."); + serviceName = serviceCreateInput.getServiceName(); + notif = ServiceNotificationTypes.ServiceCreateResult; + } else if (input instanceof ServiceReconfigureInput) { + LOG.info("Updating Service Status came from RPC serviceReconfigure ..."); + serviceName = serviceReconfigureInput.getNewServiceName(); + notif = ServiceNotificationTypes.ServiceReconfigureResult; + } else if (input instanceof Services) { + LOG.info("Updating Service Status came from RPC serviceRestoration ..."); + serviceName = service.getServiceName(); + notif = ServiceNotificationTypes.ServiceRestorationResult; + } + if (serviceName != null && notif != null) { + if (pathTopology != null) { + LOG.info("PathTopology contains in Stubrenderer notification received !"); + Topology topo = new TopologyBuilder() + .setAToZ(pathTopology.getAToZ()) + .setZToA(pathTopology.getZToA()) + .build(); - LOG.info("checking Service Compliancy ..."); - /* - * Upon receipt of service - * -create RPC, service header and sdnc - * -request header compliancy are verified. + /** + * Service implemented setting + * Service op status to up. + */ + if (writeOrModifyOrDeleteServiceList(serviceName, null,topo,0) == null) { + /** + * Service modified. + */ + StringBuilder build = new StringBuilder(); + build.append(message); + build.append(" : Service Op Status changed to Up !"); + message = build.toString(); + } else { + StringBuilder build = new StringBuilder(); + build.append(message); + build.append(" but Failed to modify service from Service List !"); + message = build.toString(); + } + notification = new ServiceRpcResultShBuilder() + .setNotificationType(notif) + .setServiceName(serviceCreateInput.getServiceName()) + .setStatus(RpcStatusEx.Successful).setStatusMessage(message) + .build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + } else { + message = "pathTopology not in stubrenderer notification, cancelling pce resource reserve ..."; + LOG.info(message); + notification = new ServiceRpcResultShBuilder() + .setNotificationType(ServiceNotificationTypes.ServiceCreateResult) + .setServiceName(serviceCreateInput.getServiceName()) + .setStatus(RpcStatusEx.Failed) + .setStatusMessage("message") + .build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + pceCancelResResource(); + } + } else { + LOG.info("Parameters 'serviceName' or/ and 'notiftype' is null"); + } + } + + /** + * Send pathComputation + * request to PCE. + * + * @param input ServiceCreate or ServiceReconfigure or Services + */ + private void pcePathComputation(T input) { + LOG.info("sending pathcomputation request to pce ..."); + ServiceRpcResultSh notification = null; + String serviceName = null; + ServiceNotificationTypes type = null; + /** + * Before sending the PCE request, input data need to be + * formatted according to the Service Handler PCE + * interface data model. */ - compliancyCheck = new ServicehandlerCompliancyCheck(input.getSdncRequestHeader(), input.getServiceName(), - input.getConnectionType(), RpcActions.ServiceCreate); - if (compliancyCheck.check(true, true)) { + if (input instanceof ServiceReconfigureInput) { + LOG.info("PCR came from RPC serviceReconfigure ..."); + ServiceReconfigureInput tmp = (ServiceReconfigureInput)input; + serviceName = tmp.getNewServiceName(); + type = ServiceNotificationTypes.ServiceReconfigureResult; + mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, tmp, true); + } else if (input instanceof ServiceCreateInput) { + LOG.info("PCR came from RPC serviceCreate ..."); + ServiceCreateInput tmp = (ServiceCreateInput)input; + serviceName = tmp.getServiceName(); + type = ServiceNotificationTypes.ServiceCreateResult; + mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, tmp, true); + } else if (input instanceof Services) { + LOG.info("PCR came from RPC serviceRestoration ..."); + Services tmp = (Services)input; + serviceName = tmp.getServiceName(); + type = ServiceNotificationTypes.ServiceRestorationResult; + mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, tmp, true); + } else if (input instanceof ServiceFeasibilityCheckInput) { + LOG.info("PCR came from RPC ServiceFeasibilityCheck ..."); + ServiceFeasibilityCheckInput tmp = (ServiceFeasibilityCheckInput)input; + serviceName = "no name"; + type = ServiceNotificationTypes.ServiceCreateResult; + mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, tmp, false); + } + final String name = serviceName; + final ServiceNotificationTypes notifType = type; + + /** + * Once PCE request is being sent to the PCE on + * interface B, PCE reply is expected until a timer + * expires. + */ + notification = new ServiceRpcResultShBuilder() + .setNotificationType(notifType) + .setServiceName(serviceName).setStatus(RpcStatusEx.Pending) + .setStatusMessage("Service compliant, submitting PathComputation Request ...").build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + FutureCallback pceCallback = new FutureCallback() { + String message = ""; + ServiceRpcResultSh notification = null; + + @Override + public void onSuccess(Boolean response) { + if (response) { + /** + * If PCE reply is received before timer + * expiration with a positive result, a + * service is created with admin and + * operational status 'down'. + */ + message = "PCE replied to PCR Request !"; + LOG.info(message); + notification = new ServiceRpcResultShBuilder() + .setNotificationType(notifType) + .setServiceName(name).setStatus(RpcStatusEx.Pending) + .setStatusMessage(message).build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + } else { + message = mappingAndSendingPCRequest.getError(); + notification = new ServiceRpcResultShBuilder() + .setNotificationType(notifType) + .setServiceName("").setStatus(RpcStatusEx.Failed).setStatusMessage(message) + .build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + } + } + + @Override + public void onFailure(Throwable arg0) { + LOG.error("Path not calculated.."); + notification = new ServiceRpcResultShBuilder() + .setNotificationType(notifType) + .setServiceName(name).setStatus(RpcStatusEx.Failed) + .setStatusMessage("PCR Request failed : " + arg0.getMessage()).build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + + } + }; + ListenableFuture pce = mappingAndSendingPCRequest.pathComputationRequest(); + Futures.addCallback(pce, pceCallback, executor); + } + + /** + * Send RPC cancel reserve + * resource to PCE. + */ + private void pceCancelResResource() { + LOG.info("sending RPC cancel reserve resource to PCE ..."); + Services pceService = null; + ServiceNotificationTypes notif = null; + if (serviceDeleteInput != null) { + LOG.info("pceCancelResResource came from RPC serviceDelete"); + notif = ServiceNotificationTypes.ServiceDeleteResult; + String serviceName = serviceDeleteInput.getServiceDeleteReqInfo().getServiceName(); + if (serviceName != null) { + pceService = readServiceList(serviceName); + } else { + LOG.info("Parameter 'serviceName' for pceCancelResResource is null"); + } + } else if (service != null) { + notif = ServiceNotificationTypes.ServiceRestorationResult; + LOG.info("pceCancelResResource came from RPC serviceRestoration"); + pceService = service; + } else if (serviceReconfigureInput != null) { + notif = ServiceNotificationTypes.ServiceReconfigureResult; + LOG.info("pceCancelResResource came from RPC serviceReconfigure"); + String serviceName = serviceReconfigureInput.getServiceName(); + if (serviceName != null) { + pceService = readServiceList(serviceName); + } else { + LOG.info("Parameter 'serviceName' for pceCancelResResource is null"); + } + } else if (serviceCreateInput != null) { + notif = ServiceNotificationTypes.ServiceCreateResult; + LOG.info("pceCancelResResource came from RPC serviceCreate"); + String serviceName = serviceCreateInput.getServiceName(); + if (serviceName != null) { + pceService = readServiceList(serviceName); + } else { + LOG.info("Parameter 'serviceName' for pceCancelResResource is null"); + } + } + if (pceService != null && notif != null) { + final Services cancelService = pceService; + final ServiceNotificationTypes type = notif; + mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, pceService, false); + FutureCallback pceCallback = new FutureCallback() { + String message = ""; + ServiceRpcResultSh notification = null; + @Override + public void onSuccess(Boolean response) { + if (response) { + /** + * If PCE reply is received before timer + * expiration with a positive result, a + * service is created with admin and + * operational status 'down'. + */ + message = "PCE replied to cancel resource Request !"; + LOG.info(message); + notification = new ServiceRpcResultShBuilder() + .setNotificationType(type) + .setServiceName(cancelService.getServiceName()).setStatus(RpcStatusEx.Pending) + .setStatusMessage(message).build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + } else { + message = mappingAndSendingPCRequest.getError(); + notification = new ServiceRpcResultShBuilder() + .setNotificationType(type) + .setServiceName("").setStatus(RpcStatusEx.Failed).setStatusMessage(message) + .build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + } + } + + @Override + public void onFailure(Throwable arg0) { + message = "Cancel resource request failed !"; + LOG.error(message); + notification = new ServiceRpcResultShBuilder() + .setNotificationType(type) + .setServiceName(cancelService.getServiceName()).setStatus(RpcStatusEx.Failed) + .setStatusMessage(message + " : " + arg0.getMessage()).build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + + } + }; + ListenableFuture pce = mappingAndSendingPCRequest.cancelResourceReserve(); + Futures.addCallback(pce, pceCallback, executor); + } + } + + private void stubrendererDelete() { + LOG.info("sending RPC service delete to stubrenderer ..."); + String tmp = null; + String id = null; + if (service != null) { + LOG.info("RPC service delete came from RPC serviceRestoration !"); + tmp = service.getServiceName(); + id = service.getCommonId(); + } else if (serviceDeleteInput != null) { + LOG.info("RPC service delete came from ServiceDelete !"); + tmp = serviceDeleteInput.getServiceDeleteReqInfo().getServiceName(); + id = serviceDeleteInput.getSdncRequestHeader().getRequestId(); + } + + if (tmp != null && id != null) { + final String serviceName = tmp; + LOG.info("stubrendererDelete service '" + serviceName + "'"); + mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, id, serviceName); + ListenableFuture renderer = mappingAndSendingSIRequest.serviceDelete(); + FutureCallback rendererCallback = new FutureCallback() { + String message = ""; + ServiceRpcResultSh notification = null; + + @Override + public void onFailure(Throwable arg0) { + message = "ServiceDelete Request failed : " + arg0; + LOG.error("ServiceDelete Request failed !"); + notification = new ServiceRpcResultShBuilder() + .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult) + .setServiceName(serviceName).setStatus(RpcStatusEx.Failed) + .setStatusMessage(message).build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + + } + + @Override + public void onSuccess(Boolean response) { + if (response) { + message = "Service deleted !"; + notification = new ServiceRpcResultShBuilder() + .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult) + .setServiceName(serviceName).setStatus(RpcStatusEx.Pending) + .setStatusMessage(message).build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + } else { + message = "deleting service failed !"; + notification = new ServiceRpcResultShBuilder() + .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult) + .setServiceName(serviceName).setStatus(RpcStatusEx.Failed) + .setStatusMessage(message) + .build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + } + } + }; + Futures.addCallback(renderer, rendererCallback, executor); + } else { + LOG.info("Parameter 'serviceName' and / or 'id' is null"); + } + } + + /** + * send a RPC serviceImplementation + * to stubrenderer after + * receiving a stubpce notification. + * + * @param input ServiceCreate or ServiceReconfigure + */ + private void stubrendererImplementation(T input) { + ServiceRpcResultSh notification = null; + String serviceName = null; + String message = ""; + String newServiceName = null; + ServiceNotificationTypes type = null; + Boolean create = false; + Boolean delete = true; + if (pathDescription != null) { + LOG.info("Pathdescription conatins in Stubpce notification received !"); + String result = null; + PathComputationRequestOutput pathComputationResponse = + new PathComputationRequestOutputBuilder() + .setResponseParameters(new org.opendaylight.yang.gen.v1.http.org + .transportpce.b.c._interface.service.types.rev170426.response + .parameters.sp.ResponseParametersBuilder() + .setPathDescription(pathDescription) + .build()) + .build(); + if (input instanceof ServiceReconfigureInput) { + /** delete and write . */ + LOG.info("RPC serviceImplementation came from RPC serviceReconfigure ..."); + ServiceReconfigureInput tmp = (ServiceReconfigureInput)input; + serviceName = tmp.getServiceName(); + newServiceName = tmp.getNewServiceName(); + type = ServiceNotificationTypes.ServiceReconfigureResult; + delete = false; + mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, tmp,pathComputationResponse); + } else if (input instanceof ServiceCreateInput) { + /** create. */ + LOG.info("RPC serviceImplementation came from RPC serviceCreate ..."); + ServiceCreateInput tmp = (ServiceCreateInput)input; + serviceName = tmp.getServiceName(); + type = ServiceNotificationTypes.ServiceCreateResult; + mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, tmp,pathComputationResponse); + delete = true; + create = true; + } else if (input instanceof Services) { + /** update. */ + LOG.info("RPC serviceImplementation came from RPC ServiceRestoration ..."); + Services tmp = new ServicesBuilder((Services)input) + .setAdministrativeState(State.OutOfService) + .setOperationalState(State.OutOfService) + .setLifecycleState(LifecycleState.Planned) + .build(); + serviceName = tmp.getServiceName(); + type = ServiceNotificationTypes.ServiceRestorationResult; + mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, tmp, pathComputationResponse); + delete = true; + create = true; + } + final String name = serviceName; + final ServiceNotificationTypes notifType = type; + if (!create) { /** ServiceReconfigure. */ + if ((result = writeOrModifyOrDeleteServiceList(serviceName, pathComputationResponse,null, 1)) == null) { + LOG.info("Service '" + serviceName + "' deleted from datastore"); + serviceName = newServiceName; + delete = true; + } else { + LOG.info("deleting Service '" + serviceName + "' failed !"); + } + } + if (delete) { + if ((result = writeOrModifyOrDeleteServiceList(serviceName,pathComputationResponse,null, 2)) != null) { + LOG.info("writting Service failed !"); + StringBuilder build = new StringBuilder(); + build.append(message); + build.append(" " + result); + message = build.toString(); + } else { + /** + * Send Implementation order to renderer + */ + notification = new ServiceRpcResultShBuilder() + .setNotificationType(notifType) + .setServiceName(name) + .setStatus(RpcStatusEx.Pending) + .setStatusMessage("Submitting ServiceImplementation Request ...") + .build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + + FutureCallback rendererCallback = new FutureCallback() { + String message = ""; + ServiceRpcResultSh notification = null; + + @Override + public void onSuccess(Boolean response) { + if (response) { + /** + * If stubrenderer reply is received before timer + * expiration with a positive result, a + * service is created with admin and + * operational status 'down'. + */ + message = "StubRenderer replied to Request !"; + LOG.info(message); + notification = new ServiceRpcResultShBuilder() + .setNotificationType(notifType) + .setServiceName(name).setStatus(RpcStatusEx.Pending) + .setStatusMessage(message).build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + } else { + message = mappingAndSendingSIRequest.getError(); + notification = new ServiceRpcResultShBuilder() + .setNotificationType(notifType) + .setServiceName(name).setStatus(RpcStatusEx.Failed).setStatusMessage(message) + .build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + } + } + + @Override + public void onFailure(Throwable arg0) { + LOG.error("Service not implemented ..."); + notification = new ServiceRpcResultShBuilder() + .setNotificationType(notifType) + .setServiceName(name).setStatus(RpcStatusEx.Failed) + .setStatusMessage("Service implementation failed : " + arg0.getMessage()).build(); + try { + notificationPublishService.putNotification(notification); + } catch (InterruptedException e) { + LOG.info("notification offer rejected : " + e); + } + } + }; + ListenableFuture renderer = mappingAndSendingSIRequest.serviceImplementation(); + Futures.addCallback(renderer, rendererCallback, executor); + } + } else { + LOG.info("deleting Service failed"); + } + } else { + message = "PathDescription contains in Stubpce notification " + + "not recieved !"; + LOG.info(message); + } + } + + /** + * Checking Service Compliancy. + * + * @return String if not compliant, null else + */ + private String serviceCompliancy(SdncRequestHeader sdncRequestHeader, String serviceName, + ConnectionType connectionType, RpcActions rpcActions, ServiceEndpoint aend, ServiceEndpoint zend, + String commonIdValue, HardConstraints hard, SoftConstraints soft) { + String message = null; + Boolean contype = false; + Boolean sdncRequest = false; + Boolean commonId = true; + Boolean coherencyHardSoft = false; + + if (sdncRequestHeader != null) { + sdncRequest = true; + } + if (connectionType != null) { + contype = true; + } + compliancyCheck = new ServicehandlerCompliancyCheck(sdncRequestHeader, serviceName, + connectionType, rpcActions); + if (compliancyCheck.check(contype, sdncRequest)) { LOG.info("Service compliant !"); - /* + /** * If compliant, service-request parameters are verified in order to * check if there is no missing parameter that prevents calculating * a path and implement a service. */ LOG.info("checking Tx/Rx Info for AEnd ..."); - txrxCheck = new ServicehandlerTxRxCheck(input.getServiceAEnd(), 1); + txrxCheck = new ServicehandlerTxRxCheck(aend, 1); if (txrxCheck.check()) { LOG.info("Tx/Rx Info for AEnd checked !"); LOG.info("checking Tx/Rx Info for ZEnd ..."); - txrxCheck = new ServicehandlerTxRxCheck(input.getServiceZEnd(), 2); + txrxCheck = new ServicehandlerTxRxCheck(zend, 2); if (txrxCheck.check()) { LOG.info("Tx/Rx Info for ZEnd checked"); - /* + /** * If OK, common-id is verified in order to see if there is * no routing policy provided. If yes, the routing * constraints of the policy are recovered and coherency * with hard/soft constraints provided in the input of the * RPC. */ - if (input.getCommonId() != null) { + if (commonIdValue != null) { LOG.info("Common-id specified"); - /* - * Check coherency with hard/soft constraints + /** + * Check coherency with hard/soft constraints. */ + checkCoherencyHardSoft = new CheckCoherencyHardSoft(hard,soft); + if (checkCoherencyHardSoft.check()) { + LOG.info("hard/soft constraints coherent !"); + coherencyHardSoft = true; + } else { + LOG.info("hard/soft constraints are not coherent !"); + message = "hard/soft constraints are not coherent !"; + } + } else { + commonId = false; + } + if (!commonId || (commonId && coherencyHardSoft)) { + message = null; + } + } else { + message = txrxCheck.getMessage(); + } + } else { + message = txrxCheck.getMessage(); + } + } else { + message = compliancyCheck.getMessage(); + } + return message; + } + + @Override + public Future> serviceCreate(ServiceCreateInput input) { + LOG.info("RPC service creation received"); + pathDescription = null; + pathTopology = null; + action = RpcActions.ServiceCreate; + notificationUrl = null; + LOG.info("notificationUrl : " + notificationUrl); + setPathDescription(null); + serviceCreateInput = input; + setServiceDeleteInput(null); + setServiceReconfigureInput(null); + service = null; + String message = ""; + String responseCode = ""; + ConfigurationResponseCommon configurationResponseCommon; + LOG.info("checking Service Compliancy ..."); + /** + * Upon receipt of service-create RPC, service header and sdnc-request + * header compliancy are verified. + */ + String serviceCompliancy = null; + if ((serviceCompliancy = serviceCompliancy(input.getSdncRequestHeader(), input.getServiceName(), + input.getConnectionType(), RpcActions.ServiceCreate, input.getServiceAEnd(), input.getServiceZEnd(), + input.getCommonId(), input.getHardConstraints(), input.getSoftConstraints())) != null) { + message = "Service not compliant : " + serviceCompliancy; + LOG.info(message); + } else { + LOG.info("Service compliant !"); + pcePathComputation(input); + LOG.info("PCR Request in progress "); + configurationResponseCommon = new ConfigurationResponseCommonBuilder() + .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId()) + .setResponseMessage("Service compliant, serviceCreate in progress...") + .setResponseCode("200").build(); + + ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder() + .setConfigurationResponseCommon(configurationResponseCommon); + + return RpcResultBuilder.success(output.build()).buildFuture(); + + } + /*compliancyCheck = new ServicehandlerCompliancyCheck(input.getSdncRequestHeader(), input.getServiceName(), + input.getConnectionType(), RpcActions.ServiceCreate); + if (compliancyCheck.check(true, true)) { + LOG.info("Service compliant !"); + LOG.info("checking Tx/Rx Info for AEnd ..."); + txrxCheck = new ServicehandlerTxRxCheck(input.getServiceAEnd(), 1); + if (txrxCheck.check()) { + LOG.info("Tx/Rx Info for AEnd checked !"); + LOG.info("checking Tx/Rx Info for ZEnd ..."); + txrxCheck = new ServicehandlerTxRxCheck(input.getServiceZEnd(), 2); + if (txrxCheck.check()) { + LOG.info("Tx/Rx Info for ZEnd checked"); + if (input.getCommonId() != null) { + LOG.info("Common-id specified"); checkCoherencyHardSoft = new CheckCoherencyHardSoft(input.getHardConstraints(), input.getSoftConstraints()); if (checkCoherencyHardSoft.check()) { @@ -241,269 +895,8 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene } else { commonId = false; } - if (!commonId || (commonId && coherencyHardSoft)) { - /* - * Before sending the PCE request, input data need to be - * formatted according to the Service Handler PCE - * interface data model. - */ - mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, input, true); - /* - * Once PCE request is being sent to the PCE on - * interface B, PCE reply is expected until a timer - * expires. - */ - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceCreateResult) - .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending) - .setStatusMessage("Service compliant, submitting PathComputation Request ...").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - FutureCallback pceCallback = - new FutureCallback() { - String message = ""; - String responseCode = ""; - ServiceRpcResult notification = null; - - @Override - public void onSuccess(PathComputationRequestOutput response) { - if (mappingAndSendingPCRequest.getSuccess() && response != null) { - /* - * If PCE reply is received before timer - * expiration with a positive result, a - * service is created with admin and - * operational status 'down'. - */ - LOG.info("PCE replied to PCR Request !"); - - message = response.getConfigurationResponseCommon().getResponseMessage(); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceCreateResult) - .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending) - .setStatusMessage("PCE replied to PCR Request !").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - String result = null; - if ((result = writeOrModifyOrDeleteServiceList(input.getServiceName(), input, - response, 2)) != null) { - StringBuilder build = new StringBuilder(); - build.append(message); - build.append(" " + result); - message = build.toString(); - } else { - /* - * Send Implementation order to renderer - */ - mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, input, - response); - - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceCreateResult) - .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending) - .setStatusMessage("Submitting ServiceImplementation Request ...") - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - - /* - * Once PCE request is being sent to the - * PCE on interface B, PCE reply is - * expected until a timer expires. - */ - ServiceImplementationRequestOutput siOutput = null; - try { - siOutput = mappingAndSendingSIRequest.serviceImplementation().get(); - } catch (InterruptedException | ExecutionException e2) { - LOG.error("mappingAndSendingSIRequest.serviceImplementation().get() : " - + e2.getMessage()); - } - if (siOutput == null) { - LOG.info("siOutput is null "); - LOG.info("Success : " + mappingAndSendingPCRequest.getSuccess()); - } - if (mappingAndSendingSIRequest.getSuccess() && siOutput != null) { - ConfigurationResponseCommon siCommon = siOutput - .getConfigurationResponseCommon(); - // message = - // siCommon.getResponseMessage(); - responseCode = siCommon.getResponseCode(); - message = "Service implemented !"; - LOG.info(message); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceCreateResult) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Successful).setStatusMessage(message) - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - /* - * Service implemented setting - * Service op status to up - */ - if (writeOrModifyOrDeleteServiceList(input.getServiceName(), null, null, - 0) == null) { - /* - * Service modified. - */ - StringBuilder build = new StringBuilder(); - build.append(message); - build.append(" : Service Op Status changed to Up !"); - message = build.toString(); - } else { - StringBuilder build = new StringBuilder(); - build.append(message); - build.append(" but Failed to modify service from Service List !"); - message = build.toString(); - } - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceCreateResult) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Successful).setStatusMessage(message) - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - } else { - LOG.info("Service not implemented !"); - message = response.getConfigurationResponseCommon().getResponseMessage(); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceCreateResult) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Failed) - .setStatusMessage( - "Service not implemented, cancelling ResourceResv ...") - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, - input, false); - /* - * Send Cancel resource Request to - * PCE. - */ - CancelResourceReserveOutput cancelOuptut = null; - try { - cancelOuptut = mappingAndSendingPCRequest.cancelResourceReserve().get(); - } catch (InterruptedException | ExecutionException e1) { - LOG.error(e1.getMessage()); - } - if (mappingAndSendingPCRequest.getSuccess() && cancelOuptut != null) { - LOG.info("Service ResourceResv cancelled !"); - message = response.getConfigurationResponseCommon() - .getResponseMessage(); - notification = new ServiceRpcResultBuilder() - .setNotificationType( - ServiceNotificationTypes.ServiceCreateResult) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Failed) - .setStatusMessage("Service ResourceResv cancelled").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - - message = cancelOuptut.getConfigurationResponseCommon() - .getResponseMessage(); - responseCode = cancelOuptut.getConfigurationResponseCommon() - .getResponseCode(); - - StringBuilder build = new StringBuilder(); - build.append("Service not implemented - "); - build.append(message); - message = build.toString(); - - LOG.info("PCE replied to CancelResourceResv Request !"); - } else { - message = "Cancelling Resource reserved failed "; - LOG.info(message); - responseCode = "500"; - StringBuilder build = new StringBuilder(); - build.append("Service not implemented - "); - build.append(message); - message = build.toString(); - - message = response.getConfigurationResponseCommon() - .getResponseMessage(); - notification = new ServiceRpcResultBuilder() - .setNotificationType( - ServiceNotificationTypes.ServiceCreateResult) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Failed) - .setStatusMessage("Cancelling Resource reserved failed") - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - } - - } - } - } else { - message = mappingAndSendingPCRequest.getError();// "Path - // not - // calculated"; - responseCode = "500"; - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceCreateResult) - .setServiceName("").setStatus(RpcStatusEx.Failed).setStatusMessage(message) - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - } - - } - - @Override - public void onFailure(Throwable arg0) { - LOG.error("Path not calculated.."); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceCreateResult) - .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) - .setStatusMessage("PCR Request failed : " + arg0.getMessage()).build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - } - }; - ListenableFuture pce = mappingAndSendingPCRequest - .pathComputationRequest(); - Futures.addCallback(pce, pceCallback); + pcePathComputation(input); LOG.info("PCR Request in progress "); configurationResponseCommon = new ConfigurationResponseCommonBuilder() .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId()) @@ -511,8 +904,7 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene .setResponseCode("200").build(); ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder() - .setConfigurationResponseCommon(configurationResponseCommon) - .setResponseParameters(responseParameters.build()); + .setConfigurationResponseCommon(configurationResponseCommon); return RpcResultBuilder.success(output.build()).buildFuture(); } @@ -527,150 +919,44 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene } else { message = compliancyCheck.getMessage(); responseCode = "500"; - } + }*/ - configurationResponseCommon = new ConfigurationResponseCommonBuilder().setAckFinalIndicator("Yes") + configurationResponseCommon = new ConfigurationResponseCommonBuilder() + .setAckFinalIndicator("Yes") .setRequestId(input.getSdncRequestHeader().getRequestId()).setResponseMessage(message) .setResponseCode(responseCode).build(); ServiceCreateOutputBuilder output = new ServiceCreateOutputBuilder() - .setConfigurationResponseCommon(configurationResponseCommon) - .setResponseParameters(responseParameters.build()); - - return RpcResultBuilder.success(output.build()).buildFuture(); - - } - - @Override - public Future> serviceDelete(ServiceDeleteInput input) { - LOG.info("RPC serviceDelete request received for Service '" + input.getServiceDeleteReqInfo().getServiceName() - + "'"); - notificationUrl = null;// input.getSdncRequestHeader().getnotificationUrl(); - String message = ""; - String responseCode = ""; - ServiceRpcResult notification = null; - ResponseParametersBuilder responseParameters = new ResponseParametersBuilder(); - LOG.info("checking Service Compliancy ..."); - /* - * Upon receipt of service-delete RPC, service header and sdnc-request - * header compliancy are verified. - */ - compliancyCheck = new ServicehandlerCompliancyCheck(input.getSdncRequestHeader(), - input.getServiceDeleteReqInfo().getServiceName(), RpcActions.ServiceDelete); - if (compliancyCheck.check(false, true)) { - LOG.info("Service compliant !"); - String serviceName = input.getServiceDeleteReqInfo().getServiceName(); - Services service = readServiceList(serviceName); - if (service != null) { - LOG.debug("Service '" + serviceName + "' present in datastore !"); - /* - * If compliant, service-delete order is send to renderer. - */ - mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, - input.getSdncRequestHeader().getRequestId(), input.getServiceDeleteReqInfo().getServiceName()); - - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceDeleteResult).setServiceName(serviceName) - .setStatus(RpcStatusEx.Pending) - .setStatusMessage("Service compliant, submitting serviceDelete Request ...").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - FutureCallback rendererCallback = - new FutureCallback() { - String message = ""; - String responseCode = ""; - ServiceRpcResult notification = null; - - @Override - public void onFailure(Throwable arg0) { - LOG.error("ServiceDelete Request failed !"); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceDeleteResult) - .setServiceName(serviceName).setStatus(RpcStatusEx.Failed) - .setStatusMessage("ServiceDelete Request failed !").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - } - - @Override - public void onSuccess(org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce - .stubrenderer.rev170426.ServiceDeleteOutput arg0) { - - if (mappingAndSendingPCRequest.getSuccess() && arg0 != null) { - message = "Service deleted !"; - LOG.info(message); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceDeleteResult) - .setServiceName(input.getServiceDeleteReqInfo().getServiceName()) - .setStatus(RpcStatusEx.Successful).setStatusMessage("Service deleted !").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - - // message = - // result.getConfigurationResponseCommon().getResponseMessage(); - responseCode = arg0.getConfigurationResponseCommon().getResponseCode(); - /* - * Service delete confirmed deleting service from - * database - */ - if (writeOrModifyOrDeleteServiceList(input.getServiceDeleteReqInfo().getServiceName(), null, - null, 1) == null) { - /* Service delete. */ - StringBuilder build = new StringBuilder(); - build.append(message); - build.append(" : Service deleted from database"); - message = build.toString(); - } else { - StringBuilder build = new StringBuilder(); - build.append(message); - build.append(" but Failed to delete service from database !"); - message = build.toString(); - } - LOG.info(message); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceDeleteResult) - .setServiceName(input.getServiceDeleteReqInfo().getServiceName()) - .setStatus(RpcStatusEx.Successful).setStatusMessage(message).build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - } else { - message = "deleting service failed"; - responseCode = "500"; - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceDeleteResult) - .setServiceName(input.getServiceDeleteReqInfo().getServiceName()) - .setStatus(RpcStatusEx.Failed).setStatusMessage(message).build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - } - } - }; - ListenableFuture renderer = - mappingAndSendingSIRequest.serviceDelete(); - Futures.addCallback(renderer, rendererCallback); + .setConfigurationResponseCommon(configurationResponseCommon); + + return RpcResultBuilder.success(output.build()).buildFuture(); + + } + + @Override + public Future> serviceDelete(ServiceDeleteInput input) { + LOG.info("RPC serviceDelete request received for Service '" + input.getServiceDeleteReqInfo().getServiceName() + + "'"); + setServiceDeleteInput(input); + setServiceReconfigureInput(null); + serviceCreateInput = null; + service = null; + String message = ""; + String responseCode = ""; + LOG.info("checking Service Compliancy ..."); + /** + * Upon receipt of service-delete RPC, service header and sdnc-request + * header compliancy are verified. + */ + compliancyCheck = new ServicehandlerCompliancyCheck(input.getSdncRequestHeader(), + input.getServiceDeleteReqInfo().getServiceName(), RpcActions.ServiceDelete); + if (compliancyCheck.check(false, true)) { + LOG.info("Service compliant !"); + String serviceName = input.getServiceDeleteReqInfo().getServiceName(); + Services service = readServiceList(serviceName); + if (service != null) { + LOG.debug("Service '" + serviceName + "' present in datastore !"); + stubrendererDelete(); LOG.info("ServiceDelete Request in progress ... "); ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder() .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId()) @@ -680,18 +966,14 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene return RpcResultBuilder.success(output).buildFuture(); } else { message = "Service '" + serviceName + "' not exists in datastore"; - LOG.error(message); + LOG.info(message); } } else { message = "Service not compliant !"; responseCode = "500"; + LOG.info(message); } - - /* - * Building output response. - */ - ConfigurationResponseCommon configurationResponseCommon = new ConfigurationResponseCommonBuilder() .setAckFinalIndicator("Yes").setRequestId(input.getSdncRequestHeader().getRequestId()) .setResponseMessage(message).setResponseCode(responseCode).build(); @@ -703,32 +985,47 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene @Override public Future> serviceFeasibilityCheck( ServiceFeasibilityCheckInput input) { - notificationUrl = null;// input.getSdncRequestHeader().getnotificationUrl(); action = RpcActions.ServiceFeasibilityCheck; LOG.info("RPC service feasibilityCheck received"); - boolean commonId = true; - boolean coherencyHardSoft = false; - ServiceRpcResult notification = null; - String name = "no name"; mappingAndSendingPCRequest = null; + serviceFeasibilityCheckInput = input; + serviceCreateInput = null; + serviceDeleteInput = null; + service = null; + serviceReconfigureInput = null; ConfigurationResponseCommon configurationResponseCommon = null; String message = ""; String responseCode = ""; LOG.info("checking Service Compliancy ..."); - /* + /** * Upon receipt of service-create RPC, service header and sdnc-request * header compliancy are verified. */ - compliancyCheck = new ServicehandlerCompliancyCheck(input.getSdncRequestHeader(), name, + String name = "no name"; + String serviceCompliancy = null; + if ((serviceCompliancy = serviceCompliancy(input.getSdncRequestHeader(), name, input.getConnectionType(), + RpcActions.ServiceFeasibilityCheck, input.getServiceAEnd(), input.getServiceZEnd(), input.getCommonId(), + input.getHardConstraints(), input.getSoftConstraints())) != null) { + message = "Service not compliant : " + serviceCompliancy; + LOG.info(message); + } else { + LOG.info("Service compliant !"); + pcePathComputation(input); + LOG.info("PCR Request in progress "); + configurationResponseCommon = new ConfigurationResponseCommonBuilder() + .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId()) + .setResponseMessage("Service compliant, ServiceFeasibilityCheck in progress...") + .setResponseCode("200").build(); + + ServiceFeasibilityCheckOutput output = new ServiceFeasibilityCheckOutputBuilder() + .setConfigurationResponseCommon(configurationResponseCommon).build(); + return RpcResultBuilder.success(output).buildFuture(); + } + /*compliancyCheck = new ServicehandlerCompliancyCheck(input.getSdncRequestHeader(), name, input.getConnectionType(), RpcActions.ServiceFeasibilityCheck); if (compliancyCheck.check(true, true)) { LOG.info("Service compliant !"); - /* - * If compliant, service-request parameters are verified in order to - * check if there is no missing parameter that prevents calculating - * a path and implement a service. - */ LOG.info("checking Tx/Rx Info for AEnd ..."); txrxCheck = new ServicehandlerTxRxCheck(input.getServiceAEnd(), 1); if (txrxCheck.check()) { @@ -737,19 +1034,8 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene txrxCheck = new ServicehandlerTxRxCheck(input.getServiceZEnd(), 2); if (txrxCheck.check()) { LOG.info("Tx/Rx Info for ZEnd checked"); - /* - * If OK, common-id is verified in order to see if there is - * no routing policy provided. If yes, the routing - * constraints of the policy are recovered and coherency - * with hard/soft constraints provided in the input of the - * RPC. - */ if (input.getCommonId() != null) { LOG.info("Common-id specified"); - /* - * Check coherency with hard/soft constraints - */ - checkCoherencyHardSoft = new CheckCoherencyHardSoft(input.getHardConstraints(), input.getSoftConstraints()); if (checkCoherencyHardSoft.check()) { @@ -765,94 +1051,7 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene } if (!commonId || (commonId && coherencyHardSoft)) { - /* - * Before sending the PCE request, input data need to be - * formatted according to the Service Handler - PCE - * interface data model. - */ - mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, input, false); - /* - * Once PCE request is being sent to the PCE on - * interface B, PCE reply is expected until a timer - * expires. - */ - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceCreateResult).setServiceName(name) - .setStatus(RpcStatusEx.Pending) - .setStatusMessage("Service compliant, Submitting PathComputation Request ...").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - - FutureCallback pceCallback = - new FutureCallback() { - String message = ""; - String responseCode = ""; - ServiceRpcResult notification = null; - - @Override - public void onFailure(Throwable arg0) { - LOG.error("Path not calculated.."); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceCreateResult) - .setServiceName(name).setStatus(RpcStatusEx.Failed) - .setStatusMessage("PCR Request failed !").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - - } - - @Override - public void onSuccess(PathComputationRequestOutput response) { - - if (mappingAndSendingPCRequest.getSuccess() && response != null) { - /* - * If PCE reply is received before timer - * expiration with a positive result, a - * service is created with admin and - * operational status 'down'. - */ - LOG.info("PCE replied to PCR Request !"); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceCreateResult) - .setServiceName("").setStatus(RpcStatusEx.Successful) - .setStatusMessage("Service Feasility Checked").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - message = response.getConfigurationResponseCommon().getResponseMessage(); - sendNotifToUrl(notification, notificationUrl); - } else { - message = mappingAndSendingPCRequest.getError();// "Path - // not - // calculated"; - responseCode = "500"; - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceCreateResult) - .setServiceName("").setStatus(RpcStatusEx.Failed).setStatusMessage(message) - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - } - } - - }; - ListenableFuture pce = mappingAndSendingPCRequest - .pathComputationRequest(); - Futures.addCallback(pce, pceCallback); + pcePathComputation(input); LOG.info("PCR Request in progress "); configurationResponseCommon = new ConfigurationResponseCommonBuilder() .setAckFinalIndicator("No").setRequestId(input.getSdncRequestHeader().getRequestId()) @@ -861,9 +1060,7 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene ServiceFeasibilityCheckOutput output = new ServiceFeasibilityCheckOutputBuilder() .setConfigurationResponseCommon(configurationResponseCommon).build(); - return RpcResultBuilder.success(output).buildFuture(); - } } else { message = txrxCheck.getMessage(); @@ -876,81 +1073,61 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene } else { message = compliancyCheck.getMessage(); responseCode = "500"; - } - + }*/ configurationResponseCommon = new ConfigurationResponseCommonBuilder().setAckFinalIndicator("Yes") .setRequestId(input.getSdncRequestHeader().getRequestId()).setResponseMessage(message) .setResponseCode(responseCode).build(); - - ResponseParameters responseParameters = new ResponseParametersBuilder() - .setHardConstraints(input.getHardConstraints()) - // .setPceMetric(input.getPceMetric()) - .setSoftConstraints(input.getSoftConstraints()) - // .setLocallyProtectedLinks(input.isLocallyProtectedLinks()) - .build(); - - org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.service.feasibility - .check.output.ServiceAEnd serviceAEnd = new org.opendaylight.yang.gen.v1.http.org.opendaylight - .transportpce.servicehandler.rev161014.service.feasibility - .check.output.ServiceAEndBuilder(input.getServiceAEnd()).build(); - - org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.service.feasibility - .check.output.ServiceZEnd serviceZEnd = new org.opendaylight.yang.gen.v1.http.org.opendaylight - .transportpce.servicehandler.rev161014.service.feasibility - .check.output.ServiceZEndBuilder(input.getServiceZEnd()).build(); - - /* TxDirection. */ - Port txPort = new PortBuilder().setPortDeviceName("ROUTER_SNJSCAMCJW1_000000.00_00").setPortType("router") - .setPortName("Gigabit Ethernet_Tx.ge-1/0/0.0").setPortRack("000000.00").setPortShelf("00").build(); - Lgx txLgx = new LgxBuilder().setLgxDeviceName("LGX Panel_SNJSCAMCJW1_000000.00_00") - .setLgxPortName("LGX_Back.23").setLgxPortRack("000000.00").setLgxPortShelf("00").build(); - TxDirection txDirection = new TxDirectionBuilder().setPort(txPort).setLgx(txLgx).build(); - - /* RxDirection. */ - Port rxPort = new PortBuilder().setPortDeviceName("ROUTER_SNJSCAMCJW1_000000.00_00").setPortType("router") - .setPortName("Gigabit Ethernet_Rx.ge-1/0/0.0").setPortRack("000000.00").setPortShelf("00").build(); - Lgx rxLgx = new LgxBuilder().setLgxDeviceName("LGX Panel_SNJSCAMCJW1_000000.00_00").setLgxPortName("LGX_Back.6") - .setLgxPortRack("000000.00").setLgxPortShelf("00").build(); - RxDirection rxDirection = new RxDirectionBuilder().setPort(rxPort).setLgx(rxLgx).build(); - - IntermediateSites inter = new IntermediateSitesBuilder().setClli("SNJSCAMCJW1").setServiceRate((long) 100) - .setServiceFormat(ServiceFormat.Ethernet).setOpticType(OpticTypes.Gray).setTxDirection(txDirection) - .setRxDirection(rxDirection).build(); - - List intersites = new ArrayList(); - intersites.add(inter); ServiceFeasibilityCheckOutput output = new ServiceFeasibilityCheckOutputBuilder() - .setIntermediateSites(intersites).setResponseParameters(responseParameters) - .setConfigurationResponseCommon(configurationResponseCommon).setServiceAEnd(serviceAEnd) - .setServiceZEnd(serviceZEnd).build(); + .setConfigurationResponseCommon(configurationResponseCommon).build(); return RpcResultBuilder.success(output).buildFuture(); } @Override public Future> serviceReconfigure(ServiceReconfigureInput input) { - LOG.info("RPC service reconfigure received"); - notificationUrl = null;// input.getnotificationUrl(); - boolean commonId = true; - boolean coherencyHardSoft = false; - ServiceRpcResult notification = null; - + setServiceReconfigureInput(input); + setServiceDeleteInput(null); + serviceCreateInput = null; + service = null; String message = ""; LOG.info("checking Service Compliancy ..."); - /* + /** * Upon receipt of service-create RPC, service header and sdnc-request * header compliancy are verified. */ - compliancyCheck = new ServicehandlerCompliancyCheck(input.getServiceName(), input.getConnectionType(), + String serviceCompliancy = null; + if ((serviceCompliancy = serviceCompliancy(null, input.getServiceName(), input.getConnectionType(), + RpcActions.ServiceReconfigure, input.getServiceAEnd(), input.getServiceZEnd(), input.getCommonId(), + input.getHardConstraints(), input.getSoftConstraints())) != null) { + message = "Service not compliant : " + serviceCompliancy; + LOG.info(message); + } else { + LOG.info("Service compliant !"); + /** + * Retrieving initial service topology. + */ + String serviceName = input.getServiceName(); + Services service = readServiceList(serviceName); + if (service != null) { + LOG.debug("Service '" + serviceName + "' present in datastore !"); + /** + * Sending cancel resource reserve request to PCE. + */ + pceCancelResResource(); + ServiceReconfigureOutput output = new ServiceReconfigureOutputBuilder() + .setStatus(RpcStatus.Successful) + .setStatusMessage("ServiceReconfigure in progress ...").build(); + return RpcResultBuilder.success(output).buildFuture(); + } else { + message = "Service '" + serviceName + "' not exists in datastore"; + LOG.info(message); + } + } + /*compliancyCheck = new ServicehandlerCompliancyCheck(input.getServiceName(), input.getConnectionType(), RpcActions.ServiceReconfigure); if (compliancyCheck.check(true, false)) { LOG.info("Service compliant !"); - /* - * If compliant, service-request parameters are verified in order to - * check if there is no missing parameter that prevents calculating - * a path and implement a service. - */ LOG.info("checking Tx/Rx Info for AEnd ..."); txrxCheck = new ServicehandlerTxRxCheck(input.getServiceAEnd(), 1); if (txrxCheck.check()) { @@ -959,19 +1136,8 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene txrxCheck = new ServicehandlerTxRxCheck(input.getServiceZEnd(), 2); if (txrxCheck.check()) { LOG.info("Tx/Rx Info for ZEnd checked"); - /* - * If OK, common-id is verified in order to see if there is - * no routing policy provided. If yes, the routing - * constraints of the policy are recovered and coherency - * with hard/soft constraints provided in the input of the - * RPC. - */ if (input.getCommonId() != null) { LOG.info("Common-id specified"); - /* - * Check coherency with hard/soft constraints - */ - checkCoherencyHardSoft = new CheckCoherencyHardSoft(input.getHardConstraints(), input.getSoftConstraints()); if (checkCoherencyHardSoft.check()) { @@ -986,334 +1152,15 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene } if (!commonId || (commonId && coherencyHardSoft)) { - /* - * Retrieving initial service topology. - */ String serviceName = input.getServiceName(); Services service = readServiceList(serviceName); if (service != null) { LOG.debug("Service '" + serviceName + "' present in datastore !"); - /* - * Sending cancel resource resv request to PCE - */ - - mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, input, false); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceReconfigureResult) - .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending) - .setStatusMessage("Cancelling ResourceResv ...").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - FutureCallback pceCallback = - new FutureCallback() { - String message = ""; - String responseCode = ""; - ServiceRpcResult notification = null; - - @Override - public void onFailure(Throwable arg0) { - LOG.error("Failed to cancel ResourceResv ! "); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceCreateResult) - .setServiceName(serviceName).setStatus(RpcStatusEx.Failed) - .setStatusMessage("PCR Request failed !").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - - } - - @Override - public void onSuccess(CancelResourceReserveOutput arg0) { - if (mappingAndSendingPCRequest.getSuccess() && arg0 != null) { - LOG.info("Service ResourceResv cancelled !"); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceReconfigureResult) - .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending) - .setStatusMessage( - "Service '" + serviceName + "' ResourceResv cancelled") - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - - message = "Service '" + serviceName + "' ResourceResv cancelled"; - - LOG.info("PCE replied to CancelResourceResv Request !"); - /* - * Before sending the PCE request, input - * data need to be formatted according - * to the Service Handler - PCE - * interface data model. - */ - mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, input, - true); - /* - * Once PCE request is being sent to the - * PCE on interface B, PCE reply is - * expected until a timer expires. - */ - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceReconfigureResult) - .setServiceName(serviceName).setStatus(RpcStatusEx.Pending) - .setStatusMessage(message + ", submitting PathComputation Request ...") - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - PathComputationRequestOutput response = null; - try { - response = mappingAndSendingPCRequest.pathComputationRequest().get(); - } catch (InterruptedException | ExecutionException e2) { - LOG.error(e2.getMessage()); - } - - if (mappingAndSendingPCRequest.getSuccess() && response != null) { - /* - * If PCE reply is received before - * timer expiration with a positive - * result, a service is created with - * admin and operational status - * 'down'. - */ - LOG.info("PCE replied to PCR Request !"); - message = response.getConfigurationResponseCommon().getResponseMessage(); - notification = new ServiceRpcResultBuilder() - .setNotificationType( - ServiceNotificationTypes.ServiceReconfigureResult) - .setServiceName(serviceName).setStatus(RpcStatusEx.Pending) - .setStatusMessage("PCE replied to PCR Request !").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - /* - * Send Implementation order to - * renderer - */ - mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, - input, response); - - notification = new ServiceRpcResultBuilder() - .setNotificationType( - ServiceNotificationTypes.ServiceReconfigureResult) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Pending) - .setStatusMessage("Submitting ServiceImplementation Request ...") - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - - ServiceImplementationRequestOutput siOutput = null; - try { - siOutput = mappingAndSendingSIRequest.serviceImplementation().get(); - } catch (InterruptedException | ExecutionException e2) { - LOG.error(e2.getMessage()); - } - ConfigurationResponseCommon siCommon = siOutput - .getConfigurationResponseCommon(); - message = siCommon.getResponseMessage(); - - if (mappingAndSendingSIRequest.getSuccess() && siOutput != null) { - message = "Service reconfigured "; - LOG.info("Service reconfigured !"); - notification = new ServiceRpcResultBuilder() - .setNotificationType( - ServiceNotificationTypes.ServiceReconfigureResult) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Pending) - .setStatusMessage("Service reconfigure !").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - /* - * Service implemented Update in - * DB. - */ - Boolean update = false; - Boolean delete = false; - Services modifService = mappingServices(null, input, response); - InstanceIdentifier iid = InstanceIdentifier - .create(ServiceList.class) - .child(Services.class, new ServicesKey(serviceName)); - WriteTransaction writeTx = db.newWriteOnlyTransaction(); - writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid); - try { - LOG.info("Deleting service info ..."); - writeTx.submit().checkedGet(); - delete = true; - } catch (TransactionCommitFailedException e) { - LOG.error("Failed to delete service from Service List"); - } - if (delete) { - iid = InstanceIdentifier.create(ServiceList.class).child( - Services.class, new ServicesKey(input.getNewServiceName())); - writeTx = db.newWriteOnlyTransaction(); - writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, modifService); - try { - LOG.info("Updating service info ..."); - writeTx.submit().checkedGet(); - update = true; - } catch (TransactionCommitFailedException e) { - LOG.error("Failed to modify service from Service List"); - } - } - if (update) { - LOG.info("Service '" + serviceName + "' updated with new name '" - + input.getNewServiceName() + "' ! "); - StringBuilder build = new StringBuilder(); - build.append(message); - build.append(" : Service updated on DataBase !"); - message = build.toString(); - } else { - LOG.info("Service '" + serviceName + "' update failed ! "); - StringBuilder build = new StringBuilder(); - build.append(message); - build.append(" : Failed to modify service from Service List "); - message = build.toString(); - } - } else { - LOG.info("Service not implemented !"); - message = response.getConfigurationResponseCommon() - .getResponseMessage(); - notification = new ServiceRpcResultBuilder() - .setNotificationType( - ServiceNotificationTypes.ServiceReconfigureResult) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Failed) - .setStatusMessage( - "Service not implemented, cancelling ResourceResv") - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, - input, false); - /* - * Send Cancel resource Request - * to PCE. - */ - CancelResourceReserveOutput cancelOuptut = null; - try { - cancelOuptut = mappingAndSendingPCRequest.cancelResourceReserve() - .get(); - } catch (InterruptedException | ExecutionException e1) { - LOG.error(e1.getMessage()); - } - if (mappingAndSendingPCRequest.getSuccess() && cancelOuptut != null) { - LOG.info("Service ResourceResv cancelled !"); - message = response.getConfigurationResponseCommon() - .getResponseMessage(); - notification = new ServiceRpcResultBuilder() - .setNotificationType( - ServiceNotificationTypes.ServiceReconfigureResult) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Failed) - .setStatusMessage("Service ResourceResv cancelled").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - - message = cancelOuptut.getConfigurationResponseCommon() - .getResponseMessage(); - - StringBuilder build = new StringBuilder(); - build.append("Service not implemented - "); - build.append(message); - message = build.toString(); - - LOG.info("PCE replied to CancelResourceResv Request !"); - } else { - message = "Cancelling Resource reserved failed "; - LOG.info(message); - StringBuilder build = new StringBuilder(); - build.append("Service not implemented - "); - build.append(message); - message = build.toString(); - - message = response.getConfigurationResponseCommon() - .getResponseMessage(); - notification = new ServiceRpcResultBuilder() - .setNotificationType( - ServiceNotificationTypes.ServiceReconfigureResult) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Failed) - .setStatusMessage("Cancelling Resource reserved failed") - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - } - } - - } else { - LOG.error("PCE pathcomputation request failed !"); - message = "PCE pathcomputation request failed : " - + mappingAndSendingPCRequest.getError();// "Path - // not - // calculated"; - } - } else { - message = "Cancelling Resource reserved failed "; - LOG.info(message); - StringBuilder build = new StringBuilder(); - build.append("Service not implemented - "); - build.append(message); - message = build.toString(); - - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceReconfigureResult) - .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) - .setStatusMessage("Cancelling Resource reserved failed").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - } - - } - }; - ListenableFuture pce = mappingAndSendingPCRequest - .cancelResourceReserve(); - Futures.addCallback(pce, pceCallback); - LOG.info("CancelResRev Request in progress "); + pceCancelResResource(); ServiceReconfigureOutput output = new ServiceReconfigureOutputBuilder() - .setStatus(RpcStatusEx.Pending).setStatusMessage(message).build(); - + .setStatus(RpcStatusEx.Pending) + .setStatusMessage("ServiceReconfigure in progress ...").build(); return RpcResultBuilder.success(output).buildFuture(); - } else { message = "Service '" + serviceName + "' not exists in datastore"; LOG.error(message); @@ -1327,33 +1174,34 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene } } else { message = compliancyCheck.getMessage(); - } + }*/ - ServiceReconfigureOutput output = new ServiceReconfigureOutputBuilder().setStatus(RpcStatusEx.Successful) + ServiceReconfigureOutput output = new ServiceReconfigureOutputBuilder().setStatus(RpcStatus.Successful) .setStatusMessage(message).build(); - return RpcResultBuilder.success(output).buildFuture(); } @Override public Future> serviceRestoration(ServiceRestorationInput input) { LOG.info("RPC service restoration received"); - ServiceRpcResult notification = null; - notificationUrl = null;// input.getnotificationUrl(); + ServiceRpcResultSh notification = null; + setServiceDeleteInput(null); + setServiceReconfigureInput(null); + notificationUrl = null; String message = ""; LOG.info("checking Service Compliancy ..."); compliancyCheck = new ServicehandlerCompliancyCheck(input.getServiceName(), RpcActions.ServiceRestoration); if (compliancyCheck.check(false, false)) { LOG.info("Service compliant !"); - /* + /** * If compliant, Getting path from service DB. */ - String serviceName = input.getServiceName(); Services service = readServiceList(serviceName); if (service != null) { + this.service = service; LOG.debug("Service '" + serviceName + "' present in datastore !"); - notification = new ServiceRpcResultBuilder() + notification = new ServiceRpcResultShBuilder() .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult) .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending) .setStatusMessage("Service '" + serviceName + "' present in datastore, deleting service ...") @@ -1363,315 +1211,40 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene } catch (InterruptedException e) { LOG.info("notification offer rejected : " + e); } - sendNotifToUrl(notification, notificationUrl); - /* - * Sending delete order to renderer - */ - mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, null, input.getServiceName()); - - ListenableFuture renderer = - mappingAndSendingSIRequest.serviceDelete(); - FutureCallback rendererCallback = - new FutureCallback() { - String message = ""; - String responseCode = ""; - ServiceRpcResult notification = null; - - @Override - public void onFailure(Throwable arg0) { - LOG.error("ServiceDelete Request failed !"); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult) - .setServiceName(serviceName).setStatus(RpcStatusEx.Failed) - .setStatusMessage("ServiceDelete Request failed !").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - } - - @Override - public void onSuccess(org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce - .stubrenderer.rev170426.ServiceDeleteOutput arg0) { - if (arg0 != null) { - message = arg0.getConfigurationResponseCommon().getResponseMessage(); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult) - .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending) - .setStatusMessage("Service deleted !").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, service, true); - /* - * Once PCE request is being sent to the PCE on - * interface B, PCE reply is expected until a timer - * expires. - */ - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult) - .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending) - .setStatusMessage("Service deleted, submitting PathComputation Request ...") - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - PathComputationRequestOutput response = null; - try { - response = mappingAndSendingPCRequest.pathComputationRequest().get(); - } catch (InterruptedException | ExecutionException e2) { - LOG.error(e2.getMessage()); - } - - if (mappingAndSendingPCRequest.getSuccess() && response != null) { - /* - * If PCE reply is received before timer - * expiration with a positive result, a service - * is created with admin and operational status - * 'down'. - */ - LOG.info("Path calculated !"); - message = response.getConfigurationResponseCommon().getResponseMessage(); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult) - .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending) - .setStatusMessage("Path calculated, modifying Service Admin / Op ...").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - - /* - * creating Service with Admin / Op to down. - * - */ - - ServicesBuilder serviceRestoration = new ServicesBuilder(service) - .setAdministrativeState(State.OutOfService) - .setOperationalState(State.OutOfService) - .setLifecycleState(LifecycleState.Planned); - - org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface - .service.types.rev170426.response - .parameters.sp.ResponseParameters responseParameters = - response.getResponseParameters(); - if (responseParameters != null) { - // serviceRestoration.setPceMetric(responseParameters.getPceMetric()); - org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface - .service.types.rev170426.response.parameters.sp.response - .parameters.PathDescription pathDescription = - responseParameters.getPathDescription(); - if (pathDescription != null) { - List atozList = new ArrayList(); - List ztoaList = new ArrayList(); - - for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface - .pathdescription.rev170426.path.description.atoz.direction.AToZ - tmp : pathDescription.getAToZDirection().getAToZ()) { - - AToZKey key = new AToZKey(tmp.getKey().getId()); - tmp.getResource().getResource(); - AToZ atoz = new AToZBuilder().setId(tmp.getId()).setKey(key) - // .setResource(tmp.getResource()) - .build(); - atozList.add(atoz); - } - - for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface - .pathdescription.rev170426.path.description.ztoa.direction.ZToA - tmp : pathDescription.getZToADirection().getZToA()) { - ZToAKey key = new ZToAKey(tmp.getKey().getId()); - ZToA ztoa = new ZToABuilder().setId(tmp.getId()).setKey(key) - // .setResource(tmp.getResource()) - .build(); - ztoaList.add(ztoa); - } - Topology topology = new TopologyBuilder().setAToZ(atozList).setZToA(ztoaList) - .build(); - serviceRestoration.setTopology(topology); - } - } - Boolean update = false; - InstanceIdentifier iid = InstanceIdentifier.create(ServiceList.class) - .child(Services.class, new ServicesKey(serviceName)); - WriteTransaction writeTx = db.newWriteOnlyTransaction(); - writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, service); - - try { - writeTx.submit().checkedGet(); - update = true; - } catch (TransactionCommitFailedException e) { - LOG.error("Failed to modify service from Service List"); - } - if (update) { - LOG.info("Service modified !"); - /* - * Send Implementation order to renderer - */ - mappingAndSendingSIRequest = new MappingAndSendingSIRequest(rpcRegistry, service); - - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult) - .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending) - .setStatusMessage( - "Service modified, submitting ServiceImplementation Request") - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - - ServiceImplementationRequestOutput siOutput = null; - try { - siOutput = mappingAndSendingSIRequest.serviceImplementation().get(); - } catch (InterruptedException | ExecutionException e2) { - LOG.error(e2.getMessage()); - } - if (mappingAndSendingSIRequest.getSuccess() && siOutput != null) { - ConfigurationResponseCommon siCommon = siOutput - .getConfigurationResponseCommon(); - message = siCommon.getResponseMessage(); - LOG.info("Service restored !"); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult) - .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Pending) - .setStatusMessage("Service restored !").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - /* - * Service implemented setting Service - * op status to up - */ - if (writeOrModifyOrDeleteServiceList(serviceName, null, null, 0) == null) { - message = "Service restored : Service Op Status changed to Up !"; - } else { - message = "Service restored : " - + "but Failed to modify service from Service List !"; - } - } else { - LOG.info("Service not restored !"); - message = response.getConfigurationResponseCommon().getResponseMessage(); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceRestorationResult) - .setServiceName(input.getServiceName()).setStatus(RpcStatusEx.Failed) - .setStatusMessage("Service not restored, cancelling ResourceResv ...") - .build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - mappingAndSendingPCRequest = new MappingAndSendingPCRequest(rpcRegistry, - service, false); - /* - * Send Cancel resource Request to PCE. - */ - CancelResourceReserveOutput cancelOuptut = null; - try { - cancelOuptut = mappingAndSendingPCRequest.cancelResourceReserve().get(); - } catch (InterruptedException | ExecutionException e1) { - LOG.error(e1.getMessage()); - } - if (mappingAndSendingPCRequest.getSuccess() && cancelOuptut != null) { - LOG.info("Service ResourceResv cancelled !"); - message = response.getConfigurationResponseCommon().getResponseMessage(); - notification = new ServiceRpcResultBuilder() - .setNotificationType( - ServiceNotificationTypes.ServiceRestorationResult) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Pending) - .setStatusMessage("Service ResourceResv cancelled").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - message = cancelOuptut.getConfigurationResponseCommon() - .getResponseMessage(); - StringBuilder build = new StringBuilder(); - build.append("Service not implemented - "); - build.append(message); - message = build.toString(); - LOG.info("PCE replied to CancelResourceResv Request !"); - } else { - message = "Cancelling Resource reserved failed "; - LOG.info(message); - StringBuilder build = new StringBuilder(); - build.append("Service not implemented - "); - build.append(message); - message = build.toString(); - message = response.getConfigurationResponseCommon().getResponseMessage(); - notification = new ServiceRpcResultBuilder() - .setNotificationType(ServiceNotificationTypes.ServiceCreateResult) - .setServiceName(input.getServiceName()) - .setStatus(RpcStatusEx.Failed) - .setStatusMessage("Cancelling Resource reserved failed").build(); - try { - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected : " + e); - } - sendNotifToUrl(notification, notificationUrl); - } - } - } else { - LOG.error("Failed to modify service from service list !"); - } - } else { - message = mappingAndSendingPCRequest.getError(); - /* Path not calculated. */ - LOG.error("Path Computation request failed : " + message); - } - } else { - message = "deleting service failed"; - LOG.error(message); - } - } - }; - Futures.addCallback(renderer, rendererCallback); - ServiceRestorationOutput output = new ServiceRestorationOutputBuilder().setStatus(RpcStatusEx.Pending) - .setStatusMessage(message).build(); - + stubrendererDelete(); + LOG.info("PCR Request in progress "); + ServiceRestorationOutput output = new ServiceRestorationOutputBuilder() + .setStatus(RpcStatus.Successful) + .setStatusMessage("ServiceRestoration in progress...").build(); return RpcResultBuilder.success(output).buildFuture(); - } else { message = "Service '" + serviceName + "' not exists in datastore"; LOG.error(message); } - } else { message = compliancyCheck.getMessage(); LOG.error(message); } - ServiceRestorationOutput output = new ServiceRestorationOutputBuilder().setStatus(RpcStatusEx.Successful) + ServiceRestorationOutput output = new ServiceRestorationOutputBuilder().setStatus(RpcStatus.Successful) .setStatusMessage(message).build(); return RpcResultBuilder.success(output).buildFuture(); } - /* + @Override + public Future> tempServiceDelete(TempServiceDeleteInput input) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Future> tempServiceCreate(TempServiceCreateInput input) { + // TODO Auto-generated method stub + return null; + } + + /** * Initialize ServiceList Structure on Datastore. * * @param DataBroker @@ -1683,12 +1256,16 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene InstanceIdentifier iid = InstanceIdentifier.create(ServiceList.class); ServiceList greetingRegistry = new ServiceListBuilder().build(); transaction.put(LogicalDatastoreType.OPERATIONAL, iid, greetingRegistry); - CheckedFuture future = transaction.submit(); - Futures.addCallback(future, new LoggingFuturesCallBack<>("Failed to create Service List", LOG)); + Future future = transaction.submit(); + try { + Futures.getChecked(future, ExecutionException.class); + } catch (ExecutionException e) { + LOG.error("Failed to create Service List"); + } } - /* - * Map Input (ServiceCreateInmput, ServiceReconfigureInput) & output + /** + * Map Input (ServiceCreateInmput, ServiceReconfigureInput) and output * (PathComputationRequestOutput) to Service. * * @param serviceCreateInput @@ -1710,26 +1287,27 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene aend = new ServiceAEndBuilder(serviceCreateInput.getServiceAEnd()).build(); zend = new ServiceZEndBuilder(serviceCreateInput.getServiceZEnd()).build(); service.setServiceName(serviceCreateInput.getServiceName()).setAdministrativeState(State.OutOfService) - .setOperationalState(State.OutOfService).setCommonId(serviceCreateInput.getCommonId()) - .setConnectionType(serviceCreateInput.getConnectionType()) - .setCustomer(serviceCreateInput.getCustomer()) - .setCustomerContact(serviceCreateInput.getCustomerContact()) - .setHardConstraints(serviceCreateInput.getHardConstraints()) - .setSoftConstraints(serviceCreateInput.getSoftConstraints()) - .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend); + .setOperationalState(State.OutOfService).setCommonId(serviceCreateInput.getCommonId()) + .setConnectionType(serviceCreateInput.getConnectionType()) + .setCustomer(serviceCreateInput.getCustomer()) + .setCustomerContact(serviceCreateInput.getCustomerContact()) + .setHardConstraints(serviceCreateInput.getHardConstraints()) + .setSoftConstraints(serviceCreateInput.getSoftConstraints()) + .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend) + .setSdncRequestHeader(serviceCreateInput.getSdncRequestHeader()); } else if (serviceReconfigureInput != null) { aend = new ServiceAEndBuilder(serviceReconfigureInput.getServiceAEnd()).build(); zend = new ServiceZEndBuilder(serviceReconfigureInput.getServiceZEnd()).build(); service.setServiceName(serviceReconfigureInput.getNewServiceName()) - .setAdministrativeState(State.OutOfService).setOperationalState(State.OutOfService) - .setCommonId(serviceReconfigureInput.getCommonId()) - .setConnectionType(serviceReconfigureInput.getConnectionType()) - .setCustomer(serviceReconfigureInput.getCustomer()) - .setCustomerContact(serviceReconfigureInput.getCustomerContact()) - .setHardConstraints(serviceReconfigureInput.getHardConstraints()) - .setSoftConstraints(serviceReconfigureInput.getSoftConstraints()) - .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend); + .setAdministrativeState(State.OutOfService).setOperationalState(State.OutOfService) + .setCommonId(serviceReconfigureInput.getCommonId()) + .setConnectionType(serviceReconfigureInput.getConnectionType()) + .setCustomer(serviceReconfigureInput.getCustomer()) + .setCustomerContact(serviceReconfigureInput.getCustomerContact()) + .setHardConstraints(serviceReconfigureInput.getHardConstraints()) + .setSoftConstraints(serviceReconfigureInput.getSoftConstraints()) + .setLifecycleState(LifecycleState.Planned).setServiceAEnd(aend).setServiceZEnd(zend); } org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426.response @@ -1738,14 +1316,14 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene // service.setPceMetric(responseParameters.getPceMetric()); org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev170426 .response.parameters.sp.response.parameters.PathDescription pathDescription = - responseParameters.getPathDescription(); + responseParameters.getPathDescription(); if (pathDescription != null) { List atozList = new ArrayList(); List ztoaList = new ArrayList(); for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426 - .path.description.atoz.direction.AToZ - tmp : pathDescription.getAToZDirection().getAToZ()) { + .path.description.atoz.direction.AToZ + tmp : pathDescription.getAToZDirection().getAToZ()) { AToZKey key = new AToZKey(tmp.getKey().getId()); AToZ atoz = new AToZBuilder().setId(tmp.getId()).setKey(key) @@ -1755,8 +1333,8 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene } for (org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev170426 - .path.description.ztoa.direction.ZToA - tmp : pathDescription.getZToADirection().getZToA()) { + .path.description.ztoa.direction.ZToA + tmp : pathDescription.getZToADirection().getZToA()) { ZToAKey key = new ZToAKey(tmp.getKey().getId()); ZToA ztoa = new ZToABuilder().setId(tmp.getId()).setKey(key) // .setResource(tmp.getResource()) @@ -1771,7 +1349,7 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene return service.build(); } - /* + /** * read Service from ServiceList DataStore. * * @param serviceName @@ -1784,12 +1362,11 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene ReadOnlyTransaction readTx = db.newReadOnlyTransaction(); InstanceIdentifier iid = InstanceIdentifier.create(ServiceList.class).child(Services.class, new ServicesKey(serviceName)); - CheckedFuture, ReadFailedException> future = readTx.read(LogicalDatastoreType.OPERATIONAL, - iid); + Future> future = readTx.read(LogicalDatastoreType.OPERATIONAL,iid); Optional optional = Optional.absent(); try { - optional = future.checkedGet(); - } catch (ReadFailedException e) { + optional = Futures.getChecked(future, ExecutionException.class); + } catch (ExecutionException e) { LOG.error("Reading service failed:", e); } if (optional.isPresent()) { @@ -1799,27 +1376,28 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene return result; } - /* - * Write or Modify or Delete Service from/to SreviceList. + /** + * Write or Modify or Delete Service from/to ServiceList. * * @param serviceName * Name of service - * @param input - * ServiceCreateInput * @param output * PathComputationRequestOutput + * @param topo + * Topology * @param choice * 0 - Modify 1 - Delete 2 - Write * @return String operations result, null if ok or not otherwise */ - private String writeOrModifyOrDeleteServiceList(String serviceName, ServiceCreateInput input, - PathComputationRequestOutput output, int choice) { - LOG.debug("WriteOrModifyOrDeleting '" + serviceName + "' Service"); + private String writeOrModifyOrDeleteServiceList(String serviceName, PathComputationRequestOutput output, + Topology topo, int choice) { + LOG.info("WriteOrModifyOrDeleting '" + serviceName + "' Service"); WriteTransaction writeTx = db.newWriteOnlyTransaction(); String result = null; Services readService = readServiceList(serviceName); + Future future = null; if (readService != null) { - /* + /** * Modify / Delete Service. */ InstanceIdentifier iid = InstanceIdentifier.create(ServiceList.class).child(Services.class, @@ -1828,82 +1406,57 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene String action = null; switch (choice) { - case 0: /* Modify. */ - LOG.debug("Modifying '" + serviceName + "' Service"); + case 0: /** Modify. */ + LOG.info("Modifying '" + serviceName + "' Service"); service.setOperationalState(State.InService).setAdministrativeState(State.InService); + service.setTopology(topo); writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, service.build()); action = "modify"; break; - case 1: /* Delete */ - LOG.debug("Deleting '" + serviceName + "' Service"); + case 1: /** Delete. */ + LOG.info("Deleting '" + serviceName + "' Service"); writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid); action = "delete"; break; default: - LOG.debug("No choice found"); + LOG.info("No choice found"); break; - } + future = writeTx.submit(); try { - writeTx.submit().checkedGet(); - } catch (TransactionCommitFailedException e) { - LOG.error("Failed to " + action + " service from Service List"); + Futures.getChecked(future, ExecutionException.class); + } catch (ExecutionException e) { + LOG.info("Failed to " + action + " service from Service List"); result = "Failed to " + action + " service from Service List"; } - } else { - if (choice == 2) { /* Write Service */ - LOG.debug("Writing '" + serviceName + "' Service"); - InstanceIdentifier iid = InstanceIdentifier.create(ServiceList.class).child(Services.class, - new ServicesKey(serviceName)); - - Services service = mappingServices(input, null, output); - writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, service); - try { - writeTx.submit().checkedGet(); - result = null; - } catch (TransactionCommitFailedException e) { - LOG.error("Failed to write service to Service List"); - result = "Failed to write service to Service List"; - } + } else if (choice == 2) { /** Write Service. */ + LOG.info("Writing '" + serviceName + "' Service"); + InstanceIdentifier iid = InstanceIdentifier.create(ServiceList.class).child(Services.class, + new ServicesKey(serviceName)); + Services writeService = null; + if (this.service != null) { + writeService = service; } else { - LOG.info("Service is not present ! "); - result = "Service is not present ! "; + writeService = mappingServices(serviceCreateInput, serviceReconfigureInput, output); + } + writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, writeService); + future = writeTx.submit(); + try { + Futures.getChecked(future, ExecutionException.class); + result = null; + } catch (ExecutionException e) { + LOG.error("Failed to write service to Service List"); + result = "Failed to write service to Service List"; } + } else { + LOG.info("Service is not present in datastore ! "); + result = "Service is not present in datastore ! "; } return result; } - private void sendNotifToUrl(ServiceRpcResult notification, String url) { - Gson gson = new GsonBuilder().setPrettyPrinting() - // .serializeNulls() - .create(); - String data = gson.toJson(notification); - URL obj; - try { - obj = new URL(url); - HttpURLConnection con = (HttpURLConnection) obj.openConnection(); - - // add request header - con.setRequestMethod("POST"); - con.setRequestProperty("Content-Type", "application/json"); - con.setRequestProperty("Accept", "application/json"); - - // Send post request - con.setDoOutput(true); - DataOutputStream wr = new DataOutputStream(con.getOutputStream()); - wr.writeBytes(data); - wr.flush(); - wr.close(); - int responseCode = con.getResponseCode(); - LOG.info("Response Code : " + responseCode); - } catch (IOException e) { - LOG.error("IOException : " + e.toString()); - } - - } - @Override public void close() throws Exception { executor.shutdown(); @@ -1945,61 +1498,115 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene return null; } - @Override - public Future> tempServiceDelete(TempServiceDeleteInput input) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Future> tempServiceCreate(TempServiceCreateInput input) { - // TODO Auto-generated method stub - return null; - } - @Override public void onServiceRpcResultSp(ServiceRpcResultSp notification) { - if (!compareServiceRpcResultSp(notification)) { + if (notification != null && !compareServiceRpcResultSp(notification)) { serviceRpcResultSp = notification; StringBuilder build = new StringBuilder(); build.append( "Received '" + notification.getNotificationType() + "' StubRenderer notification" + "from service '" + notification.getServiceName() + "' " + "with status '" + notification.getStatus() + "'"); build.append(" with StatusMessage '" + notification.getStatusMessage() + "'"); - if (notification.getStatus() == RpcStatusEx.Successful && notification.getNotificationType() - .getIntValue() == ServicePathNotificationTypes.ServiceImplementationRequest.getIntValue()) { - build.append(" PathTopology : " + notification.getPathTopology().toString()); - } LOG.info(build.toString()); + switch (serviceRpcResultSp.getNotificationType().getIntValue()) { + case 3 : /** service-implementation-request. */ + if (serviceRpcResultSp.getStatus() == RpcStatusEx.Successful) { + if (serviceRpcResultSp.getPathTopology() != null) { + pathTopology = new PathTopologyBuilder() + .setAToZ(serviceRpcResultSp.getPathTopology().getAToZ()) + .setZToA(serviceRpcResultSp.getPathTopology().getZToA()) + .build(); + LOG.info("PathTopology gets !"); + } else { + LOG.info("'serviceRpcResultSp.getPathTopology()' parameter is null "); + } + if (serviceCreateInput != null) { + updateServiceStatus(serviceCreateInput); + } else if (serviceReconfigureInput != null) { + updateServiceStatus(serviceReconfigureInput); + } else if (service != null) { + updateServiceStatus(service); + } + } else if (serviceRpcResultSp.getStatus() == RpcStatusEx.Failed) { + LOG.info("Stubrenderer computation failed !"); + pceCancelResResource(); + } + break; + + case 4 : /** service-delete. */ + if (serviceRpcResultSp.getStatus() == RpcStatusEx.Successful) { + if (service != null) { //serviceRestoration + LOG.info("RPC service delete came from serviceRestoration"); + pcePathComputation(service); + } else { + pceCancelResResource(); + } + } else if (serviceRpcResultSp.getStatus() == RpcStatusEx.Failed) { + LOG.info("Stubrenderer computation failed !"); + } + break; + + default: + break; + } } else { - LOG.info("ServicePathRpcResult already wired !"); + LOG.info("ServiceRpcResultSp already wired !"); } - } @Override public void onServicePathRpcResult(ServicePathRpcResult notification) { - if (!compareServicePathRpcResult(notification)) { + if (notification != null && !compareServicePathRpcResult(notification)) { servicePathRpcResult = notification; StringBuilder build = new StringBuilder(); build.append( - "Received '" + notification.getNotificationType() + "' StubPce notification " + "from service '" + "Received '" + notification.getNotificationType() + "' Stubpce notification" + "from service '" + notification.getServiceName() + "' " + "with status '" + notification.getStatus() + "'"); build.append(" with StatusMessage '" + notification.getStatusMessage() + "'"); - if (notification.getStatus() == RpcStatusEx.Successful && notification.getNotificationType() - .getIntValue() == ServicePathNotificationTypes.PathComputationRequest.getIntValue()) { - build.append(" PathDescription : " + notification.getPathDescription().toString()); - /* - * switch (action.getIntValue()) { case 1: //service-create case - * 3: //service-delete case 8: //service-reconfigure case 9: - * //service-restoration case 10://service-reversion case - * 11://service-reroute break; - * - * default: break; } - */ - } - LOG.info(build.toString()); + switch (servicePathRpcResult.getNotificationType().getIntValue()) { + case 1 : /** path-computation-request. */ + if (servicePathRpcResult.getStatus() == RpcStatusEx.Successful) { + if (servicePathRpcResult.getPathDescription() != null) { + pathDescription = new PathDescriptionBuilder() + .setAToZDirection(servicePathRpcResult.getPathDescription().getAToZDirection()) + .setZToADirection(servicePathRpcResult.getPathDescription().getZToADirection()) + .build(); + LOG.info("PathDescription gets !"); + if (serviceReconfigureInput != null) { + stubrendererImplementation(serviceReconfigureInput); + } else if (serviceCreateInput != null) { + stubrendererImplementation(serviceCreateInput); + } else if (service != null) { + stubrendererImplementation(service); + } + } else { + LOG.info("'servicePathRpcResult.getPathDescription()'parameter is null "); + } + } else if (servicePathRpcResult.getStatus() == RpcStatusEx.Failed) { + LOG.info("Stupce computation failed !"); + } + break; + + case 2 : /** cancel-resource-reserve. */ + if (servicePathRpcResult.getStatus() == RpcStatusEx.Successful) { + /**if it was an RPC serviceReconfigure, relaunch + * PCR else delete the service. + */ + if (serviceReconfigureInput != null) { + LOG.info("cancel reserve resource request came from RPC serviceReconfigure !"); + pcePathComputation(serviceReconfigureInput); + } else { + deleteServiceFromDatastore(); + } + } else if (servicePathRpcResult.getStatus() == RpcStatusEx.Failed) { + LOG.info("Stupce computation failed !"); + } + break; + + default: + break; + } } else { LOG.info("ServicePathRpcResult already wired !"); } @@ -2013,6 +1620,12 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene this.action = action; } + /** + * Compare ServicePathRpcResult. + * + * @param notification ServicePathRpcResult + * @return Boolean true if idem, false else + */ public Boolean compareServicePathRpcResult(ServicePathRpcResult notification) { Boolean result = true; if (servicePathRpcResult == null) { @@ -2034,6 +1647,12 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene return result; } + /** + * Compare ServiceRpcResultSp. + * + * @param notification ServiceRpcResultSp + * @return Boolean true if idem, false else + */ public Boolean compareServiceRpcResultSp(ServiceRpcResultSp notification) { Boolean result = true; if (serviceRpcResultSp == null) { @@ -2054,4 +1673,36 @@ public class ServicehandlerImpl implements ServicehandlerService, StubpceListene } return result; } + + public PathDescription getPathDescription() { + return pathDescription; + } + + public void setPathDescription(PathDescription pathDescription) { + this.pathDescription = pathDescription; + } + + public ServiceDeleteInput getServiceDeleteInput() { + return serviceDeleteInput; + } + + public void setServiceDeleteInput(ServiceDeleteInput serviceDeleteInput) { + this.serviceDeleteInput = serviceDeleteInput; + } + + public ServiceReconfigureInput getServiceReconfigureInput() { + return serviceReconfigureInput; + } + + public void setServiceReconfigureInput(ServiceReconfigureInput serviceReconfigureInput) { + this.serviceReconfigureInput = serviceReconfigureInput; + } + + public ServiceFeasibilityCheckInput getServiceFeasibilityCheckInput() { + return serviceFeasibilityCheckInput; + } + + public void setServiceFeasibilityCheckInput(ServiceFeasibilityCheckInput serviceFeasibilityCheckInput) { + this.serviceFeasibilityCheckInput = serviceFeasibilityCheckInput; + } } diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java index 29e838d16..f2b9fbe51 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/impl/ServicehandlerProvider.java @@ -13,9 +13,9 @@ import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService import org.opendaylight.controller.md.sal.binding.api.NotificationService; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.servicehandler.rev161014.ServicehandlerService; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.StubpceListener; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubrenderer.rev170426.StubrendererListener; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.OrgOpenroadmServiceService; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,7 +23,8 @@ import org.slf4j.LoggerFactory; /** * Class to register * Servicehandler Service and Notification. - * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange + * + * @author Martial Coulibaly on behalf of Orange * */ public class ServicehandlerProvider { @@ -35,12 +36,10 @@ public class ServicehandlerProvider { private final NotificationService notificationService; private final NotificationPublishService notificationPublishService; - //private ListenerRegistration ServicehandlerlistenerRegistration; - /* Listener register for StubPce Notification. */ - private ListenerRegistration stubPcelistenerRegistration; - /* Listener register for StubRender Notification. */ - private ListenerRegistration stubRendererlistenerRegistration; - private RpcRegistration rpcRegistration; + /** Listener register for TransportpceService Notification. */ + private ListenerRegistration stubpcelistenerRegistration; + private ListenerRegistration stubrendererlistenerRegistration; + private RpcRegistration rpcRegistration; public ServicehandlerProvider(final DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry, @@ -57,9 +56,9 @@ public class ServicehandlerProvider { public void init() { LOG.info("ServicehandlerProvider Session Initiated"); final ServicehandlerImpl consumer = new ServicehandlerImpl(dataBroker, rpcRegistry, notificationPublishService); - stubPcelistenerRegistration = notificationService.registerNotificationListener(consumer); - stubRendererlistenerRegistration = notificationService.registerNotificationListener(consumer); - rpcRegistration = rpcRegistry.addRpcImplementation(ServicehandlerService.class, consumer); + stubpcelistenerRegistration = notificationService.registerNotificationListener(consumer); + stubrendererlistenerRegistration = notificationService.registerNotificationListener(consumer); + rpcRegistration = rpcRegistry.addRpcImplementation(OrgOpenroadmServiceService.class, consumer); } /** @@ -67,8 +66,8 @@ public class ServicehandlerProvider { */ public void close() { LOG.info("ServicehandlerProvider Closed"); - stubPcelistenerRegistration.close(); - stubRendererlistenerRegistration.close(); + stubpcelistenerRegistration.close(); + stubrendererlistenerRegistration.close(); rpcRegistration.close(); } }