Merge "Reorder modifiers"
[so.git] / adapters / mso-adapter-utils / src / main / java / org / openecomp / mso / openstack / utils / MsoNeutronUtils.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.mso.openstack.utils;
22
23
24 import java.io.Serializable;
25 import java.util.ArrayList;
26 import java.util.Calendar;
27 import java.util.HashMap;
28 import java.util.List;
29 import java.util.Map;
30
31 import org.openecomp.mso.cloud.CloudConfig;
32 import org.openecomp.mso.cloud.CloudConfigFactory;
33 import org.openecomp.mso.cloud.CloudIdentity;
34 import org.openecomp.mso.cloud.CloudSite;
35 import org.openecomp.mso.logger.MessageEnum;
36 import org.openecomp.mso.logger.MsoAlarmLogger;
37 import org.openecomp.mso.logger.MsoLogger;
38 import org.openecomp.mso.openstack.beans.NetworkInfo;
39 import org.openecomp.mso.openstack.exceptions.MsoAdapterException;
40 import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound;
41 import org.openecomp.mso.openstack.exceptions.MsoException;
42 import org.openecomp.mso.openstack.exceptions.MsoIOException;
43 import org.openecomp.mso.openstack.exceptions.MsoNetworkAlreadyExists;
44 import org.openecomp.mso.openstack.exceptions.MsoNetworkNotFound;
45 import org.openecomp.mso.openstack.exceptions.MsoOpenstackException;
46 import com.woorea.openstack.base.client.OpenStackBaseException;
47 import com.woorea.openstack.base.client.OpenStackConnectException;
48 import com.woorea.openstack.base.client.OpenStackRequest;
49 import com.woorea.openstack.base.client.OpenStackResponseException;
50 import com.woorea.openstack.keystone.Keystone;
51 import com.woorea.openstack.keystone.model.Access;
52 import com.woorea.openstack.keystone.utils.KeystoneUtils;
53 import com.woorea.openstack.quantum.Quantum;
54 import com.woorea.openstack.quantum.model.Network;
55 import com.woorea.openstack.quantum.model.Networks;
56 import com.woorea.openstack.quantum.model.Segment;
57 import com.woorea.openstack.keystone.model.Authentication;
58
59 public class MsoNeutronUtils extends MsoCommonUtils
60 {
61         // Cache Neutron Clients statically.  Since there is just one MSO user, there is no
62         // benefit to re-authentication on every request (or across different flows).  The
63         // token will be used until it expires.
64         //
65         // The cache key is "tenantId:cloudId"
66         private static Map<String,NeutronCacheEntry> neutronClientCache = new HashMap<>();
67
68         private CloudConfigFactory cloudConfigFactory;
69
70         private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
71         private String msoPropID;
72
73         public enum NetworkType {
74                 BASIC, PROVIDER, MULTI_PROVIDER
75         };
76
77         public MsoNeutronUtils(String msoPropID, CloudConfigFactory cloudConfigFactory) {
78                 this.cloudConfigFactory = cloudConfigFactory;
79                 this.msoPropID = msoPropID;
80         }
81         
82         protected CloudConfigFactory getCloudConfigFactory() {
83                 return cloudConfigFactory;
84         }
85
86         /**
87          * Create a network with the specified parameters in the given cloud/tenant.
88          *
89          * If a network already exists with the same name, an exception will be thrown.  Note that
90          * this is an MSO-imposed restriction.  Openstack does not require uniqueness on network names.
91          * <p>
92          * @param cloudSiteId The cloud identifier (may be a region) in which to create the network.
93          * @param tenantId The tenant in which to create the network
94          * @param type The type of network to create (Basic, Provider, Multi-Provider)
95          * @param networkName The network name to create
96          * @param provider The provider network name (for Provider or Multi-Provider networks)
97          * @param vlans A list of VLAN segments for the network (for Provider or Multi-Provider networks)
98          * @return a NetworkInfo object which describes the newly created network
99          * @throws MsoNetworkAlreadyExists Thrown if a network with the same name already exists
100          * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception
101          * @throws MsoCloudSiteNotFound Thrown if the cloudSite is invalid or unknown
102          */
103         public NetworkInfo createNetwork (String cloudSiteId, String tenantId, NetworkType type, String networkName, String provider, List<Integer> vlans)
104             throws MsoException
105         {
106                 // Obtain the cloud site information where we will create the stack
107         CloudSite cloudSite = getCloudConfigFactory().getCloudConfig().getCloudSite(cloudSiteId).orElseThrow(
108                 () -> new MsoCloudSiteNotFound(cloudSiteId));
109
110                 Quantum neutronClient = getNeutronClient (cloudSite, tenantId);
111
112                 // Check if a network already exists with this name
113                 // Openstack will allow duplicate name, so require explicit check
114                 Network network = findNetworkByName (neutronClient, networkName);
115
116                 if (network != null) {
117                         // Network already exists.  Throw an exception
118                         LOGGER.error(MessageEnum.RA_NETWORK_ALREADY_EXIST, networkName, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Network already exists");
119                         throw new MsoNetworkAlreadyExists (networkName, tenantId, cloudSiteId);
120                 }
121
122                 // Does not exist, create a new one
123                 network = new Network();
124                 network.setName(networkName);
125                 network.setAdminStateUp(true);
126
127                 if (type == NetworkType.PROVIDER) {
128                         if (provider != null && vlans != null && vlans.size() > 0) {
129                                 network.setProviderPhysicalNetwork (provider);
130                                 network.setProviderNetworkType("vlan");
131                                 network.setProviderSegmentationId (vlans.get(0));
132                         }
133                 } else if (type == NetworkType.MULTI_PROVIDER) {
134                         if (provider != null && vlans != null && vlans.size() > 0) {
135                                 List<Segment> segments = new ArrayList<>(vlans.size());
136                                 for (int vlan : vlans) {
137                                         Segment segment = new Segment();
138                                         segment.setProviderPhysicalNetwork (provider);
139                                         segment.setProviderNetworkType("vlan");
140                                         segment.setProviderSegmentationId (vlan);
141
142                                         segments.add(segment);
143                                 }
144                                 network.setSegments(segments);
145                         }
146                 }
147
148                 try {
149                         OpenStackRequest<Network> request = neutronClient.networks().create(network);
150                         Network newNetwork = executeAndRecordOpenstackRequest(request);
151                         return new NetworkInfo(newNetwork);
152                 }
153                 catch (OpenStackBaseException e) {
154                         // Convert Neutron exception to an MsoOpenstackException
155                         MsoException me = neutronExceptionToMsoException (e, "CreateNetwork");
156                         throw me;
157                 }
158                 catch (RuntimeException e) {
159                         // Catch-all
160                         MsoException me = runtimeExceptionToMsoException(e, "CreateNetwork");
161                         throw me;
162                 }
163         }
164
165
166         /**
167          * Query for a network with the specified name or ID in the given cloud.  If the network exists,
168          * return an NetworkInfo object.  If not, return null.
169          * <p>
170          * Whenever possible, the network ID should be used as it is much more efficient.  Query by
171          * name requires retrieval of all networks for the tenant and search for matching name.
172          * <p>
173          * @param networkNameOrId The network to query
174          * @param tenantId The Openstack tenant to look in for the network
175          * @param cloudSiteId The cloud identifier (may be a region) in which to query the network.
176          * @return a NetworkInfo object describing the queried network, or null if not found
177          * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception
178          * @throws MsoCloudSiteNotFound
179          */
180     public NetworkInfo queryNetwork(String networkNameOrId, String tenantId, String cloudSiteId) throws MsoException
181         {
182                 LOGGER.debug("In queryNetwork");
183
184                 // Obtain the cloud site information
185         CloudSite cloudSite = getCloudConfigFactory().getCloudConfig().getCloudSite(cloudSiteId).orElseThrow(
186                 () -> new MsoCloudSiteNotFound(cloudSiteId));
187
188                 Quantum neutronClient = getNeutronClient (cloudSite, tenantId);
189                 // Check if the network exists and return its info
190                 try {
191                         Network network = findNetworkByNameOrId (neutronClient, networkNameOrId);
192                         if (network == null) {
193                                 LOGGER.debug ("Query Network: " + networkNameOrId + " not found in tenant " + tenantId);
194                                 return null;
195                         }
196                         return new NetworkInfo(network);
197                 }
198                 catch (OpenStackBaseException e) {
199                         // Convert Neutron exception to an MsoOpenstackException
200                         MsoException me = neutronExceptionToMsoException (e, "QueryNetwork");
201                         throw me;
202                 }
203                 catch (RuntimeException e) {
204                         // Catch-all
205                         MsoException me = runtimeExceptionToMsoException(e, "QueryNetwork");
206                         throw me;
207                 }
208         }
209
210         /**
211          * Delete the specified Network (by ID) in the given cloud.
212          * If the network does not exist, success is returned.
213          * <p>
214          * @param networkId Openstack ID of the network to delete
215          * @param tenantId The Openstack tenant.
216          * @param cloudSiteId The cloud identifier (may be a region) from which to delete the network.
217          * @return true if the network was deleted, false if the network did not exist
218          * @throws MsoOpenstackException If the Openstack API call returns an exception, this local
219          * exception will be thrown.
220          * @throws MsoCloudSiteNotFound
221          */
222     public boolean deleteNetwork(String networkId, String tenantId, String cloudSiteId) throws MsoException
223         {
224                 // Obtain the cloud site information where we will create the stack
225         CloudSite cloudSite = getCloudConfigFactory().getCloudConfig().getCloudSite(cloudSiteId).orElseThrow(
226                 () -> new MsoCloudSiteNotFound(cloudSiteId));
227                 Quantum neutronClient = getNeutronClient (cloudSite, tenantId);
228                 try {
229                         // Check that the network exists.
230                         Network network = findNetworkById (neutronClient, networkId);
231                         if (network == null) {
232                                 LOGGER.info(MessageEnum.RA_DELETE_NETWORK_EXC, networkId, cloudSiteId, tenantId, "Openstack", "");
233                                 return false;
234                         }
235
236                         OpenStackRequest<Void> request = neutronClient.networks().delete(network.getId());
237                         executeAndRecordOpenstackRequest(request);
238
239                         LOGGER.debug ("Deleted Network " + network.getId() + " (" + network.getName() + ")");
240                 }
241                 catch (OpenStackBaseException e) {
242                         // Convert Neutron exception to an MsoOpenstackException
243                         MsoException me = neutronExceptionToMsoException (e, "Delete Network");
244                         throw me;
245                 }
246                 catch (RuntimeException e) {
247                         // Catch-all
248                         MsoException me = runtimeExceptionToMsoException(e, "DeleteNetwork");
249                         throw me;
250                 }
251
252                 return true;
253         }
254
255
256         /**
257          * Update a network with the specified parameters in the given cloud/tenant.
258          *
259          * Specifically, this call is intended to update the VLAN segments on a
260          * multi-provider network.  The provider segments will be replaced with the
261          * supplied list of VLANs.
262          * <p>
263          * Note that updating the 'segments' array is not normally supported by Neutron.
264          * This method relies on a Platform Orchestration extension (using SDN controller
265          * to manage the virtual networking).
266          *
267          * @param cloudSiteId The cloud site ID (may be a region) in which to update the network.
268          * @param tenantId Openstack ID of the tenant in which to update the network
269          * @param networkId The unique Openstack ID of the network to be updated
270          * @param type The network type (Basic, Provider, Multi-Provider)
271          * @param provider The provider network name.  This should not change.
272          * @param vlans The list of VLAN segments to replace
273          * @return a NetworkInfo object which describes the updated network
274          * @throws MsoNetworkNotFound Thrown if the requested network does not exist
275          * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception
276          * @throws MsoCloudSiteNotFound
277          */
278         public NetworkInfo updateNetwork (String cloudSiteId, String tenantId, String networkId, NetworkType type, String provider, List<Integer> vlans)
279             throws MsoException
280         {
281                 // Obtain the cloud site information where we will create the stack
282         CloudSite cloudSite = getCloudConfigFactory().getCloudConfig().getCloudSite(cloudSiteId).orElseThrow(
283                 () -> new MsoCloudSiteNotFound(cloudSiteId));
284                 Quantum neutronClient = getNeutronClient (cloudSite, tenantId);
285                 // Check that the network exists
286                 Network network = findNetworkById (neutronClient, networkId);
287
288                 if (network == null) {
289                         // Network not found.  Throw an exception
290                         LOGGER.error(MessageEnum.RA_NETWORK_NOT_FOUND, networkId, cloudSiteId, tenantId, "Openstack", "", MsoLogger.ErrorCode.DataError, "Network not found");
291                         throw new MsoNetworkNotFound (networkId, tenantId, cloudSiteId);
292                 }
293
294                 // Overwrite the properties to be updated
295                 if (type == NetworkType.PROVIDER) {
296                         if (provider != null && vlans != null && vlans.size() > 0) {
297                                 network.setProviderPhysicalNetwork (provider);
298                                 network.setProviderNetworkType("vlan");
299                                 network.setProviderSegmentationId (vlans.get(0));
300                         }
301                 } else if (type == NetworkType.MULTI_PROVIDER) {
302                         if (provider != null && vlans != null && vlans.size() > 0) {
303                                 List<Segment> segments = new ArrayList<>(vlans.size());
304                                 for (int vlan : vlans) {
305                                         Segment segment = new Segment();
306                                         segment.setProviderPhysicalNetwork (provider);
307                                         segment.setProviderNetworkType("vlan");
308                                         segment.setProviderSegmentationId (vlan);
309
310                                         segments.add(segment);
311                                 }
312                                 network.setSegments(segments);
313                         }
314                 }
315
316                 try {
317                         OpenStackRequest<Network> request = neutronClient.networks().update(network);
318                         Network newNetwork = executeAndRecordOpenstackRequest(request);
319                         return new NetworkInfo(newNetwork);
320                 }
321                 catch (OpenStackBaseException e) {
322                         // Convert Neutron exception to an MsoOpenstackException
323                         MsoException me = neutronExceptionToMsoException (e, "UpdateNetwork");
324                         throw me;
325                 }
326                 catch (RuntimeException e) {
327                         // Catch-all
328                         MsoException me = runtimeExceptionToMsoException(e, "UpdateNetwork");
329                         throw me;
330                 }
331         }
332
333
334         // -------------------------------------------------------------------
335         // PRIVATE UTILITY FUNCTIONS FOR USE WITHIN THIS CLASS
336
337         /**
338          * Get a Neutron (Quantum) client for the Openstack Network service.
339          * This requires a 'member'-level userId + password, which will be retrieved from
340          * properties based on the specified cloud Id.  The tenant in which to operate
341          * must also be provided.
342          * <p>
343          * On successful authentication, the Quantum object will be cached for the
344          * tenantID + cloudId so that it can be reused without reauthenticating with
345          *  Openstack every time.
346          *
347          * @param cloudSite - a cloud site definition
348          * @param tenantId - Openstack tenant ID
349          * @return an authenticated Quantum object
350          */
351     private Quantum getNeutronClient(CloudSite cloudSite, String tenantId) throws MsoException
352         {
353                 String cloudId = cloudSite.getId();
354
355                 // Check first in the cache of previously authorized clients
356                 String cacheKey = cloudId + ":" + tenantId;
357                 if (neutronClientCache.containsKey(cacheKey)) {
358                         if (! neutronClientCache.get(cacheKey).isExpired()) {
359                                 LOGGER.debug ("Using Cached HEAT Client for " + cacheKey);
360                                 Quantum neutronClient = neutronClientCache.get(cacheKey).getNeutronClient();
361                                 return neutronClient;
362                         }
363                         else {
364                                 // Token is expired.  Remove it from cache.
365                                 neutronClientCache.remove(cacheKey);
366                                 LOGGER.debug ("Expired Cached Neutron Client for " + cacheKey);
367                         }
368                 }
369
370                 // Obtain an MSO token for the tenant from the identity service
371                 CloudIdentity cloudIdentity = cloudSite.getIdentityService();
372                 Keystone keystoneTenantClient = new Keystone (cloudIdentity.getKeystoneUrl(cloudId, msoPropID));
373                 Access access = null;
374                 try {
375                         Authentication credentials = cloudIdentity.getAuthentication ();
376                         OpenStackRequest<Access> request = keystoneTenantClient.tokens().authenticate(credentials).withTenantId(tenantId);
377                         access = executeAndRecordOpenstackRequest(request);
378                 }
379                 catch (OpenStackResponseException e) {
380                         if (e.getStatus() == 401) {
381                                 // Authentication error.
382                                 String error = "Authentication Failure: tenant=" + tenantId + ",cloud=" + cloudIdentity.getId();
383                                 alarmLogger .sendAlarm("MsoAuthenticationError", MsoAlarmLogger.CRITICAL, error);
384                                 throw new MsoAdapterException(error);
385                         }
386                         else {
387                                 MsoException me = keystoneErrorToMsoException(e, "TokenAuth");
388                                 throw me;
389                         }
390                 }
391                 catch (OpenStackConnectException e) {
392                         // Connection to Openstack failed
393                         MsoIOException me = new MsoIOException (e.getMessage(), e);
394                         me.addContext("TokenAuth");
395                         throw me;
396                 }
397                 catch (RuntimeException e) {
398                         // Catch-all
399                         MsoException me = runtimeExceptionToMsoException(e, "TokenAuth");
400                         throw me;
401                 }
402
403                 String region = cloudSite.getRegionId();
404                 String neutronUrl = null;
405                 try {
406                         neutronUrl = KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "network", region, "public");
407                         if (! neutronUrl.endsWith("/")) {
408                 neutronUrl += "/v2.0/";
409             }
410                 } catch (RuntimeException e) {
411                         // This comes back for not found (probably an incorrect region ID)
412                         String error = "Network service not found: region=" + region + ",cloud=" + cloudIdentity.getId();
413                         alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL, error);
414                         throw new MsoAdapterException (error, e);
415                 }
416
417                 Quantum neutronClient = new Quantum(neutronUrl);
418                 neutronClient.token(access.getToken().getId());
419
420                 neutronClientCache.put(cacheKey, new NeutronCacheEntry(neutronUrl, access.getToken().getId(), access.getToken().getExpires()));
421                 LOGGER.debug ("Caching Neutron Client for " + cacheKey);
422
423                 return neutronClient;
424         }
425
426         /**
427          * Forcibly expire a Neutron client from the cache.  This call is for use by
428          * the KeystoneClient in case where a tenant is deleted.  In that case,
429          * all cached credentials must be purged so that fresh authentication is
430          * done on subsequent calls.
431          */
432         public static void expireNeutronClient (String tenantId, String cloudId) {
433                 String cacheKey = cloudId + ":" + tenantId;
434                 if (neutronClientCache.containsKey(cacheKey)) {
435                         neutronClientCache.remove(cacheKey);
436                         LOGGER.debug ("Deleted Cached Neutron Client for " + cacheKey);
437                 }
438         }
439
440
441         /*
442          * Find a tenant (or query its existence) by its Name or Id.  Check first against the
443          * ID.  If that fails, then try by name.
444          *
445          * @param adminClient an authenticated Keystone object
446          * @param tenantName the tenant name or ID to query
447          * @return a Tenant object or null if not found
448          */
449         public Network findNetworkByNameOrId (Quantum neutronClient, String networkNameOrId)
450         {
451                 if (networkNameOrId == null) {
452             return null;
453         }
454
455                 Network network = findNetworkById(neutronClient, networkNameOrId);
456
457                 if (network == null) {
458             network = findNetworkByName(neutronClient, networkNameOrId);
459         }
460
461                 return network;
462         }
463
464         /*
465          * Find a network (or query its existence) by its Id.
466          *
467          * @param neutronClient an authenticated Quantum object
468          * @param networkId the network ID to query
469          * @return a Network object or null if not found
470          */
471         private static Network findNetworkById (Quantum neutronClient, String networkId)
472         {
473                 if (networkId == null) {
474             return null;
475         }
476
477                 try {
478                         OpenStackRequest<Network> request = neutronClient.networks().show(networkId);
479                         Network network = executeAndRecordOpenstackRequest(request);
480                         return network;
481                 }
482                 catch (OpenStackResponseException e) {
483                         if (e.getStatus() == 404) {
484                                 return null;
485                         } else {
486                                 LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Error, GET Network By ID (" + networkId + "): " + e, "Openstack", "", MsoLogger.ErrorCode.DataError, "Exception in Openstack");
487                                 throw e;
488                         }
489                 }
490         }
491
492         /*
493          * Find a network (or query its existence) by its Name.  This method avoids an
494          * initial lookup by ID when it's known that we have the network Name.
495          *
496          * Neutron does not support 'name=*' query parameter for Network query (show).
497          * The only way to query by name is to retrieve all networks and look for the
498          * match.  While inefficient, this capability will be provided as it is needed
499          * by MSO, but should be avoided in favor of ID whenever possible.
500          *
501          * TODO:
502          * Network names are not required to be unique, though MSO will attempt to enforce
503          * uniqueness.  This call probably needs to return an error (instead of returning
504          * the first match).
505          *
506          * @param neutronClient an authenticated Quantum object
507          * @param networkName the network name to query
508          * @return a Network object or null if not found
509          */
510         public Network findNetworkByName (Quantum neutronClient, String networkName)
511         {
512                 if (networkName == null) {
513             return null;
514         }
515
516                 try {
517                         OpenStackRequest<Networks> request = neutronClient.networks().list();
518                         Networks networks = executeAndRecordOpenstackRequest(request);
519                         for (Network network : networks.getList()) {
520                                 if (network.getName().equals(networkName)) {
521                                         LOGGER.debug ("Found match on network name: " + networkName);
522                                         return network;
523                                 }
524                         }
525                         LOGGER.debug ("findNetworkByName - no match found for " + networkName);
526                         return null;
527                 }
528                 catch (OpenStackResponseException e) {
529                         if (e.getStatus() == 404) {
530                                 return null;
531                         } else {
532                                 LOGGER.error (MessageEnum.RA_CONNECTION_EXCEPTION, "OpenStack", "Openstack Error, GET Network By Name (" + networkName + "): " + e, "OpenStack", "", MsoLogger.ErrorCode.DataError, "Exception in OpenStack");
533                                 throw e;
534                         }
535                 }
536         }
537
538
539         /*
540          * An entry in the Neutron Client Cache.  It saves the Neutron client object
541          * along with the token expiration.  After this interval, this cache
542          * item will no longer be used.
543          */
544         private static class NeutronCacheEntry implements Serializable
545         {
546                 private static final long serialVersionUID = 1L;
547
548                 private String neutronUrl;
549                 private String token;
550                 private Calendar expires;
551
552                 public NeutronCacheEntry (String neutronUrl, String token, Calendar expires) {
553                         this.neutronUrl = neutronUrl;
554                         this.token = token;
555                         this.expires = expires;
556                 }
557
558                 public Quantum getNeutronClient () {
559                         Quantum neutronClient = new Quantum(neutronUrl);
560                         neutronClient.token(token);
561                         return neutronClient;
562                 }
563
564                 public boolean isExpired() {
565                         return expires == null || System.currentTimeMillis() > expires.getTimeInMillis();
566                 }
567         }
568
569         /**
570          * Clean up the Neutron client cache to remove expired entries.
571          */
572         public static void neutronCacheCleanup () {
573                 for (String cacheKey : neutronClientCache.keySet()) {
574                         if (neutronClientCache.get(cacheKey).isExpired()) {
575                                 neutronClientCache.remove(cacheKey);
576                                 LOGGER.debug ("Cleaned Up Cached Neutron Client for " + cacheKey);
577                         }
578                 }
579         }
580
581         /**
582          * Reset the Neutron client cache.
583          * This may be useful if cached credentials get out of sync.
584          */
585         public static void neutronCacheReset () {
586                 neutronClientCache = new HashMap<>();
587         }
588 }