Allow to specify endpoint perspective property through SONA CLI
Change-Id: Iaf6c1f9bc8e7f8d1064dd7dc17d50d3bcbf34dfe
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenStackEndPointCompleter.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenStackEndPointCompleter.java
index cf2901c..54975c2 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenStackEndPointCompleter.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenStackEndPointCompleter.java
@@ -28,9 +28,9 @@
public class OpenStackEndPointCompleter implements Completer {
private static final String OPENSTACK_ENDPOINT_EXAMPLE_V2 =
- "http://IP address of OpenStack end point:35357/v2.0 ProjectName ID Password";
+ "http://IP address of OpenStack end point:35357/v2.0 Perspective ProjectName ID Password";
private static final String OPENSTACK_ENDPOINT_EXAMPLE_V3 =
- "http://IP address of OpenStack end point/identity/v3 ProjectName ID Password";
+ "http://IP address of OpenStack end point/identity/v3 Perspective ProjectName ID Password";
private static final String SEPARATOR = "\n or \n";
@Override
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackSyncStateCommand.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackSyncStateCommand.java
index ddabb62..066714a 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackSyncStateCommand.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/cli/OpenstackSyncStateCommand.java
@@ -25,6 +25,7 @@
import org.onosproject.openstacknetworking.api.OpenstackSecurityGroupAdminService;
import org.openstack4j.api.OSClient;
import org.openstack4j.api.exceptions.AuthenticationException;
+import org.openstack4j.api.types.Facing;
import org.openstack4j.core.transport.Config;
import org.openstack4j.model.common.Identifier;
import org.openstack4j.model.network.IP;
@@ -62,15 +63,19 @@
required = true, multiValued = false)
private String endpoint = null;
- @Argument(index = 1, name = "tenant", description = "OpenStack admin tenant name",
+ @Argument(index = 1, name = "perspective", description = "OpenStack endpoint perspective",
+ required = true, multiValued = false)
+ private String perspective = null;
+
+ @Argument(index = 2, name = "tenant", description = "OpenStack admin tenant name",
required = true, multiValued = false)
private String tenant = null;
- @Argument(index = 2, name = "user", description = "OpenStack admin user name",
+ @Argument(index = 3, name = "user", description = "OpenStack admin user name",
required = true, multiValued = false)
private String user = null;
- @Argument(index = 3, name = "password", description = "OpenStack admin user password",
+ @Argument(index = 4, name = "password", description = "OpenStack admin user password",
required = true, multiValued = false)
private String password = null;
@@ -97,6 +102,8 @@
OSClient osClient;
+ // we bypass the SSL certification verification for now
+ // TODO: verify server side SSL using a given certification
Config config = Config.newConfig().withSSLVerificationDisabled();
TrustManager[] trustAllCerts = new TrustManager[]{
@@ -123,6 +130,12 @@
config.withSSLContext(sc);
+ Facing facing = getFacing(perspective);
+ if (facing == null) {
+ error("Perspective is invalid. Use public | internal | admin ");
+ return;
+ }
+
if (endpoint != null) {
if (endpoint.contains(KEYSTONE_V2)) {
osClient = OSFactory.builderV2()
@@ -130,6 +143,7 @@
.tenantName(this.tenant)
.credentials(this.user, this.password)
.withConfig(config)
+ .perspective(facing)
.authenticate();
} else if (endpoint.contains(KEYSTONE_V3)) {
@@ -141,6 +155,7 @@
.credentials(this.user, this.password, domain)
.scopeToProject(project, domain)
.withConfig(config)
+ .perspective(facing)
.authenticate();
} else {
print("Unrecognized keystone version type");
@@ -314,4 +329,22 @@
"" : floatingIp.getFixedIpAddress());
print(strFloating);
}
+
+ private Facing getFacing(String strFacing) {
+
+ if (strFacing == null) {
+ return null;
+ }
+
+ switch (strFacing) {
+ case "public":
+ return Facing.PUBLIC;
+ case "admin":
+ return Facing.ADMIN;
+ case "internal":
+ return Facing.INTERNAL;
+ default:
+ return null;
+ }
+ }
}