aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterAsyncImpl.java
blob: 11b16365d9d2b606cdbaad00d6cee53ca411a2f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
/*-
 * ============LICENSE_START=======================================================
 * OPENECOMP - MSO
 * ================================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.openecomp.mso.adapters.network;


import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.jws.WebService;
import javax.xml.bind.DatatypeConverter;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Holder;
import javax.xml.ws.handler.MessageContext;

import org.openecomp.mso.adapters.network.async.client.CreateNetworkNotification;
import org.openecomp.mso.adapters.network.async.client.MsoExceptionCategory;
import org.openecomp.mso.adapters.network.async.client.NetworkAdapterNotify;
import org.openecomp.mso.adapters.network.async.client.NetworkAdapterNotify_Service;
import org.openecomp.mso.adapters.network.async.client.QueryNetworkNotification;
import org.openecomp.mso.adapters.network.async.client.UpdateNetworkNotification;
import org.openecomp.mso.adapters.network.exceptions.NetworkException;
import org.openecomp.mso.cloud.CloudConfigFactory;
import org.openecomp.mso.entity.MsoRequest;
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoAlarmLogger;
import org.openecomp.mso.logger.MsoLogger;
import org.openecomp.mso.openstack.beans.NetworkRollback;
import org.openecomp.mso.openstack.beans.NetworkStatus;
import org.openecomp.mso.openstack.beans.Subnet;
import org.openecomp.mso.properties.MsoPropertiesFactory;


@WebService(serviceName = "NetworkAdapterAsync", endpointInterface = "org.openecomp.mso.adapters.network.MsoNetworkAdapterAsync", targetNamespace = "http://org.openecomp.mso/networkA")
public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync {

	MsoPropertiesFactory msoPropertiesFactory=new MsoPropertiesFactory();

	CloudConfigFactory cloudConfigFactory=new CloudConfigFactory();

	public static final String MSO_PROP_NETWORK_ADAPTER="MSO_PROP_NETWORK_ADAPTER";
    private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
    private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger ();
    private static final String BPEL_AUTH_PROP = "org.openecomp.mso.adapters.network.bpelauth";
    private static final String ENCRYPTION_KEY = "aa3871669d893c7fb8abbcda31b88b4f";
    /**
     * Health Check web method. Does nothing but return to show the adapter is deployed.
     */
    @Override
    public void healthCheckA () {
        LOGGER.debug ("Health check call in Network Adapter");
    }

    /**
     * This is the "Create Network" web service implementation.
     * It will create a new Network of the requested type in the specified cloud
     * and tenant. The tenant must exist at the time this service is called.
     *
     * If a network with the same name already exists, this can be considered a
     * success or failure, depending on the value of the 'failIfExists' parameter.
     *
     * There will be a pre-defined set of network types defined in the MSO Catalog.
     * All such networks will have a similar configuration, based on the allowable
     * Openstack networking definitions. This includes basic networks, provider
     * networks (with a single VLAN), and multi-provider networks (one or more VLANs)
     *
     * Initially, all provider networks must be "vlan" type, and multiple segments in
     * a multi-provider network must be multiple VLANs on the same physical network.
     *
     * This service supports two modes of Network creation/update:
     * - via Heat Templates
     * - via Neutron API
     * The network orchestration mode for each network type is declared in its
     * catalog definition. All Heat-based templates must support some subset of
     * the same input parameters: network_name, physical_network, vlan(s).
     *
     * The method returns the network ID and a NetworkRollback object. This latter
     * object can be passed as-is to the rollbackNetwork operation to undo everything
     * that was created. This is useful if a network is successfully created but
     * the orchestration fails on a subsequent operation.
     */
    @Override
    public void createNetworkA (String cloudSiteId,
                                String tenantId,
                                String networkType,
                                String networkName,
                                String physicalNetworkName,
                                List <Integer> vlans,
                                Boolean failIfExists,
                                Boolean backout,
                                List <Subnet> subnets,
                                String messageId,
                                MsoRequest msoRequest,
                                String notificationUrl) {
        String error;
        // Will capture execution time for metrics
        long startTime = System.currentTimeMillis ();
        MsoLogger.setLogContext (msoRequest);
        MsoLogger.setServiceName ("CreateNetworkA");
        LOGGER.debug ("Async Create Network: " + networkName
                                      + " of type "
                                      + networkType
                                      + " in "
                                      + cloudSiteId
                                      + "/"
                                      + tenantId);

        // Use the synchronous method to perform the actual Create
        MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);

        // Synchronous Web Service Outputs
        Holder <String> networkId = new Holder <String> ();
        Holder <String> neutronNetworkId = new Holder <String> ();
        Holder <NetworkRollback> networkRollback = new Holder <NetworkRollback> ();
        Holder <Map <String, String>> subnetIdMap = new Holder <Map <String, String>> ();

        try {
            networkAdapter.createNetwork (cloudSiteId,
                                          tenantId,
                                          networkType,
                                          networkName,
                                          physicalNetworkName,
                                          vlans,
                                          failIfExists,
                                          backout,
                                          subnets,
                                          msoRequest,
                                          networkId,
                                          neutronNetworkId,
                                          subnetIdMap,
                                          networkRollback);
        } catch (NetworkException e) {
            LOGGER.debug ("Got a NetworkException on createNetwork: ", e);
            MsoExceptionCategory exCat = null;
            String eMsg = null;
            try {
                eMsg = e.getFaultInfo ().getMessage ();
                exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
            } catch (Exception e1) {
                LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
            }
            // Build and send Asynchronous error response
            try {
                NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
                notifyPort.createNetworkNotification (messageId, false, exCat, eMsg, null, null, null, null);
            } catch (Exception e1) {
                error = "Error sending createNetwork notification " + e1.getMessage ();
                LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1);
                alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
            }
            return;
        }
        LOGGER.debug ("Async Create Network:Name " + networkName + " physicalNetworkName:" + physicalNetworkName);
        // Build and send Asynchronous response
        try {
            NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
            notifyPort.createNetworkNotification (messageId,
                                                  true,
                                                  null,
                                                  null,
                                                  networkId.value,
                                                  neutronNetworkId.value,
                                                  copyCreateSubnetIdMap (subnetIdMap),
                                                  copyNrb (networkRollback));
        } catch (Exception e) {
            error = "Error sending createNetwork notification " + e.getMessage ();
            LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e);
            alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
        }
        return;
    }

    /**
     * This is the "Update Network" web service implementation.
     * It will update an existing Network of the requested type in the specified cloud
     * and tenant. The typical use will be to replace the VLANs with the supplied
     * list (to add or remove a VLAN), but other properties may be updated as well.
     *
     * There will be a pre-defined set of network types defined in the MSO Catalog.
     * All such networks will have a similar configuration, based on the allowable
     * Openstack networking definitions. This includes basic networks, provider
     * networks (with a single VLAN), and multi-provider networks (one or more VLANs).
     *
     * Initially, all provider networks must currently be "vlan" type, and multi-provider
     * networks must be multiple VLANs on the same physical network.
     *
     * This service supports two modes of Network update:
     * - via Heat Templates
     * - via Neutron API
     * The network orchestration mode for each network type is declared in its
     * catalog definition. All Heat-based templates must support some subset of
     * the same input parameters: network_name, physical_network, vlan, segments.
     *
     * The method returns a NetworkRollback object. This object can be passed
     * as-is to the rollbackNetwork operation to undo everything that was updated.
     * This is useful if a network is successfully updated but orchestration
     * fails on a subsequent operation.
     */
    @Override
    public void updateNetworkA (String cloudSiteId,
                                String tenantId,
                                String networkType,
                                String networkId,
                                String networkName,
                                String physicalNetworkName,
                                List <Integer> vlans,
                                List <Subnet> subnets,
                                String messageId,
                                MsoRequest msoRequest,
                                String notificationUrl) {
        String error;
        // Will capture execution time for metrics
        long startTime = System.currentTimeMillis ();
        String serviceName = "UpdateNetworkA";
        MsoLogger.setServiceName (serviceName);
        MsoLogger.setLogContext (msoRequest);
        LOGGER.debug ("Async Update Network: " + networkId
                      + " of type "
                      + networkType
                      + "in "
                      + cloudSiteId
                      + "/"
                      + tenantId);

        // Use the synchronous method to perform the actual Create
        MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);

        // Synchronous Web Service Outputs
        Holder <NetworkRollback> networkRollback = new Holder <NetworkRollback> ();
        Holder <Map <String, String>> subnetIdMap = new Holder <Map <String, String>> ();

        try {
            networkAdapter.updateNetwork (cloudSiteId,
                                          tenantId,
                                          networkType,
                                          networkId,
                                          networkName,
                                          physicalNetworkName,
                                          vlans,
                                          subnets,
                                          msoRequest,
                                          subnetIdMap,
                                          networkRollback);
            MsoLogger.setServiceName (serviceName);
        } catch (NetworkException e) {
        	MsoLogger.setServiceName (serviceName);
            LOGGER.debug ("Got a NetworkException on updateNetwork: ", e);
            MsoExceptionCategory exCat = null;
            String eMsg = null;
            try {
                eMsg = e.getFaultInfo ().getMessage ();
                exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
            } catch (Exception e1) {
                LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
            }
            // Build and send Asynchronous error response
            try {
                NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
                notifyPort.updateNetworkNotification (messageId, false, exCat, eMsg, null, copyNrb (networkRollback));
            } catch (Exception e1) {
                error = "Error sending updateNetwork notification " + e1.getMessage ();
                LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending updateNetwork notification", e1);
                alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
            }
            return;
        }
        LOGGER.debug ("Async Update Network:Name " + networkName + " NetworkId:" + networkId);
        // Build and send Asynchronous response
        try {
            NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
            notifyPort.updateNetworkNotification (messageId,
                                                  true,
                                                  null,
                                                  null,
                                                  copyUpdateSubnetIdMap (subnetIdMap),
                                                  copyNrb (networkRollback));
        } catch (Exception e) {
            error = "Error sending updateNotification request" + e.getMessage ();
            LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending updateNotification request", e);
            alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
        }
        return;
    }

    /**
     * This is the queryNetwork method. It returns the existence and status of
     * the specified network, along with its Neutron UUID and list of VLANs.
     * This method attempts to find the network using both Heat and Neutron.
     * Heat stacks are first searched based on the provided network name/id.
     * If none is found, the Neutron is directly queried.
     */
    @Override
    public void queryNetworkA (String cloudSiteId,
                               String tenantId,
                               String networkNameOrId,
                               String messageId,
                               MsoRequest msoRequest,
                               String notificationUrl) {
        String error;
        // Will capture execution time for metrics
        long startTime = System.currentTimeMillis ();
        MsoLogger.setLogContext (msoRequest);
        String serviceName = "QueryNetworkA";
        MsoLogger.setServiceName (serviceName);
        LOGGER.debug ("Async Query Network " + networkNameOrId + " in " + cloudSiteId + "/" + tenantId);

        // Use the synchronous method to perform the actual Create
        MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);

        // Synchronous Web Service Outputs
        Holder <Boolean> networkExists = new Holder <Boolean> ();
        Holder <String> networkId = new Holder <String> ();
        Holder <String> neutronNetworkId = new Holder <String> ();
        Holder <NetworkStatus> status = new Holder <NetworkStatus> ();
        Holder <List <Integer>> vlans = new Holder <List <Integer>> ();
        Holder <Map <String, String>> subnetIdMap = new Holder <Map <String, String>> ();

        try {
            networkAdapter.queryNetwork (cloudSiteId,
                                         tenantId,
                                         networkNameOrId,
                                         msoRequest,
                                         networkExists,
                                         networkId,
                                         neutronNetworkId,
                                         status,
                                         vlans,
                                         subnetIdMap);
            MsoLogger.setServiceName (serviceName);
        } catch (NetworkException e) {
        	MsoLogger.setServiceName (serviceName);
            LOGGER.debug ("Got a NetworkException on createNetwork: ", e);
            MsoExceptionCategory exCat = null;
            String eMsg = null;
            try {
                eMsg = e.getFaultInfo ().getMessage ();
                exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
            } catch (Exception e1) {
                LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
            }
            // Build and send Asynchronous error response
            try {
                NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
                notifyPort.queryNetworkNotification (messageId, false, exCat, eMsg, null, null, null, null, null, null);
            } catch (Exception e1) {
                error = "Error sending createNetwork notification " + e1.getMessage ();
                LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1);
                alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
            }
            return;
        }
        LOGGER.debug ("Async Query Network:NameOrId " + networkNameOrId + " tenantId:" + tenantId);
        // Build and send Asynchronous response
        try {
            NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
            org.openecomp.mso.adapters.network.async.client.NetworkStatus networkS = org.openecomp.mso.adapters.network.async.client.NetworkStatus.fromValue (status.value.name ());
            notifyPort.queryNetworkNotification (messageId,
                                                 true,
                                                 null,
                                                 null,
                                                 networkExists.value,
                                                 networkId.value,
                                                 neutronNetworkId.value,
                                                 networkS,
                                                 vlans.value,
                                                 copyQuerySubnetIdMap (subnetIdMap));
        } catch (Exception e) {
            error = "Error sending createNetwork notification " + e.getMessage ();
            LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e);
            alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
        }
        return;
    }

    /**
     * This is the "Delete Network" web service implementation.
     * It will delete a Network in the specified cloud and tenant.
     *
     * If the network is not found, it is treated as a success.
     *
     * This service supports two modes of Network creation/update/delete:
     * - via Heat Templates
     * - via Neutron API
     * The network orchestration mode for each network type is declared in its
     * catalog definition.
     *
     * For Heat-based orchestration, the networkId should be the stack ID.
     * For Neutron-based orchestration, the networkId should be the Neutron network UUID.
     *
     * The method returns nothing on success. Rollback is not possible for delete
     * commands, so any failure on delete will require manual fallout in the client.
     */
    @Override
    public void deleteNetworkA (String cloudSiteId,
                                String tenantId,
                                String networkType,
                                String networkId,
                                String messageId,
                                MsoRequest msoRequest,
                                String notificationUrl) {
        String error;
        // Will capture execution time for metrics
        long startTime = System.currentTimeMillis ();
        MsoLogger.setLogContext (msoRequest);
        String serviceName = "DeleteNetworkA";
        MsoLogger.setServiceName (serviceName);
        LOGGER.debug ("Async Delete Network " + networkId + " in " + cloudSiteId + "/" + tenantId);

        // Use the synchronous method to perform the actual Create
        MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);

        // Synchronous Web Service Outputs
        Holder <Boolean> networkDeleted = new Holder <Boolean> ();

        try {
            networkAdapter.deleteNetwork (cloudSiteId, tenantId, networkType, networkId, msoRequest, networkDeleted);
            MsoLogger.setServiceName (serviceName);
        } catch (NetworkException e) {
        	MsoLogger.setServiceName (serviceName);
            LOGGER.debug ("Got a NetworkException on createNetwork: ", e);
            MsoExceptionCategory exCat = null;
            String eMsg = null;
            try {
                eMsg = e.getFaultInfo ().getMessage ();
                exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
            } catch (Exception e1) {
                LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - fault info", e1);
            }
            // Build and send Asynchronous error response
            try {
                NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
                notifyPort.deleteNetworkNotification (messageId, false, exCat, eMsg, null);
            } catch (Exception e1) {
                error = "Error sending createNetwork notification " + e1.getMessage ();
                LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1);
                alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
            }
            return;
        }
        LOGGER.debug ("Async Delete NetworkId: " + networkId + " tenantId:" + tenantId);
        // Build and send Asynchronous response
        try {
            NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
            notifyPort.deleteNetworkNotification (messageId, true, null, null, networkDeleted.value);
        } catch (Exception e) {
            error = "Error sending deleteNetwork notification " + e.getMessage ();
            LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending deleteNetwork notification", e);
            alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
        }
        return;
    }

    /**
     * This web service endpoint will rollback a previous Create VNF operation.
     * A rollback object is returned to the client in a successful creation
     * response. The client can pass that object as-is back to the rollbackNetwork
     * operation to undo the creation.
     *
     * The rollback includes removing the VNF and deleting the tenant if the
     * tenant did not exist prior to the VNF creation.
     */
    @Override
    public void rollbackNetworkA (NetworkRollback rollback, String messageId, String notificationUrl) {
        String error;
        String serviceName = "RollbackNetworkA";
        MsoLogger.setServiceName (serviceName);
        // Will capture execution time for metrics
        long startTime = System.currentTimeMillis ();
        // rollback may be null (e.g. if network already existed when Create was called)
        if (rollback == null) {
            LOGGER.warn (MessageEnum.RA_ROLLBACK_NULL, "", "", MsoLogger.ErrorCode.SchemaError, "Rollback is null");
            return;
        }

        MsoLogger.setLogContext (rollback.getMsoRequest ());
        LOGGER.info (MessageEnum.RA_ASYNC_ROLLBACK, rollback.getNetworkStackId (), "", "");
        // Use the synchronous method to perform the actual Create
        MsoNetworkAdapter networkAdapter = new MsoNetworkAdapterImpl (msoPropertiesFactory,cloudConfigFactory);

        try {
            networkAdapter.rollbackNetwork (rollback);
            MsoLogger.setServiceName (serviceName);
        } catch (NetworkException e) {
        	MsoLogger.setServiceName (serviceName);
            LOGGER.debug ("Got a NetworkException on rollbackNetwork: ", e);
            // Build and send Asynchronous error response
            MsoExceptionCategory exCat = null;
            String eMsg = null;
            try {
                eMsg = e.getFaultInfo ().getMessage ();
                exCat = MsoExceptionCategory.fromValue (e.getFaultInfo ().getCategory ().name ());
            } catch (Exception e1) {
                LOGGER.error (MessageEnum.RA_FAULT_INFO_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in get fault info", e1);
            }
            // Build and send Asynchronous error response
            try {
                NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
                notifyPort.rollbackNetworkNotification (rollback.getMsoRequest ().getRequestId (), false, exCat, eMsg);
            } catch (Exception e1) {
                error = "Error sending createNetwork notification " + e1.getMessage ();
                LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in sending createNetwork notification ", e1);
                alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
            }
            return;
        }
        LOGGER.debug ("Async Rollback NetworkId: " + rollback.getNetworkStackId () + " tenantId:" + rollback.getTenantId ());
        // Build and send Asynchronous response
        try {
            NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl);
            notifyPort.rollbackNetworkNotification (rollback.getMsoRequest ().getRequestId (), true, null, null);
        } catch (Exception e) {
            error = "Error sending rollbackNetwork notification " + e.getMessage ();
            LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in sending rollbackNetwork notification", e);
            alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error);
        }
        return;
    }

    private org.openecomp.mso.adapters.network.async.client.NetworkRollback copyNrb (Holder <NetworkRollback> hNrb) {
        org.openecomp.mso.adapters.network.async.client.NetworkRollback cnrb = new org.openecomp.mso.adapters.network.async.client.NetworkRollback ();

        if (hNrb != null && hNrb.value != null) {
            org.openecomp.mso.adapters.network.async.client.MsoRequest cmr = new org.openecomp.mso.adapters.network.async.client.MsoRequest ();

            cnrb.setCloudId (hNrb.value.getCloudId ());
            cmr.setRequestId (hNrb.value.getMsoRequest ().getRequestId ());
            cmr.setServiceInstanceId (hNrb.value.getMsoRequest ().getServiceInstanceId ());
            cnrb.setMsoRequest (cmr);
            cnrb.setNetworkId (hNrb.value.getNetworkId ());
            cnrb.setNetworkStackId (hNrb.value.getNetworkStackId ());
            cnrb.setNeutronNetworkId (hNrb.value.getNeutronNetworkId ());
            cnrb.setTenantId (hNrb.value.getTenantId ());
            cnrb.setNetworkType (hNrb.value.getNetworkType ());
            cnrb.setNetworkCreated (hNrb.value.getNetworkCreated ());
            cnrb.setNetworkName (hNrb.value.getNetworkName ());
            cnrb.setPhysicalNetwork (hNrb.value.getPhysicalNetwork ());
            List <Integer> vlansc = cnrb.getVlans ();
            List <Integer> vlansh = hNrb.value.getVlans ();
            if (vlansh != null) {
                vlansc.addAll (vlansh);
            }
        }
        return cnrb;
    }

    private NetworkAdapterNotify getNotifyEP (String notificationUrl) {

        URL warWsdlLoc = null;
        try {
            warWsdlLoc = Thread.currentThread ().getContextClassLoader ().getResource ("NetworkAdapterNotify.wsdl");
        } catch (Exception e) {
            LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e);
        }
        if (warWsdlLoc == null) {
            LOGGER.error (MessageEnum.RA_WSDL_NOT_FOUND, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.DataError, "WSDL not found");
        } else {
            try {
                LOGGER.debug ("NetworkAdpaterNotify.wsdl location:" + warWsdlLoc.toURI ().toString ());
            } catch (Exception e) {
                LOGGER.error (MessageEnum.RA_WSDL_URL_CONVENTION_EXC, "NetworkAdpaterNotify.wsdl", "", "", MsoLogger.ErrorCode.SchemaError, "Exception - WSDL URL convention", e);
            }
        }

        NetworkAdapterNotify_Service notifySvc = new NetworkAdapterNotify_Service (warWsdlLoc,
                                                                                   new QName ("http://org.openecomp.mso/networkNotify",
                                                                                              "networkAdapterNotify"));

        NetworkAdapterNotify notifyPort = notifySvc.getMsoNetworkAdapterAsyncImplPort ();

        BindingProvider bp = (BindingProvider) notifyPort;

        URL epUrl = null;
        try {
            epUrl = new URL (notificationUrl);
        } catch (MalformedURLException e1) {
            LOGGER.error (MessageEnum.RA_INIT_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - init notification", e1);
        }

        LOGGER.debug ("Notification Endpoint URL: " + epUrl.toExternalForm ());

        bp.getRequestContext ().put (BindingProvider.ENDPOINT_ADDRESS_PROPERTY, epUrl.toExternalForm ());

        // authentication
        try {
            Map <String, Object> reqCtx = bp.getRequestContext ();
            Map <String, List <String>> headers = new HashMap <String, List <String>> ();

            String userCredentials = msoPropertiesFactory.getMsoJavaProperties (MSO_PROP_NETWORK_ADAPTER).getEncryptedProperty (BPEL_AUTH_PROP,
                                                                                             "",
                                                                                          ENCRYPTION_KEY);

            String basicAuth = "Basic " + DatatypeConverter.printBase64Binary (userCredentials.getBytes ());
            reqCtx.put (MessageContext.HTTP_REQUEST_HEADERS, headers);
            headers.put ("Authorization", Collections.singletonList (basicAuth));
        } catch (Exception e) {
            String error1 = "Unable to set authorization in callback request" + e.getMessage ();
            LOGGER.error (MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to set authorization in callback request", e);
            alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error1);
        }

        return notifyPort;
    }

    private CreateNetworkNotification.SubnetIdMap copyCreateSubnetIdMap (Holder <Map <String, String>> hMap) {

        CreateNetworkNotification.SubnetIdMap subnetIdMap = new CreateNetworkNotification.SubnetIdMap ();

        if (hMap != null && hMap.value != null) {
            Map <String, String> sMap = new HashMap <String, String> ();
            sMap = hMap.value;
            CreateNetworkNotification.SubnetIdMap.Entry entry = new CreateNetworkNotification.SubnetIdMap.Entry ();

            for (String key : sMap.keySet ()) {
                entry.setKey (key);
                entry.setValue (sMap.get (key));
                subnetIdMap.getEntry ().add (entry);
            }
        }
        return subnetIdMap;
    }

    private UpdateNetworkNotification.SubnetIdMap copyUpdateSubnetIdMap (Holder <Map <String, String>> hMap) {

        UpdateNetworkNotification.SubnetIdMap subnetIdMap = new UpdateNetworkNotification.SubnetIdMap ();

        if (hMap != null && hMap.value != null) {
            Map <String, String> sMap = new HashMap <String, String> ();
            sMap = hMap.value;
            UpdateNetworkNotification.SubnetIdMap.Entry entry = new UpdateNetworkNotification.SubnetIdMap.Entry ();

            for (String key : sMap.keySet ()) {
                entry.setKey (key);
                entry.setValue (sMap.get (key));
                subnetIdMap.getEntry ().add (entry);
            }
        }
        return subnetIdMap;
    }

    private QueryNetworkNotification.SubnetIdMap copyQuerySubnetIdMap (Holder <Map <String, String>> hMap) {

        QueryNetworkNotification.SubnetIdMap subnetIdMap = new QueryNetworkNotification.SubnetIdMap ();

        if (hMap != null && hMap.value != null) {
            Map <String, String> sMap = new HashMap <String, String> ();
            sMap = hMap.value;
            QueryNetworkNotification.SubnetIdMap.Entry entry = new QueryNetworkNotification.SubnetIdMap.Entry ();

            for (String key : sMap.keySet ()) {
                entry.setKey (key);
                entry.setValue (sMap.get (key));
                subnetIdMap.getEntry ().add (entry);
            }
        }
        return subnetIdMap;
    }
}