You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ni...@apache.org on 2014/03/18 04:00:03 UTC

[11/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 - adding Openstack-nova module to dependencies

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java
new file mode 100644
index 0000000..740c5e8
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Properties;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.keystone.v2_0.internal.KeystoneFixture;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseServerListTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * 
+ * @see KeystoneProperties#CREDENTIAL_TYPE
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest")
+public class AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest extends BaseNovaApiExpectTest {
+   public AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest() {
+      identity = "identity";
+   }
+
+   /**
+    * this reflects the properties that a user would pass to createContext
+    */
+   @Override
+   protected Properties setupProperties() {
+      Properties contextProperties = super.setupProperties();
+      contextProperties.setProperty("jclouds.keystone.credential-type", "apiAccessKeyCredentials");
+      contextProperties.setProperty("jclouds.keystone.tenant-name", KeystoneFixture.INSTANCE.getTenantName());
+      return contextProperties;
+   }
+
+   public void testListServersWhenResponseIs2xx() throws Exception {
+      HttpRequest listServers = HttpRequest
+            .builder()
+            .method("GET")
+            .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers")
+            .addHeader("Accept", "application/json")
+            .addHeader("X-Auth-Token", authToken).build();
+
+      HttpResponse listServersResponse = HttpResponse.builder().statusCode(200)
+            .payload(payloadFromResource("/server_list.json")).build();
+
+      NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName,
+            responseWithKeystoneAccess, listServers, listServersResponse);
+
+      assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
+
+      assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
+            new ParseServerListTest().expected().toString());
+   }
+
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java
new file mode 100644
index 0000000..0784a7b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Properties;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseServerListTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * 
+ * @see KeystoneProperties#CREDENTIAL_TYPE
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "AccessKeyAndSecretKeyAuthenticationExpectTest")
+public class AccessKeyAndSecretKeyAuthenticationExpectTest extends BaseNovaApiExpectTest {
+
+   /**
+    * this reflects the properties that a user would pass to createContext
+    */
+   @Override
+   protected Properties setupProperties() {
+      Properties contextProperties = super.setupProperties();
+      contextProperties.setProperty("jclouds.keystone.credential-type", "apiAccessKeyCredentials");
+      return contextProperties;
+   }
+
+   public void testListServersWhenResponseIs2xx() throws Exception {
+      HttpRequest listServers = HttpRequest
+            .builder()
+            .method("GET")
+            .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers")
+            .addHeader("Accept", "application/json")
+            .addHeader("X-Auth-Token", authToken).build();
+
+      HttpResponse listServersResponse = HttpResponse.builder().statusCode(200)
+            .payload(payloadFromResource("/server_list.json")).build();
+
+      NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithAccessKeyAndSecretKeyAndTenantName,
+            responseWithKeystoneAccess, listServers, listServersResponse);
+
+      assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
+
+      assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
+            new ParseServerListTest().expected().toString());
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java
new file mode 100644
index 0000000..a158875
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0;
+
+import static org.jclouds.Constants.PROPERTY_ENDPOINT;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Properties;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests to ensure that we can pick the only endpoint of a service
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "EndpointIdIsRandomExpectTest")
+public class EndpointIdIsRandomExpectTest extends BaseNovaApiExpectTest {
+
+   public EndpointIdIsRandomExpectTest() {
+      this.identity = "demo:demo";
+      this.credential = "password";
+   }
+
+   @Override
+   protected Properties setupProperties() {
+      Properties overrides = super.setupProperties();
+      overrides.setProperty(PROPERTY_ENDPOINT, "http://10.10.10.10:5000/v2.0/");
+      return overrides;
+   }
+
+   public void testVersionMatchOnConfiguredZonesWhenResponseIs2xx() {
+
+      HttpRequest authenticate = HttpRequest
+            .builder()
+            .method("POST")
+            .endpoint("http://10.10.10.10:5000/v2.0/tokens")
+            .addHeader("Accept", "application/json")
+            .payload(
+                  payloadFromStringWithContentType(
+                        "{\"auth\":{\"passwordCredentials\":{\"username\":\"demo\",\"password\":\"password\"},\"tenantName\":\"demo\"}}",
+                        "application/json")).build();
+
+      HttpResponse authenticationResponse = HttpResponse.builder().statusCode(200)
+            .payload(payloadFromResourceWithContentType("/access_version_uids.json", "application/json")).build();
+
+      NovaApi whenNovaRegionExists = requestSendsResponse(authenticate, authenticationResponse);
+
+      assertEquals(whenNovaRegionExists.getConfiguredZones(), ImmutableSet.of("RegionOne"));
+
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadataTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadataTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadataTest.java
new file mode 100644
index 0000000..fbca404
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadataTest.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0;
+
+import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
+import org.testng.annotations.Test;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "NovaApiMetadataTest")
+public class NovaApiMetadataTest extends BaseComputeServiceApiMetadataTest {
+
+   public NovaApiMetadataTest() {
+      super(new NovaApiMetadata());
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java
new file mode 100644
index 0000000..ad7bf9a
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0;
+
+import static org.testng.Assert.assertEquals;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseServerListTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * 
+ * @see KeystoneProperties#CREDENTIAL_TYPE
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "PasswordAuthenticationExpectTest")
+public class PasswordAuthenticationExpectTest extends BaseNovaApiExpectTest {
+   public PasswordAuthenticationExpectTest() {
+      identity = "identity";
+   }
+   
+   public void testListServersWhenResponseIs2xx() throws Exception {
+      HttpRequest listServers = HttpRequest
+            .builder()
+            .method("GET")
+            .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers")
+            .addHeader("Accept", "application/json")
+            .addHeader("X-Auth-Token", authToken).build();
+
+      HttpResponse listServersResponse = HttpResponse.builder().statusCode(200)
+            .payload(payloadFromResource("/server_list.json")).build();
+
+      NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPassword,
+            responseWithKeystoneAccess, listServers, listServersResponse);
+
+      assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
+
+      assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
+            new ParseServerListTest().expected().toString());
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java
new file mode 100644
index 0000000..06b6f85
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Properties;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseServerListTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * 
+ * @see KeystoneProperties#CREDENTIAL_TYPE
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "PasswordAuthenticationWithTenantNameExpectTest")
+public class PasswordAuthenticationWithTenantNameExpectTest extends BaseNovaApiExpectTest {
+
+   /**
+    * this reflects the properties that a user would pass to createContext
+    */
+   @Override
+   protected Properties setupProperties() {
+      Properties contextProperties = super.setupProperties();
+      contextProperties.setProperty("jclouds.keystone.credential-type", "passwordCredentials");
+      return contextProperties;
+   }
+
+   public void testListServersWhenResponseIs2xx() throws Exception {
+      HttpRequest listServers = HttpRequest
+            .builder()
+            .method("GET")
+            .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers")
+            .addHeader("Accept", "application/json")
+            .addHeader("X-Auth-Token", authToken).build();
+
+      HttpResponse listServersResponse = HttpResponse.builder().statusCode(200)
+            .payload(payloadFromResource("/server_list.json")).build();
+
+      NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+            responseWithKeystoneAccess, listServers, listServersResponse);
+
+      assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
+
+      assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().toString(),
+            new ParseServerListTest().expected().toString());
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java
new file mode 100644
index 0000000..edf5a56
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java
@@ -0,0 +1,321 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.compute;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
+import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
+import org.jclouds.openstack.nova.v2_0.domain.Network;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaComputeServiceContextExpectTest;
+import org.testng.annotations.Test;
+
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Tests the compute service abstraction of the nova api.
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "NovaComputeServiceAdapterExpectTest")
+public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceContextExpectTest<Injector> {
+   HttpRequest serverDetail = HttpRequest
+         .builder()
+         .method("GET")
+         .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/71752")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken).build();
+
+   HttpResponse serverDetailResponse = HttpResponse.builder().statusCode(200)
+         .payload(payloadFromResource("/server_details.json")).build();
+
+   public void testCreateNodeWithGroupEncodedIntoNameWithNetworks() throws Exception {
+
+      HttpRequest createServer = HttpRequest
+         .builder()
+         .method("POST")
+         .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken)
+         .payload(payloadFromStringWithContentType(
+                  "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"networks\": [{\"uuid\": \"4ebd35cf-bfe7-4d93-b0d8-eb468ce2245a\"}]}}","application/json"))
+         .build();
+
+      HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
+         .payload(payloadFromResourceWithContentType("/new_server_networks_response.json","application/json; charset=UTF-8")).build();
+
+      Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder()
+               .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess)
+               .put(extensionsOfNovaRequest, extensionsOfNovaResponse)
+               .put(listDetail, listDetailResponse)
+               .put(listFlavorsDetail, listFlavorsDetailResponse)
+               .put(createServer, createServerResponse)
+               .put(serverDetail, serverDetailResponse).build();
+
+      Injector forNetworks = requestsSendResponses(requestResponseMap);
+
+      Template template = forNetworks.getInstance(TemplateBuilder.class).build();
+      template.getOptions().as(NovaTemplateOptions.class).networks("4ebd35cf-bfe7-4d93-b0d8-eb468ce2245a");
+      
+      NovaComputeServiceAdapter adapter = forNetworks.getInstance(NovaComputeServiceAdapter.class);
+
+      NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template);
+      assertNotNull(server);
+      // Response irrelevant in this expect test - just verifying the request.
+   }
+   
+   public void testCreateNodeWithGroupEncodedIntoNameWithDiskConfig() throws Exception {
+
+      HttpRequest createServer = HttpRequest
+         .builder()
+         .method("POST")
+         .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken)
+         .payload(payloadFromStringWithContentType(
+                  "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"OS-DCF:diskConfig\":\"AUTO\"}}","application/json"))
+         .build();
+
+      HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
+         .payload(payloadFromResourceWithContentType("/new_server_disk_config_auto.json","application/json; charset=UTF-8")).build();
+
+      Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder()
+               .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess)
+               .put(extensionsOfNovaRequest, extensionsOfNovaResponse)
+               .put(listDetail, listDetailResponse)
+               .put(listFlavorsDetail, listFlavorsDetailResponse)
+               .put(createServer, createServerResponse)
+               .put(serverDetail, serverDetailResponse).build();
+
+      Injector forDiskConfig = requestsSendResponses(requestResponseMap);
+
+      Template template = forDiskConfig.getInstance(TemplateBuilder.class).build();
+      template.getOptions().as(NovaTemplateOptions.class).diskConfig(Server.DISK_CONFIG_AUTO);
+      
+      NovaComputeServiceAdapter adapter = forDiskConfig.getInstance(NovaComputeServiceAdapter.class);
+
+      NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template);
+      assertNotNull(server);
+      assertEquals(server.getNode().getServer().getDiskConfig().orNull(), Server.DISK_CONFIG_AUTO);
+   }
+
+   public void testCreateNodeWithGroupEncodedIntoNameWithNovaNetworks() throws Exception {
+
+      HttpRequest createServer = HttpRequest
+         .builder()
+         .method("POST")
+         .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken)
+         .payload(payloadFromStringWithContentType(
+                  "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"networks\":[{\"uuid\":\"12345\", \"port\":\"67890\", \"fixed_ip\":\"192.168.0.1\"},{\"uuid\":\"54321\", \"port\":\"09876\", \"fixed_ip\":\"192.168.0.2\"},{\"uuid\":\"non-nova-uuid\"}]}}","application/json"))
+         .build();
+
+      HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
+         .payload(payloadFromResourceWithContentType("/new_server_nova_networks.json","application/json; charset=UTF-8")).build();
+
+      Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder()
+               .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess)
+               .put(extensionsOfNovaRequest, extensionsOfNovaResponse)
+               .put(listDetail, listDetailResponse)
+               .put(listFlavorsDetail, listFlavorsDetailResponse)
+               .put(createServer, createServerResponse)
+               .put(serverDetail, serverDetailResponse).build();
+
+      Injector forNovaNetworks = requestsSendResponses(requestResponseMap);
+
+      Template template = forNovaNetworks.getInstance(TemplateBuilder.class).build();
+      template.getOptions().as(NovaTemplateOptions.class)
+         .networks("non-nova-uuid")
+         .novaNetworks(
+               ImmutableSet.of(
+                     Network.builder()
+                        .networkUuid("12345")
+                        .portUuid("67890")
+                        .fixedIp("192.168.0.1")
+                        .build(),
+                     Network.builder()
+                        .networkUuid("54321")
+                        .portUuid("09876")
+                        .fixedIp("192.168.0.2")
+                        .build()));
+
+      NovaComputeServiceAdapter adapter = forNovaNetworks.getInstance(NovaComputeServiceAdapter.class);
+
+      NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template);
+      assertNotNull(server);
+   }
+
+   public void testCreateNodeWithGroupEncodedIntoNameWhenSecurityGroupsArePresent() throws Exception {
+
+      HttpRequest createServer = HttpRequest
+         .builder()
+         .method("POST")
+         .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken)
+         .payload(payloadFromStringWithContentType(
+                  "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"security_groups\":[{\"name\":\"group1\"}, {\"name\":\"group2\"}]}}","application/json"))
+         .build();
+
+      HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
+         .payload(payloadFromResourceWithContentType("/new_server.json","application/json; charset=UTF-8")).build();
+
+      Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder()
+               .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess)
+               .put(extensionsOfNovaRequest, extensionsOfNovaResponse)
+               .put(listDetail, listDetailResponse)
+               .put(listFlavorsDetail, listFlavorsDetailResponse)
+               .put(createServer, createServerResponse)
+               .put(serverDetail, serverDetailResponse).build();
+
+      Injector forSecurityGroups = requestsSendResponses(requestResponseMap);
+
+      Template template = forSecurityGroups.getInstance(TemplateBuilder.class).build();
+      template.getOptions().as(NovaTemplateOptions.class).securityGroupNames("group1", "group2");
+      
+      NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class);
+
+      NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92",
+               template);
+      assertNotNull(server);
+      assertEquals(server.getCredentials(), LoginCredentials.builder().password("ZWuHcmTMQ7eXoHeM").build());
+   }
+
+   /**
+    * We need to choose the correct credential for attempts to start the server. cloud-init or the
+    * like will set the ssh key as the login credential, and not necessarily will password
+    * authentication even be available.
+    */
+   public void testWhenKeyPairPresentWeUsePrivateKeyAsCredentialNotPassword() throws Exception {
+      
+      HttpRequest createServer = HttpRequest
+         .builder()
+         .method("POST")
+         .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken)
+         .payload(payloadFromStringWithContentType(
+                  "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"key_name\":\"foo\"}}","application/json"))
+         .build();
+
+  
+      HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
+         .payload(payloadFromResourceWithContentType("/new_server_no_adminpass.json","application/json; charset=UTF-8")).build();
+
+      Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder()
+               .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess)
+               .put(extensionsOfNovaRequest, extensionsOfNovaResponse)
+               .put(listDetail, listDetailResponse)
+               .put(listFlavorsDetail, listFlavorsDetailResponse)
+               .put(createServer, createServerResponse)
+               .put(serverDetail, serverDetailResponse).build();
+
+      Injector forSecurityGroups = requestsSendResponses(requestResponseMap);
+
+      Template template = forSecurityGroups.getInstance(TemplateBuilder.class).build();
+      template.getOptions().as(NovaTemplateOptions.class).keyPairName("foo");
+      
+      NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class);
+      
+      // we expect to have already an entry in the cache for the key
+      LoadingCache<ZoneAndName, KeyPair> keyPairCache = forSecurityGroups.getInstance(Key
+               .get(new TypeLiteral<LoadingCache<ZoneAndName, KeyPair>>() {
+               }));
+      keyPairCache.put(ZoneAndName.fromZoneAndName("az-1.region-a.geo-1", "foo"), KeyPair.builder().name("foo")
+               .privateKey("privateKey").build());
+      
+      NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92",
+               template);
+      assertNotNull(server);
+      assertEquals(server.getCredentials(), LoginCredentials.builder().privateKey("privateKey").build());
+   }
+
+
+   /**
+    * When enable_instance_password is false, then no admin pass is generated.
+    * However in this case if you don't specify the name of the SSH keypair to
+    * inject, then you simply cannot log in to the server.
+    */
+   public void testNoKeyPairOrAdminPass() throws Exception {
+      
+      HttpRequest createServer = HttpRequest
+         .builder()
+         .method("POST")
+         .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken)
+         .payload(payloadFromStringWithContentType(
+                  "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\"}}","application/json"))
+         .build();
+  
+      HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
+         .payload(payloadFromResourceWithContentType("/new_server_no_adminpass.json","application/json; charset=UTF-8")).build();
+
+      Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder()
+               .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess)
+               .put(extensionsOfNovaRequest, extensionsOfNovaResponse)
+               .put(listDetail, listDetailResponse)
+               .put(listFlavorsDetail, listFlavorsDetailResponse)
+               .put(createServer, createServerResponse)
+               .put(serverDetail, serverDetailResponse).build();
+
+      Injector forSecurityGroups = requestsSendResponses(requestResponseMap);
+
+      Template template = forSecurityGroups.getInstance(TemplateBuilder.class).build();
+      
+      NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class);
+      
+      NodeAndInitialCredentials<ServerInZone> server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92",
+            template);
+      assertNotNull(server);
+      assertNull(server.getCredentials());
+   }
+   
+   @Override
+   public Injector apply(ComputeServiceContext input) {
+      return input.utils().injector();
+   }
+   
+   @Override
+   protected Properties setupProperties() {
+      Properties overrides = super.setupProperties();
+      // only specify one zone so that we don't have to configure requests for multiple zones
+      overrides.setProperty("jclouds.zones", "az-1.region-a.geo-1");
+      return overrides;
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java
new file mode 100644
index 0000000..1888963
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java
@@ -0,0 +1,382 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.compute;
+
+import static org.jclouds.compute.util.ComputeServiceUtils.getCores;
+import static org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions.Builder.blockUntilRunning;
+import static org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions.Builder.keyPairName;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.domain.Location;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaComputeServiceExpectTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.Iterables;
+import com.google.inject.AbstractModule;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Tests the compute service abstraction of the nova api.
+ * 
+ * @author Matt Stephenson
+ */
+@Test(groups = "unit", testName = "NovaComputeServiceExpectTest")
+public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTest {
+   
+   @Override
+   protected Properties setupProperties() {
+      Properties overrides = super.setupProperties();
+      // only specify limited zones so that we don't have to configure requests for multiple zones.
+      // since we are doing tests with keystone responses from hpcloud and also openstack, we have
+      // to whitelist one zone from each
+      overrides.setProperty("jclouds.zones", "az-1.region-a.geo-1,RegionOne");
+      return overrides;
+   }
+   
+   public void testListLocationsWhenResponseIs2xx() throws Exception {
+
+      Map<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder()
+            .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess)
+            .put(extensionsOfNovaRequest, extensionsOfNovaResponse).put(listDetail, listDetailResponse)
+            .put(listServers, listServersResponse).put(listFlavorsDetail, listFlavorsDetailResponse).build();
+
+      ComputeService apiWhenServersExist = requestsSendResponses(requestResponseMap);
+
+      Set<? extends Location> locations = apiWhenServersExist.listAssignableLocations();
+      assertNotNull(locations);
+      assertEquals(locations.size(), 1);
+      assertEquals(locations.iterator().next().getId(), "az-1.region-a.geo-1");
+
+      assertNotNull(apiWhenServersExist.listNodes());
+      assertEquals(apiWhenServersExist.listNodes().size(), 1);
+      assertEquals(apiWhenServersExist.listNodes().iterator().next().getId(),
+            "az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f000004d2");
+      assertEquals(apiWhenServersExist.listNodes().iterator().next().getName(), "sample-server");
+   }
+
+   Map<HttpRequest, HttpResponse> defaultTemplateOpenStack = ImmutableMap
+         .<HttpRequest, HttpResponse> builder()
+         .put(keystoneAuthWithUsernameAndPasswordAndTenantName,
+               HttpResponse
+                     .builder()
+                     .statusCode(200)
+                     .message("HTTP/1.1 200")
+                     .payload(
+                           payloadFromResourceWithContentType("/keystoneAuthResponse_openstack.json", "application/json"))
+                     .build())
+         .put(extensionsOfNovaRequest.toBuilder()
+               .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/extensions").build(),
+               HttpResponse.builder().statusCode(200).payload(payloadFromResource("/extension_list_openstack.json"))
+                     .build())
+         .put(listDetail.toBuilder()
+               .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/images/detail").build(),
+               HttpResponse.builder().statusCode(200).payload(payloadFromResource("/image_list_detail_openstack.json"))
+                     .build())
+         .put(listServers.toBuilder()
+               .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/servers/detail").build(),
+               listServersResponse)
+         .put(listFlavorsDetail.toBuilder()
+               .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/flavors/detail").build(),
+               HttpResponse.builder().statusCode(200).payload(payloadFromResource("/flavor_list_detail_openstack.json"))
+                     .build()).build();
+
+   public void testDefaultTemplateOpenStack() throws Exception {
+
+      ComputeService apiForOpenStack = requestsSendResponses(defaultTemplateOpenStack);
+
+      Template defaultTemplate = apiForOpenStack.templateBuilder().imageId("RegionOne/15").build();
+      checkTemplate(defaultTemplate);
+      checkTemplate(apiForOpenStack.templateBuilder().fromTemplate(defaultTemplate).build());
+
+   }
+
+   private void checkTemplate(Template defaultTemplate) {
+      assertEquals(defaultTemplate.getImage().getId(), "RegionOne/15");
+      assertEquals(defaultTemplate.getImage().getProviderId(), "15");
+      assertEquals(defaultTemplate.getHardware().getId(), "RegionOne/1");
+      assertEquals(defaultTemplate.getHardware().getProviderId(), "1");
+      assertEquals(defaultTemplate.getLocation().getId(), "RegionOne");
+      assertEquals(getCores(defaultTemplate.getHardware()), 1.0d);
+   }
+
+   public void testListServersWhenReponseIs404IsEmpty() throws Exception {
+      HttpRequest listServers = HttpRequest
+            .builder()
+            .method("GET")
+            .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/detail")
+            .addHeader("Accept", "application/json")
+            .addHeader("X-Auth-Token", authToken).build();
+
+      HttpResponse listServersResponse = HttpResponse.builder().statusCode(404).build();
+
+      ComputeService apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+            responseWithKeystoneAccess, listServers, listServersResponse);
+
+      assertTrue(apiWhenNoServersExist.listNodes().isEmpty());
+   }
+
+   HttpRequest list = HttpRequest
+         .builder()
+         .method("GET")
+         .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/os-security-groups")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken).build();
+
+   HttpResponse notFound = HttpResponse.builder().statusCode(404).build();
+
+   HttpRequest createWithPrefixOnGroup = HttpRequest
+         .builder()
+         .method("POST")
+         .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/os-security-groups")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken)
+         .payload(
+               payloadFromStringWithContentType(
+                     "{\"security_group\":{\"name\":\"jclouds-test\",\"description\":\"jclouds-test\"}}",
+                     "application/json")).build();
+
+   HttpResponse securityGroupCreated = HttpResponse.builder().statusCode(200)
+         .payload(payloadFromResource("/securitygroup_created.json")).build();
+
+   HttpRequest createRuleForDefaultPort22 = HttpRequest
+         .builder()
+         .method("POST")
+         .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/os-security-group-rules")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken)
+         .payload(
+               payloadFromStringWithContentType(
+                     "{\"security_group_rule\":{\"parent_group_id\":\"160\",\"cidr\":\"0.0.0.0/0\",\"ip_protocol\":\"tcp\",\"from_port\":\"22\",\"to_port\":\"22\"}}",
+                     "application/json")).build();
+
+   HttpResponse securityGroupRuleCreated = HttpResponse.builder().statusCode(200)
+         .payload(payloadFromResource("/securitygrouprule_created.json")).build();
+
+   HttpRequest getSecurityGroup = HttpRequest
+         .builder()
+         .method("GET")
+         .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/os-security-groups/160")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken).build();
+
+   HttpResponse securityGroupWithPort22 = HttpResponse.builder().statusCode(200)
+         .payload(payloadFromResource("/securitygroup_details_port22.json")).build();
+   
+   HttpRequest create = HttpRequest
+         .builder()
+         .method("POST")
+         .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/os-keypairs")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken)
+         .payload(
+               payloadFromStringWithContentType(
+                     "{\"keypair\":{\"name\":\"jclouds-test-0\"}}",
+                     "application/json")).build();
+
+   HttpResponse keyPairWithPrivateKey = HttpResponse.builder().statusCode(200)
+         .payload(payloadFromResource("/keypair_created_computeservice.json")).build();
+
+   HttpRequest serverDetail = HttpRequest
+         .builder()
+         .method("GET")
+         .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/servers/71752")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken).build();
+
+   HttpResponse serverDetailResponse = HttpResponse.builder().statusCode(200)
+         .payload(payloadFromResource("/server_details.json")).build();
+
+   @Test
+   public void testCreateNodeWithGeneratedKeyPair() throws Exception {
+      Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder()
+            .putAll(defaultTemplateOpenStack);
+      requestResponseMap.put(list, notFound);
+
+      requestResponseMap.put(createWithPrefixOnGroup, securityGroupCreated);
+
+      requestResponseMap.put(createRuleForDefaultPort22, securityGroupRuleCreated);
+
+      requestResponseMap.put(getSecurityGroup, securityGroupWithPort22);
+
+      requestResponseMap.put(create, keyPairWithPrivateKey);
+
+      requestResponseMap.put(serverDetail, serverDetailResponse);
+
+      HttpRequest createServerWithGeneratedKeyPair = HttpRequest
+            .builder()
+            .method("POST")
+            .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/servers")
+            .addHeader("Accept", "application/json")
+            .addHeader("X-Auth-Token", authToken)
+            .payload(
+                  payloadFromStringWithContentType(
+                        "{\"server\":{\"name\":\"test-1\",\"imageRef\":\"14\",\"flavorRef\":\"1\"," +
+                        "\"metadata\":{\"jclouds-group\":\"test\"},\"key_name\":\"jclouds-test-0\",\"security_groups\":[{\"name\":\"jclouds-test\"}]}}",
+                        "application/json")).build();
+
+      HttpResponse createdServer = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
+            .payload(payloadFromResourceWithContentType("/new_server.json", "application/json; charset=UTF-8")).build();
+
+      requestResponseMap.put(createServerWithGeneratedKeyPair, createdServer);
+
+      ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build(), new AbstractModule() {
+
+         @Override
+         protected void configure() {
+            // predicatable node names
+            final AtomicInteger suffix = new AtomicInteger();
+            bind(new TypeLiteral<Supplier<String>>() {
+            }).toInstance(new Supplier<String>() {
+
+               @Override
+               public String get() {
+                  return suffix.getAndIncrement() + "";
+               }
+
+            });
+         }
+
+      });
+
+      NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1,
+            blockUntilRunning(false).generateKeyPair(true)));
+      assertNotNull(node.getCredentials().getPrivateKey());
+   }
+
+   @Test
+   public void testCreateNodeWhileUserSpecifiesKeyPair() throws Exception {
+      Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder()
+            .putAll(defaultTemplateOpenStack);
+      requestResponseMap.put(list, notFound);
+
+      requestResponseMap.put(createWithPrefixOnGroup, securityGroupCreated);
+
+      requestResponseMap.put(createRuleForDefaultPort22, securityGroupRuleCreated);
+
+      requestResponseMap.put(getSecurityGroup, securityGroupWithPort22);
+
+      requestResponseMap.put(serverDetail, serverDetailResponse);
+
+      HttpRequest createServerWithSuppliedKeyPair = HttpRequest
+            .builder()
+            .method("POST")
+            .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/servers")
+            .addHeader("Accept", "application/json")
+            .addHeader("X-Auth-Token", authToken)
+            .payload(
+                  payloadFromStringWithContentType(
+                        "{\"server\":{\"name\":\"test-0\",\"imageRef\":\"14\",\"flavorRef\":\"1\"," +
+                                "\"metadata\":{\"jclouds-group\":\"test\"},\"key_name\":\"fooPair\",\"security_groups\":[{\"name\":\"jclouds-test\"}]}}",
+                        "application/json")).build();
+
+      HttpResponse createdServer = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
+            .payload(payloadFromResourceWithContentType("/new_server.json", "application/json; charset=UTF-8")).build();
+
+      requestResponseMap.put(createServerWithSuppliedKeyPair, createdServer);
+
+      ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build(), new AbstractModule() {
+
+         @Override
+         protected void configure() {
+            // predicatable node names
+            final AtomicInteger suffix = new AtomicInteger();
+            bind(new TypeLiteral<Supplier<String>>() {
+            }).toInstance(new Supplier<String>() {
+
+               @Override
+               public String get() {
+                  return suffix.getAndIncrement() + "";
+               }
+
+            });
+         }
+
+      });
+
+      NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1,
+            keyPairName("fooPair").blockUntilRunning(false)));
+      // we don't have access to this private key
+      assertEquals(node.getCredentials().getPrivateKey(), null);
+   }
+
+
+   @Test
+   public void testCreateNodeWhileUserSpecifiesKeyPairAndUserSpecifiedGroups() throws Exception {
+      Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder()
+            .putAll(defaultTemplateOpenStack);
+      requestResponseMap.put(list, notFound);
+
+      requestResponseMap.put(serverDetail, serverDetailResponse);
+
+      HttpRequest createServerWithSuppliedKeyPairAndGroup = HttpRequest
+            .builder()
+            .method("POST")
+            .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/servers")
+            .addHeader("Accept", "application/json")
+            .addHeader("X-Auth-Token", authToken)
+            .payload(
+                  payloadFromStringWithContentType(
+                        "{\"server\":{\"name\":\"test-0\",\"imageRef\":\"14\",\"flavorRef\":\"1\"," +
+                        "\"metadata\":{\"jclouds-group\":\"test\"},\"key_name\":\"fooPair\",\"security_groups\":[{\"name\":\"mygroup\"}]}}",
+                        "application/json")).build();
+
+      HttpResponse createdServer = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
+            .payload(payloadFromResourceWithContentType("/new_server.json", "application/json; charset=UTF-8")).build();
+
+      requestResponseMap.put(createServerWithSuppliedKeyPairAndGroup, createdServer);
+
+      ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build(), new AbstractModule() {
+
+         @Override
+         protected void configure() {
+            // predicatable node names
+            final AtomicInteger suffix = new AtomicInteger();
+            bind(new TypeLiteral<Supplier<String>>() {
+            }).toInstance(new Supplier<String>() {
+
+               @Override
+               public String get() {
+                  return suffix.getAndIncrement() + "";
+               }
+
+            });
+         }
+
+      });
+
+      NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1,
+            keyPairName("fooPair").securityGroupNames("mygroup").blockUntilRunning(false)));
+      // we don't have access to this private key
+      assertEquals(node.getCredentials().getPrivateKey(), null);
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java
new file mode 100644
index 0000000..d20126c
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.compute;
+
+import static java.util.logging.Logger.getAnonymousLogger;
+
+import java.util.Properties;
+
+import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
+import org.jclouds.openstack.nova.v2_0.config.NovaProperties;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.testng.annotations.Test;
+
+import com.google.inject.Module;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "live", singleThreaded = true, testName = "NovaComputeServiceLiveTest")
+public class NovaComputeServiceLiveTest extends BaseComputeServiceLiveTest {
+
+   public NovaComputeServiceLiveTest() {
+      provider = "openstack-nova";
+   }
+
+   @Override
+   protected Module getSshModule() {
+      return new SshjSshClientModule();
+   }
+   
+   @Override
+   public void testOptionToNotBlock() {
+      // start call is blocking anyway.
+   }
+
+   @Test(enabled = true, dependsOnMethods = "testReboot")
+   public void testSuspendResume() throws Exception {
+      try {
+         // may fail because of lack of AdminActions extension or non-admin user, so log and continue
+         super.testSuspendResume();
+      } catch (AuthorizationException e) {
+         getAnonymousLogger().info("testSuspendResume() threw, probably due to lack of privileges: " + e.getMessage());
+      } catch (UnsupportedOperationException e) {
+         getAnonymousLogger().info("testSuspendResume() threw, probably due to unavailable AdminActions extension: " + e.getMessage());
+      }
+   }
+
+   @Test(enabled = true, dependsOnMethods = "testSuspendResume")
+   @Override
+   public void testGetNodesWithDetails() throws Exception {
+      super.testGetNodesWithDetails();
+   }
+
+   @Test(enabled = true, dependsOnMethods = "testSuspendResume")
+   @Override
+   public void testListNodes() throws Exception {
+      super.testListNodes();
+   }
+
+   @Test(enabled = true, dependsOnMethods = "testSuspendResume")
+   @Override
+   public void testListNodesByIds() throws Exception {
+      super.testListNodesByIds();
+   }
+
+   @Test(enabled = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails", "testListNodesByIds" })
+   @Override
+   public void testDestroyNodes() {
+      super.testDestroyNodes();
+   }
+
+   @Override
+   protected Properties setupProperties() {
+      Properties props = super.setupProperties();
+      setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
+      setIfTestSystemPropertyPresent(props, NovaProperties.AUTO_ALLOCATE_FLOATING_IPS);
+      return props;
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java
new file mode 100644
index 0000000..afd289f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.compute.extensions;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Properties;
+
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.ImageTemplate;
+import org.jclouds.compute.extensions.ImageExtension;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaComputeServiceExpectTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.util.concurrent.Futures;
+
+/**
+ * 
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "NovaImageExtensionExpectTest")
+public class NovaImageExtensionExpectTest extends BaseNovaComputeServiceExpectTest {
+   
+   @Override
+   protected Properties setupProperties() {
+      Properties overrides = super.setupProperties();
+      overrides.setProperty("jclouds.zones", "az-1.region-a.geo-1");
+      return overrides;
+   }
+
+   HttpRequest serverDetail = HttpRequest.builder().method("GET")
+         .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/71752")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken).build();
+
+   HttpResponse serverDetailResponse = HttpResponse.builder().statusCode(200)
+         .payload(payloadFromResource("/server_details.json")).build();
+
+   HttpRequest createImage = HttpRequest.builder().method("POST")
+         .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/71752/action")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken)
+         .payload(
+               payloadFromStringWithContentType(
+                     "{\"createImage\":{\"name\":\"test\", \"metadata\": {}}}",
+                     "application/json")).build();
+   
+   HttpResponse createImageResponse = HttpResponse.builder().statusCode(202)
+         .addHeader("Location", "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2")
+         .build();
+
+   HttpRequest getImage = HttpRequest.builder().method("GET")
+         .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2")
+         .addHeader("Accept", "application/json")
+         .addHeader("X-Auth-Token", authToken).build();
+   
+   HttpResponse getImageResponse = HttpResponse.builder().statusCode(200)
+         .payload(payloadFromResource("/image_active.json")).build();
+
+   public void testCreateImage() {
+      Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+      requestResponseMap.put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess);
+      requestResponseMap.put(serverDetail, serverDetailResponse).build();
+      requestResponseMap.put(createImage, createImageResponse).build();
+      requestResponseMap.put(getImage, getImageResponse).build();
+
+      ImageExtension apiThatCreatesImage = requestsSendResponses(requestResponseMap.build()).getImageExtension().get();
+      
+      ImageTemplate newImageTemplate = apiThatCreatesImage.buildImageTemplateFromNode("test", "az-1.region-a.geo-1/71752");
+
+      Image image = Futures.getUnchecked(apiThatCreatesImage.createImage(newImageTemplate));
+      assertEquals(image.getId(), "az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f5736d2a2");
+   }
+}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionLiveTest.java
new file mode 100644
index 0000000..463ff55
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionLiveTest.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.compute.extensions;
+
+import org.jclouds.compute.extensions.internal.BaseImageExtensionLiveTest;
+import org.jclouds.sshj.config.SshjSshClientModule;
+import org.testng.annotations.Test;
+
+import com.google.inject.Module;
+
+/**
+ * Live test for openstack-nova {@link ImageExtension} implementation.
+ * 
+ * @author David Alves
+ * 
+ */
+@Test(groups = "live", singleThreaded = true, testName = "NovaImageExtensionLiveTest")
+public class NovaImageExtensionLiveTest extends BaseImageExtensionLiveTest {
+
+   public NovaImageExtensionLiveTest() {
+      provider = "openstack-nova";
+   }
+
+   @Override
+   protected Module getSshModule() {
+      return new SshjSshClientModule();
+   }
+
+}