Add keystone and neutron config classes and codec with unit tests
Change-Id: Ia89f5be9bac88927a383d56d56413ba23e3e5eb3
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DefaultKeystoneConfig.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DefaultKeystoneConfig.java
new file mode 100644
index 0000000..b324759
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DefaultKeystoneConfig.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+package org.onosproject.openstacknode.api;
+
+import com.google.common.base.MoreObjects;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * Implementation class of keystone config.
+ */
+public final class DefaultKeystoneConfig implements KeystoneConfig {
+
+ private final String endpoint;
+ private final OpenstackAuth auth;
+
+ private static final String NOT_NULL_MSG = "% cannot be null";
+
+ private DefaultKeystoneConfig(String endpoint, OpenstackAuth auth) {
+ this.endpoint = endpoint;
+ this.auth = auth;
+ }
+
+ @Override
+ public String endpoint() {
+ return endpoint;
+ }
+
+ @Override
+ public OpenstackAuth authentication() {
+ return auth;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o instanceof DefaultKeystoneConfig) {
+ DefaultKeystoneConfig that = (DefaultKeystoneConfig) o;
+ return Objects.equals(endpoint, that.endpoint) &&
+ Objects.equals(auth, that.auth);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+
+ return Objects.hash(endpoint, auth);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("endpoint", endpoint)
+ .add("auth", auth)
+ .toString();
+ }
+
+ /**
+ * Returns new builder instance.
+ *
+ * @return keystone config instance builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * A builder class for keystone config.
+ */
+ public static final class Builder implements KeystoneConfig.Builder {
+
+ private String endpoint;
+ private OpenstackAuth auth;
+
+ // private constructor not intended to use from external
+ private Builder() {
+ }
+
+ @Override
+ public KeystoneConfig build() {
+ checkArgument(endpoint != null, NOT_NULL_MSG, "endpoint");
+ checkArgument(auth != null, NOT_NULL_MSG, "auth");
+
+ return new DefaultKeystoneConfig(endpoint, auth);
+ }
+
+ @Override
+ public Builder endpoint(String endpoint) {
+ this.endpoint = endpoint;
+ return this;
+ }
+
+ @Override
+ public Builder authentication(OpenstackAuth auth) {
+ this.auth = auth;
+ return this;
+ }
+ }
+}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DefaultNeutronConfig.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DefaultNeutronConfig.java
new file mode 100644
index 0000000..acb5a3d
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DefaultNeutronConfig.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+package org.onosproject.openstacknode.api;
+
+import com.google.common.base.MoreObjects;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * Implementation class of neutron config.
+ */
+public final class DefaultNeutronConfig implements NeutronConfig {
+
+ private final boolean useMetadataProxy;
+ private final String metadataProxySecret;
+
+ private static final String NOT_NULL_MSG = "% cannot be null";
+
+ private DefaultNeutronConfig(boolean useMetadataProxy, String metadataProxySecret) {
+ this.useMetadataProxy = useMetadataProxy;
+ this.metadataProxySecret = metadataProxySecret;
+ }
+
+ @Override
+ public boolean useMetadataProxy() {
+ return useMetadataProxy;
+ }
+
+ @Override
+ public String metadataProxySecret() {
+ return metadataProxySecret;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o instanceof DefaultNeutronConfig) {
+ DefaultNeutronConfig that = (DefaultNeutronConfig) o;
+ return Objects.equals(useMetadataProxy, that.useMetadataProxy) &&
+ Objects.equals(metadataProxySecret, that.metadataProxySecret);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+
+ return Objects.hash(useMetadataProxy, metadataProxySecret);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("useMetadataProxy", useMetadataProxy)
+ .add("metadataProxySecret", metadataProxySecret)
+ .toString();
+ }
+
+ /**
+ * Returns new builder instance.
+ *
+ * @return neutron config instance builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * A builder class for neutron config.
+ */
+ public static final class Builder implements NeutronConfig.Builder {
+
+ private boolean useMetadataProxy;
+ private String metadataProxySecret;
+
+ // private constructor not intended to use from external
+ private Builder() {
+ }
+
+ @Override
+ public NeutronConfig build() {
+ checkArgument(metadataProxySecret != null,
+ NOT_NULL_MSG, "metadataProxySecret");
+
+ return new DefaultNeutronConfig(useMetadataProxy, metadataProxySecret);
+ }
+
+ @Override
+ public NeutronConfig.Builder useMetadataProxy(boolean useMetadataProxy) {
+ this.useMetadataProxy = useMetadataProxy;
+ return this;
+ }
+
+ @Override
+ public NeutronConfig.Builder metadataProxySecret(String metadataProxySecret) {
+ this.metadataProxySecret = metadataProxySecret;
+ return this;
+ }
+ }
+}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DefaultOpenstackNode.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DefaultOpenstackNode.java
index 94afc4e..ec811b3 100644
--- a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DefaultOpenstackNode.java
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/DefaultOpenstackNode.java
@@ -53,10 +53,10 @@
private final NodeState state;
private final Collection<OpenstackPhyInterface> phyIntfs;
private final Collection<ControllerInfo> controllers;
- private final OpenstackAuth auth;
- private final String endpoint;
private final OpenstackSshAuth sshAuth;
private final DpdkConfig dpdkConfig;
+ private final KeystoneConfig keystoneConfig;
+ private final NeutronConfig neutronConfig;
private static final String NOT_NULL_MSG = "Node % cannot be null";
@@ -65,20 +65,20 @@
/**
* A default constructor of Openstack Node.
*
- * @param hostname hostname
- * @param type node type
- * @param intgBridge integration bridge
- * @param managementIp management IP address
- * @param dataIp data IP address
- * @param vlanIntf VLAN interface
- * @param uplinkPort uplink port name
- * @param state node state
- * @param phyIntfs physical interfaces
- * @param controllers customized controllers
- * @param auth keystone authentication info
- * @param endpoint openstack endpoint URL
- * @param sshAuth ssh authentication info
- * @param dpdkConfig dpdk config
+ * @param hostname hostname
+ * @param type node type
+ * @param intgBridge integration bridge
+ * @param managementIp management IP address
+ * @param dataIp data IP address
+ * @param vlanIntf VLAN interface
+ * @param uplinkPort uplink port name
+ * @param state node state
+ * @param phyIntfs physical interfaces
+ * @param controllers customized controllers
+ * @param sshAuth ssh authentication info
+ * @param dpdkConfig dpdk config
+ * @param keystoneConfig keystone config
+ * @param neutronConfig neutron config
*/
protected DefaultOpenstackNode(String hostname, NodeType type,
DeviceId intgBridge,
@@ -89,10 +89,10 @@
NodeState state,
Collection<OpenstackPhyInterface> phyIntfs,
Collection<ControllerInfo> controllers,
- OpenstackAuth auth,
- String endpoint,
OpenstackSshAuth sshAuth,
- DpdkConfig dpdkConfig) {
+ DpdkConfig dpdkConfig,
+ KeystoneConfig keystoneConfig,
+ NeutronConfig neutronConfig) {
this.hostname = hostname;
this.type = type;
this.intgBridge = intgBridge;
@@ -103,10 +103,10 @@
this.state = state;
this.phyIntfs = phyIntfs;
this.controllers = controllers;
- this.auth = auth;
- this.endpoint = endpoint;
this.sshAuth = sshAuth;
this.dpdkConfig = dpdkConfig;
+ this.keystoneConfig = keystoneConfig;
+ this.neutronConfig = neutronConfig;
}
@Override
@@ -253,10 +253,10 @@
Objects.equals(vlanIntf, that.vlanIntf) &&
Objects.equals(phyIntfs, that.phyIntfs) &&
Objects.equals(controllers, that.controllers) &&
- Objects.equals(auth, that.auth) &&
- Objects.equals(endpoint, that.endpoint) &&
Objects.equals(sshAuth, that.sshAuth) &&
- Objects.equals(dpdkConfig, that.dpdkConfig);
+ Objects.equals(dpdkConfig, that.dpdkConfig) &&
+ Objects.equals(keystoneConfig, that.keystoneConfig) &&
+ Objects.equals(neutronConfig, that.neutronConfig);
}
return false;
}
@@ -272,10 +272,10 @@
uplinkPort,
phyIntfs,
controllers,
- auth,
- endpoint,
sshAuth,
- dpdkConfig);
+ dpdkConfig,
+ keystoneConfig,
+ neutronConfig);
}
@Override
@@ -291,10 +291,10 @@
.add("state", state)
.add("phyIntfs", phyIntfs)
.add("controllers", controllers)
- .add("auth", auth)
- .add("endpoint", endpoint)
.add("sshAuth", sshAuth)
- .add("datapathType", dpdkConfig)
+ .add("dpdkConfig", dpdkConfig)
+ .add("keystoneConfig", keystoneConfig)
+ .add("neutronConfig", neutronConfig)
.toString();
}
@@ -311,10 +311,10 @@
.state(newState)
.phyIntfs(phyIntfs)
.controllers(controllers)
- .authentication(auth)
- .endpoint(endpoint)
.sshAuthInfo(sshAuth)
.dpdkConfig(dpdkConfig)
+ .keystoneConfig(keystoneConfig)
+ .neutronConfig(neutronConfig)
.build();
}
@@ -330,11 +330,10 @@
.uplinkPort(uplinkPort)
.state(state)
.phyIntfs(phyIntfs)
- .controllers(controllers)
- .authentication(auth)
- .endpoint(endpoint)
.sshAuthInfo(sshAuth)
.dpdkConfig(dpdkConfig)
+ .keystoneConfig(keystoneConfig)
+ .neutronConfig(neutronConfig)
.build();
}
@@ -368,6 +367,16 @@
}
@Override
+ public KeystoneConfig keystoneConfig() {
+ return keystoneConfig;
+ }
+
+ @Override
+ public NeutronConfig neutronConfig() {
+ return neutronConfig;
+ }
+
+ @Override
public PortNumber phyIntfPortNum(String providerPhysnet) {
Optional<OpenstackPhyInterface> openstackPhyInterface =
phyIntfs.stream().filter(p -> p.network().equals(providerPhysnet)).findAny();
@@ -386,16 +395,6 @@
}
- @Override
- public OpenstackAuth authentication() {
- return auth;
- }
-
- @Override
- public String endpoint() {
- return endpoint;
- }
-
/**
* Returns new builder instance.
*
@@ -423,10 +422,10 @@
.state(osNode.state())
.phyIntfs(osNode.phyIntfs())
.controllers(osNode.controllers())
- .authentication(osNode.authentication())
- .endpoint(osNode.endpoint())
.sshAuthInfo(osNode.sshAuthInfo())
- .dpdkConfig(osNode.dpdkConfig());
+ .dpdkConfig(osNode.dpdkConfig())
+ .keystoneConfig(osNode.keystoneConfig())
+ .neutronConfig(osNode.neutronConfig());
}
/**
@@ -444,10 +443,10 @@
private NodeState state;
private Collection<OpenstackPhyInterface> phyIntfs;
private Collection<ControllerInfo> controllers;
- private OpenstackAuth auth;
- private String endpoint;
private OpenstackSshAuth sshAuth;
private DpdkConfig dpdkConfig;
+ private KeystoneConfig keystoneConfig;
+ private NeutronConfig neutronConfig;
// private constructor not intended to use from external
private Builder() {
@@ -465,7 +464,7 @@
throw new IllegalArgumentException("Either data IP or VLAN interface is required");
}
} else {
- checkArgument(endpoint != null, NOT_NULL_MSG, "endpoint URL");
+ checkArgument(keystoneConfig != null, NOT_NULL_MSG, "keystone config");
}
if (type == NodeType.GATEWAY && uplinkPort == null) {
@@ -482,10 +481,10 @@
state,
phyIntfs,
controllers,
- auth,
- endpoint,
sshAuth,
- dpdkConfig);
+ dpdkConfig,
+ keystoneConfig,
+ neutronConfig);
}
@Override
@@ -551,18 +550,6 @@
}
@Override
- public Builder authentication(OpenstackAuth auth) {
- this.auth = auth;
- return this;
- }
-
- @Override
- public Builder endpoint(String endpoint) {
- this.endpoint = endpoint;
- return this;
- }
-
- @Override
public Builder sshAuthInfo(OpenstackSshAuth sshAuth) {
this.sshAuth = sshAuth;
return this;
@@ -573,6 +560,18 @@
this.dpdkConfig = dpdkConfig;
return this;
}
+
+ @Override
+ public Builder keystoneConfig(KeystoneConfig keystoneConfig) {
+ this.keystoneConfig = keystoneConfig;
+ return this;
+ }
+
+ @Override
+ public Builder neutronConfig(NeutronConfig neutronConfig) {
+ this.neutronConfig = neutronConfig;
+ return this;
+ }
}
}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/KeystoneConfig.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/KeystoneConfig.java
new file mode 100644
index 0000000..6407993
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/KeystoneConfig.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+package org.onosproject.openstacknode.api;
+
+/**
+ * Representation of openstack keystone config information.
+ */
+public interface KeystoneConfig {
+
+ /**
+ * Returns the endpoint URL info.
+ *
+ * @return keystone authentication info
+ */
+ String endpoint();
+
+ /**
+ * Returns the keystone authentication info.
+ *
+ * @return keystone authentication info
+ */
+ OpenstackAuth authentication();
+
+ /**
+ * Builder of new keystone config entity.
+ */
+ interface Builder {
+
+ /**
+ * Builds an immutable keystone config instance.
+ *
+ * @return keystone config instance
+ */
+ KeystoneConfig build();
+
+ /**
+ * Returns keystone config builder with supplied endpoint.
+ *
+ * @param endpoint endpoint of keystone
+ * @return keystone config builder
+ */
+ Builder endpoint(String endpoint);
+
+ /**
+ * Returns keystone config builder with supplied authentication info.
+ *
+ * @param auth authentication info
+ * @return keystone config builder
+ */
+ Builder authentication(OpenstackAuth auth);
+ }
+}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/NeutronConfig.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/NeutronConfig.java
new file mode 100644
index 0000000..86ea2a9
--- /dev/null
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/NeutronConfig.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+package org.onosproject.openstacknode.api;
+
+/**
+ * Representation of openstack neutron config information.
+ */
+public interface NeutronConfig {
+
+ /**
+ * Returns whether to use metadata proxy service.
+ * Note that SONA will behave as a metadata proxy server
+ *
+ * @return true if metadata proxy service is enabled, false otherwise
+ */
+ boolean useMetadataProxy();
+
+ /**
+ * Returns metadata proxy secret.
+ *
+ * @return metadata proxy secret
+ */
+ String metadataProxySecret();
+
+ /**
+ * Builder of neutron config.
+ */
+ interface Builder {
+
+ /**
+ * Builds an immutable neutron config instance.
+ *
+ * @return neutron config instance
+ */
+ NeutronConfig build();
+
+ /**
+ * Returns neutron config with supplied useMetadataProxy flag.
+ *
+ * @param useMetadataProxy useMetadataProxy flag
+ * @return neutron config builder
+ */
+ Builder useMetadataProxy(boolean useMetadataProxy);
+
+ /**
+ * Returns neutron config with supplied metadataProxySecret.
+ *
+ * @param metadataProxySecret metadata proxy secret
+ * @return neutron config builder
+ */
+ Builder metadataProxySecret(String metadataProxySecret);
+ }
+}
diff --git a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
index 3ffdda9..a2000ee 100644
--- a/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
+++ b/apps/openstacknode/api/src/main/java/org/onosproject/openstacknode/api/OpenstackNode.java
@@ -192,20 +192,6 @@
PortNumber phyIntfPortNum(String providerPhysnet);
/**
- * Returns the keystone authentication info.
- *
- * @return keystone authentication info
- */
- OpenstackAuth authentication();
-
- /**
- * Returns the endpoint URL info.
- *
- * @return keystone authentication info
- */
- String endpoint();
-
- /**
* Returns a collection of customized controllers.
*
* @return customized controllers
@@ -227,6 +213,20 @@
DpdkConfig dpdkConfig();
/**
+ * Returns the keystone config info.
+ *
+ * @return keystone config
+ */
+ KeystoneConfig keystoneConfig();
+
+ /**
+ * Returns the neutron config info.
+ *
+ * @return neutron config
+ */
+ NeutronConfig neutronConfig();
+
+ /**
* Builder of new node entities.
*/
interface Builder {
@@ -319,22 +319,6 @@
Builder controllers(Collection<ControllerInfo> controllers);
/**
- * Returns openstack node builder with supplied authentication info.
- *
- * @param auth keystone authentication info
- * @return openstack node builder
- */
- Builder authentication(OpenstackAuth auth);
-
- /**
- * Returns openstack node builder with supplied endpoint info.
- *
- * @param endpoint endpoint info
- * @return openstack node builder
- */
- Builder endpoint(String endpoint);
-
- /**
* Returns openstack node builder with supplied ssh authentication info.
*
* @param sshAuth ssh authentication info
@@ -349,6 +333,22 @@
* @return openstack node builder
*/
Builder dpdkConfig(DpdkConfig dpdkConfig);
+
+ /**
+ * Returns openstack node builder with supplied keystone config info.
+ *
+ * @param keystoneConfig keystone config
+ * @return openstack node builder
+ */
+ Builder keystoneConfig(KeystoneConfig keystoneConfig);
+
+ /**
+ * Returns openstack node builder with supplied neutron config info.
+ *
+ * @param neutronConfig neutron config
+ * @return openstack node builder
+ */
+ Builder neutronConfig(NeutronConfig neutronConfig);
}
}
diff --git a/apps/openstacknode/api/src/test/java/org/onosproject/openstacknode/api/DefaultKeystoneConfigTest.java b/apps/openstacknode/api/src/test/java/org/onosproject/openstacknode/api/DefaultKeystoneConfigTest.java
new file mode 100644
index 0000000..348695b
--- /dev/null
+++ b/apps/openstacknode/api/src/test/java/org/onosproject/openstacknode/api/DefaultKeystoneConfigTest.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+package org.onosproject.openstacknode.api;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+import static org.onosproject.openstacknode.api.OpenstackAuth.Perspective.PUBLIC;
+import static org.onosproject.openstacknode.api.OpenstackAuth.Protocol.HTTP;
+
+/**
+ * Unit tests for DefaultKeystoneConfig.
+ */
+public final class DefaultKeystoneConfigTest {
+
+ private static final String ENDPOINT_1 = "192.168.0.10:35357/v2.0";
+ private static final String ENDPOINT_2 = "192.168.0.11:80/v3";
+
+ private static final String USERNAME = "admin";
+ private static final String PASSWORD = "nova";
+ private static final String PROJECT = "admin";
+ private static final String VERSION_2 = "v2.0";
+ private static final String VERSION_3 = "v3";
+
+ private static final OpenstackAuth AUTHENTICATION_1 = createAuthv2();
+ private static final OpenstackAuth AUTHENTICATION_2 = createAuthv3();
+
+ private KeystoneConfig config1;
+ private KeystoneConfig sameAsConfig1;
+ private KeystoneConfig config2;
+
+ private static OpenstackAuth createAuthv2() {
+ return DefaultOpenstackAuth.builder()
+ .username(USERNAME)
+ .password(PASSWORD)
+ .project(PROJECT)
+ .version(VERSION_2)
+ .perspective(PUBLIC)
+ .protocol(HTTP)
+ .build();
+ }
+
+ private static OpenstackAuth createAuthv3() {
+ return DefaultOpenstackAuth.builder()
+ .username(USERNAME)
+ .password(PASSWORD)
+ .project(PROJECT)
+ .version(VERSION_3)
+ .perspective(PUBLIC)
+ .protocol(HTTP)
+ .build();
+ }
+
+ /**
+ * Tests class immutability.
+ */
+ @Test
+ public void testImmutability() {
+ assertThatClassIsImmutable(DefaultKeystoneConfig.class);
+ }
+
+ /**
+ * Initial setup for this unit test.
+ */
+ @Before
+ public void setUp() {
+ config1 = DefaultKeystoneConfig.builder()
+ .endpoint(ENDPOINT_1)
+ .authentication(AUTHENTICATION_1)
+ .build();
+
+ sameAsConfig1 = DefaultKeystoneConfig.builder()
+ .endpoint(ENDPOINT_1)
+ .authentication(AUTHENTICATION_1)
+ .build();
+
+ config2 = DefaultKeystoneConfig.builder()
+ .endpoint(ENDPOINT_2)
+ .authentication(AUTHENTICATION_2)
+ .build();
+ }
+
+ /**
+ * Tests object equality.
+ */
+ @Test
+ public void testEquality() {
+ new EqualsTester().addEqualityGroup(config1, sameAsConfig1)
+ .addEqualityGroup(config2)
+ .testEquals();
+ }
+
+ /**
+ * Test object construction.
+ */
+ @Test
+ public void testConstruction() {
+ KeystoneConfig config = config1;
+
+ assertEquals(config.endpoint(), ENDPOINT_1);
+ assertEquals(config.authentication(), AUTHENTICATION_1);
+ }
+}
diff --git a/apps/openstacknode/api/src/test/java/org/onosproject/openstacknode/api/DefaultNeutronConfigTest.java b/apps/openstacknode/api/src/test/java/org/onosproject/openstacknode/api/DefaultNeutronConfigTest.java
new file mode 100644
index 0000000..63c3833
--- /dev/null
+++ b/apps/openstacknode/api/src/test/java/org/onosproject/openstacknode/api/DefaultNeutronConfigTest.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+package org.onosproject.openstacknode.api;
+
+import com.google.common.testing.EqualsTester;
+import org.junit.Before;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+/**
+ * Unit tests for DefaultNeutronConfig.
+ */
+public class DefaultNeutronConfigTest {
+
+ private static final boolean USE_METADATA_PROXY_1 = true;
+ private static final boolean USE_METADATA_PROXY_2 = false;
+
+ private static final String METADATA_PROXY_SECRET_1 = "onos";
+ private static final String METADATA_PROXY_SECRET_2 = "cord";
+
+ private NeutronConfig config1;
+ private NeutronConfig sameAsConfig1;
+ private NeutronConfig config2;
+
+ /**
+ * Tests class immutability.
+ */
+ @Test
+ public void testImmutability() {
+ assertThatClassIsImmutable(DefaultNeutronConfig.class);
+ }
+
+ /**
+ * Initial setup for this unit test.
+ */
+ @Before
+ public void setUp() {
+ config1 = DefaultNeutronConfig.builder()
+ .useMetadataProxy(USE_METADATA_PROXY_1)
+ .metadataProxySecret(METADATA_PROXY_SECRET_1)
+ .build();
+
+ sameAsConfig1 = DefaultNeutronConfig.builder()
+ .useMetadataProxy(USE_METADATA_PROXY_1)
+ .metadataProxySecret(METADATA_PROXY_SECRET_1)
+ .build();
+
+ config2 = DefaultNeutronConfig.builder()
+ .useMetadataProxy(USE_METADATA_PROXY_2)
+ .metadataProxySecret(METADATA_PROXY_SECRET_2)
+ .build();
+ }
+
+ /**
+ * Tests object equality.
+ */
+ @Test
+ public void testEquality() {
+ new EqualsTester().addEqualityGroup(config1, sameAsConfig1)
+ .addEqualityGroup(config2)
+ .testEquals();
+ }
+
+ /**
+ * Test object construction.
+ */
+ @Test
+ public void testConstruction() {
+ NeutronConfig config = config1;
+
+ assertEquals(config.useMetadataProxy(), USE_METADATA_PROXY_1);
+ assertEquals(config.metadataProxySecret(), METADATA_PROXY_SECRET_1);
+ }
+}
diff --git a/apps/openstacknode/api/src/test/java/org/onosproject/openstacknode/api/OpenstackNodeAdapter.java b/apps/openstacknode/api/src/test/java/org/onosproject/openstacknode/api/OpenstackNodeAdapter.java
index 68fa85e..d625a05 100644
--- a/apps/openstacknode/api/src/test/java/org/onosproject/openstacknode/api/OpenstackNodeAdapter.java
+++ b/apps/openstacknode/api/src/test/java/org/onosproject/openstacknode/api/OpenstackNodeAdapter.java
@@ -129,16 +129,6 @@
}
@Override
- public OpenstackAuth authentication() {
- return null;
- }
-
- @Override
- public String endpoint() {
- return null;
- }
-
- @Override
public Collection<ControllerInfo> controllers() {
return null;
}
@@ -152,4 +142,14 @@
public DpdkConfig dpdkConfig() {
return null;
}
+
+ @Override
+ public KeystoneConfig keystoneConfig() {
+ return null;
+ }
+
+ @Override
+ public NeutronConfig neutronConfig() {
+ return null;
+ }
}