Hyunsun Moon
Committed by Gerrit Code Review

Handle OpenStack authenticate exception and show warnings

Change-Id: Id7ac38c4dab1e43cf46bc8262adf98ea0a7d3558
...@@ -25,6 +25,7 @@ import org.onosproject.xosclient.api.VtnPortId; ...@@ -25,6 +25,7 @@ import org.onosproject.xosclient.api.VtnPortId;
25 import org.onosproject.xosclient.api.VtnServiceId; 25 import org.onosproject.xosclient.api.VtnServiceId;
26 import org.onosproject.xosclient.api.XosAccess; 26 import org.onosproject.xosclient.api.XosAccess;
27 import org.openstack4j.api.OSClient; 27 import org.openstack4j.api.OSClient;
28 +import org.openstack4j.api.exceptions.AuthenticationException;
28 import org.openstack4j.model.network.IP; 29 import org.openstack4j.model.network.IP;
29 import org.openstack4j.model.network.Port; 30 import org.openstack4j.model.network.Port;
30 import org.openstack4j.openstack.OSFactory; 31 import org.openstack4j.openstack.OSFactory;
...@@ -132,10 +133,15 @@ public final class DefaultVtnPortApi extends XosApi implements VtnPortApi { ...@@ -132,10 +133,15 @@ public final class DefaultVtnPortApi extends XosApi implements VtnPortApi {
132 133
133 // creating a client every time must be inefficient, but this method 134 // creating a client every time must be inefficient, but this method
134 // will be removed once XOS provides equivalent APIs 135 // will be removed once XOS provides equivalent APIs
136 + try {
135 return OSFactory.builder() 137 return OSFactory.builder()
136 .endpoint(osAccess.endpoint()) 138 .endpoint(osAccess.endpoint())
137 .credentials(osAccess.user(), osAccess.password()) 139 .credentials(osAccess.user(), osAccess.password())
138 .tenantName(osAccess.tenant()) 140 .tenantName(osAccess.tenant())
139 .authenticate(); 141 .authenticate();
142 + } catch (AuthenticationException e) {
143 + log.warn("Failed to authenticate OpenStack API with {}", osAccess);
144 + return null;
145 + }
140 } 146 }
141 } 147 }
......
...@@ -28,6 +28,7 @@ import org.onosproject.xosclient.api.VtnService; ...@@ -28,6 +28,7 @@ import org.onosproject.xosclient.api.VtnService;
28 import org.onosproject.xosclient.api.VtnServiceId; 28 import org.onosproject.xosclient.api.VtnServiceId;
29 29
30 import org.openstack4j.api.OSClient; 30 import org.openstack4j.api.OSClient;
31 +import org.openstack4j.api.exceptions.AuthenticationException;
31 import org.openstack4j.model.network.Network; 32 import org.openstack4j.model.network.Network;
32 import org.openstack4j.model.network.Subnet; 33 import org.openstack4j.model.network.Subnet;
33 import org.openstack4j.openstack.OSFactory; 34 import org.openstack4j.openstack.OSFactory;
...@@ -162,11 +163,16 @@ public final class DefaultVtnServiceApi extends XosApi implements VtnServiceApi ...@@ -162,11 +163,16 @@ public final class DefaultVtnServiceApi extends XosApi implements VtnServiceApi
162 163
163 // creating a client every time must be inefficient, but this method 164 // creating a client every time must be inefficient, but this method
164 // will be removed once XOS provides equivalent APIs 165 // will be removed once XOS provides equivalent APIs
166 + try {
165 return OSFactory.builder() 167 return OSFactory.builder()
166 .endpoint(osAccess.endpoint()) 168 .endpoint(osAccess.endpoint())
167 .credentials(osAccess.user(), osAccess.password()) 169 .credentials(osAccess.user(), osAccess.password())
168 .tenantName(osAccess.tenant()) 170 .tenantName(osAccess.tenant())
169 .authenticate(); 171 .authenticate();
172 + } catch (AuthenticationException e) {
173 + log.warn("Failed to authenticate OpenStack API with {}", osAccess);
174 + return null;
175 + }
170 } 176 }
171 177
172 // TODO remove this when XOS provides this information 178 // TODO remove this when XOS provides this information
......