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 03:59:53 UTC
[01/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Repository: incubator-stratos
Updated Branches:
refs/heads/master 5857efca8 -> bf3a353bc
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details.json
new file mode 100644
index 0000000..7ad6a75
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details.json
@@ -0,0 +1,79 @@
+{
+ "servers": [
+ {
+ "id": "52415800-8b69-11e0-9b19-734f000004d2",
+ "tenant_id": "1234",
+ "user_id": "5678",
+ "name": "sample-server",
+ "updated": "2010-10-10T12:00:00Z",
+ "created": "2010-08-10T12:00:00Z",
+ "hostId": "e4d909c290d0fb1ca068ffaddf22cbd0",
+ "accessIPv4" : "67.23.10.132",
+ "accessIPv6" : "::babe:67.23.10.132",
+ "status": "BUILD",
+ "progress": 60,
+ "image" : {
+ "id": "52415800-8b69-11e0-9b19-734f6f006e54",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"
+ }
+ ]
+ },
+ "flavor" : {
+ "id": "52415800-8b69-11e0-9b19-734f216543fd",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"
+ }
+ ]
+ },
+ "addresses": {
+ "public" : [
+ {
+ "version": 4,
+ "addr": "67.23.10.132"
+ },
+ {
+ "version": 6,
+ "addr": "::babe:67.23.10.132"
+ },
+ {
+ "version": 4,
+ "addr": "67.23.10.131"
+ },
+ {
+ "version": 6,
+ "addr": "::babe:4317:0A83"
+ }
+ ],
+ "private" : [
+ {
+ "version": 4,
+ "addr": "10.176.42.16"
+ },
+ {
+ "version": 6,
+ "addr": "::babe:10.176.42.16"
+ }
+ ]
+ },
+ "metadata": {
+ "Server Label": "Web Head 1",
+ "Image Version": "2.1"
+ },
+ "links": [
+ ]
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details_essex.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details_essex.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details_essex.json
new file mode 100644
index 0000000..9ca9445
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details_essex.json
@@ -0,0 +1,152 @@
+{
+ "servers": [{
+ "OS-EXT-STS:task_state": null,
+ "addresses": {
+ "Net TenantA Front-Middle": [{
+ "version": 4,
+ "addr": "172.16.11.5"
+ }],
+ "Public network": [{
+ "version": 4,
+ "addr": "172.16.1.13"
+ }, {
+ "version": 4,
+ "addr": "10.193.112.119"
+ }]
+ },
+ "links": [{
+ "href": "http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207",
+ "rel": "self"
+ }, {
+ "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207",
+ "rel": "bookmark"
+ }],
+ "image": {
+ "id": "416af940-2d3c-4a7c-977c-a9030685ad5e",
+ "links": [{
+ "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e",
+ "rel": "bookmark"
+ }]
+ },
+ "OS-EXT-STS:vm_state": "active",
+ "flavor": {
+ "id": "1",
+ "links": [{
+ "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1",
+ "rel": "bookmark"
+ }]
+ },
+ "id": "0c80b392-db30-4736-ae02-4480090f1207",
+ "user_id": "df13814f6c354d00a8acf66502836323",
+ "OS-DCF:diskConfig": "MANUAL",
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "progress": 0,
+ "OS-EXT-STS:power_state": 1,
+ "config_drive": "",
+ "status": "ACTIVE",
+ "updated": "2012-04-12T11:21:33Z",
+ "hostId": "03d796ebb52b1b555e5f6d9262f7dbd52b3f7c181e3aa89b34ca5408",
+ "key_name": "",
+ "name": "VM proxy",
+ "created": "2012-04-12T11:21:23Z",
+ "tenant_id": "8d10e6646d5d4585937395b04839a353",
+ "metadata": {}
+ }, {
+ "OS-EXT-STS:task_state": null,
+ "addresses": {
+ "Net TenantA Front-Middle": [{
+ "version": 4,
+ "addr": "172.16.11.4"
+ }],
+ "Net TenantA Middle-Back": [{
+ "version": 4,
+ "addr": "172.16.12.5"
+ }]
+ },
+ "links": [{
+ "href": "http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236",
+ "rel": "self"
+ }, {
+ "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236",
+ "rel": "bookmark"
+ }],
+ "image": {
+ "id": "416af940-2d3c-4a7c-977c-a9030685ad5e",
+ "links": [{
+ "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e",
+ "rel": "bookmark"
+ }]
+ },
+ "OS-EXT-STS:vm_state": "active",
+ "flavor": {
+ "id": "1",
+ "links": [{
+ "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1",
+ "rel": "bookmark"
+ }]
+ },
+ "id": "b332b5cd-535e-4677-b68e-fc8badc13236",
+ "user_id": "df13814f6c354d00a8acf66502836323",
+ "OS-DCF:diskConfig": "MANUAL",
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "progress": 0,
+ "OS-EXT-STS:power_state": 1,
+ "config_drive": "",
+ "status": "ACTIVE",
+ "updated": "2012-04-12T11:18:58Z",
+ "hostId": "e5bbff80bebacfe1db63951e787b5341427060a602d33abfefb6a1bc",
+ "key_name": "",
+ "name": "VM blog",
+ "created": "2012-04-12T11:18:48Z",
+ "tenant_id": "8d10e6646d5d4585937395b04839a353",
+ "metadata": {}
+ }, {
+ "OS-EXT-STS:task_state": null,
+ "addresses": {
+ "Net TenantA Middle-Back": [{
+ "version": 4,
+ "addr": "172.16.12.4"
+ }]
+ },
+ "links": [{
+ "href": "http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21",
+ "rel": "self"
+ }, {
+ "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21",
+ "rel": "bookmark"
+ }],
+ "image": {
+ "id": "416af940-2d3c-4a7c-977c-a9030685ad5e",
+ "links": [{
+ "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e",
+ "rel": "bookmark"
+ }]
+ },
+ "OS-EXT-STS:vm_state": "active",
+ "flavor": {
+ "id": "1",
+ "links": [{
+ "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1",
+ "rel": "bookmark"
+ }]
+ },
+ "id": "f9d43436-4572-4c9b-9b74-5fa6890a2f21",
+ "user_id": "df13814f6c354d00a8acf66502836323",
+ "OS-DCF:diskConfig": "MANUAL",
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "progress": 0,
+ "OS-EXT-STS:power_state": 1,
+ "config_drive": "",
+ "status": "ACTIVE",
+ "updated": "2012-04-12T11:15:09Z",
+ "hostId": "03d796ebb52b1b555e5f6d9262f7dbd52b3f7c181e3aa89b34ca5408",
+ "key_name": "",
+ "name": "VM MySQL",
+ "created": "2012-04-12T11:14:56Z",
+ "tenant_id": "8d10e6646d5d4585937395b04839a353",
+ "metadata": {}
+ }]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_public_ip_in_private.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_public_ip_in_private.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_public_ip_in_private.json
new file mode 100644
index 0000000..5a5b84e
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_public_ip_in_private.json
@@ -0,0 +1,51 @@
+{
+ "server": {
+ "status": "ACTIVE",
+ "updated": "2012-03-22T22:11:55Z",
+ "hostId": "cb0d9e5004bef8c21270a0b09f7624f4c387f3a523f3aaa4c5694a61",
+ "user_id": "54297837463082",
+ "name": "hpcloud-computes-38d",
+ "links": [{
+ "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/59662",
+ "rel": "self"
+ }, {
+ "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/59662",
+ "rel": "bookmark"
+ }],
+ "addresses": {
+ "private": [{
+ "version": 4,
+ "addr": "10.6.39.189"
+ }, {
+ "version": 4,
+ "addr": "15.185.181.94"
+ }]
+ },
+ "tenant_id": "37936628937291",
+ "image": {
+ "id": "229",
+ "links": [{
+ "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/229",
+ "rel": "bookmark"
+ }]
+ },
+ "created": "2012-03-22T22:11:19Z",
+ "uuid": "7aed8e05-1daf-476a-87b2-640e8f7dcafd",
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "key_name": "jclouds_hpcloud-computes_77",
+ "progress": 100,
+ "flavor": {
+ "id": "100",
+ "links": [{
+ "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100",
+ "rel": "bookmark"
+ }]
+ },
+ "config_drive": "",
+ "id": 59662,
+ "metadata": {
+ "Name": "hpcloud-computes"
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups.json
new file mode 100644
index 0000000..16e03fe
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups.json
@@ -0,0 +1 @@
+{"server": {"status": "ACTIVE", "updated": "2012-05-04T12:15:01Z", "hostId": "02c7c81e36024d2bfdb473cb762900138bc07777922479d3d4f8f690", "user_id": "1e8a56719e0d4ab4b7edb85c77f7290f", "name": "test", "links": [{"href": "http://172.16.89.148:8774/v2/4287930c796741aa898425f40832cb3c/servers/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", "rel": "self"}, {"href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/servers/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", "rel": "bookmark"}], "created": "2012-05-04T12:14:57Z", "tenant_id": "4287930c796741aa898425f40832cb3c", "image": {"id": "ea17cc36-f7c9-40cd-b6bf-a952b74870f2", "links": [{"href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/images/ea17cc36-f7c9-40cd-b6bf-a952b74870f2", "rel": "bookmark"}]}, "addresses": {"private": [{"version": 4, "addr": "10.0.0.8"}]}, "accessIPv4": "", "accessIPv6": "", "key_name": "", "progress": 0, "flavor": {"id": "1", "links": [{"href": "http://172.16.89.148:8774/4287930c796741aa898425f40832c
b3c/flavors/1", "rel": "bookmark"}]}, "config_drive": "", "id": "8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", "security_groups": [{"name": "default"},{"name": "group1"}], "metadata": {}}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups_extension.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups_extension.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups_extension.json
new file mode 100644
index 0000000..7a3c4b2
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups_extension.json
@@ -0,0 +1 @@
+{"server": {"status": "ACTIVE", "updated": "2012-05-04T12:15:01Z", "hostId": "02c7c81e36024d2bfdb473cb762900138bc07777922479d3d4f8f690", "user_id": "1e8a56719e0d4ab4b7edb85c77f7290f", "name": "test", "links": [{"href": "http://172.16.89.148:8774/v2/4287930c796741aa898425f40832cb3c/servers/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", "rel": "self"}, {"href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/servers/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", "rel": "bookmark"}], "created": "2012-05-04T12:14:57Z", "tenant_id": "4287930c796741aa898425f40832cb3c", "image": {"id": "ea17cc36-f7c9-40cd-b6bf-a952b74870f2", "links": [{"href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/images/ea17cc36-f7c9-40cd-b6bf-a952b74870f2", "rel": "bookmark"}]}, "addresses": {"private": [{"version": 4, "addr": "10.0.0.8"}]}, "accessIPv4": "", "accessIPv6": "", "key_name": "", "progress": 0, "flavor": {"id": "1", "links": [{"href": "http://172.16.89.148:8774/4287930c796741aa898425f40832c
b3c/flavors/1", "rel": "bookmark"}]}, "config_drive": "", "id": "8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", "security_groups": [{"name": "name1"}], "metadata": {}}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usage.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usage.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usage.json
new file mode 100644
index 0000000..de07dc4
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usage.json
@@ -0,0 +1 @@
+{"tenant_usage": {"total_memory_mb_usage": 0.0014847999999999999, "total_vcpus_usage": 7.249999999999999e-07, "total_hours": 4.833333333333333e-07, "tenant_id": "f8535069c3fb404cb61c873b1a0b4921", "stop": "2012-04-18 13:32:07.255830", "server_usages": [{"hours": 2.4166666666666665e-07, "uptime": 91149, "local_gb": 50, "ended_at": null, "name": "test1", "tenant_id": "f8535069c3fb404cb61c873b1a0b4921", "vcpus": 2, "memory_mb": 4096, "state": "active", "flavor": "m1.medium", "started_at": "2012-04-17 12:12:58"}, {"hours": 2.4166666666666665e-07, "uptime": 84710, "local_gb": 30, "ended_at": null, "name": "mish_test", "tenant_id": "f8535069c3fb404cb61c873b1a0b4921", "vcpus": 1, "memory_mb": 2048, "state": "active", "flavor": "m1.small", "started_at": "2012-04-17 14:00:17"}], "start": "2012-04-18 13:32:07.255743", "total_local_gb_usage": 1.933333333333333e-05}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usages.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usages.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usages.json
new file mode 100644
index 0000000..6f3c0d7
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usages.json
@@ -0,0 +1 @@
+{"tenant_usages": [{"total_memory_mb_usage": 0.0015018666666666667, "total_vcpus_usage": 7.333333333333333e-07, "start": "2012-04-18 12:18:39.702411", "tenant_id": "f8535069c3fb404cb61c873b1a0b4921", "stop": "2012-04-18 12:18:39.702499", "total_hours": 4.888888888888889e-07, "total_local_gb_usage": 1.9555555555555557e-05}]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_details.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_details.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_details.json
new file mode 100644
index 0000000..375127b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_details.json
@@ -0,0 +1 @@
+{"snapshot": {"status": "available", "displayDescription": "jclouds live test snapshot", "displayName": "jclouds-live-test", "volumeId": 9, "id": 7, "createdAt": "2012-04-24 13:34:42", "size": 1}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list.json
new file mode 100644
index 0000000..03980b1
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list.json
@@ -0,0 +1 @@
+{"snapshots": [{"status": "available", "displayDescription": "jclouds live test snapshot", "displayName": "jclouds-live-test", "volumeId": 9, "id": 7, "createdAt": "2012-04-24 13:34:42", "size": 1}]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list_detail.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list_detail.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list_detail.json
new file mode 100644
index 0000000..03980b1
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list_detail.json
@@ -0,0 +1 @@
+{"snapshots": [{"status": "available", "displayDescription": "jclouds live test snapshot", "displayName": "jclouds-live-test", "volumeId": 9, "id": 7, "createdAt": "2012-04-24 13:34:42", "size": 1}]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/virtual_interfaces_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/virtual_interfaces_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/virtual_interfaces_list.json
new file mode 100644
index 0000000..7df0182
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/virtual_interfaces_list.json
@@ -0,0 +1 @@
+{"virtual_interfaces": [{"id": "02315827-b05c-4668-9c05-75c68838074a", "mac_address": "fa:16:3e:09:71:34"}]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_details.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_details.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_details.json
new file mode 100644
index 0000000..8dd11dc
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_details.json
@@ -0,0 +1 @@
+{"volume": {"status": "in-use", "displayDescription": "This is a test volume", "availabilityZone": "nova", "displayName": "test", "attachments": [{"device": "/dev/vdc", "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", "id": 1, "volumeId": 1}], "volumeType": null, "snapshotId": null, "size": 1, "id": 1, "createdAt": "2012-04-23 12:16:45", "metadata": {}}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_list.json
new file mode 100644
index 0000000..d2179e7
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_list.json
@@ -0,0 +1 @@
+{"volumes": [{"status": "in-use", "displayDescription": "This is a test volume", "availabilityZone": "nova", "displayName": "test", "attachments": [{"device": "/dev/vdc", "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", "id": 1, "volumeId": 1}], "volumeType": null, "snapshotId": null, "size": 1, "id": 1, "createdAt": "2012-04-23 12:16:45", "metadata": {}}]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_list_detail.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_list_detail.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_list_detail.json
new file mode 100644
index 0000000..d2179e7
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_list_detail.json
@@ -0,0 +1 @@
+{"volumes": [{"status": "in-use", "displayDescription": "This is a test volume", "availabilityZone": "nova", "displayName": "test", "attachments": [{"device": "/dev/vdc", "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", "id": 1, "volumeId": 1}], "volumeType": null, "snapshotId": null, "size": 1, "id": 1, "createdAt": "2012-04-23 12:16:45", "metadata": {}}]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_type.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_type.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_type.json
new file mode 100644
index 0000000..8739d09
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_type.json
@@ -0,0 +1,9 @@
+{"volume_type": {
+ "name": "jclouds-test-1",
+ "deleted": false,
+ "created_at": "2012-05-10 12:33:06",
+ "updated_at": null,
+ "extra_specs": {"test": "value1", "test1": "wibble"},
+ "deleted_at": null,
+ "id": 8
+}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_extra_specs.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_extra_specs.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_extra_specs.json
new file mode 100644
index 0000000..6e71d5d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_extra_specs.json
@@ -0,0 +1 @@
+{"extra_specs": {"test": "value1"}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_list.json
new file mode 100644
index 0000000..3e613a3
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_list.json
@@ -0,0 +1 @@
+{"volume_types": [{"name": "jclouds-test-1", "deleted": false, "created_at": "2012-05-10 12:33:06", "updated_at": null, "extra_specs": {"test": "value1", "test1": "wibble"}, "deleted_at": null, "id": 8}]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/pom.xml
----------------------------------------------------------------------
diff --git a/dependencies/pom.xml b/dependencies/pom.xml
index 8c31467..1b456fe 100644
--- a/dependencies/pom.xml
+++ b/dependencies/pom.xml
@@ -36,6 +36,7 @@
<modules>
<module>jclouds/vcloud/1.7.1-stratos</module>
+ <module>jclouds/openstack-nova/1.7.1-stratos</module>
</modules>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/features/cloud-controller/org.apache.stratos.cloud.controller.feature/pom.xml
----------------------------------------------------------------------
diff --git a/features/cloud-controller/org.apache.stratos.cloud.controller.feature/pom.xml b/features/cloud-controller/org.apache.stratos.cloud.controller.feature/pom.xml
index f72e9f7..2436a5c 100644
--- a/features/cloud-controller/org.apache.stratos.cloud.controller.feature/pom.xml
+++ b/features/cloud-controller/org.apache.stratos.cloud.controller.feature/pom.xml
@@ -88,7 +88,7 @@
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-nova</artifactId>
- <version>${jclouds.version}</version>
+ <version>${jclouds.stratos.version}</version>
</dependency>
<dependency>
@@ -121,7 +121,7 @@
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>vcloud</artifactId>
- <version>${jclouds.vcloud.version}</version>
+ <version>${jclouds.stratos.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
@@ -232,8 +232,8 @@
<bundleDef>org.apache.jclouds:jclouds-core:${jclouds.version}</bundleDef>
<bundleDef>org.apache.jclouds:jclouds-compute:${jclouds.version}</bundleDef>
<bundleDef>org.apache.jclouds.api:ec2:${jclouds.version}</bundleDef>
- <bundleDef>org.apache.jclouds.api:openstack-nova:${jclouds.version}</bundleDef>
- <bundleDef>org.apache.jclouds.api:vcloud:${jclouds.vcloud.version}</bundleDef>
+ <bundleDef>org.apache.jclouds.api:openstack-nova:${jclouds.stratos.version}</bundleDef>
+ <bundleDef>org.apache.jclouds.api:vcloud:${jclouds.stratos.version}</bundleDef>
<bundleDef>com.jamesmurty.utils.wso2:java-xmlbuilder:0.4.wso2v1</bundleDef>
<bundleDef>org.apache.jclouds.common:openstack-common:${jclouds.version}</bundleDef>
<bundleDef>org.apache.jclouds.api:openstack-keystone:${jclouds.version}</bundleDef>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 961d951..1984746 100644
--- a/pom.xml
+++ b/pom.xml
@@ -434,6 +434,6 @@
<carbon.platform.package.export.version>4.2.0</carbon.platform.package.export.version>
<axis2.osgi.version>1.6.1.wso2v10</axis2.osgi.version>
<jclouds.version>1.7.1</jclouds.version>
- <jclouds.vcloud.version>1.7.1-stratos</jclouds.vcloud.version>
+ <jclouds.stratos.version>1.7.1-stratos</jclouds.stratos.version>
</properties>
</project>
[03/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
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/parse/ParseMetadataListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataListTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataListTest.java
new file mode 100644
index 0000000..5559b20
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataListTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.parse;
+
+import java.util.Map;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Jeremy Daggett
+ */
+@Test(groups = "unit", testName = "ParseMetadataListTest")
+public class ParseMetadataListTest extends BaseItemParserTest<Map<String, String>> {
+
+ @Override
+ public String resource() {
+ return "/metadata_list.json";
+ }
+
+ @Override
+ @SelectJson("metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Map<String, String> expected() {
+ ImmutableMap<String, String> metadata =
+ new ImmutableMap.Builder<String, String>()
+ .put("Server Label", "Web Head 1")
+ .put("Image Version", "2.1")
+ .build();
+
+ return metadata;
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+
+}
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/parse/ParseMetadataUpdateTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataUpdateTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataUpdateTest.java
new file mode 100644
index 0000000..eb7a1e8
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataUpdateTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.parse;
+
+import java.util.Map;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Jeremy Daggett
+ */
+@Test(groups = "unit", testName = "ParseMetadataUpdateTest")
+public class ParseMetadataUpdateTest extends BaseItemParserTest<Map<String, String>> {
+
+ @Override
+ public String resource() {
+ return "/metadata_updated.json";
+ }
+
+ @Override
+ @SelectJson("metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Map<String, String> expected() {
+ ImmutableMap<String, String> metadata =
+ new ImmutableMap.Builder<String, String>()
+ .put("Server Label", "Web Head 2")
+ .put("Image Version", "2.1")
+ .put("Server Description", "Simple Server")
+ .build();
+
+ return metadata;
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+
+}
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/parse/ParseSecurityGroupListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupListTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupListTest.java
new file mode 100644
index 0000000..4e46ede
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupListTest.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.parse;
+
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseSetParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Michael Arnold
+ */
+@Test(groups = "unit", testName = "ParseSecurityGroupListTest")
+public class ParseSecurityGroupListTest extends BaseSetParserTest<SecurityGroup> {
+
+ @Override
+ public String resource() {
+ return "/securitygroup_list.json";
+ }
+
+ @Override
+ @SelectJson("security_groups")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Set<SecurityGroup> expected() {
+
+ Set<SecurityGroupRule> securityGroupRules = ImmutableSet.<SecurityGroupRule> of(
+ SecurityGroupRule.builder().fromPort(22)
+ .ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("3").ipRange("0.0.0.0/0")
+ .id("107").build(),
+ SecurityGroupRule.builder().fromPort(7600)
+ .ipProtocol(IpProtocol.TCP).toPort(7600).parentGroupId("3").ipRange("0.0.0.0/0")
+ .id("118").build(),
+ SecurityGroupRule.builder().fromPort(8084)
+ .ipProtocol(IpProtocol.TCP).toPort(8084).parentGroupId("3").ipRange("0.0.0.0/0")
+ .id("119").build());
+
+ return ImmutableSet.of(SecurityGroup.builder().description("description1").id("1").tenantId("tenant1")
+ .rules(securityGroupRules).name("name1").build());
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/parse/ParseSecurityGroupTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupTest.java
new file mode 100644
index 0000000..784a0bd
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupTest.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.parse;
+
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+import org.jclouds.openstack.nova.v2_0.domain.TenantIdAndName;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Michael Arnold
+ */
+@Test(groups = "unit", testName = "ParseSecurityGroupTest")
+public class ParseSecurityGroupTest extends BaseItemParserTest<SecurityGroup> {
+ @Override
+ public String resource() {
+ return "/securitygroup_details.json";
+ }
+
+ @Override
+ @SelectJson("security_group")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public SecurityGroup expected() {
+
+ Set<SecurityGroupRule> securityGroupRules = ImmutableSet.<SecurityGroupRule> of(
+ SecurityGroupRule.builder().fromPort(22)
+ .ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("28")
+ .ipRange("10.2.6.0/24").id("108").build(),
+ SecurityGroupRule.builder().fromPort(22).group(TenantIdAndName.builder().name("11111").tenantId("admin").build())
+ .ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("28")
+ .id("109").build());
+
+ return SecurityGroup.builder().description("description0").id("0").tenantId("tenant0").rules(securityGroupRules)
+ .name("name0").build();
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/parse/ParseServerDetailsEssexTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDetailsEssexTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDetailsEssexTest.java
new file mode 100644
index 0000000..afa6874
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDetailsEssexTest.java
@@ -0,0 +1,170 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.json.BaseSetParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.Address;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
+import org.jclouds.openstack.nova.v2_0.domain.ServerExtendedStatus;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseServerDetailsEssexTest")
+public class ParseServerDetailsEssexTest extends BaseSetParserTest<Server> {
+
+ @Override
+ public String resource() {
+ return "/server_list_details_essex.json";
+ }
+
+ @Override
+ @SelectJson("servers")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Set<Server> expected() {
+ return ImmutableSet.<Server>of(
+ Server.builder()
+ .addresses(ImmutableMultimap.<String, Address>builder()
+ .putAll("Net TenantA Front-Middle", Address.createV4("172.16.11.5"))
+ .putAll("Public network", Address.createV4("172.16.1.13"), Address.createV4("10.193.112.119")).build())
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207")))
+ .image(
+ Resource.builder()
+ .id("416af940-2d3c-4a7c-977c-a9030685ad5e")
+ .links(
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e"))).build())
+ .flavor(
+ Resource.builder()
+ .id("1")
+ .links(
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1"))).build())
+ .id("0c80b392-db30-4736-ae02-4480090f1207")
+ .userId("df13814f6c354d00a8acf66502836323")
+ .status(Status.ACTIVE)
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-04-12T11:21:33Z"))
+ .hostId("03d796ebb52b1b555e5f6d9262f7dbd52b3f7c181e3aa89b34ca5408")
+ .name("VM proxy")
+ .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-04-12T11:21:23Z"))
+ .tenantId("8d10e6646d5d4585937395b04839a353")
+ .extendedStatus(ServerExtendedStatus.builder().vmState("active").powerState(1).build())
+ .diskConfig("MANUAL").build(),
+ Server.builder()
+ .addresses(ImmutableMultimap.<String, Address>builder()
+ .putAll("Net TenantA Front-Middle", Address.createV4("172.16.11.4"))
+ .putAll("Net TenantA Middle-Back", Address.createV4("172.16.12.5")).build())
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236")))
+ .image(
+ Resource.builder()
+ .id("416af940-2d3c-4a7c-977c-a9030685ad5e")
+ .links(
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e"))).build())
+ .flavor(
+ Resource.builder()
+ .id("1")
+ .links(
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1"))).build())
+ .id("b332b5cd-535e-4677-b68e-fc8badc13236")
+ .userId("df13814f6c354d00a8acf66502836323")
+ .status(Status.ACTIVE)
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-04-12T11:18:58Z"))
+ .hostId("e5bbff80bebacfe1db63951e787b5341427060a602d33abfefb6a1bc")
+ .name("VM blog")
+ .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-04-12T11:18:48Z"))
+ .tenantId("8d10e6646d5d4585937395b04839a353")
+ .extendedStatus(ServerExtendedStatus.builder().vmState("active").powerState(1).build())
+ .diskConfig("MANUAL").build(),
+ Server.builder()
+ .addresses(ImmutableMultimap.<String, Address>builder()
+ .putAll("Net TenantA Middle-Back", Address.createV4("172.16.12.4")).build())
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21")))
+ .image(
+ Resource.builder()
+ .id("416af940-2d3c-4a7c-977c-a9030685ad5e")
+ .links(
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e"))).build())
+ .flavor(
+ Resource.builder()
+ .id("1")
+ .links(
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1"))).build())
+ .id("f9d43436-4572-4c9b-9b74-5fa6890a2f21")
+ .userId("df13814f6c354d00a8acf66502836323")
+ .status(Status.ACTIVE)
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-04-12T11:15:09Z"))
+ .hostId("03d796ebb52b1b555e5f6d9262f7dbd52b3f7c181e3aa89b34ca5408")
+ .name("VM MySQL")
+ .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-04-12T11:14:56Z"))
+ .tenantId("8d10e6646d5d4585937395b04839a353")
+ .extendedStatus(ServerExtendedStatus.builder().vmState("active").powerState(1).build())
+ .diskConfig("MANUAL").build());
+ }
+
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/parse/ParseServerDiagnostics.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDiagnostics.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDiagnostics.java
new file mode 100644
index 0000000..8d4eb8b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDiagnostics.java
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ */
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.jclouds.openstack.nova.v2_0.parse;
+
+import java.util.Map;
+
+import org.jclouds.json.BaseItemParserTest;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ *
+ * @author Leander Beernaert
+ */
+public class ParseServerDiagnostics extends BaseItemParserTest<Optional<Map<String,String>>> {
+
+
+ @Override
+ public Optional<Map<String,String>> expected() {
+ return Optional.<Map<String,String>>of(
+ new ImmutableMap.Builder<String,String>()
+ .put("vnet0_tx_errors", "0")
+ .put("vda_read","77364736")
+ .put("vda_write","415446016")
+ .put("vnet0_tx_packets","9701")
+ .put("vda_write_req","47278")
+ .put("cpu0_time","143150000000")
+ .put("vnet0_tx","1691221")
+ .put("vnet0_rx_drop","0")
+ .put("vda_errors","-1")
+ .put("vnet0_rx_errors","0")
+ .put("memory","524288")
+ .put("vnet0_rx_packets","11271")
+ .put("vda_read_req","9551")
+ .put("vnet0_rx","1805288")
+ .put("vnet0_tx_drop","0").build());
+ }
+}
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/parse/ParseServerListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerListTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerListTest.java
new file mode 100644
index 0000000..4ebbcf2
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerListTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseSetParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseServerListTest")
+public class ParseServerListTest extends BaseSetParserTest<Resource> {
+
+ @Override
+ public String resource() {
+ return "/server_list.json";
+ }
+
+ @Override
+ @SelectJson("servers")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Set<Resource> expected() {
+ return ImmutableSet
+ .of(Resource
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f6af67565")
+ .name("sample-server")
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6af67565")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f6af67565")))
+ .build(),
+ Resource
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f1f1350e5")
+ .name("sample-server2")
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5")))
+ .build());
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+
+}
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/parse/ParseServerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerTest.java
new file mode 100644
index 0000000..1b53135
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.Address;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+import static org.jclouds.openstack.nova.v2_0.domain.Address.createV4;
+import static org.jclouds.openstack.nova.v2_0.domain.Address.createV6;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseServerTest")
+public class ParseServerTest extends BaseItemParserTest<Server> {
+
+ @Override
+ public String resource() {
+ return "/server_details.json";
+ }
+
+ @Override
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Server expected() {
+ return Server
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f000004d2")
+ .tenantId("1234")
+ .userId("5678")
+ .name("sample-f352")
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-10-10T12:00:00Z"))
+ .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-08-10T12:00:00Z"))
+ .hostId("e4d909c290d0fb1ca068ffaddf22cbd0")
+ .accessIPv4("67.23.10.132")
+ .accessIPv6("::babe:67.23.10.132")
+ .status(Status.BUILD)
+ .diskConfig(Server.DISK_CONFIG_AUTO)
+ .image(
+ Resource
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f6f006e54")
+ .name("null")
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")))
+ .build())
+ .flavor(
+ Resource
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f216543fd")
+ .name("null")
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")))
+ .build())
+ .metadata(
+ new ImmutableMap.Builder<String, String>().put("Server Label", "Web Head 1")
+ .put("Image Version", "2.1").build())
+ .addresses(ImmutableMultimap.<String, Address>builder()
+ .putAll("public", createV4("67.23.10.132"), createV6("::babe:67.23.10.132"), createV4("67.23.10.131"), createV6("::babe:4317:0A83"))
+ .putAll("private", createV4("10.176.42.16"), createV6("::babe:10.176.42.16"))
+ .build())
+ .links(Link.create(
+ Relation.SELF, URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54")))
+ .build();
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/parse/ParseServerWithAllExtensionsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithAllExtensionsTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithAllExtensionsTest.java
new file mode 100644
index 0000000..e5d37d0
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithAllExtensionsTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.Address;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
+import org.jclouds.openstack.nova.v2_0.domain.ServerExtendedAttributes;
+import org.jclouds.openstack.nova.v2_0.domain.ServerExtendedStatus;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMultimap;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "ParseServerWithAllExtensionsTest")
+public class ParseServerWithAllExtensionsTest extends BaseItemParserTest<Server> {
+
+ @Override
+ public String resource() {
+ return "/server_details_devstack.json";
+ }
+
+ @Override
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Server expected() {
+ return Server
+ .builder()
+ .id("141b775f-7ac1-45f0-9a95-146260f33a53")
+ .tenantId("7f312675f9b84c97bff8f5054e181419")
+ .userId("89c01b67395d4bea945f7f5bfd7f344a")
+ .name("test")
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-05-04T15:07:48Z"))
+ .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-05-04T15:07:36Z"))
+ .hostId("eab9a77d1c44b8833e4a3dc6d2d9d50de556e780a319f184d8c82d9b")
+ .status(Status.PAUSED)
+ .image(
+ Resource
+ .builder()
+ .id("8e6f5bc4-a210-45b2-841f-c510eae14300")
+ .links(
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://172.16.89.149:8774/7f312675f9b84c97bff8f5054e181419/images/8e6f5bc4-a210-45b2-841f-c510eae14300")))
+ .build())
+ .flavor(
+ Resource
+ .builder()
+ .id("1")
+ .links(
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://172.16.89.149:8774/7f312675f9b84c97bff8f5054e181419/flavors/1")))
+ .build())
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://172.16.89.149:8774/v2/7f312675f9b84c97bff8f5054e181419/servers/141b775f-7ac1-45f0-9a95-146260f33a53")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://172.16.89.149:8774/7f312675f9b84c97bff8f5054e181419/servers/141b775f-7ac1-45f0-9a95-146260f33a53")))
+ .addresses(ImmutableMultimap.of("private", Address.createV4("10.0.0.8")))
+ .diskConfig("MANUAL")
+ .extendedStatus(ServerExtendedStatus.builder().vmState("paused").powerState(3).build())
+ .extendedAttributes(ServerExtendedAttributes.builder().instanceName("instance-00000014").hostName("ubuntu").build())
+ .build();
+ }
+
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/parse/ParseServerWithInternetAddressesTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithInternetAddressesTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithInternetAddressesTest.java
new file mode 100644
index 0000000..2065f20
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithInternetAddressesTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.Address;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMultimap;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseServerTest")
+public class ParseServerWithInternetAddressesTest extends BaseItemParserTest<Server> {
+
+ @Override
+ public String resource() {
+ return "/server_details_openstack.json";
+ }
+
+ @Override
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Server expected() {
+ return Server
+ .builder()
+ .id("1459")
+ .uuid("2443c9c7-9791-412e-ac09-a6d55ec25335")
+ .tenantId("37")
+ .userId("508151008")
+ .name("mygroup-72c")
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-03-23T01:30:26Z"))
+ .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-03-23T01:30:26Z"))
+ .hostId("881706597197955ac7cc4b353bc7ec884e13fa280de9cc82057796cb")
+ .status(Status.ACTIVE)
+ .image(
+ Resource
+ .builder()
+ .id("14")
+ .links(
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("https://nova-api.openstack.org:9774/37/images/14")))
+ .build())
+ .flavor(
+ Resource
+ .builder()
+ .id("1")
+ .links(
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("https://nova-api.openstack.org:9774/37/flavors/1")))
+ .build())
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("https://nova-api.openstack.org:9774/v1.1/37/servers/1459")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("https://nova-api.openstack.org:9774/37/servers/1459")))
+ .addresses(ImmutableMultimap.of("internet", Address.createV4("8.21.28.47"))).build();
+ }
+
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/parse/PublicIpsInPrivateAddressBlockExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/PublicIpsInPrivateAddressBlockExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/PublicIpsInPrivateAddressBlockExpectTest.java
new file mode 100644
index 0000000..3b56766
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/PublicIpsInPrivateAddressBlockExpectTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.Address;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseCreatedServerTest")
+public class PublicIpsInPrivateAddressBlockExpectTest extends BaseItemParserTest<Server> {
+
+ @Override
+ public String resource() {
+ return "/server_public_ip_in_private.json";
+ }
+
+ @Override
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Server expected() {
+ return Server
+ .builder()
+ .id("59662")
+ .hostId("cb0d9e5004bef8c21270a0b09f7624f4c387f3a523f3aaa4c5694a61")
+ .uuid("7aed8e05-1daf-476a-87b2-640e8f7dcafd")
+ .tenantId("37936628937291")
+ .userId("54297837463082")
+ .name("hpcloud-computes-38d")
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-03-22T22:11:55Z"))
+ .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-03-22T22:11:19Z"))
+ .status(Status.ACTIVE)
+ .keyName("jclouds_hpcloud-computes_77")
+ .image(
+ Resource
+ .builder()
+ .id("229")
+ .links(
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/229")))
+ .build())
+ .flavor(
+ Resource
+ .builder()
+ .id("100")
+ .links(
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100")))
+ .build())
+ .metadata(ImmutableMap.of("Name", "hpcloud-computes"))
+ .addresses(ImmutableMultimap.<String, Address>builder()
+ .putAll("private", Address.createV4("10.6.39.189"), Address.createV4("15.185.181.94")).build())
+ .links(
+ Link.create(Relation.SELF, URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/59662")),
+ Link.create(Relation.BOOKMARK, URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/59662"))).build();
+
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/predicates/ImagePredicatesTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicatesTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicatesTest.java
new file mode 100644
index 0000000..b4cad2b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicatesTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.predicates;
+
+import static org.jclouds.openstack.nova.v2_0.predicates.ImagePredicates.statusEquals;
+
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+import org.jclouds.openstack.nova.v2_0.domain.Image.Status;
+import org.jclouds.openstack.nova.v2_0.parse.ParseImageTest;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ImagePredicatesTest")
+public class ImagePredicatesTest {
+ Image ref = new ParseImageTest().expected();
+
+ @Test
+ public void teststatusEqualsWhenEqual() {
+ assert statusEquals(Status.SAVING).apply(ref);
+ }
+
+ @Test
+ public void teststatusEqualsWhenNotEqual() {
+ assert !statusEquals(Status.DELETED).apply(ref);
+ }
+
+}
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/predicates/SecurityGroupPredicatesTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicatesTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicatesTest.java
new file mode 100644
index 0000000..26e5ce2
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicatesTest.java
@@ -0,0 +1,129 @@
+/*
+ * 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.predicates;
+
+import static org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates.nameEquals;
+import static org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates.nameIn;
+import static org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates.ruleCidr;
+import static org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates.ruleEndPort;
+import static org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates.ruleGroup;
+import static org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates.ruleProtocol;
+import static org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates.ruleStartPort;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+import org.jclouds.openstack.nova.v2_0.domain.TenantIdAndName;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "SecurityGroupPredicatesTest")
+public class SecurityGroupPredicatesTest {
+ SecurityGroup ref = SecurityGroup.builder().id("12345").name("jclouds").description("description").build();
+ SecurityGroupRule ruleRef = SecurityGroupRule.builder().id("6789").parentGroupId("12345").ipRange("0.0.0.0/0")
+ .fromPort(10).toPort(20).ipProtocol(IpProtocol.TCP)
+ .group(TenantIdAndName.builder().tenantId("11111111").name("abcd").build())
+ .build();
+
+ public void testnameEqualsWhenEqual() {
+ assertTrue(nameEquals("jclouds").apply(ref), "expected 'jclouds' as the name of " + ref);
+ }
+
+ @Test
+ public void testnameEqualsWhenNotEqual() {
+ assertTrue(!nameEquals("foo").apply(ref), "expected 'foo' not to be the name of " + ref);
+ }
+
+ @Test
+ public void testNameInWhenIn() {
+ assertTrue(nameIn(ImmutableSet.of("jclouds", "pants")).apply(ref),
+ "expected the name of " + ref + " to be one of 'jclouds' or 'pants'");
+ }
+
+ @Test
+ public void testNameInWhenNotIn() {
+ assertTrue(!nameIn(ImmutableSet.of("foo", "pants")).apply(ref),
+ "expected the name of " + ref + " to not be either of 'foo' or 'pants'");
+
+ }
+
+ @Test
+ public void testRuleCidrWhenEqual() {
+ assertTrue(ruleCidr("0.0.0.0/0").apply(ruleRef),
+ "expected the CIDR to be '0.0.0.0/0' for " + ruleRef);
+ }
+
+ @Test
+ public void testRuleCidrWhenNotEqual() {
+ assertTrue(!ruleCidr("1.1.1.1/0").apply(ruleRef),
+ "expected the CIDR to not be '1.1.1.1/0' for " + ruleRef);
+ }
+
+ @Test
+ public void testRuleGroupWhenEqual() {
+ assertTrue(ruleGroup("abcd").apply(ruleRef),
+ "expected the group to be equal to 'abcd' for " + ruleRef);
+ }
+
+ @Test
+ public void testRuleGroupWhenNotEqual() {
+ assertTrue(!ruleGroup("pants").apply(ruleRef),
+ "expected the group to not be equal to 'pants' for " + ruleRef);
+ }
+
+ @Test
+ public void testRuleProtocolWhenEqual() {
+ assertTrue(ruleProtocol(IpProtocol.TCP).apply(ruleRef),
+ "expected TCP for " + ruleRef);
+ }
+
+ @Test
+ public void testRuleProtocolWhenNotEqual() {
+ assertTrue(!ruleProtocol(IpProtocol.UDP).apply(ruleRef),
+ "expected not UDP for " + ruleRef);
+ }
+
+ @Test
+ public void testRuleStartPortWhenEqual() {
+ assertTrue(ruleStartPort(10).apply(ruleRef),
+ "expected start port 10 for " + ruleRef);
+ }
+
+ @Test
+ public void testRuleStartPortWhenNotEqual() {
+ assertTrue(!ruleStartPort(50).apply(ruleRef),
+ "expected start port not to be 50 for " + ruleRef);
+ }
+
+ @Test
+ public void testRuleEndPortWhenEqual() {
+ assertTrue(ruleEndPort(20).apply(ruleRef),
+ "expected end port 20 for " + ruleRef);
+ }
+
+ @Test
+ public void testRuleEndPortWhenNotEqual() {
+ assertTrue(!ruleEndPort(50).apply(ruleRef),
+ "expected end port not to be 50 for " + ruleRef);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/attachment_details.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/attachment_details.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/attachment_details.json
new file mode 100644
index 0000000..c436406
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/attachment_details.json
@@ -0,0 +1 @@
+{"volumeAttachment": {"device": "/dev/vdc", "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", "id": 1, "volumeId": 1}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/attachment_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/attachment_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/attachment_list.json
new file mode 100644
index 0000000..b40de0b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/attachment_list.json
@@ -0,0 +1 @@
+{"volumeAttachments": [{"device": "/dev/vdc", "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", "id": 1, "volumeId": 1}]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_details.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_details.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_details.json
new file mode 100644
index 0000000..6336a42
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_details.json
@@ -0,0 +1,21 @@
+{
+ "extension" : {
+ "name" : "Public Image Extension",
+ "namespace" : "http://docs.rackspacecloud.com/servers/api/ext/pie/v1.0",
+ "alias" : "RS-PIE",
+ "updated" : "2011-01-22T13:25:27-06:00",
+ "description" : "Adds the capability to share an image with other users.",
+ "links" : [
+ {
+ "rel" : "describedby",
+ "type" : "application/pdf",
+ "href" : "http://docs.rackspacecloud.com/servers/api/ext/cs-pie-20111111.pdf"
+ },
+ {
+ "rel" : "describedby",
+ "type" : "application/vnd.sun.wadl+xml",
+ "href" : "http://docs.rackspacecloud.com/servers/api/ext/cs-pie.wadl"
+ }
+ ]
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list.json
new file mode 100644
index 0000000..4f3faa5
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list.json
@@ -0,0 +1,42 @@
+{
+ "extensions": [
+ {
+ "name": "Public Image Extension",
+ "namespace": "http://docs.rackspacecloud.com/servers/api/ext/pie/v1.0",
+ "alias": "RAX-PIE",
+ "updated": "2011-01-22T13:25:27-06:00",
+ "description": "Adds the capability to share an image with other users.",
+ "links": [
+ {
+ "rel": "describedby",
+ "type": "application/pdf",
+ "href": "http://docs.rackspacecloud.com/servers/api/ext/cs-pie-20111111.pdf"
+ },
+ {
+ "rel": "describedby",
+ "type": "application/vnd.sun.wadl+xml",
+ "href": "http://docs.rackspacecloud.com/servers/api/ext/cs-pie.wadl"
+ }
+ ]
+ },
+ {
+ "name": "Cloud Block Storage",
+ "namespace": "http://docs.rackspacecloud.com/servers/api/ext/cbs/v1.0",
+ "alias": "RAX-CBS",
+ "updated": "2011-01-12T11:22:33-06:00",
+ "description": "Allows mounting cloud block storage volumes.",
+ "links": [
+ {
+ "rel": "describedby",
+ "type": "application/pdf",
+ "href": "http://docs.rackspacecloud.com/servers/api/ext/cs-cbs-20111201.pdf"
+ },
+ {
+ "rel": "describedby",
+ "type": "application/vnd.sun.wadl+xml",
+ "href": "http://docs.rackspacecloud.com/servers/api/ext/cs-cbs.wadl"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_full.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_full.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_full.json
new file mode 100644
index 0000000..490bebc
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_full.json
@@ -0,0 +1,281 @@
+{"extensions": [
+{
+ "updated": "2011-09-27T00:00:00+00:00",
+ "name": "DiskConfig",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/disk_config/api/v1.1",
+ "alias": "OS-DCF",
+ "description": "Disk Management Extension"
+},
+{
+ "updated": "2011-06-29T00:00:00+00:00",
+ "name": "Hosts",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/hosts/api/v1.1",
+ "alias": "os-hosts",
+ "description": "Admin-only host administration"
+},
+{
+ "updated": "2011-07-19T00:00:00+00:00",
+ "name": "SchedulerHints",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/scheduler-hints/api/v2",
+ "alias": "os-scheduler-hints",
+ "description": "Pass arbitrary key/value pairs to the scheduler"
+},
+{
+ "updated": "2011-08-08T00:00:00+00:00",
+ "name": "Quotas",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/quotas-sets/api/v1.1",
+ "alias": "os-quota-sets",
+ "description": "Quotas management support"
+},
+{
+ "updated": "2011-12-23T00:00:00+00:00",
+ "name": "Floating_ip_dns",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/floating_ip_dns/api/v1.1",
+ "alias": "os-floating-ip-dns",
+ "description": "Floating IP DNS support"
+},
+{
+ "updated": "2011-09-14T00:00:00+00:00",
+ "name": "FlavorExtraData",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1",
+ "alias": "OS-FLV-EXT-DATA",
+ "description": "Provide additional data for flavors"
+},
+{
+ "updated": "2011-06-23T00:00:00+00:00",
+ "name": "FlavorExtraSpecs",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/flavor_extra_specs/api/v1.1",
+ "alias": "os-flavor-extra-specs",
+ "description": "Instance type (flavor) extra specs"
+},
+{
+ "updated": "2011-08-17T00:00:00+00:00",
+ "name": "VirtualInterfaces",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/virtual_interfaces/api/v1.1",
+ "alias": "virtual_interfaces",
+ "description": "Virtual interface support"
+},
+{
+ "updated": "2011-12-23T00:00:00+00:00",
+ "name": "Accounts",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/accounts/api/v1.1",
+ "alias": "os-accounts",
+ "description": "Admin-only access to accounts"
+},
+{
+ "updated": "2011-03-25T00:00:00+00:00",
+ "name": "Volumes",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/volumes/api/v1.1",
+ "alias": "os-volumes",
+ "description": "Volumes support"
+},
+{
+ "updated": "2011-11-03T00:00:00+00:00",
+ "name": "ExtendedStatus",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/extended_status/api/v1.1",
+ "alias": "OS-EXT-STS",
+ "description": "Extended Status support"
+},
+{
+ "updated": "2011-12-23T00:00:00+00:00",
+ "name": "Consoles",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/os-consoles/api/v2",
+ "alias": "os-consoles",
+ "description": "Interactive Console support."
+},
+{
+ "updated": "2011-07-21T00:00:00+00:00",
+ "name": "SecurityGroups",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/securitygroups/api/v1.1",
+ "alias": "security_groups",
+ "description": "Security group support"
+},
+{
+ "updated": "2012-01-12T00:00:00+00:00",
+ "name": "Aggregates",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/aggregates/api/v1.1",
+ "alias": "os-aggregates",
+ "description": "Admin-only aggregate administration"
+},
+{
+ "updated": "2011-07-19T00:00:00+00:00",
+ "name": "Createserverext",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/createserverext/api/v1.1",
+ "alias": "os-create-server-ext",
+ "description": "Extended support to the Create Server v1.1 API"
+},
+{
+ "updated": "2011-09-01T00:00:00+00:00",
+ "name": "DeferredDelete",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/deferred-delete/api/v1.1",
+ "alias": "os-deferred-delete",
+ "description": "Instance deferred delete"
+},
+{
+ "updated": "2011-12-21T00:00:00+00:00",
+ "name": "ServerDiagnostics",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/server-diagnostics/api/v1.1",
+ "alias": "os-server-diagnostics",
+ "description": "Allow Admins to view server diagnostics through server action"
+},
+{
+ "updated": "2011-12-23T00:00:00+00:00",
+ "name": "Networks",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/networks/api/v1.1",
+ "alias": "os-networks",
+ "description": "Admin-only Network Management Extension"
+},
+{
+ "updated": "2011-11-03T00:00:00+00:00",
+ "name": "ExtendedServerAttributes",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/extended_status/api/v1.1",
+ "alias": "OS-EXT-SRV-ATTR",
+ "description": "Extended Server Attributes support."
+},
+{
+ "updated": "2011-08-08T00:00:00+00:00",
+ "name": "Keypairs",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/keypairs/api/v1.1",
+ "alias": "os-keypairs",
+ "description": "Keypair Support"
+},
+{
+ "updated": "2011-08-24T00:00:00+00:00",
+ "name": "VolumeTypes",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/volume_types/api/v1.1",
+ "alias": "os-volume-types",
+ "description": "Volume types support"
+},
+{
+ "updated": "2011-08-19T00:00:00+00:00",
+ "name": "SimpleTenantUsage",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/os-simple-tenant-usage/api/v1.1",
+ "alias": "os-simple-tenant-usage",
+ "description": "Simple tenant usage extension"
+},
+{
+ "updated": "2012-01-04T00:00:00+00:00",
+ "name": "Floating_ip_pools",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/floating_ip_pools/api/v1.1",
+ "alias": "os-floating-ip-pools",
+ "description": "Floating IPs support"
+},
+{
+ "updated": "2012-01-23T00:00:00+00:00",
+ "name": "ServerStartStop",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/servers/api/v1.1",
+ "alias": "os-server-start-stop",
+ "description": "Start/Stop instance compute API support"
+},
+{
+ "updated": "2012-03-12T00:00:00+00:00",
+ "name": "QuotaClasses",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/quota-classes-sets/api/v1.1",
+ "alias": "os-quota-class-sets",
+ "description": "Quota classes management support"
+},
+{
+ "updated": "2012-01-19T00:00:00+00:00",
+ "name": "Certificates",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/certificates/api/v1.1",
+ "alias": "os-certificates",
+ "description": "Certificates support"
+},
+{
+ "updated": "2011-08-18T00:00:00+00:00",
+ "name": "Rescue",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/rescue/api/v1.1",
+ "alias": "os-rescue",
+ "description": "Instance rescue mode"
+},
+{
+ "updated": "2012-01-19T00:00:00+00:00",
+ "name": "FlavorManage",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/flavor_manage/api/v1.1",
+ "alias": "os-flavor-manage",
+ "description": "\n Flavor create/delete API support\n "
+},
+{
+ "updated": "2011-12-16T00:00:00+00:00",
+ "name": "Cloudpipe",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/cloudpipe/api/v1.1",
+ "alias": "os-cloudpipe",
+ "description": "Adds actions to create cloudpipe instances.\n\n When running with the Vlan network mode, you need a mechanism to route\n from the public Internet to your vlans. This mechanism is known as a\n cloudpipe.\n\n At the time of creating this class, only OpenVPN is supported. Support for\n a SSH Bastion host is forthcoming.\n "
+},
+{
+ "updated": "2011-06-09T00:00:00+00:00",
+ "name": "Multinic",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/multinic/api/v1.1",
+ "alias": "NMN",
+ "description": "Multiple network support"
+},
+{
+ "updated": "2011-08-08T00:00:00+00:00",
+ "name": "Users",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/users/api/v1.1",
+ "alias": "os-users",
+ "description": "Allow admins to acces user information"
+},
+{
+ "updated": "2011-09-20T00:00:00+00:00",
+ "name": "AdminActions",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/admin-actions/api/v1.1",
+ "alias": "os-admin-actions",
+ "description": "Enable admin-only server actions\n\n Actions include: pause,unpause, suspend, resume, migrate,\n resetNetwork, injectNetworkInfo, lock, unlock, createBackup\n "
+},
+{
+ "updated": "2011-12-21T00:00:00+00:00",
+ "name": "ServerActionList",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/server-actions-list/api/v1.1",
+ "alias": "os-server-action-list",
+ "description": "Allow Admins to view pending server actions"
+},
+{
+ "updated": "2011-12-08T00:00:00+00:00",
+ "name": "Console_output",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/os-console-output/api/v2",
+ "alias": "os-console-output",
+ "description": "Console log output support, with tailing ability."
+},
+{
+ "updated": "2011-06-16T00:00:00+00:00",
+ "name": "Floating_ips",
+ "links": [],
+ "namespace": "http://docs.openstack.org/compute/ext/floating_ips/api/v1.1",
+ "alias": "os-floating-ips",
+ "description": "Floating IPs support"}
+]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_normal.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_normal.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_normal.json
new file mode 100644
index 0000000..37fd53f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_normal.json
@@ -0,0 +1,31 @@
+{
+ "extensions": [{
+ "updated": "2011-08-08T00:00:00+00:00",
+ "name": "Keypairs",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/keypairs/api/v1.1",
+ "alias": "os-keypairs",
+ "description": "Keypair Support"
+ }, {
+ "updated": "2011-03-25T00:00:00+00:00",
+ "name": "Volumes",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/volumes/api/v1.1",
+ "alias": "os-volumes",
+ "description": "Volumes support"
+ }, {
+ "updated": "2011-07-21T00:00:00+00:00",
+ "name": "SecurityGroups",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/securitygroups/api/v1.1",
+ "alias": "security_groups",
+ "description": "Security group support"
+ }, {
+ "updated": "2011-06-16T00:00:00+00:00",
+ "name": "Floating_ips",
+ "links": [],
+ "namespace": "http://docs.openstack.org/ext/floating_ips/api/v1.1",
+ "alias": "os-floating-ips",
+ "description": "Floating IPs support"
+ }]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_openstack.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_openstack.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_openstack.json
new file mode 100644
index 0000000..0144af6
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_openstack.json
@@ -0,0 +1,115 @@
+{
+ "extensions": [{
+ "updated": "2011-06-09T00:00:00+00:00",
+ "name": "Multinic",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/multinic/api/v1.1",
+ "alias": "NMN",
+ "description": "Multiple network support"
+ }, {
+ "updated": "2011-06-29T00:00:00+00:00",
+ "name": "Hosts",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/hosts/api/v1.1",
+ "alias": "os-hosts",
+ "description": "Host administration"
+ }, {
+ "updated": "2011-03-25T00:00:00+00:00",
+ "name": "Volumes",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/volumes/api/v1.1",
+ "alias": "os-volumes",
+ "description": "Volumes support"
+ }, {
+ "updated": "2011-05-25 16:12:21.656723",
+ "name": "Admin Controller",
+ "links": [],
+ "namespace": "https:TODO/",
+ "alias": "ADMIN",
+ "description": "The Admin API Extension"
+ }, {
+ "updated": "2011-08-08T00:00:00+00:00",
+ "name": "Quotas",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/quotas-sets/api/v1.1",
+ "alias": "os-quota-sets",
+ "description": "Quotas management support"
+ }, {
+ "updated": "2011-08-24T00:00:00+00:00",
+ "name": "VolumeTypes",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/volume_types/api/v1.1",
+ "alias": "os-volume-types",
+ "description": "Volume types support"
+ }, {
+ "updated": "2011-06-23T00:00:00+00:00",
+ "name": "FlavorExtraSpecs",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/flavor_extra_specs/api/v1.1",
+ "alias": "os-flavor-extra-specs",
+ "description": "Instance type (flavor) extra specs"
+ }, {
+ "updated": "2011-09-14T00:00:00+00:00",
+ "name": "FlavorExtraData",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/flavor_extra_data/api/v1.1",
+ "alias": "os-flavor-extra-data",
+ "description": "Provide additional data for flavors"
+ }, {
+ "updated": "2011-08-17T00:00:00+00:00",
+ "name": "VirtualInterfaces",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/virtual_interfaces/api/v1.1",
+ "alias": "virtual_interfaces",
+ "description": "Virtual interface support"
+ }, {
+ "updated": "2011-07-19T00:00:00+00:00",
+ "name": "Createserverext",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/createserverext/api/v1.1",
+ "alias": "os-create-server-ext",
+ "description": "Extended support to the Create Server v1.1 API"
+ }, {
+ "updated": "2011-08-08T00:00:00+00:00",
+ "name": "Keypairs",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/keypairs/api/v1.1",
+ "alias": "os-keypairs",
+ "description": "Keypair Support"
+ }, {
+ "updated": "2011-08-25T00:00:00+00:00",
+ "name": "VSAs",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/vsa/api/v1.1",
+ "alias": "zadr-vsa",
+ "description": "Virtual Storage Arrays support"
+ }, {
+ "updated": "2011-08-19T00:00:00+00:00",
+ "name": "SimpleTenantUsage",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/os-simple-tenant-usage/api/v1.1",
+ "alias": "os-simple-tenant-usage",
+ "description": "Simple tenant usage extension"
+ }, {
+ "updated": "2011-08-18T00:00:00+00:00",
+ "name": "Rescue",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/rescue/api/v1.1",
+ "alias": "os-rescue",
+ "description": "Instance rescue mode"
+ }, {
+ "updated": "2011-07-21T00:00:00+00:00",
+ "name": "SecurityGroups",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/securitygroups/api/v1.1",
+ "alias": "security_groups",
+ "description": "Security group support"
+ }, {
+ "updated": "2011-06-16T00:00:00+00:00",
+ "name": "Floating_ips",
+ "links": [],
+ "namespace": "https://docs.openstack.org/ext/floating_ips/api/v1.1",
+ "alias": "os-floating-ips",
+ "description": "Floating IPs support"
+ }]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_details.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_details.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_details.json
new file mode 100644
index 0000000..b2a3556
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_details.json
@@ -0,0 +1,19 @@
+{
+ "flavor" : {
+ "id" : "52415800-8b69-11e0-9b19-734f1195ff37",
+ "name" : "256 MB Server",
+ "ram" : 256,
+ "disk" : 10,
+ "vcpus" : 1,
+ "links": [
+ {
+ "rel" : "self",
+ "href" : "http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37"
+ },
+ {
+ "rel" : "bookmark",
+ "href" : "http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37"
+ }
+ ]
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list.json
new file mode 100644
index 0000000..1e4cdeb
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list.json
@@ -0,0 +1,32 @@
+{
+ "flavors": [
+ {
+ "id": "52415800-8b69-11e0-9b19-734f1195ff37",
+ "name": "256 MB Server",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37"
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37"
+ }
+ ]
+ },
+ {
+ "id": "52415800-8b69-11e0-9b19-734f216543fd",
+ "name": "512 MB Server",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail.json
new file mode 100644
index 0000000..e810b48
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail.json
@@ -0,0 +1 @@
+{"flavors": [{"rxtx_quota": 0, "name": "standard.xsmall", "links": [{"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/flavors/100", "rel": "self"}, {"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100", "rel": "bookmark"}], "ram": 1024, "vcpus": 1, "rxtx_cap": 0, "swap": 0, "disk": 30, "id": 100}, {"rxtx_quota": 0, "name": "standard.small", "links": [{"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/flavors/101", "rel": "self"}, {"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/101", "rel": "bookmark"}], "ram": 2048, "vcpus": 2, "rxtx_cap": 0, "swap": 0, "disk": 60, "id": 101}, {"rxtx_quota": 0, "name": "standard.2xlarge", "links": [{"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/flavors/105", "rel": "self"}, {"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/105", "rel": "bookmark"}], "ra
m": 32768, "vcpus": 8, "rxtx_cap": 0, "swap": 0, "disk": 960, "id": 105}, {"rxtx_quota": 0, "name": "standard.large", "links": [{"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/flavors/103", "rel": "self"}, {"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/103", "rel": "bookmark"}], "ram": 8192, "vcpus": 4, "rxtx_cap": 0, "swap": 0, "disk": 240, "id": 103}, {"rxtx_quota": 0, "name": "standard.medium", "links": [{"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/flavors/102", "rel": "self"}, {"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/102", "rel": "bookmark"}], "ram": 4096, "vcpus": 2, "rxtx_cap": 0, "swap": 0, "disk": 120, "id": 102}, {"rxtx_quota": 0, "name": "standard.xlarge", "links": [{"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/flavors/104", "rel": "self"}, {"href": "https://az-2.region-a.geo-1.compute.hpclou
dsvc.com/37936628937291/flavors/104", "rel": "bookmark"}], "ram": 16384, "vcpus": 4, "rxtx_cap": 0, "swap": 0, "disk": 480, "id": 104}]}
\ No newline at end of file
[09/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
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/functions/ServerInZoneToNodeMetadataTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadataTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadataTest.java
new file mode 100644
index 0000000..7ef9fa7
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadataTest.java
@@ -0,0 +1,311 @@
+/*
+ * 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.functions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Set;
+
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.HardwareBuilder;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.ImageBuilder;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
+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.parse.ParseServerTest;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+
+/**
+ * Tests for the function for transforming a nova specific Server into a generic
+ * NodeMetadata object.
+ *
+ * @author Matt Stephenson, Adam Lowe, Adrian Cole
+ */
+@Test(testName = "ServerInZoneToNodeMetadataTest")
+public class ServerInZoneToNodeMetadataTest {
+
+ Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova")
+ .description("openstack-nova").build();
+ Location zone = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1")
+ .scope(LocationScope.ZONE).parent(provider).build();
+ Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
+ .<String, Location> of("az-1.region-a.geo-1", zone));
+
+ GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class);
+
+ @Test
+ public void testWhenNoHardwareOrImageMatchServerScopedIdsImageIdIsStillSet() {
+
+ Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/FOOOOOOOO").providerId("FOOOOOOOO")
+ .location(zone).build();
+ Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/FOOOOOOOO")
+ .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
+ .providerId("FOOOOOOOO").description("foobuntu").location(zone).status(Image.Status.AVAILABLE).build();
+
+ checkHardwareAndImageStatus(null, existingHardware, "az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54",
+ null, existingImage);
+ }
+
+ @Test
+ public void testWhenNoHardwareAndImageMatchServerScopedIdsHardwareOperatingSystemAndImageIdAreSet() {
+
+ Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
+ .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(zone).build();
+ Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
+ .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
+ .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
+ .location(zone).build();
+
+ checkHardwareAndImageStatus(existingHardware, existingHardware, existingImage.getId(),
+ existingImage.getOperatingSystem(), existingImage);
+ }
+
+ @Test
+ public void testNullAccessIPs() {
+ Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
+ .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(zone).build();
+ Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
+ .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
+ .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
+ .location(zone).build();
+
+ Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage);
+ Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet
+ .of(existingHardware);
+ Server serverToConvert = new ParseServerTest().expected().toBuilder()
+ .accessIPv4(null)
+ .accessIPv6(null)
+ .build();
+
+ ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1");
+
+ ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
+ NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
+ .<Set<? extends Image>> ofInstance(images), Suppliers
+ .<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
+
+ NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert);
+
+ assertNotNull(convertedNodeMetadata.getPrivateAddresses());
+ assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16"));
+
+ assertNotNull(convertedNodeMetadata.getPublicAddresses());
+ // note jclouds doesn't yet support ipv6 b/c not tested yet
+ assertEquals(convertedNodeMetadata.getPublicAddresses(), ImmutableSet.of("67.23.10.132", "67.23.10.131"));
+ }
+
+ @Test
+ public void testDuplicateAccessIPs() {
+ Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
+ .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(zone).build();
+ Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
+ .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
+ .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
+ .location(zone).build();
+
+ Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage);
+ Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet
+ .of(existingHardware);
+ Server serverToConvert = new ParseServerTest().expected().toBuilder()
+ .accessIPv4("67.23.10.132")
+ .accessIPv6("::babe:67.23.10.132")
+ .build();
+
+ ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1");
+
+ ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
+ NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
+ .<Set<? extends Image>> ofInstance(images), Suppliers
+ .<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
+
+ NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert);
+
+ assertNotNull(convertedNodeMetadata.getPrivateAddresses());
+ assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16"));
+
+ assertNotNull(convertedNodeMetadata.getPublicAddresses());
+ // note jclouds doesn't yet support ipv6 b/c not tested yet
+ assertEquals(convertedNodeMetadata.getPublicAddresses(), ImmutableSet.of("67.23.10.132", "67.23.10.131"));
+ }
+
+ @Test
+ public void testAlternateAccessIPs() {
+ Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd")
+ .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(zone).build();
+ Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54")
+ .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build())
+ .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE)
+ .location(zone).build();
+
+ Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage);
+ Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet
+ .of(existingHardware);
+ Server serverToConvert = new ParseServerTest().expected().toBuilder()
+ .accessIPv4("76.32.1.231")
+ .accessIPv6("::babe:76.32.1.231")
+ .build();
+
+ ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1");
+
+ ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
+ NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
+ .<Set<? extends Image>> ofInstance(images), Suppliers
+ .<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
+
+ NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert);
+
+ assertNotNull(convertedNodeMetadata.getPrivateAddresses());
+ assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16"));
+
+ assertNotNull(convertedNodeMetadata.getPublicAddresses());
+ // note jclouds doesn't yet support ipv6 b/c not tested yet
+ assertEquals(convertedNodeMetadata.getPublicAddresses(), ImmutableSet.of("67.23.10.132", "67.23.10.131", "76.32.1.231"));
+ }
+
+ // TODO: clean up this syntax
+ private void checkHardwareAndImageStatus(Hardware expectedHardware, Hardware existingHardware,
+ String expectedImageId, OperatingSystem expectedOs, Image existingImage) {
+
+ Set<Image> images = existingImage == null ? ImmutableSet.<Image> of() : ImmutableSet.of(existingImage);
+ Set<Hardware> hardwares = existingHardware == null ? ImmutableSet.<Hardware> of() : ImmutableSet
+ .of(existingHardware);
+ Server serverToConvert = new ParseServerTest().expected();
+
+ ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1");
+
+ ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
+ NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
+ .<Set<? extends Image>> ofInstance(images), Suppliers
+ .<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
+
+ NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert);
+
+ assertEquals(serverInZoneToConvert.slashEncode(), convertedNodeMetadata.getId());
+ assertEquals(serverToConvert.getId(), convertedNodeMetadata.getProviderId());
+
+ assertEquals(convertedNodeMetadata.getLocation().getScope(), LocationScope.HOST);
+ assertEquals(convertedNodeMetadata.getLocation().getId(), "e4d909c290d0fb1ca068ffaddf22cbd0");
+
+ assertEquals(convertedNodeMetadata.getLocation().getParent(), locationIndex.get().get("az-1.region-a.geo-1"));
+
+ assertEquals(serverToConvert.getName(), convertedNodeMetadata.getName());
+ assertEquals(convertedNodeMetadata.getGroup(), "sample");
+
+ assertEquals(convertedNodeMetadata.getImageId(), expectedImageId);
+ assertEquals(convertedNodeMetadata.getOperatingSystem(), expectedOs);
+
+ assertEquals(convertedNodeMetadata.getHardware(), expectedHardware);
+
+ assertEquals(NovaComputeServiceContextModule.toPortableNodeStatus.get(serverToConvert.getStatus()),
+ convertedNodeMetadata.getStatus());
+
+ assertNotNull(convertedNodeMetadata.getPrivateAddresses());
+ assertEquals(convertedNodeMetadata.getPrivateAddresses(), ImmutableSet.of("10.176.42.16"));
+
+ assertNotNull(convertedNodeMetadata.getPublicAddresses());
+ // note jclouds doesn't yet support ipv6 b/c not tested yet
+ assertEquals(convertedNodeMetadata.getPublicAddresses(), ImmutableSet.of("67.23.10.132", "67.23.10.131"));
+
+ assertNotNull(convertedNodeMetadata.getUserMetadata());
+ assertEquals(convertedNodeMetadata.getUserMetadata(),
+ ImmutableMap.<String, String> of("Server Label", "Web Head 1", "Image Version", "2.1"));
+
+ URI expectedURI = URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54");
+ assertEquals(convertedNodeMetadata.getUri(), expectedURI);
+ }
+
+ @Test
+ public void testNewServerWithoutHostIdSetsZoneAsLocation() {
+
+ Set<Image> images = ImmutableSet.<Image> of();
+ Set<Hardware> hardwares = ImmutableSet.<Hardware> of();
+
+ Server serverToConvert = expectedServer();
+
+ ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1");
+
+ ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
+ NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
+ .<Set<? extends Image>> ofInstance(images), Suppliers
+ .<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
+
+ NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert);
+
+ assertEquals(serverInZoneToConvert.slashEncode(), convertedNodeMetadata.getId());
+ assertEquals(serverToConvert.getId(), convertedNodeMetadata.getProviderId());
+
+ assertEquals(convertedNodeMetadata.getLocation(), zone);
+
+ URI expectedURI = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752");
+ assertEquals(convertedNodeMetadata.getUri(), expectedURI);
+ }
+
+ public Server expectedServer() {
+ return Server
+ .builder()
+ .id("71752")
+ .uuid("47491020-6a78-4f63-9475-23195ac4515c")
+ .tenantId("37936628937291")
+ .userId("54297837463082")
+ .name("test-e92")
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-03-19T06:21:13Z"))
+ .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2012-03-19T06:21:13Z"))
+ .status(Server.Status.BUILD)
+ .image(
+ Resource
+ .builder()
+ .id("1241")
+ .links(
+ Link.create(
+ Link.Relation.BOOKMARK,
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241")))
+ .build())
+ .flavor(
+ Resource
+ .builder()
+ .id("100")
+ .links(
+ Link.create(
+ Link.Relation.BOOKMARK,
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100")))
+ .build())
+ .links(
+ Link.create(Link.Relation.SELF, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752")),
+ Link.create(Link.Relation.BOOKMARK, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752"))).build();
+
+ }
+}
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/loaders/CreateUniqueKeyPairTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPairTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPairTest.java
new file mode 100644
index 0000000..9bca8e1
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPairTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.loaders;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.testng.Assert.assertEquals;
+
+import java.net.UnknownHostException;
+
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.TypeLiteral;
+
+/**
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "CreateUniqueKeyPairTest")
+public class CreateUniqueKeyPairTest {
+
+ @Test
+ public void testApply() throws UnknownHostException {
+ final NovaApi api = createMock(NovaApi.class);
+ KeyPairApi keyApi = createMock(KeyPairApi.class);
+
+ KeyPair pair = createMock(KeyPair.class);
+
+ Optional optKeyApi = Optional.of(keyApi);
+
+ expect(api.getKeyPairExtensionForZone("zone")).andReturn(optKeyApi).atLeastOnce();
+
+ expect(keyApi.create("group-1")).andReturn(pair);
+
+ replay(api, keyApi);
+
+ CreateUniqueKeyPair parser = Guice.createInjector(new AbstractModule() {
+
+ @Override
+ protected void configure() {
+ bind(new TypeLiteral<Supplier<String>>() {
+ }).toInstance(Suppliers.ofInstance("1"));
+ bind(NovaApi.class).toInstance(api);
+ }
+
+ }).getInstance(CreateUniqueKeyPair.class);
+
+ assertEquals(parser.load(ZoneAndName.fromZoneAndName("zone", "group")), pair);
+
+ verify(api, keyApi);
+ }
+
+ @Test
+ public void testApplyWithIllegalStateException() throws UnknownHostException {
+ final NovaApi api = createMock(NovaApi.class);
+ KeyPairApi keyApi = createMock(KeyPairApi.class);
+ @SuppressWarnings("unchecked")
+ final Supplier<String> uniqueIdSupplier = createMock(Supplier.class);
+
+ KeyPair pair = createMock(KeyPair.class);
+
+ expect(api.getKeyPairExtensionForZone("zone")).andReturn((Optional) Optional.of(keyApi)).atLeastOnce();
+
+ expect(uniqueIdSupplier.get()).andReturn("1");
+ expect(keyApi.create("group-1")).andThrow(new IllegalStateException());
+ expect(uniqueIdSupplier.get()).andReturn("2");
+ expect(keyApi.create("group-2")).andReturn(pair);
+
+ replay(api, keyApi, uniqueIdSupplier);
+
+ CreateUniqueKeyPair parser = Guice.createInjector(new AbstractModule() {
+
+ @Override
+ protected void configure() {
+ bind(new TypeLiteral<Supplier<String>>() {
+ }).toInstance(uniqueIdSupplier);
+ bind(NovaApi.class).toInstance(api);
+ }
+
+ }).getInstance(CreateUniqueKeyPair.class);
+
+ assertEquals(parser.load(ZoneAndName.fromZoneAndName("zone", "group")), pair);
+
+ verify(api, keyApi, uniqueIdSupplier);
+ }
+
+}
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/loaders/FindSecurityGroupOrCreateTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreateTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreateTest.java
new file mode 100644
index 0000000..62f45fd
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreateTest.java
@@ -0,0 +1,144 @@
+/*
+ * 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.loaders;
+
+import static org.easymock.EasyMock.createMock;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.base.Functions;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", singleThreaded = true, testName = "FindSecurityGroupOrCreateTest")
+public class FindSecurityGroupOrCreateTest {
+
+ @Test
+ public void testWhenNotFoundCreatesANewSecurityGroup() throws Exception {
+ Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = Predicates.alwaysFalse();
+
+ SecurityGroupInZone securityGroupInZone = createMock(SecurityGroupInZone.class);
+
+ ZoneSecurityGroupNameAndPorts input = new ZoneSecurityGroupNameAndPorts("zone", "groupName", ImmutableSet
+ .<Integer> of(22, 8080));
+
+ Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = Functions.forMap(ImmutableMap
+ .<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> of(input, securityGroupInZone));
+
+ FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
+ returnSecurityGroupExistsInZone, groupCreator);
+
+ assertEquals(parser.load(input), securityGroupInZone);
+
+ }
+
+ @Test
+ public void testWhenFoundReturnsSecurityGroupFromAtomicReferenceValueUpdatedDuringPredicateCheck() throws Exception {
+ final SecurityGroupInZone securityGroupInZone = createMock(SecurityGroupInZone.class);
+
+ Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = new Predicate<AtomicReference<ZoneAndName>>() {
+
+ @Override
+ public boolean apply(AtomicReference<ZoneAndName> input) {
+ input.set(securityGroupInZone);
+ return true;
+ }
+
+ };
+
+ ZoneAndName input = ZoneAndName.fromZoneAndName("zone", "groupName");
+
+ Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = new Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>() {
+
+ @Override
+ public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
+ fail();
+ return null;
+ }
+
+ };
+
+ FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
+ returnSecurityGroupExistsInZone, groupCreator);
+
+ assertEquals(parser.load(input), securityGroupInZone);
+
+ }
+
+
+ @Test(expectedExceptions = IllegalStateException.class)
+ public void testWhenFoundPredicateMustUpdateAtomicReference() throws Exception {
+
+ Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = Predicates.alwaysTrue();
+
+ ZoneAndName input = ZoneAndName.fromZoneAndName("zone", "groupName");
+
+ Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = new Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>() {
+
+ @Override
+ public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
+ fail();
+ return null;
+ }
+
+ };
+
+ FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
+ returnSecurityGroupExistsInZone, groupCreator);
+
+ parser.load(input);
+
+ }
+
+
+
+ @Test(expectedExceptions = IllegalStateException.class)
+ public void testWhenNotFoundInputMustBeZoneSecurityGroupNameAndPorts() throws Exception {
+ Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = Predicates.alwaysFalse();
+
+ ZoneAndName input = ZoneAndName.fromZoneAndName("zone", "groupName");
+
+ Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator = new Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>() {
+
+ @Override
+ public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts input) {
+ fail();
+ return null;
+ }
+
+ };
+
+ FindSecurityGroupOrCreate parser = new FindSecurityGroupOrCreate(
+ returnSecurityGroupExistsInZone, groupCreator);
+
+ parser.load(input);
+
+ }
+}
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/loaders/LoadFloatingIpsForInstanceTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstanceTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstanceTest.java
new file mode 100644
index 0000000..771d63f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstanceTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.loaders;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.testng.Assert.assertEquals;
+import static org.testng.AssertJUnit.assertFalse;
+
+
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
+import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", singleThreaded = true, testName = "LoadFloatingIpsForInstanceTest")
+public class LoadFloatingIpsForInstanceTest {
+
+ @Test
+ public void testReturnsPublicIpOnMatch() throws Exception {
+ NovaApi api = createMock(NovaApi.class);
+ FloatingIPApi ipApi = createMock(FloatingIPApi.class);
+ FloatingIP testIp = FloatingIP.builder().id("1").ip("1.1.1.1").fixedIp("10.1.1.1").instanceId("i-blah").build();
+
+ expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
+ expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of(testIp)))
+ .atLeastOnce();
+
+ replay(api);
+ replay(ipApi);
+
+ LoadFloatingIpsForInstance parser = new LoadFloatingIpsForInstance(api);
+
+ assertEquals(ImmutableSet.copyOf(parser.load(ZoneAndId.fromZoneAndId("Zone", "i-blah"))), ImmutableSet.of(testIp));
+
+ verify(api);
+ verify(ipApi);
+ }
+
+ @Test
+ public void testReturnsNullWhenNotFound() throws Exception {
+ NovaApi api = createMock(NovaApi.class);
+ FloatingIPApi ipApi = createMock(FloatingIPApi.class);
+
+ expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
+
+ expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of()))
+ .atLeastOnce();
+
+ replay(api);
+ replay(ipApi);
+
+ LoadFloatingIpsForInstance parser = new LoadFloatingIpsForInstance(api);
+
+ assertFalse(parser.load(ZoneAndId.fromZoneAndId("Zone", "i-blah")).iterator().hasNext());
+
+ verify(api);
+ verify(ipApi);
+
+ }
+
+ @Test
+ public void testReturnsNullWhenNotAssigned() throws Exception {
+ NovaApi api = createMock(NovaApi.class);
+ FloatingIPApi ipApi = createMock(FloatingIPApi.class);
+
+ expect(api.getFloatingIPExtensionForZone("Zone")).andReturn((Optional) Optional.of(ipApi)).atLeastOnce();
+
+ expect(ipApi.list()).andReturn((FluentIterable) FluentIterable.from(ImmutableSet.<FloatingIP> of(FloatingIP.builder().id("1").ip("1.1.1.1").build())))
+ .atLeastOnce();
+
+ replay(api);
+ replay(ipApi);
+
+ LoadFloatingIpsForInstance parser = new LoadFloatingIpsForInstance(api);
+
+ assertFalse(parser.load(ZoneAndId.fromZoneAndId("Zone", "i-blah")).iterator().hasNext());
+
+ verify(api);
+ verify(ipApi);
+
+ }
+
+}
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/options/NovaTemplateOptionsTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptionsTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptionsTest.java
new file mode 100644
index 0000000..106da5b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptionsTest.java
@@ -0,0 +1,263 @@
+/*
+ * 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.options;
+
+import static org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions.Builder.authorizePublicKey;
+import static org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions.Builder.autoAssignFloatingIp;
+import static org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions.Builder.blockOnPort;
+import static org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions.Builder.generateKeyPair;
+import static org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions.Builder.inboundPorts;
+import static org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions.Builder.installPrivateKey;
+import static org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions.Builder.securityGroupNames;
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests possible uses of NovaTemplateOptions and NovaTemplateOptions.Builder.*
+ *
+ * @author Adrian Cole
+ */
+@Test(testName = "NovaTemplateOptionsTest")
+public class NovaTemplateOptionsTest {
+
+ public void testAs() {
+ TemplateOptions options = new NovaTemplateOptions();
+ assertEquals(options.as(NovaTemplateOptions.class), options);
+ }
+
+ @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "all security groups must be non-empty")
+ public void testsecurityGroupNamesIterableBadFormat() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ options.securityGroupNames(ImmutableSet.of("group1", ""));
+ }
+
+ @Test
+ public void testsecurityGroupNamesIterable() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ options.securityGroupNames(ImmutableSet.of("group1", "group2"));
+ assertEquals(options.getSecurityGroupNames(), Optional.of(ImmutableSet.of("group1", "group2")));
+
+ }
+
+ @Test
+ public void testsecurityGroupNamesIterableStatic() {
+ NovaTemplateOptions options = securityGroupNames(ImmutableSet.of("group1", "group2"));
+ assertEquals(options.getSecurityGroupNames(), Optional.of(ImmutableSet.of("group1", "group2")));
+ }
+
+ @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "all security groups must be non-empty")
+ public void testsecurityGroupNamesVarArgsBadFormat() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ options.securityGroupNames("mygroup", "");
+ }
+
+ @Test
+ public void testsecurityGroupNamesVarArgs() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ options.securityGroupNames("group1", "group2");
+ assertEquals(options.getSecurityGroupNames(), Optional.of(ImmutableSet.of("group1", "group2")));
+
+ }
+
+ @Test
+ public void testDefaultGroupsVarArgsEmpty() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ assertEquals(options.getSecurityGroupNames(), Optional.absent());
+ }
+
+ @Test
+ public void testsecurityGroupNamesVarArgsStatic() {
+ NovaTemplateOptions options = securityGroupNames("group1", "group2");
+ assertEquals(options.getSecurityGroupNames(), Optional.of(ImmutableSet.of("group1", "group2")));
+ }
+
+ @Test
+ public void testautoAssignFloatingIpDefault() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ assert !options.shouldAutoAssignFloatingIp();
+ }
+
+ @Test
+ public void testautoAssignFloatingIp() {
+ NovaTemplateOptions options = new NovaTemplateOptions().autoAssignFloatingIp(true);
+ assert options.shouldAutoAssignFloatingIp();
+ }
+
+ @Test
+ public void testautoAssignFloatingIpStatic() {
+ NovaTemplateOptions options = autoAssignFloatingIp(true);
+ assert options.shouldAutoAssignFloatingIp();
+ }
+
+ @Test
+ public void testGenerateKeyPairDefault() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ assert !options.shouldGenerateKeyPair();
+ }
+
+ @Test
+ public void testGenerateKeyPair() {
+ NovaTemplateOptions options = new NovaTemplateOptions().generateKeyPair(true);
+ assert options.shouldGenerateKeyPair();
+ }
+
+ @Test
+ public void testGenerateKeyPairStatic() {
+ NovaTemplateOptions options = generateKeyPair(true);
+ assert options.shouldGenerateKeyPair();
+ }
+
+ // superclass tests
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testinstallPrivateKeyBadFormat() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ options.installPrivateKey("whompy");
+ }
+
+ @Test
+ public void testinstallPrivateKey() throws IOException {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ options.installPrivateKey("-----BEGIN RSA PRIVATE KEY-----");
+ assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----");
+ }
+
+ @Test
+ public void testNullinstallPrivateKey() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ assertEquals(options.getPrivateKey(), null);
+ }
+
+ @Test
+ public void testinstallPrivateKeyStatic() throws IOException {
+ NovaTemplateOptions options = installPrivateKey("-----BEGIN RSA PRIVATE KEY-----");
+ assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----");
+ }
+
+ @Test(expectedExceptions = NullPointerException.class)
+ public void testinstallPrivateKeyNPE() {
+ installPrivateKey(null);
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testauthorizePublicKeyBadFormat() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ options.authorizePublicKey("whompy");
+ }
+
+ @Test
+ public void testauthorizePublicKey() throws IOException {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ options.authorizePublicKey("ssh-rsa");
+ assertEquals(options.getPublicKey(), "ssh-rsa");
+ }
+
+ @Test
+ public void testNullauthorizePublicKey() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ assertEquals(options.getPublicKey(), null);
+ }
+
+ @Test
+ public void testauthorizePublicKeyStatic() throws IOException {
+ NovaTemplateOptions options = authorizePublicKey("ssh-rsa");
+ assertEquals(options.getPublicKey(), "ssh-rsa");
+ }
+
+ @Test(expectedExceptions = NullPointerException.class)
+ public void testauthorizePublicKeyNPE() {
+ authorizePublicKey(null);
+ }
+
+ @Test
+ public void testUserData() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ options.userData("test".getBytes());
+ assertEquals(new String(options.getUserData()), "test");
+ }
+
+ @Test
+ public void testDiskConfig() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ options.diskConfig(Server.DISK_CONFIG_AUTO);
+ assertEquals(options.getDiskConfig(), Server.DISK_CONFIG_AUTO);
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testblockOnPortBadFormat() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ options.blockOnPort(-1, -1);
+ }
+
+ @Test
+ public void testblockOnPort() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ options.blockOnPort(22, 30);
+ assertEquals(options.getPort(), 22);
+ assertEquals(options.getSeconds(), 30);
+
+ }
+
+ @Test
+ public void testNullblockOnPort() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ assertEquals(options.getPort(), -1);
+ assertEquals(options.getSeconds(), -1);
+ }
+
+ @Test
+ public void testblockOnPortStatic() {
+ NovaTemplateOptions options = blockOnPort(22, 30);
+ assertEquals(options.getPort(), 22);
+ assertEquals(options.getSeconds(), 30);
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testinboundPortsBadFormat() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ options.inboundPorts(-1, -1);
+ }
+
+ @Test
+ public void testinboundPorts() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ options.inboundPorts(22, 30);
+ assertEquals(options.getInboundPorts()[0], 22);
+ assertEquals(options.getInboundPorts()[1], 30);
+
+ }
+
+ @Test
+ public void testDefaultOpen22() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ assertEquals(options.getInboundPorts()[0], 22);
+ }
+
+ @Test
+ public void testinboundPortsStatic() {
+ NovaTemplateOptions options = inboundPorts(22, 30);
+ assertEquals(options.getInboundPorts()[0], 22);
+ assertEquals(options.getInboundPorts()[1], 30);
+ }
+}
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/extensions/AdminActionsApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiExpectTest.java
new file mode 100644
index 0000000..32c4617
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiExpectTest.java
@@ -0,0 +1,350 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.domain.BackupType;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.options.CreateBackupOfServerOptions;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests parsing and guice wiring of AdminActionsApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "AdminActionsApiExpectTest")
+public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest {
+
+ public void testSuspend() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "suspend").build(),
+ HttpResponse.builder().statusCode(202).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.suspend("1"));
+ }
+
+ public void testSuspendFailsNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "suspend").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.suspend("1"));
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testSuspendFailsNotAuthorized() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "suspend").build(),
+ HttpResponse.builder().statusCode(403).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ api.suspend("1");
+ }
+
+ public void testResume() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "resume").build(),
+ HttpResponse.builder().statusCode(202).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.resume("1"));
+ }
+
+ public void testResumeFailsNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "resume").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.resume("1"));
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testResumeFailsNotAuthorized() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "resume").build(),
+ HttpResponse.builder().statusCode(403).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ api.resume("1");
+ }
+
+ public void testLock() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "lock").build(),
+ HttpResponse.builder().statusCode(202).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.lock("1"));
+ }
+
+ public void testLockFailsNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "lock").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.lock("1"));
+ }
+
+ public void testUnlock() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "unlock").build(),
+ HttpResponse.builder().statusCode(202).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.unlock("1"));
+ }
+
+ public void testUnlockFailsNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "unlock").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.unlock("1"));
+ }
+
+ public void testPause() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "pause").build(),
+ HttpResponse.builder().statusCode(202).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.pause("1"));
+ }
+
+ public void testPauseFailsNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "pause").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.pause("1"));
+ }
+
+ public void testUnpause() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "unpause").build(),
+ HttpResponse.builder().statusCode(202).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.unpause("1"));
+ }
+
+ public void testUnpauseFailsNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "unpause").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.unpause("1"));
+ }
+
+ public void testMigrateServer() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "migrate").build(),
+ HttpResponse.builder().statusCode(202).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.migrate("1"));
+ }
+
+
+ public void testMigrateServerFailsNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "migrate").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.migrate("1"));
+ }
+
+ public void testResetNetworkOfServer() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "resetNetwork").build(),
+ HttpResponse.builder().statusCode(202).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.resetNetwork("1"));
+ }
+
+ public void testResetNetworkOfServerFailsNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "resetNetwork").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.resetNetwork("1"));
+ }
+
+ public void testInjectNetworkInfoIntoServer() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "injectNetworkInfo").build(),
+ HttpResponse.builder().statusCode(202).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.injectNetworkInfo("1"));
+ }
+
+ public void testInjectNetworkInfoIntoServerFailsNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "injectNetworkInfo").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.injectNetworkInfo("1"));
+ }
+
+ public void testBackupServer() {
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action").method("POST")
+ .payload(payloadFromStringWithContentType("{\"createBackup\":{\"backup_type\":\"weekly\",\"rotation\":3,\"name\":\"mybackup\",\"metadata\":{\"some\":\"data or other\"}}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(202).addHeader("Location", "http://172.16.89.149:8774/v2/images/1976b3b3-409a-468d-b16c-a9172c341b46").build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ String imageId = api.createBackup("1", "mybackup", BackupType.WEEKLY, 3, CreateBackupOfServerOptions.Builder.metadata(ImmutableMap.of("some", "data or other")));
+ assertEquals(imageId, "1976b3b3-409a-468d-b16c-a9172c341b46");
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testBackupServerFailNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("POST")
+ .payload(payloadFromStringWithContentType("{\"createBackup\":{\"backup_type\":\"weekly\",\"rotation\":3,\"name\":\"mybackup\",\"metadata\":{\"some\":\"data or other\"}}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ api.createBackup("1", "mybackup", BackupType.WEEKLY, 3, CreateBackupOfServerOptions.Builder.metadata(ImmutableMap.of("some", "data or other")));
+ }
+
+ public void testLiveMigrateServer() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "GONNAOVERWRITE")
+ .payload(payloadFromStringWithContentType("{\"os-migrateLive\":{\"host\":\"bighost\",\"block_migration\":true,\"disk_over_commit\":false}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(202).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.liveMigrate("1", "bighost", true, false));
+ }
+
+ public void testLiveMigrateServerFailsNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action");
+ ServerAdminApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ standardActionRequestBuilderVoidResponse(endpoint, "GONNAOVERWRITE")
+ .payload(payloadFromStringWithContentType("{\"os-migrateLive\":{\"host\":\"bighost\",\"block_migration\":true,\"disk_over_commit\":false}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.liveMigrate("1", "bighost", true, false));
+ }
+
+ protected HttpRequest.Builder<?> standardActionRequestBuilderVoidResponse(URI endpoint, String actionName) {
+ return HttpRequest.builder()
+ .method("POST")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"" + actionName + "\":null}", MediaType.APPLICATION_JSON))
+ .endpoint(endpoint);
+ }
+
+}
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/extensions/AdminActionsApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiLiveTest.java
new file mode 100644
index 0000000..1d15058
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiLiveTest.java
@@ -0,0 +1,195 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.openstack.nova.v2_0.domain.BackupType;
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
+import org.jclouds.openstack.nova.v2_0.features.ImageApi;
+import org.jclouds.openstack.nova.v2_0.features.ServerApi;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.jclouds.openstack.nova.v2_0.options.CreateBackupOfServerOptions;
+import org.jclouds.openstack.v2_0.features.ExtensionApi;
+import org.testng.SkipException;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests behavior of HostAdministrationApi
+ *
+ * TODO test migration methods
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "live", testName = "AdminActionsApiLiveTest", singleThreaded = true)
+public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
+ private ImageApi imageApi;
+ private ServerApi serverApi;
+ private ExtensionApi extensionApi;
+ private Optional<? extends ServerAdminApi> apiOption;
+ private String zone;
+
+ private String testServerId;
+ private String backupImageId;
+
+ @BeforeClass(groups = {"integration", "live"})
+ @Override
+ public void setup() {
+ super.setup();
+ zone = Iterables.getLast(api.getConfiguredZones(), "nova");
+ serverApi = api.getServerApiForZone(zone);
+ extensionApi = api.getExtensionApiForZone(zone);
+ imageApi = api.getImageApiForZone(zone);
+ apiOption = api.getServerAdminExtensionForZone(zone);
+ if (apiOption.isPresent()) {
+ testServerId = createServerInZone(zone).getId();
+ }
+ }
+
+ @AfterClass(groups = { "integration", "live" })
+ @Override
+ protected void tearDown() {
+ if (apiOption.isPresent()) {
+ if (testServerId != null) {
+ assertTrue(api.getServerApiForZone(zone).delete(testServerId));
+ }
+ if (backupImageId != null) {
+ imageApi.delete(backupImageId);
+ }
+ }
+ super.tearDown();
+ }
+
+ protected void skipOnAdminExtensionAbsent() {
+ if (!apiOption.isPresent()) {
+ throw new SkipException("Test depends on ServerAdminApi extension");
+ }
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void ensureServerIsActiveAgain() {
+ if (apiOption.isPresent())
+ blockUntilServerInState(testServerId, serverApi, Status.ACTIVE);
+ }
+
+ public void testSuspendAndResume() {
+ skipOnAdminExtensionAbsent();
+ ServerAdminApi api = apiOption.get();
+
+ // Suspend-resume
+ try {
+ api.resume(testServerId);
+ fail("Resumed an active server!");
+ } catch (HttpResponseException e) {
+ }
+ assertTrue(api.suspend(testServerId));
+ blockUntilServerInState(testServerId, serverApi, Status.SUSPENDED);
+ try {
+ api.suspend(testServerId);
+ fail("Suspended an already suspended server!");
+ } catch (HttpResponseException e) {
+ }
+ assertTrue(api.resume(testServerId));
+ blockUntilServerInState(testServerId, serverApi, Status.ACTIVE);
+ try {
+ api.resume(testServerId);
+ fail("Resumed an already resumed server!");
+ } catch (HttpResponseException e) {
+ }
+
+ }
+
+ public void testLockAndUnlock() {
+ skipOnAdminExtensionAbsent();
+ ServerAdminApi api = apiOption.get();
+
+ // TODO should we be able to double-lock (as it were)
+ assertTrue(api.unlock(testServerId));
+ assertTrue(api.unlock(testServerId));
+ assertTrue(api.lock(testServerId));
+ assertTrue(api.lock(testServerId));
+ assertTrue(api.unlock(testServerId));
+ assertTrue(api.unlock(testServerId));
+
+ }
+
+ public void testResetNetworkAndInjectNetworkInfo() {
+ skipOnAdminExtensionAbsent();
+ ServerAdminApi api = apiOption.get();
+ assertTrue(api.resetNetwork(testServerId));
+ assertTrue(api.injectNetworkInfo(testServerId));
+ }
+
+ @Test
+ public void testPauseAndUnpause() {
+ skipOnAdminExtensionAbsent();
+ ServerAdminApi api = apiOption.get();
+
+ // Unlock and lock (double-checking error contitions too)
+ try {
+ api.unpause(testServerId);
+ fail("Unpaused active server!");
+ } catch (HttpResponseException e) {
+ }
+ assertTrue(api.pause(testServerId));
+ blockUntilServerInState(testServerId, serverApi, Status.PAUSED);
+ try {
+ api.pause(testServerId);
+ fail("paused a paused server!");
+ } catch (HttpResponseException e) {
+ }
+ assertTrue(api.unpause(testServerId));
+ blockUntilServerInState(testServerId, serverApi, Status.ACTIVE);
+ try {
+ api.unpause(testServerId);
+ fail("Unpaused a server we just unpaused!");
+ } catch (HttpResponseException e) {
+ }
+
+ }
+
+ @Test
+ public void testCreateBackupOfServer() throws InterruptedException {
+ skipOnAdminExtensionAbsent();
+ backupImageId = apiOption.get().createBackup(testServerId, "jclouds-test-backup", BackupType.DAILY, 0,
+ CreateBackupOfServerOptions.Builder.metadata(ImmutableMap.of("test", "metadata")));
+
+ assertNotNull(backupImageId);
+
+ // If we don't have extended task status, we'll have to wait here!
+ if (extensionApi.get("OS-EXT-STS") == null) {
+ Thread.sleep(30000);
+ }
+
+ blockUntilServerInState(testServerId, serverApi, Status.ACTIVE);
+
+ Image backupImage = imageApi.get(backupImageId);
+ assertEquals(backupImage.getId(), backupImageId);
+ }
+}
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/extensions/AvailabilityZoneApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApiExpectTest.java
new file mode 100644
index 0000000..f033a1b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApiExpectTest.java
@@ -0,0 +1,64 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.extensions;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableSet;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * @author Inbar Stolberg
+ */
+@Test(groups = "unit", testName = "AvailabilityZoneApiExpectTest")
+public class AvailabilityZoneApiExpectTest extends BaseNovaApiExpectTest {
+
+ public void testLAvailabilityZonesList() throws Exception {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-availability-zone")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/listAvailabilityZones.json")).build();
+
+ NovaApi availabilityZonesApi = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
+
+ assertEquals(availabilityZonesApi.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
+
+ FluentIterable<? extends AvailabilityZone> zones = availabilityZonesApi.getAvailabilityZoneApi("az-1.region-a.geo-1").list();
+
+ Optional<? extends AvailabilityZone> zone = zones.first();
+
+ assertTrue(zone.isPresent(), "Couldn't find zone");
+ assertTrue(zone.get().getName().equals("nova"), "Expected zone name to be nova but it was: " + zone.get().getName());
+ assertTrue(zone.get().getState().available(), "Zone: "+ zone.get().getName() + " is not available.");
+ }
+}
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/extensions/AvailabilityZonesApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZonesApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZonesApiLiveTest.java
new file mode 100644
index 0000000..a7ad44f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZonesApiLiveTest.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.extensions;
+
+import com.google.common.collect.FluentIterable;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * @author inbar stolberg
+ */
+@Test(groups = "live", testName = "AvailabilityZonesApiLiveTest")
+public class AvailabilityZonesApiLiveTest extends BaseNovaApiLiveTest {
+
+ @Test
+ public void testListAvailabilityZones() throws Exception {
+
+ AvailabilityZoneAPI availabilityZoneApi = api.getAvailabilityZoneApi("RegionOne");
+ FluentIterable<? extends AvailabilityZone> zones = availabilityZoneApi.list();
+
+ for (AvailabilityZone zone : zones) {
+ assertNotNull(zone.getName());
+ assertTrue(zone.getState().available(), "zone: " + zone.getName() + " is not available.");
+ }
+ }
+}
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/extensions/FlavorExtraSpecsApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiExpectTest.java
new file mode 100644
index 0000000..b04b5f2
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiExpectTest.java
@@ -0,0 +1,142 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests guice wiring and parsing of FlavorExtraSpecsApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "FlavorExtraSpecsApiExpectTest")
+public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest {
+
+ public void testGetAllExtraSpecs() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/9/os-extra_specs");
+ FlavorExtraSpecsApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_type_extra_specs.json")).build()
+ ).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertEquals(api.getMetadata("9"), ImmutableMap.of("test", "value1"));
+ }
+
+ public void testGetAllExtraSpecsFailNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/9/os-extra_specs");
+ FlavorExtraSpecsApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.getMetadata("9").isEmpty());
+ }
+
+ public void testSetAllExtraSpecs() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/9/os-extra_specs");
+ FlavorExtraSpecsApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint)
+ .method("POST")
+ .payload(payloadFromStringWithContentType("{\"extra_specs\":{\"test1\":\"somevalue\"}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).build()
+ ).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.updateMetadata("9", ImmutableMap.of("test1", "somevalue")));
+ }
+
+ public void testSetExtraSpec() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/5/os-extra_specs/test1");
+ FlavorExtraSpecsApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint)
+ .method("PUT")
+ .payload(payloadFromStringWithContentType("{\"test1\":\"somevalue\"}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).build()
+ ).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.updateMetadataEntry("5", "test1", "somevalue"));
+ }
+
+ public void testGetExtraSpec() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/5/os-extra_specs/test1");
+ FlavorExtraSpecsApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromStringWithContentType("{\"test1\":\"another value\"}", MediaType.APPLICATION_JSON)).build()
+ ).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertEquals(api.getMetadataKey("5", "test1"), "another value");
+ }
+
+ public void testGetExtraSpecFailNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/5/os-extra_specs/test1");
+ FlavorExtraSpecsApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertNull(api.getMetadataKey("5", "test1"));
+ }
+
+ public void testDeleteExtraSpec() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/5/os-extra_specs/test1");
+ FlavorExtraSpecsApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(200).build()
+ ).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.deleteMetadataKey("5", "test1"));
+ }
+
+ public void testDeleteExtraSpecFailNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/5/os-extra_specs/test1");
+ FlavorExtraSpecsApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getFlavorExtraSpecsExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.deleteMetadataKey("5", "test1"));
+ }
+
+}
[15/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeSnapshot.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeSnapshot.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeSnapshot.java
new file mode 100644
index 0000000..bbd45a4
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeSnapshot.java
@@ -0,0 +1,239 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.util.Date;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * An OpenStack Nova Volume Snapshot
+*/
+public class VolumeSnapshot {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromVolumeSnapshot(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String id;
+ protected String volumeId;
+ protected Volume.Status status;
+ protected int size;
+ protected Date created;
+ protected String name;
+ protected String description;
+
+ /**
+ * @see VolumeSnapshot#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see VolumeSnapshot#getVolumeId()
+ */
+ public T volumeId(String volumeId) {
+ this.volumeId = volumeId;
+ return self();
+ }
+
+ /**
+ * @see VolumeSnapshot#getStatus()
+ */
+ public T status(Volume.Status status) {
+ this.status = status;
+ return self();
+ }
+
+ /**
+ * @see VolumeSnapshot#getSize()
+ */
+ public T size(int size) {
+ this.size = size;
+ return self();
+ }
+
+ /**
+ * @see VolumeSnapshot#getCreated()
+ */
+ public T created(Date created) {
+ this.created = created;
+ return self();
+ }
+
+ /**
+ * @see VolumeSnapshot#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see VolumeSnapshot#getDescription()
+ */
+ public T description(String description) {
+ this.description = description;
+ return self();
+ }
+
+ public VolumeSnapshot build() {
+ return new VolumeSnapshot(id, volumeId, status, size, created, name, description);
+ }
+
+ public T fromVolumeSnapshot(VolumeSnapshot in) {
+ return this
+ .id(in.getId())
+ .volumeId(in.getVolumeId())
+ .status(in.getStatus())
+ .size(in.getSize())
+ .created(in.getCreated())
+ .name(in.getName())
+ .description(in.getDescription());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String id;
+ private final String volumeId;
+ private final Volume.Status status;
+ private final int size;
+ @Named("createdAt")
+ private final Date created;
+ @Named("displayName")
+ private final String name;
+ @Named("displayDescription")
+ private final String description;
+
+ @ConstructorProperties({
+ "id", "volumeId", "status", "size", "createdAt", "displayName", "displayDescription"
+ })
+ protected VolumeSnapshot(String id, String volumeId, Volume.Status status, int size, @Nullable Date created, @Nullable String name, @Nullable String description) {
+ this.id = checkNotNull(id, "id");
+ this.volumeId = checkNotNull(volumeId, "volumeId");
+ this.status = checkNotNull(status, "status");
+ this.size = size;
+ this.created = created;
+ this.name = name;
+ this.description = description;
+ }
+
+ /**
+ * @return the id of this snapshot
+ */
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * @return the id of the Volume this snapshot was taken from
+ */
+ public String getVolumeId() {
+ return this.volumeId;
+ }
+
+ /**
+ * @return the status of this snapshot
+ */
+ public Volume.Status getStatus() {
+ return this.status;
+ }
+
+ /**
+ * @return the size in GB of the volume this snapshot was taken from
+ */
+ public int getSize() {
+ return this.size;
+ }
+
+ /**
+ * @return the data the snapshot was taken
+ */
+ @Nullable
+ public Date getCreated() {
+ return this.created;
+ }
+
+ /**
+ * @return the name of this snapshot - as displayed in the openstack console
+ */
+ @Nullable
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * @return the description of this snapshot - as displayed in the openstack console
+ */
+ @Nullable
+ public String getDescription() {
+ return this.description;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, volumeId, status, size, created, name, description);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ VolumeSnapshot that = VolumeSnapshot.class.cast(obj);
+ return Objects.equal(this.id, that.id)
+ && Objects.equal(this.volumeId, that.volumeId)
+ && Objects.equal(this.status, that.status)
+ && Objects.equal(this.size, that.size)
+ && Objects.equal(this.created, that.created)
+ && Objects.equal(this.name, that.name)
+ && Objects.equal(this.description, that.description);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("id", id).add("volumeId", volumeId).add("status", status).add("size", size).add("created", created).add("name", name).add("description", description);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeType.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeType.java
new file mode 100644
index 0000000..43a0aba
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeType.java
@@ -0,0 +1,192 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.util.Date;
+import java.util.Map;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Volume Type used in the Volume Type Extension for Nova
+ *
+ * @see org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeApi
+*/
+public class VolumeType {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromVolumeType(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String id;
+ protected String name;
+ protected Date created;
+ protected Date updated;
+ protected Map<String, String> extraSpecs = ImmutableMap.of();
+
+ /**
+ * @see VolumeType#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see VolumeType#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see VolumeType#getCreated()
+ */
+ public T created(Date created) {
+ this.created = created;
+ return self();
+ }
+
+ /**
+ * @see VolumeType#getUpdated()
+ */
+ public T updated(Date updated) {
+ this.updated = updated;
+ return self();
+ }
+
+ /**
+ * @see VolumeType#getExtraSpecs()
+ */
+ public T extraSpecs(Map<String, String> extraSpecs) {
+ this.extraSpecs = ImmutableMap.copyOf(checkNotNull(extraSpecs, "extraSpecs"));
+ return self();
+ }
+
+ public VolumeType build() {
+ return new VolumeType(id, name, created, updated, extraSpecs);
+ }
+
+ public T fromVolumeType(VolumeType in) {
+ return this
+ .id(in.getId())
+ .name(in.getName())
+ .created(in.getCreated())
+ .updated(in.getUpdated().orNull())
+ .extraSpecs(in.getExtraSpecs());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String id;
+ private final String name;
+ @Named("created_at")
+ private final Date created;
+ @Named("updated_at")
+ private final Optional<Date> updated;
+ @Named("extra_specs")
+ private final Map<String, String> extraSpecs;
+
+ @ConstructorProperties({
+ "id", "name", "created_at", "updated_at", "extra_specs"
+ })
+ protected VolumeType(String id, String name, Date created, @Nullable Date updated, Map<String, String> extraSpecs) {
+ this.id = checkNotNull(id, "id");
+ this.name = checkNotNull(name, "name");
+ this.created = checkNotNull(created, "created");
+ this.updated = Optional.fromNullable(updated);
+ this.extraSpecs = ImmutableMap.copyOf(checkNotNull(extraSpecs, "extraSpecs"));
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * The Date the VolumeType was created
+ */
+ public Date getCreated() {
+ return this.created;
+ }
+
+ /**
+ * The Date the VolumeType as last updated - absent if no updates have taken place
+ */
+ public Optional<Date> getUpdated() {
+ return this.updated;
+ }
+
+ public Map<String, String> getExtraSpecs() {
+ return this.extraSpecs;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, name, created, updated, extraSpecs);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ VolumeType that = VolumeType.class.cast(obj);
+ return Objects.equal(this.id, that.id)
+ && Objects.equal(this.name, that.name)
+ && Objects.equal(this.created, that.created)
+ && Objects.equal(this.updated, that.updated)
+ && Objects.equal(this.extraSpecs, that.extraSpecs);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("id", id).add("name", name).add("created", created).add("updated", updated).add("extraSpecs", extraSpecs);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java
new file mode 100644
index 0000000..6946961
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.domain.zonescoped;
+
+import com.google.common.base.Objects;
+import com.google.gson.annotations.SerializedName;
+
+import java.beans.ConstructorProperties;
+
+/**
+ * @author Inbar Stolberg
+ */
+public class AvailabilityZone {
+
+ @SerializedName("zoneName")
+ private final String name;
+ private final ZoneState state;
+
+ @ConstructorProperties({"zoneName" , "zoneState"})
+ protected AvailabilityZone(String name, ZoneState state) {
+ this.name = name;
+ this.state = state;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public ZoneState getState() {
+ return state;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, state);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this != obj) return false;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ AvailabilityZone that = AvailabilityZone.class.cast(obj);
+ return Objects.equal(this.name, that.name) && Objects.equal(this.state, that.state);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("name", name)
+ .add("state", state);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java
new file mode 100644
index 0000000..5836ac2
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java
@@ -0,0 +1,46 @@
+/*
+ * 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.domain.zonescoped;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+
+/**
+ * @author Adrian Cole
+ */
+public class FlavorInZone extends ZoneAndId {
+ protected final Flavor image;
+
+ public FlavorInZone(Flavor image, String zoneId) {
+ super(zoneId, checkNotNull(image, "image").getId());
+ this.image = image;
+ }
+
+ public Flavor getFlavor() {
+ return image;
+ }
+
+ // superclass hashCode/equals are good enough, and help us use ZoneAndId and FlavorInZone
+ // interchangeably as Map keys
+
+ @Override
+ public String toString() {
+ return "[image=" + image + ", zoneId=" + zoneId + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java
new file mode 100644
index 0000000..b7d03f4
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java
@@ -0,0 +1,46 @@
+/*
+ * 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.domain.zonescoped;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+
+/**
+ * @author Adrian Cole
+ */
+public class ImageInZone extends ZoneAndId {
+ protected final Image image;
+
+ public ImageInZone(Image image, String zoneId) {
+ super(zoneId, checkNotNull(image, "image").getId());
+ this.image = image;
+ }
+
+ public Image getImage() {
+ return image;
+ }
+
+ // superclass hashCode/equals are good enough, and help us use ZoneAndId and ImageInZone
+ // interchangeably as Map keys
+
+ @Override
+ public String toString() {
+ return "[image=" + image + ", zoneId=" + zoneId + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java
new file mode 100644
index 0000000..28e2b0f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java
@@ -0,0 +1,46 @@
+/*
+ * 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.domain.zonescoped;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
+
+/**
+ * @author Adrian Cole
+ */
+public class SecurityGroupInZone extends ZoneAndName {
+ protected final SecurityGroup securityGroup;
+
+ public SecurityGroupInZone(SecurityGroup securityGroup, String zoneId) {
+ super(zoneId, checkNotNull(securityGroup, "securityGroup").getName());
+ this.securityGroup = securityGroup;
+ }
+
+ public SecurityGroup getSecurityGroup() {
+ return securityGroup;
+ }
+
+ // superclass hashCode/equals are good enough, and help us use ZoneAndName and ServerInZone
+ // interchangeably as Map keys
+
+ @Override
+ public String toString() {
+ return "[securityGroup=" + securityGroup + ", zoneId=" + zoneId + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java
new file mode 100644
index 0000000..2249cf7
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java
@@ -0,0 +1,46 @@
+/*
+ * 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.domain.zonescoped;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+
+/**
+ * @author Adrian Cole
+ */
+public class ServerInZone extends ZoneAndId {
+ protected final Server server;
+
+ public ServerInZone(Server server, String zoneId) {
+ super(zoneId, checkNotNull(server, "server").getId());
+ this.server = server;
+ }
+
+ public Server getServer() {
+ return server;
+ }
+
+ // superclass hashCode/equals are good enough, and help us use ZoneAndId and ServerInZone
+ // interchangeably as Map keys
+
+ @Override
+ public String toString() {
+ return "[server=" + server + ", zoneId=" + zoneId + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java
new file mode 100644
index 0000000..6c6f0c6
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java
@@ -0,0 +1,86 @@
+/*
+ * 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.domain.zonescoped;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
+
+/**
+ * @author Adam Lowe
+ */
+public class ZoneAndId {
+ public static ZoneAndId fromSlashEncoded(String id) {
+ Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id"));
+ checkArgument(Iterables.size(parts) == 2, "id must be in format zoneId/id");
+ return new ZoneAndId(Iterables.get(parts, 0), Iterables.get(parts, 1));
+ }
+
+ public static ZoneAndId fromZoneAndId(String zoneId, String id) {
+ return new ZoneAndId(zoneId, id);
+ }
+
+ private static String slashEncodeZoneAndId(String zoneId, String id) {
+ return checkNotNull(zoneId, "zoneId") + "/" + checkNotNull(id, "id");
+ }
+
+ public String slashEncode() {
+ return slashEncodeZoneAndId(zoneId, id);
+ }
+
+ protected final String zoneId;
+ protected final String id;
+
+ protected ZoneAndId(String zoneId, String id) {
+ this.zoneId = checkNotNull(zoneId, "zoneId");
+ this.id = checkNotNull(id, "id");
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(zoneId, id);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ZoneAndId other = (ZoneAndId) obj;
+ return Objects.equal(zoneId, other.zoneId) && Objects.equal(id, other.id);
+ }
+
+ public String getZone() {
+ return zoneId;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public String toString() {
+ return "[zoneId=" + zoneId + ", id=" + id + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java
new file mode 100644
index 0000000..fdb49e1
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java
@@ -0,0 +1,111 @@
+/*
+ * 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.domain.zonescoped;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.base.Splitter;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.Iterables;
+
+/**
+ * Helpful when looking for resources by zone and name
+ *
+ * @author Adrian Cole
+ */
+public class ZoneAndName {
+
+ public static final Function<ZoneAndName, String> NAME_FUNCTION = new Function<ZoneAndName, String>() {
+
+ @Override
+ public String apply(ZoneAndName input) {
+ return input.getName();
+ }
+
+ };
+
+ public static final Function<ZoneAndName, String> ZONE_FUNCTION = new Function<ZoneAndName, String>() {
+
+ @Override
+ public String apply(ZoneAndName input) {
+ return input.getZone();
+ }
+
+ };
+
+ public static ZoneAndName fromSlashEncoded(String name) {
+ Iterable<String> parts = Splitter.on('/').split(checkNotNull(name, "name"));
+ checkArgument(Iterables.size(parts) == 2, "name must be in format zoneId/name");
+ return new ZoneAndName(Iterables.get(parts, 0), Iterables.get(parts, 1));
+ }
+
+ public static ZoneAndName fromZoneAndName(String zoneId, String name) {
+ return new ZoneAndName(zoneId, name);
+ }
+
+ private static String slashEncodeZoneAndName(String zoneId, String name) {
+ return checkNotNull(zoneId, "zoneId") + "/" + checkNotNull(name, "name");
+ }
+
+ public String slashEncode() {
+ return slashEncodeZoneAndName(zoneId, name);
+ }
+
+ protected final String zoneId;
+ protected final String name;
+
+ protected ZoneAndName(String zoneId, String name) {
+ this.zoneId = checkNotNull(zoneId, "zoneId");
+ this.name = checkNotNull(name, "name");
+ }
+
+ public String getZone() {
+ return zoneId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ ZoneAndName that = ZoneAndName.class.cast(o);
+ return equal(this.zoneId, that.zoneId) && equal(this.name, that.name);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(zoneId, name);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper("").add("zoneId", zoneId).add("name", name);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java
new file mode 100644
index 0000000..4182d91
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java
@@ -0,0 +1,62 @@
+/*
+ * 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.domain.zonescoped;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Set;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Adrian Cole
+ */
+public class ZoneSecurityGroupNameAndPorts extends ZoneAndName {
+ protected final Set<Integer> ports;
+
+ public ZoneSecurityGroupNameAndPorts(String zoneId, String name, Iterable<Integer> ports) {
+ super(zoneId, name);
+ this.ports = ImmutableSet.<Integer> copyOf(checkNotNull(ports, "ports"));
+ }
+
+ public Set<Integer> getPorts() {
+ return ports;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ ZoneSecurityGroupNameAndPorts that = ZoneSecurityGroupNameAndPorts.class.cast(o);
+ return super.equals(that) && equal(this.ports, that.ports);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), ports);
+ }
+
+ @Override
+ public ToStringHelper string() {
+ return super.string().add("ports", ports);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java
new file mode 100644
index 0000000..c786095
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java
@@ -0,0 +1,61 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.domain.zonescoped;
+
+import com.google.common.base.Objects;
+
+/**
+ * @author Inbar Stolberg
+ */
+public class ZoneState {
+
+ private final boolean available;
+
+ protected ZoneState(boolean available) {
+ this.available = available;
+ }
+
+ public boolean available() {
+ return this.available;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(available);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this != obj) return false;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ ZoneState that = ZoneState.class.cast(obj);
+ return Objects.equal(this.available, that.available);
+ }
+
+ protected Objects.ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("available", available);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAPI.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAPI.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAPI.java
new file mode 100644
index 0000000..d248681
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAPI.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.extensions;
+
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+/**
+ * @author Inbar Stolberg
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.ADMIN_ACTIONS)
+public interface AvailabilityZoneAPI {
+
+ /**
+ * @return all availability zones
+ */
+ FluentIterable<? extends AvailabilityZone> list();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAsyncApi.java
new file mode 100644
index 0000000..d85f305
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAsyncApi.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to jclouds, Inc. (jclouds) under one or more
+ * contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. jclouds 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.extensions;
+
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+import com.google.common.util.concurrent.ListenableFuture;
+import org.jclouds.Fallbacks;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * @author Inbar Stolberg
+ */
+
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.ADMIN_ACTIONS)
+@RequestFilters(AuthenticateRequest.class)
+public interface AvailabilityZoneAsyncApi {
+
+ /**
+ * @return all availability zones
+ */
+ @GET
+ @Path("/os-availability-zone")
+ @SelectJson("availabilityZoneInfo")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends AvailabilityZone>> list();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java
new file mode 100644
index 0000000..a249190
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java
@@ -0,0 +1,110 @@
+/*
+ * 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.extensions;
+
+/**
+ * Extension namespaces
+ *
+ * @author Adrian Cole
+ * @see <a href= "http://nova.openstack.org/api_ext/" />
+ */
+public interface ExtensionNamespaces {
+ /**
+ * Keypair Support
+ */
+ public static final String KEYPAIRS = "http://docs.openstack.org/ext/keypairs/api/v1.1";
+ /**
+ * Volumes support
+ */
+ public static final String VOLUMES = "http://docs.openstack.org/ext/volumes/api/v1.1";
+ /**
+ * Volume types support
+ */
+ public static final String VOLUME_TYPES = "http://docs.openstack.org/ext/volume_types/api/v1.1";
+ /**
+ * Security group support
+ */
+ public static final String SECURITY_GROUPS = "http://docs.openstack.org/ext/securitygroups/api/v1.1";
+ /**
+ * Floating IPs support
+ */
+ public static final String FLOATING_IPS = "http://docs.openstack.org/ext/floating_ips/api/v1.1";
+ /**
+ * Multiple network support
+ */
+ public static final String MULTINIC = "http://docs.openstack.org/ext/multinic/api/v1.1";
+ /**
+ * Host administration
+ */
+ public static final String HOSTS = "http://docs.openstack.org/ext/hosts/api/v1.1";
+ /**
+ * Quotas management support
+ */
+ public static final String QUOTAS = "http://docs.openstack.org/ext/quotas-sets/api/v1.1";
+ /**
+ * Instance type (flavor) extra specs
+ */
+ public static final String FLAVOR_EXTRA_SPECS = "http://docs.openstack.org/ext/flavor_extra_specs/api/v1.1";
+ /**
+ * Provide additional data for flavors
+ */
+ public static final String FLAVOR_EXTRA_DATA = "http://docs.openstack.org/ext/flavor_extra_data/api/v1.1";
+ /**
+ * Virtual interface support
+ */
+ public static final String VIRTUAL_INTERFACES = "http://docs.openstack.org/ext/virtual_interfaces/api/v1.1";
+ /**
+ * Extended support to the Create Server v1.1 API
+ */
+ public static final String CREATESERVEREXT = "http://docs.openstack.org/ext/createserverext/api/v1.1";
+ /**
+ * Virtual Storage Arrays support
+ */
+ public static final String VSA = "http://docs.openstack.org/ext/vsa/api/v1.1";
+ /**
+ * Simple tenant usage extension
+ */
+ public static final String SIMPLE_TENANT_USAGE = "http://docs.openstack.org/ext/os-simple-tenant-usage/api/v1.1";
+ /**
+ * Instance rescue mode
+ */
+ public static final String RESCUE = "http://docs.openstack.org/ext/rescue/api/v1.1";
+ /**
+ * Admin Action extension
+ */
+ public static final String ADMIN_ACTIONS = "http://docs.openstack.org/ext/admin-actions/api/v1.1";
+
+ /**
+ * Extended Server Status extension
+ */
+ public static final String EXTENDED_STATUS = "http://docs.openstack.org/compute/ext/extended_status/api/v1.1";
+
+ /**
+ * Quota Classes extension
+ */
+ public static final String QUOTA_CLASSES = "http://docs.openstack.org/ext/quota-classes-sets/api/v1.1";
+
+ /**
+ * Disk Config extension
+ */
+ public static final String DISK_CONFIG = "http://docs.openstack.org/compute/ext/disk_config/api/v1.1";
+
+ /**
+ * Aggregates extension
+ */
+ public static final String AGGREGATES = "http://docs.openstack.org/ext/aggregates/api/v1.1";
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java
new file mode 100644
index 0000000..946463c
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java
@@ -0,0 +1,77 @@
+/*
+ * 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.extensions;
+
+import java.util.Map;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Provide access to extra metadata for Nova flavors.
+ *
+ * @author Adam Lowe
+ * @see <a href="http://nova.openstack.org/api/nova.api.openstack.compute.contrib.flavorextraspecs.html"/>
+ * @see org.jclouds.openstack.nova.v2_0.features.FlavorApi
+ * @see org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsAsyncApi
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.FLAVOR_EXTRA_SPECS)
+public interface FlavorExtraSpecsApi {
+
+ /**
+ * Retrieve all extra specs for a flavor
+ *
+ * @return the set of extra metadata for the flavor
+ */
+ Map<String, String> getMetadata(String flavorId);
+
+ /**
+ * Creates or updates the extra specs for a given flavor
+ *
+ * @param flavorId the id of the flavor to modify
+ * @param specs the extra specs to apply
+ */
+ Boolean updateMetadata(String flavorId, Map<String, String> specs);
+
+ /**
+ * Return a single extra spec value
+ *
+ * @param flavorId the id of the flavor to modify
+ * @param key the extra spec key to retrieve
+ */
+ String getMetadataKey(String flavorId, String key);
+
+ /**
+ * Creates or updates a single extra spec value
+ *
+ * @param flavorId the id of the flavor to modify
+ * @param key the extra spec key (when creating ensure this does not include whitespace or other difficult characters)
+ * @param value the value to associate with the key
+ */
+ Boolean updateMetadataEntry(String flavorId, String key, String value);
+
+ /**
+ * Deletes an extra spec
+ *
+ * @param flavorId the id of the flavor to modify
+ * @param key the extra spec key to delete
+ */
+ Boolean deleteMetadataKey(String flavorId, String key);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsAsyncApi.java
new file mode 100644
index 0000000..f788e6e
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsAsyncApi.java
@@ -0,0 +1,118 @@
+/*
+ * 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.extensions;
+
+import java.util.Map;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404;
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.Payload;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Unwrap;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.annotations.Beta;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provide access to extra metadata for Nova flavors.
+ *
+ * @author Adam Lowe
+ * @see <a href="http://nova.openstack.org/api/nova.api.openstack.compute.contrib.flavorextraspecs.html"/>
+ * @see org.jclouds.openstack.nova.v2_0.features.FlavorApi
+ * @see FlavorExtraSpecsApi
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.FLAVOR_EXTRA_SPECS)
+@RequestFilters(AuthenticateRequest.class)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface FlavorExtraSpecsAsyncApi {
+
+ /**
+ * @see FlavorExtraSpecsApi#getMetadata(String)
+ */
+ @Named("flavor:getmetadata")
+ @GET
+ @SelectJson("extra_specs")
+ @Path("/flavors/{flavor_id}/os-extra_specs")
+ @Fallback(EmptyMapOnNotFoundOr404.class)
+ ListenableFuture<Map<String, String>> getMetadata(@PathParam("flavor_id") String flavorId);
+
+ /**
+ * @see FlavorExtraSpecsApi#updateMetadataEntry(String, String, String)
+ */
+ @Named("flavor:updatemetadata")
+ @POST
+ @Path("/flavors/{flavor_id}/os-extra_specs")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(FalseOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ ListenableFuture<Boolean> updateMetadata(@PathParam("flavor_id") String flavorId, @PayloadParam("extra_specs") Map<String, String> specs);
+
+ /**
+ * @see FlavorExtraSpecsApi#getMetadataKey(String, String)
+ */
+ @Named("flavor:getmetadata")
+ @GET
+ @Path("/flavors/{flavor_id}/os-extra_specs/{key}")
+ @Unwrap
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<String> getMetadataKey(@PathParam("flavor_id") String flavorId, @PathParam("key") String key);
+
+ /**
+ * @see FlavorExtraSpecsApi#updateMetadataEntry(String, String, String)
+ */
+ @Named("flavor:updatemetadata")
+ @PUT
+ @Path("/flavors/{flavor_id}/os-extra_specs/{key}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(FalseOnNotFoundOr404.class)
+ @Payload("%7B\"{key}\":\"{value}\"%7D")
+ ListenableFuture<Boolean> updateMetadataEntry(@PathParam("flavor_id") String flavorId,
+ @PathParam("key") @PayloadParam("key") String key,
+ @PayloadParam("value") String value);
+
+ /**
+ * @see FlavorExtraSpecsApi#deleteMetadataKey(String, String)
+ */
+ @Named("flavor:deletemetadata")
+ @DELETE
+ @Path("/flavors/{flavor_id}/os-extra_specs/{key}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> deleteMetadataKey(@PathParam("flavor_id") String flavorId,
+ @PathParam("key") String key);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java
new file mode 100644
index 0000000..ddf720f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java
@@ -0,0 +1,98 @@
+/*
+ * 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.extensions;
+
+import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+
+/**
+ * Provides synchronous access to Floating IPs.
+ * <p/>
+ *
+ * @see FloatingIPAsyncApi
+ * @author Jeremy Daggett
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.FLOATING_IPS)
+public interface FloatingIPApi {
+
+ /**
+ * List all Floating IP addresses
+ *
+ * @return all Floating IPs
+ */
+ FluentIterable<? extends FloatingIP> list();
+
+ /**
+ * Get a specific Floating IP address
+ *
+ * @return all Floating IPs
+ */
+ FloatingIP get(String id);
+
+ /**
+ * Allocate a Floating IP address
+ *
+ * @return a newly created FloatingIP
+ */
+ FloatingIP create();
+
+ /**
+ * Allocate a Floating IP address from a pool
+ *
+ * @param pool
+ * Pool to allocate IP address from
+ * @return a newly created FloatingIP
+ */
+ FloatingIP allocateFromPool(String pool);
+
+ /**
+ * Decreate a Floating IP address
+ *
+ * @param id
+ * the Floating IP id
+ */
+ void delete(String id);
+
+ /**
+ * Add a Floating IP address to a Server
+ *
+ * @param serverId
+ * the serverId
+ * @param address
+ * the IP address to add
+ *
+ * NOTE: Possibly move this to ServerApi?
+ */
+ void addToServer(String address, String serverId);
+
+ /**
+ * Remove a Floating IP address from a Server
+ *
+ * @param serverId
+ * the serverId
+ * @param address
+ * the IP address to remove
+ *
+ * NOTE: Possibly move this to ServerApi?
+ */
+ void removeFromServer(String address, String serverId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPAsyncApi.java
new file mode 100644
index 0000000..f6cc543
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPAsyncApi.java
@@ -0,0 +1,145 @@
+/*
+ * 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.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.Payload;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to Floating IPs via the REST API.
+ * <p/>
+ *
+ * @see FloatingIPApi
+ * @author Jeremy Daggett
+ * @see ExtensionAsyncApi
+ * @see <a href= "http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
+ * />
+ * @see <a href="http://nova.openstack.org/api_ext" />
+ * @see <a href="http://wiki.openstack.org/os_api_floating_ip"/>
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.FLOATING_IPS)
+@RequestFilters(AuthenticateRequest.class)
+public interface FloatingIPAsyncApi {
+
+ /**
+ * @see FloatingIPApi#list
+ */
+ @Named("floatingip:list")
+ @GET
+ @Path("/os-floating-ips")
+ @SelectJson("floating_ips")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends FloatingIP>> list();
+
+ /**
+ * @see FloatingIPApi#get
+ */
+ @Named("floatingip:get")
+ @GET
+ @Path("/os-floating-ips/{id}")
+ @SelectJson("floating_ip")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends FloatingIP> get(@PathParam("id") String id);
+
+ /**
+ * @see FloatingIPApi#create
+ */
+ @Named("floatingip:create")
+ @POST
+ @Path("/os-floating-ips")
+ @SelectJson("floating_ip")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Payload("{}")
+ ListenableFuture<? extends FloatingIP> create();
+
+ /**
+ * @see org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi#allocateFromPool
+ */
+ @Named("floatingip:create")
+ @POST
+ @Path("/os-floating-ips")
+ @SelectJson("floating_ip")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Payload("%7B\"pool\":\"{pool}\"%7D")
+ ListenableFuture<? extends FloatingIP> allocateFromPool(@PayloadParam("pool") String pool);
+
+
+ /**
+ * @see FloatingIPApi#delete
+ */
+ @Named("floatingip:delete")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Path("/os-floating-ips/{id}")
+ ListenableFuture<Void> delete(@PathParam("id") String id);
+
+ /**
+ * @see FloatingIPApi#addToServer
+ */
+ @Named("floatingip:add")
+ @POST
+ @Path("/servers/{server}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"addFloatingIp\":%7B\"address\":\"{address}\"%7D%7D")
+ ListenableFuture<Void> addToServer(@PayloadParam("address") String address,
+ @PathParam("server") String serverId);
+
+ /**
+ * @see FloatingIPApi#removeFromServer
+ */
+ @Named("floatingip:remove")
+ @POST
+ @Path("/servers/{server}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"removeFloatingIp\":%7B\"address\":\"{address}\"%7D%7D")
+ ListenableFuture<Void> removeFromServer(@PayloadParam("address") String address,
+ @PathParam("server") String serverId);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java
new file mode 100644
index 0000000..95b8f42
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java
@@ -0,0 +1,103 @@
+/*
+ * 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.extensions;
+
+import org.jclouds.openstack.nova.v2_0.domain.Host;
+import org.jclouds.openstack.nova.v2_0.domain.HostResourceUsage;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+
+/**
+ * Provides asynchronous access to Host Administration features via the REST API.
+ * <p/>
+ *
+ * @author Adam Lowe
+ * @see HostAdministrationAsyncApi
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.HOSTS)
+public interface HostAdministrationApi {
+
+ /**
+ * Returns the list of hosts
+ *
+ * @return the usage information
+ */
+ FluentIterable<? extends Host> list();
+
+ /**
+ * Retrieves the physical/usage resource on a specific host
+ *
+ * @return the usage information
+ */
+ FluentIterable<? extends HostResourceUsage> listResourceUsage(String hostId);
+
+ /**
+ * Allow the specified host to accept new instances.
+ *
+ * @return true if successful
+ */
+ boolean enable(String hostId);
+
+ /**
+ * Prevent the specified host from accepting new instances.
+ *
+ * @return true if successful
+ */
+ boolean disable(String hostId);
+
+ /**
+ * Start host maintenance window.
+ * <p/>
+ * Note: this triggers guest VMs evacuation.
+ *
+ * @return true if successful
+ */
+ boolean startMaintenance(String hostId);
+
+ /**
+ * Stop host maintenance window.
+ *
+ * @return true if successful
+ */
+ boolean stopMaintenance(String hostId);
+
+ /**
+ * Startup a host.
+ *
+ * @return true if successful
+ */
+ boolean startup(String hostId);
+
+ /**
+ * Shutdown a host.
+ *
+ * @return true if successful
+ */
+ boolean shutdown(String hostId);
+
+ /**
+ * Reboot a host.
+ *
+ * @return true if successful
+ */
+ boolean reboot(String hostId);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationAsyncApi.java
new file mode 100644
index 0000000..cf066c2
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationAsyncApi.java
@@ -0,0 +1,157 @@
+/*
+ * 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.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.domain.Host;
+import org.jclouds.openstack.nova.v2_0.domain.HostResourceUsage;
+import org.jclouds.openstack.nova.v2_0.functions.FieldValueResponseParsers.MaintenanceModeDisabledResponseParser;
+import org.jclouds.openstack.nova.v2_0.functions.FieldValueResponseParsers.MaintenanceModeEnabledResponseParser;
+import org.jclouds.openstack.nova.v2_0.functions.FieldValueResponseParsers.PowerIsRebootResponseParser;
+import org.jclouds.openstack.nova.v2_0.functions.FieldValueResponseParsers.PowerIsShutdownResponseParser;
+import org.jclouds.openstack.nova.v2_0.functions.FieldValueResponseParsers.PowerIsStartupResponseParser;
+import org.jclouds.openstack.nova.v2_0.functions.FieldValueResponseParsers.StatusDisabledResponseParser;
+import org.jclouds.openstack.nova.v2_0.functions.FieldValueResponseParsers.StatusEnabledResponseParser;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.Payload;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to Host Administration features via the REST API.
+ * <p/>
+ *
+ * @author Adam Lowe
+ * @see HostAdministrationApi
+ * @see <a href= "http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"/>
+ * @see <a href="http://nova.openstack.org/api_ext" />
+ * @see <a href="http://nova.openstack.org/api/nova.api.openstack.compute.contrib.hosts.html" />
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.HOSTS)
+@RequestFilters(AuthenticateRequest.class)
+@Path("/os-hosts")
+@Consumes(MediaType.APPLICATION_JSON)
+public interface HostAdministrationAsyncApi {
+
+ /**
+ * @see HostAdministrationApi#list()
+ */
+ @Named("hostadmin:list")
+ @GET
+ @SelectJson("hosts")
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends Host>> list();
+
+ /**
+ * @see HostAdministrationApi#listResourceUsage(String)
+ */
+ @Named("hostadmin:listresource")
+ @GET
+ @Path("/{id}")
+ @SelectJson("host")
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends HostResourceUsage>> listResourceUsage(@PathParam("id") String hostId);
+
+ /**
+ * @see HostAdministrationApi#enable(String)
+ */
+ @Named("hostadmin:enable")
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{id}")
+ @Payload("{\"status\":\"enable\"}")
+ @ResponseParser(StatusEnabledResponseParser.class)
+ ListenableFuture<Boolean> enable(@PathParam("id") String hostId);
+
+ /**
+ * @see HostAdministrationApi#disable(String)
+ */
+ @Named("hostadmin:disable")
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{id}")
+ @Payload("{\"status\":\"disable\"}")
+ @ResponseParser(StatusDisabledResponseParser.class)
+ ListenableFuture<Boolean> disable(@PathParam("id") String hostId);
+
+ /**
+ * @see HostAdministrationApi#startMaintenance(String)
+ */
+ @Named("hostadmin:startmaintenance")
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{id}")
+ @Payload("{\"maintenance_mode\":\"enable\"}")
+ @ResponseParser(MaintenanceModeEnabledResponseParser.class)
+ ListenableFuture<Boolean> startMaintenance(@PathParam("id") String hostId);
+
+ /**
+ * @see HostAdministrationApi#stopMaintenance(String)
+ */
+ @Named("hostadmin:stopmaintenance")
+ @PUT
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/{id}")
+ @Payload("{\"maintenance_mode\":\"disable\"}")
+ @ResponseParser(MaintenanceModeDisabledResponseParser.class)
+ ListenableFuture<Boolean> stopMaintenance(@PathParam("id") String hostId);
+
+ /**
+ * @see HostAdministrationApi#startup(String)
+ */
+ @Named("hostadmin:startup")
+ @GET
+ @Path("/{id}/startup")
+ @ResponseParser(PowerIsStartupResponseParser.class)
+ ListenableFuture<Boolean> startup(@PathParam("id") String hostId);
+
+ /**
+ * @see HostAdministrationApi#shutdown(String)
+ */
+ @Named("hostadmin:shutdown")
+ @GET
+ @Path("/{id}/shutdown")
+ @ResponseParser(PowerIsShutdownResponseParser.class)
+ ListenableFuture<Boolean> shutdown(@PathParam("id") String hostId);
+
+ /**
+ * @see HostAdministrationApi#reboot(String)
+ */
+ @Named("hostadmin:reboot")
+ @GET
+ @Path("/{id}/reboot")
+ @ResponseParser(PowerIsRebootResponseParser.class)
+ ListenableFuture<Boolean> reboot(@PathParam("id") String hostId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java
new file mode 100644
index 0000000..a6461aa
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java
@@ -0,0 +1,87 @@
+/*
+ * 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.extensions;
+
+import java.util.Map;
+import org.jclouds.openstack.nova.v2_0.domain.HostAggregate;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+
+/**
+ * Provide access to Host Aggregates in Nova (alias "OS-AGGREGATES")
+ *
+ * @author Adam Lowe
+ * @see HostAggregateAsyncApi
+ * @see <a href="http://nova.openstack.org/api_ext/ext_aggregates.html"/>
+ * @see <a href="http://wiki.openstack.org/host-aggregates"/>
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.AGGREGATES)
+public interface HostAggregateApi {
+
+ /**
+ * @return the set of host aggregates.
+ */
+ FluentIterable<? extends HostAggregate> list();
+
+ /**
+ * Retrieves the details of an aggregate, hosts and metadata included.
+ *
+ * @return the details of the aggregate requested.
+ */
+ HostAggregate get(String id);
+
+ /**
+ * Creates an aggregate, given its name and availability zone.
+ *
+ * @return the newly created Aggregate
+ */
+ HostAggregate createInAvailabilityZone(String name, String availabilityZone);
+
+ /**
+ * Updates the name of an aggregate.
+ */
+ HostAggregate updateName(String id, String name);
+
+ /**
+ * Updates the availability zone an aggregate.
+ */
+ HostAggregate updateAvailabilityZone(String id, String availabilityZone);
+
+ /**
+ * Removes an aggregate.
+ */
+ Boolean delete(String id);
+
+ /**
+ * Adds a host to an aggregate
+ */
+ HostAggregate addHost(String id, String host);
+
+ /**
+ * Removes a host from an aggregate
+ */
+ HostAggregate removeHost(String id, String host);
+
+ /**
+ * Adds metadata to an aggregate
+ */
+ HostAggregate setMetadata(String id, Map<String, String> metadata);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateAsyncApi.java
new file mode 100644
index 0000000..1ee3dc7
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateAsyncApi.java
@@ -0,0 +1,161 @@
+/*
+ * 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.extensions;
+
+import java.util.Map;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.domain.HostAggregate;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.WrapWith;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provide access to Aggregates in Nova.
+ *
+ * @author Adam Lowe
+ * @see HostAggregateApi
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.AGGREGATES)
+@RequestFilters(AuthenticateRequest.class)
+@Path("/os-aggregates")
+public interface HostAggregateAsyncApi {
+
+ /**
+ * @see HostAggregateApi#list()
+ */
+ @Named("hostaggregate:list")
+ @GET
+ @SelectJson("aggregates")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends HostAggregate>> list();
+
+ /**
+ * @see HostAggregateApi#get(String)
+ */
+ @Named("hostaggregate:get")
+ @GET
+ @Path("/{id}")
+ @SelectJson("aggregate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends HostAggregate> get(@PathParam("id") String id);
+
+ /**
+ * @see HostAggregateApi#createInAvailabilityZone(String, String)
+ */
+ @Named("hostaggregate:create")
+ @POST
+ @SelectJson("aggregate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @WrapWith("aggregate")
+ ListenableFuture<? extends HostAggregate> createInAvailabilityZone(@PayloadParam("name") String name,
+ @PayloadParam("availability_zone") String availabilityZone);
+
+ /**
+ * @see HostAggregateApi#updateName
+ */
+ @Named("hostaggregate:update")
+ @POST
+ @Path("/{id}")
+ @SelectJson("aggregate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @WrapWith("aggregate")
+ ListenableFuture<? extends HostAggregate> updateName(@PathParam("id") String id, @PayloadParam("name") String name);
+
+ /**
+ * @see HostAggregateApi#updateAvailabilityZone
+ */
+ @Named("hostaggregate:update")
+ @POST
+ @Path("/{id}")
+ @SelectJson("aggregate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @WrapWith("aggregate")
+ ListenableFuture<? extends HostAggregate> updateAvailabilityZone(@PathParam("id") String id, @PayloadParam("availability_zone") String availabilityZone);
+
+ /**
+ * @see HostAggregateApi#delete(String)
+ */
+ @Named("hostaggregate:delete")
+ @DELETE
+ @Path("/{id}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> delete(@PathParam("id") String id);
+
+ /**
+ * @see HostAggregateApi#addHost(String,String)
+ */
+ @Named("hostaggregate:addhost")
+ @POST
+ @Path("/{id}/action")
+ @SelectJson("aggregate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @WrapWith("add_host")
+ ListenableFuture<? extends HostAggregate> addHost(@PathParam("id") String id, @PayloadParam("host") String host);
+
+
+ /**
+ * @see HostAggregateApi#removeHost(String,String)
+ */
+ @Named("hostaggregate:removehost")
+ @POST
+ @Path("/{id}/action")
+ @SelectJson("aggregate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @WrapWith("remove_host")
+ ListenableFuture<? extends HostAggregate> removeHost(@PathParam("id") String id, @PayloadParam("host") String host);
+
+ /**
+ * @see HostAggregateApi#setMetadata
+ */
+ @Named("hostaggregate:setmetadata")
+ @POST
+ @Path("/{id}/action")
+ @SelectJson("aggregate")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @WrapWith("set_metadata")
+ ListenableFuture<? extends HostAggregate> setMetadata(@PathParam("id") String id, @PayloadParam("metadata") Map<String, String> metadata);
+}
[02/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail_openstack.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail_openstack.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail_openstack.json
new file mode 100644
index 0000000..4725d8b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail_openstack.json
@@ -0,0 +1,83 @@
+{
+ "flavors": [{
+ "rxtx_quota": 0,
+ "name": "m1.medium",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/flavors/3",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/flavors/3",
+ "rel": "bookmark"
+ }],
+ "ram": 4096,
+ "vcpus": 2,
+ "rxtx_cap": 0,
+ "swap": 0,
+ "disk": 40,
+ "id": 3
+ }, {
+ "rxtx_quota": 0,
+ "name": "m1.large",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/flavors/4",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/flavors/4",
+ "rel": "bookmark"
+ }],
+ "ram": 8192,
+ "vcpus": 4,
+ "rxtx_cap": 0,
+ "swap": 0,
+ "disk": 80,
+ "id": 4
+ }, {
+ "rxtx_quota": 0,
+ "name": "m1.tiny",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/flavors/1",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/flavors/1",
+ "rel": "bookmark"
+ }],
+ "ram": 512,
+ "vcpus": 1,
+ "rxtx_cap": 0,
+ "swap": 0,
+ "disk": 0,
+ "id": 1
+ }, {
+ "rxtx_quota": 0,
+ "name": "m1.xlarge",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/flavors/5",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/flavors/5",
+ "rel": "bookmark"
+ }],
+ "ram": 16384,
+ "vcpus": 8,
+ "rxtx_cap": 0,
+ "swap": 0,
+ "disk": 160,
+ "id": 5
+ }, {
+ "rxtx_quota": 0,
+ "name": "m1.small",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/flavors/2",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/flavors/2",
+ "rel": "bookmark"
+ }],
+ "ram": 2048,
+ "vcpus": 1,
+ "rxtx_cap": 0,
+ "swap": 0,
+ "disk": 20,
+ "id": 2
+ }]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_new.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_new.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_new.json
new file mode 100644
index 0000000..5356f8c
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/flavor_new.json
@@ -0,0 +1,10 @@
+{
+ "flavor" : {
+ "id" : "1cb47a44-9b84-4da4-bf81-c1976e8414ab",
+ "name" : "128 MB Server",
+ "ram" : 128,
+ "disk" : 10,
+ "vcpus" : 1,
+ "links" : []
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_details.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_details.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_details.json
new file mode 100644
index 0000000..c2411fd
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_details.json
@@ -0,0 +1,9 @@
+{
+ "floating_ip" :
+ {
+ "id" : 1,
+ "ip" : "10.0.0.3",
+ "fixed_ip" : "10.0.0.2",
+ "instance_id" : 123
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_list.json
new file mode 100644
index 0000000..27d2519
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_list.json
@@ -0,0 +1,16 @@
+{
+ "floating_ips" : [
+ {
+ "instance_id": 12,
+ "ip" : "10.0.0.3",
+ "fixed_ip": "11.0.0.1",
+ "id" : 1
+ },
+ {
+ "instance_id": null,
+ "ip": "10.0.0.5",
+ "fixed_ip": null,
+ "id": 2
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host.json
new file mode 100644
index 0000000..ad2e217
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host.json
@@ -0,0 +1 @@
+{"host": [{"resource": {"project": "(total)", "memory_mb": 16083, "host": "ubuntu", "cpu": 4, "disk_gb": 181}}, {"resource": {"project": "(used_now)", "memory_mb": 3396, "host": "ubuntu", "cpu": 3, "disk_gb": 5}}, {"resource": {"project": "(used_max)", "memory_mb": 6144, "host": "ubuntu", "cpu": 3, "disk_gb": 80}}, {"resource": {"project": "f8535069c3fb404cb61c873b1a0b4921", "memory_mb": 6144, "host": "ubuntu", "cpu": 3, "disk_gb": 80}}]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_details.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_details.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_details.json
new file mode 100644
index 0000000..5e939dd
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_details.json
@@ -0,0 +1 @@
+{"aggregate": {"name": "jclouds-test-a", "availability_zone": "nova", "deleted": false, "created_at": "2012-05-11 11:40:17", "updated_at": "2012-05-11 11:46:44", "operational_state": "created", "hosts": [], "deleted_at": null, "id": 1, "metadata": {"somekey": "somevalue", "anotherkey": "another val"}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_list.json
new file mode 100644
index 0000000..92dfd38
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_list.json
@@ -0,0 +1 @@
+{"aggregates": [{"name": "jclouds-test-a", "availability_zone": "nova", "deleted": false, "created_at": "2012-05-11 11:40:17", "updated_at": "2012-05-11 11:46:44", "operational_state": "created", "hosts": [], "deleted_at": null, "id": 1, "metadata": {"somekey": "somevalue", "anotherkey": "another val"}}]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_with_host_details.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_with_host_details.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_with_host_details.json
new file mode 100644
index 0000000..2d132f4
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_with_host_details.json
@@ -0,0 +1 @@
+{"aggregate": {"name": "jclouds-test-a", "availability_zone": "nova", "deleted": false, "created_at": "2012-05-11 11:40:17", "updated_at": "2012-05-11 11:46:44", "operational_state": "created", "hosts": ["ubuntu"], "deleted_at": null, "id": 1, "metadata": {"somekey": "somevalue", "anotherkey": "another val"}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/hosts_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/hosts_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/hosts_list.json
new file mode 100644
index 0000000..30d3770
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/hosts_list.json
@@ -0,0 +1 @@
+{"hosts": [{"host_name": "ubuntu", "service": "compute"}]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_active.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_active.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_active.json
new file mode 100644
index 0000000..4b778e4
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_active.json
@@ -0,0 +1,41 @@
+{
+ "image" : {
+ "id" : "52415800-8b69-11e0-9b19-734f5736d2a2",
+ "name" : "My Server Backup",
+ "updated" : "2010-10-10T12:00:00Z",
+ "created" : "2010-08-10T12:00:00Z",
+ "tenant_id" : "12345",
+ "user_id" : "joe",
+ "status" : "ACTIVE",
+ "progress" : 80,
+ "minDisk" : 5,
+ "minRam" : 256,
+ "metadata" : {
+ "ImageType" : "Gold",
+ "ImageVersion" : "1.5"
+ },
+ "server" : {
+ "id": "52415800-8b69-11e0-9b19-734f335aa7b3",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3"
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3"
+ }
+ ]
+ },
+ "links": [
+ {
+ "rel" : "self",
+ "href" : "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2"
+ },
+ {
+ "rel" : "bookmark",
+ "href" : "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2"
+ }
+ ]
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_details.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_details.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_details.json
new file mode 100644
index 0000000..b75d94c
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_details.json
@@ -0,0 +1,41 @@
+{
+ "image" : {
+ "id" : "52415800-8b69-11e0-9b19-734f5736d2a2",
+ "name" : "My Server Backup",
+ "updated" : "2010-10-10T12:00:00Z",
+ "created" : "2010-08-10T12:00:00Z",
+ "tenant_id" : "12345",
+ "user_id" : "joe",
+ "status" : "SAVING",
+ "progress" : 80,
+ "minDisk" : 5,
+ "minRam" : 256,
+ "metadata" : {
+ "ImageType" : "Gold",
+ "ImageVersion" : "1.5"
+ },
+ "server" : {
+ "id": "52415800-8b69-11e0-9b19-734f335aa7b3",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3"
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3"
+ }
+ ]
+ },
+ "links": [
+ {
+ "rel" : "self",
+ "href" : "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2"
+ },
+ {
+ "rel" : "bookmark",
+ "href" : "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2"
+ }
+ ]
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list.json
new file mode 100644
index 0000000..afecf34
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list.json
@@ -0,0 +1,32 @@
+{
+ "images": [
+ {
+ "id": "52415800-8b69-11e0-9b19-734f6f006e54",
+ "name": "CentOS 5.2",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"
+ }
+ ]
+ },
+ {
+ "id" : "52415800-8b69-11e0-9b19-734f5736d2a2",
+ "name" : "My Server Backup",
+ "links": [
+ {
+ "rel" : "self",
+ "href" : "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2"
+ },
+ {
+ "rel" : "bookmark",
+ "href" : "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail.json
new file mode 100644
index 0000000..0b4dcc0
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail.json
@@ -0,0 +1 @@
+{"images": [{"status": "ACTIVE", "updated": "2012-03-12T07:52:30Z", "name": "Debian Squeeze 6.0.3 Server 64-bit 20120123", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1361", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1361", "rel": "bookmark"}], "created": "2012-02-21T14:13:55Z", "progress": 100, "id": "1361", "metadata": {"hp_image_type": "machine", "image_location": "local", "image_state": "available", "project_id": "None", "hp_md_version": "1", "kernel_id": "1359", "min_ram": 0, "ramdisk_id": "1360", "hp_image_id": "c89dee3bca7a62103f7d88d2a02f4dc8", "owner": null, "hp_image_builddate": "20120123", "architecture": "amd64", "min_disk": 0, "hp_image_version": "1hp1.1"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:52:17Z", "name": "Debian Squeeze 6.0.3 Server 64-bit 20120123 (Ramdisk)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3793662893
7291/images/1360", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1360", "rel": "bookmark"}], "created": "2012-02-21T14:13:53Z", "progress": 100, "id": "1360", "metadata": {"hp_image_type": "ramdisk", "image_location": "local", "image_state": "available", "project_id": "None", "hp_md_version": "1", "min_ram": 0, "hp_image_id": "c89dee3bca7a62103f7d88d2a02f4dc8", "owner": null, "hp_image_builddate": "20120123", "architecture": "amd64", "min_disk": 0, "hp_image_version": "1hp1.1"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:52:09Z", "name": "Debian Squeeze 6.0.3 Server 64-bit 20120123 (Kernel)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1359", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1359", "rel": "bookmark"}], "created": "2012-02-21T14:13:52Z", "progress": 100, "id": "1359", "metadata": {"hp_image_type": "kernel", "
image_location": "local", "image_state": "available", "project_id": "None", "hp_md_version": "1", "min_ram": 0, "hp_image_id": "c89dee3bca7a62103f7d88d2a02f4dc8", "owner": null, "hp_image_builddate": "20120123", "architecture": "amd64", "min_disk": 0, "hp_image_version": "1hp1.1"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:51:52Z", "name": "CentOS 6.2 Server 64-bit 20120125", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1358", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1358", "rel": "bookmark"}], "created": "2012-02-21T13:58:51Z", "progress": 100, "id": "1358", "metadata": {"hp_image_type": "machine", "image_location": "local", "image_state": "available", "project_id": "None", "hp_md_version": "1", "kernel_id": "1356", "min_ram": 0, "ramdisk_id": "1357", "hp_image_id": "f2fbb1bf37a13e7c5da897c7082684df", "owner": null, "hp_image_builddate": "20120125", "architecture": "
x86_64", "min_disk": 0, "hp_image_version": "1hp1"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:51:37Z", "name": "CentOS 6.2 Server 64-bit 20120125 (Ramdisk)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1357", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1357", "rel": "bookmark"}], "created": "2012-02-21T13:58:49Z", "progress": 100, "id": "1357", "metadata": {"hp_image_type": "ramdisk", "image_location": "local", "image_state": "available", "project_id": "None", "hp_md_version": "1", "min_ram": 0, "hp_image_id": "f2fbb1bf37a13e7c5da897c7082684df", "owner": null, "hp_image_builddate": "20120125", "architecture": "x86_64", "min_disk": 0, "hp_image_version": "1hp1"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:51:28Z", "name": "CentOS 6.2 Server 64-bit 20120125 (Kernel)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1
356", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1356", "rel": "bookmark"}], "created": "2012-02-21T13:58:47Z", "progress": 100, "id": "1356", "metadata": {"hp_image_type": "kernel", "image_location": "local", "image_state": "available", "project_id": "None", "hp_md_version": "1", "min_ram": 0, "hp_image_id": "f2fbb1bf37a13e7c5da897c7082684df", "owner": null, "hp_image_builddate": "20120125", "architecture": "x86_64", "min_disk": 0, "hp_image_version": "1hp1"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:51:04Z", "name": "Ubuntu Oneiric 11.10 Server 64-bit 20111212", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1242", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1242", "rel": "bookmark"}], "created": "2011-12-21T11:57:15Z", "progress": 100, "id": "1242", "metadata": {"image_location": "local", "image_state": "available
", "kernel_id": "1241", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:50:58Z", "name": "Ubuntu Oneiric 11.10 Server 64-bit 20111212 (Kernel)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1241", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241", "rel": "bookmark"}], "created": "2011-12-21T11:57:07Z", "progress": 100, "id": "1241", "metadata": {"image_location": "local", "image_state": "available", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:50:52Z", "name": "Ubuntu Natty 11.04 Server 64-bit 20111212", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1240", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/3793662893
7291/images/1240", "rel": "bookmark"}], "created": "2011-12-21T11:55:03Z", "progress": 100, "id": "1240", "metadata": {"image_location": "local", "image_state": "available", "kernel_id": "1239", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:50:45Z", "name": "Ubuntu Natty 11.04 Server 64-bit 20111212 (Kernel)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1239", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1239", "rel": "bookmark"}], "created": "2011-12-21T11:55:02Z", "progress": 100, "id": "1239", "metadata": {"image_location": "local", "image_state": "available", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:50:32Z", "name": "Ubuntu Maverick 10.10 Server 64-bit 20111212", "links": [{"href": "
https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1238", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1238", "rel": "bookmark"}], "created": "2011-12-21T11:52:34Z", "progress": 100, "id": "1238", "metadata": {"image_location": "local", "image_state": "available", "kernel_id": "1237", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:50:24Z", "name": "Ubuntu Maverick 10.10 Server 64-bit 20111212 (Kernel)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1237", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1237", "rel": "bookmark"}], "created": "2011-12-21T11:52:27Z", "progress": 100, "id": "1237", "metadata": {"image_location": "local", "image_state": "available", "min_ram": 0, "min_disk": 0, "architecture": "amd6
4", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:49:30Z", "name": "Ubuntu Lucid 10.04 LTS Server 64-bit 20111212", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1236", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1236", "rel": "bookmark"}], "created": "2011-12-21T11:40:17Z", "progress": 100, "id": "1236", "metadata": {"image_location": "local", "image_state": "available", "kernel_id": "1235", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:49:23Z", "name": "Ubuntu Lucid 10.04 LTS Server 64-bit 20111212 (Kernel)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1235", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1235", "rel": "bookmark"}], "create
d": "2011-12-21T11:39:58Z", "progress": 100, "id": "1235", "metadata": {"image_location": "local", "image_state": "available", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:49:05Z", "name": "CentOS 5.6 Server 64-bit 20111207", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1234", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1234", "rel": "bookmark"}], "created": "2011-12-21T11:07:09Z", "progress": 100, "id": "1234", "metadata": {"image_location": "local", "image_state": "available", "kernel_id": "1232", "min_ram": 0, "ramdisk_id": "1233", "min_disk": 0, "architecture": "x86_64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:48:59Z", "name": "CentOS 5.6 Server 64-bit 20111207 (Ramdisk)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpclou
dsvc.com/v1.1/37936628937291/images/1233", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1233", "rel": "bookmark"}], "created": "2011-12-21T11:07:08Z", "progress": 100, "id": "1233", "metadata": {"image_location": "local", "image_state": "available", "min_ram": 0, "min_disk": 0, "architecture": "x86_64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:48:39Z", "name": "CentOS 5.6 Server 64-bit 20111207 (Kernel)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1232", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1232", "rel": "bookmark"}], "created": "2011-12-21T11:07:07Z", "progress": 100, "id": "1232", "metadata": {"image_location": "local", "image_state": "available", "min_ram": 0, "min_disk": 0, "architecture": "x86_64", "owner": null, "project_id": "None"}}]}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_imageextension.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_imageextension.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_imageextension.json
new file mode 100644
index 0000000..396d1f4
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_imageextension.json
@@ -0,0 +1,121 @@
+{
+ "images": [{
+ "status": "UNRECOGNIZED",
+ "updated": "2012-02-02T19:11:00Z",
+ "name": "oneiric-server-cloudimg-amd64",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/images/15",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/images/15",
+ "rel": "bookmark"
+ }],
+ "created": "2012-02-02T19:10:52Z",
+ "progress": 100,
+ "id": "15",
+ "metadata": {
+ "kernel_id": "14",
+ "min_disk": 0,
+ "min_ram": 0,
+ "owner": "1"
+ }
+ }, {
+ "status": "UNKNOWN",
+ "updated": "2012-02-02T19:10:51Z",
+ "name": "oneiric-server-cloudimg-amd64-kernel",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/images/14",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/images/14",
+ "rel": "bookmark"
+ }],
+ "created": "2012-02-02T19:10:50Z",
+ "progress": 100,
+ "id": "14",
+ "metadata": {
+ "min_disk": 0,
+ "owner": "1",
+ "min_ram": 0
+ }
+ }, {
+ "status": "ACTIVE",
+ "updated": "2012-02-02T19:10:41Z",
+ "name": "natty-server-cloudimg-amd64",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/images/13",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/images/13",
+ "rel": "bookmark"
+ }],
+ "created": "2012-02-02T19:10:33Z",
+ "progress": 100,
+ "id": "13",
+ "metadata": {
+ "kernel_id": "12",
+ "min_disk": 0,
+ "min_ram": 0,
+ "owner": "1"
+ }
+ }, {
+ "status": "SAVING",
+ "updated": "2012-02-02T19:10:33Z",
+ "name": "natty-server-cloudimg-amd64-kernel",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/images/12",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/images/12",
+ "rel": "bookmark"
+ }],
+ "created": "2012-02-02T19:10:32Z",
+ "progress": 100,
+ "id": "12",
+ "metadata": {
+ "min_disk": 0,
+ "owner": "1",
+ "min_ram": 0
+ }
+ }, {
+ "status": "ERROR",
+ "updated": "2012-02-02T19:10:41Z",
+ "name": "natty-server-cloudimg-amd64",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/images/11",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/images/11",
+ "rel": "bookmark"
+ }],
+ "created": "2012-02-02T19:10:33Z",
+ "progress": 100,
+ "id": "11",
+ "metadata": {
+ "kernel_id": "12",
+ "min_disk": 0,
+ "min_ram": 0,
+ "owner": "1"
+ }
+ }, {
+ "status": "ERROR",
+ "updated": "2012-02-02T19:10:41Z",
+ "name": "natty-server-cloudimg-amd64",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/images/10",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/images/10",
+ "rel": "bookmark"
+ }],
+ "created": "2012-02-02T19:10:33Z",
+ "progress": 100,
+ "id": "10",
+ "metadata": {
+ "kernel_id": "12",
+ "min_disk": 0,
+ "min_ram": 0,
+ "owner": "1"
+ }
+ }]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_openstack.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_openstack.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_openstack.json
new file mode 100644
index 0000000..f0575db
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_openstack.json
@@ -0,0 +1,81 @@
+{
+ "images": [{
+ "status": "ACTIVE",
+ "updated": "2012-02-02T19:11:00Z",
+ "name": "oneiric-server-cloudimg-amd64",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/images/15",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/images/15",
+ "rel": "bookmark"
+ }],
+ "created": "2012-02-02T19:10:52Z",
+ "progress": 100,
+ "id": "15",
+ "metadata": {
+ "kernel_id": "14",
+ "min_disk": 0,
+ "min_ram": 0,
+ "owner": "1"
+ }
+ }, {
+ "status": "ACTIVE",
+ "updated": "2012-02-02T19:10:51Z",
+ "name": "oneiric-server-cloudimg-amd64-kernel",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/images/14",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/images/14",
+ "rel": "bookmark"
+ }],
+ "created": "2012-02-02T19:10:50Z",
+ "progress": 100,
+ "id": "14",
+ "metadata": {
+ "min_disk": 0,
+ "owner": "1",
+ "min_ram": 0
+ }
+ }, {
+ "status": "ACTIVE",
+ "updated": "2012-02-02T19:10:41Z",
+ "name": "natty-server-cloudimg-amd64",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/images/13",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/images/13",
+ "rel": "bookmark"
+ }],
+ "created": "2012-02-02T19:10:33Z",
+ "progress": 100,
+ "id": "13",
+ "metadata": {
+ "kernel_id": "12",
+ "min_disk": 0,
+ "min_ram": 0,
+ "owner": "1"
+ }
+ }, {
+ "status": "ACTIVE",
+ "updated": "2012-02-02T19:10:33Z",
+ "name": "natty-server-cloudimg-amd64-kernel",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/images/12",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/images/12",
+ "rel": "bookmark"
+ }],
+ "created": "2012-02-02T19:10:32Z",
+ "progress": 100,
+ "id": "12",
+ "metadata": {
+ "min_disk": 0,
+ "owner": "1",
+ "min_ram": 0
+ }
+ }]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/keypair_created.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/keypair_created.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/keypair_created.json
new file mode 100644
index 0000000..188f929
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/keypair_created.json
@@ -0,0 +1,9 @@
+{
+ "keypair": {
+ "public_key": "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001\n",
+ "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIICXQIAAAKBgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABAC\nE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumA\nDSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQIDAQAB\nAoGAW8Ww+KbpQK8smcgCTr/RqcmsSI8VeL2hXjJvDq0L5WbyYuFdkanDvCztUVZn\nsmyfDtwAqZXB4Ct/dN1tY7m8QpdyRaKRW4Q+hghGCAQpsG7rYDdvwdEyvMaW5RA4\ntucQyajMNyQ/tozU3wMx/v8A7RvGcE9tqoG0WK1C3kBu95UCQQDrOd+joYDkvccz\nFIVu5gNPMXEh3fGGzDxk225UlvESquYLzfz4TfmuUjH4Z1BL3wRiwfJsrrjFkm33\njIidDE8PAkEA1qHjxuaIS1yz/rfzErmcOVNlbFHMP4ihjGTTvh1ZctXlNeLwzENQ\nEDaQV3IpUY1KQR6rxcWb5AXgfF9D9PYFpwJBANucAqGAbRgh3lJgPFtXP4u2O0tF\nLPOOxmvbOdybt6KYD4LB5AXmts77SlACFMNhCXUyYaT6UuOSXDyb5gfJsB0CQQC3\nFaGXKU9Z+doQjhlq/6mjvN/nZl80Uvh7Kgb1RVPoAU1kihGeLE0/h0vZTCiyyDNv\nGRqtucMg32J+tUTi0HpBAkAwHiCZMHMeJWHUwIwlRQY/dnR86FWobRl98ViF2rCL\nDHkDVOeIser3Q6zSqU5/m99lX6an5g8pAh/R5LqnOQZC\n-----END RSA PRIVATE KEY-----\n",
+ "user_id": "65649731189278",
+ "name": "testkeypair",
+ "fingerprint": "d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/keypair_created_computeservice.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/keypair_created_computeservice.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/keypair_created_computeservice.json
new file mode 100644
index 0000000..7a3cef0
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/keypair_created_computeservice.json
@@ -0,0 +1,9 @@
+{
+ "keypair": {
+ "public_key": "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001\n",
+ "private_key": "-----BEGIN RSA PRIVATE KEY-----\nMIICXQIAAAKBgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABAC\nE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumA\nDSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQIDAQAB\nAoGAW8Ww+KbpQK8smcgCTr/RqcmsSI8VeL2hXjJvDq0L5WbyYuFdkanDvCztUVZn\nsmyfDtwAqZXB4Ct/dN1tY7m8QpdyRaKRW4Q+hghGCAQpsG7rYDdvwdEyvMaW5RA4\ntucQyajMNyQ/tozU3wMx/v8A7RvGcE9tqoG0WK1C3kBu95UCQQDrOd+joYDkvccz\nFIVu5gNPMXEh3fGGzDxk225UlvESquYLzfz4TfmuUjH4Z1BL3wRiwfJsrrjFkm33\njIidDE8PAkEA1qHjxuaIS1yz/rfzErmcOVNlbFHMP4ihjGTTvh1ZctXlNeLwzENQ\nEDaQV3IpUY1KQR6rxcWb5AXgfF9D9PYFpwJBANucAqGAbRgh3lJgPFtXP4u2O0tF\nLPOOxmvbOdybt6KYD4LB5AXmts77SlACFMNhCXUyYaT6UuOSXDyb5gfJsB0CQQC3\nFaGXKU9Z+doQjhlq/6mjvN/nZl80Uvh7Kgb1RVPoAU1kihGeLE0/h0vZTCiyyDNv\nGRqtucMg32J+tUTi0HpBAkAwHiCZMHMeJWHUwIwlRQY/dnR86FWobRl98ViF2rCL\nDHkDVOeIser3Q6zSqU5/m99lX6an5g8pAh/R5LqnOQZC\n-----END RSA PRIVATE KEY-----\n",
+ "user_id": "65649731189278",
+ "name": "jclouds-test-0",
+ "fingerprint": "d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/keypair_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/keypair_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/keypair_list.json
new file mode 100644
index 0000000..28040ab
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/keypair_list.json
@@ -0,0 +1,18 @@
+{
+ "keypairs": [
+ {
+ "keypair": {
+ "public_key": "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQCy9EC3O7Ff80vPEfAHDQob61PGwcpYc5KE7tEZnZhrB9n0NyHPRm0E0M+ls3fcTa04HDi+R0DzmRwoyhHQJyI658v8kWZZcuvFjKCcsgsSh/dzdX0xTreLIzSOzt5U7RnZYfshP5cmxtF99yrEY3M/swdin0L+fXsTSkR1B42STQ== nova@nv-aw2az1-api0001",
+ "name": "default",
+ "fingerprint": "ab:0c:f4:f3:54:c0:5d:3f:ed:62:ad:d3:94:7c:79:7c"
+ }
+ },
+ {
+ "keypair": {
+ "public_key": "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001",
+ "name": "testkeypair",
+ "fingerprint": "d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4"
+ }
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/listAvailabilityZones.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/listAvailabilityZones.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/listAvailabilityZones.json
new file mode 100644
index 0000000..2d4ad78
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/listAvailabilityZones.json
@@ -0,0 +1,11 @@
+{
+ "availabilityZoneInfo": [
+ {
+ "zoneState": {
+ "available": true
+ },
+ "hosts": null,
+ "zoneName": "nova"
+ }
+ ]
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/metadata_item.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/metadata_item.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/metadata_item.json
new file mode 100644
index 0000000..f853109
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/metadata_item.json
@@ -0,0 +1,5 @@
+{
+ "metadata": {
+ "Server Label": "Web Head 1"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/metadata_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/metadata_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/metadata_list.json
new file mode 100644
index 0000000..174d7d6
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/metadata_list.json
@@ -0,0 +1,6 @@
+{
+ "metadata": {
+ "Server Label": "Web Head 1",
+ "Image Version": "2.1"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/metadata_updated.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/metadata_updated.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/metadata_updated.json
new file mode 100644
index 0000000..82d9fd3
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/metadata_updated.json
@@ -0,0 +1,7 @@
+{
+ "metadata": {
+ "Server Label": "Web Head 2",
+ "Image Version": "2.1",
+ "Server Description": "Simple Server"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server.json
new file mode 100644
index 0000000..71fb1f2
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server.json
@@ -0,0 +1,41 @@
+{
+ "server": {
+ "status": "BUILD(scheduling)",
+ "updated": "2012-03-19T06:21:13Z",
+ "hostId": "",
+ "user_id": "54297837463082",
+ "name": "test-e92",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752",
+ "rel": "self"
+ }, {
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752",
+ "rel": "bookmark"
+ }],
+ "addresses": {},
+ "tenant_id": "37936628937291",
+ "image": {
+ "id": "1241",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241",
+ "rel": "bookmark"
+ }]
+ },
+ "created": "2012-03-19T06:21:13Z",
+ "uuid": "47491020-6a78-4f63-9475-23195ac4515c",
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "key_name": null,
+ "adminPass": "ZWuHcmTMQ7eXoHeM",
+ "flavor": {
+ "id": "100",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100",
+ "rel": "bookmark"
+ }]
+ },
+ "config_drive": "",
+ "id": 71752,
+ "metadata": {}
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_disk_config_auto.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_disk_config_auto.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_disk_config_auto.json
new file mode 100644
index 0000000..7238333
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_disk_config_auto.json
@@ -0,0 +1,42 @@
+{
+ "server": {
+ "status": "BUILD(scheduling)",
+ "updated": "2012-03-19T06:21:13Z",
+ "hostId": "",
+ "user_id": "54297837463082",
+ "name": "test-e92",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752",
+ "rel": "self"
+ }, {
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752",
+ "rel": "bookmark"
+ }],
+ "addresses": {},
+ "tenant_id": "37936628937291",
+ "image": {
+ "id": "1241",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241",
+ "rel": "bookmark"
+ }]
+ },
+ "created": "2012-03-19T06:21:13Z",
+ "uuid": "47491020-6a78-4f63-9475-23195ac4515c",
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "key_name": null,
+ "adminPass": "ZWuHcmTMQ7eXoHeM",
+ "flavor": {
+ "id": "100",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100",
+ "rel": "bookmark"
+ }]
+ },
+ "config_drive": "",
+ "id": 71752,
+ "metadata": {},
+ "OS-DCF:diskConfig": "AUTO"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_disk_config_manual.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_disk_config_manual.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_disk_config_manual.json
new file mode 100644
index 0000000..2cfba41
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_disk_config_manual.json
@@ -0,0 +1,42 @@
+{
+ "server": {
+ "status": "BUILD(scheduling)",
+ "updated": "2012-03-19T06:21:13Z",
+ "hostId": "",
+ "user_id": "54297837463082",
+ "name": "test-e92",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752",
+ "rel": "self"
+ }, {
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752",
+ "rel": "bookmark"
+ }],
+ "addresses": {},
+ "tenant_id": "37936628937291",
+ "image": {
+ "id": "1241",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241",
+ "rel": "bookmark"
+ }]
+ },
+ "created": "2012-03-19T06:21:13Z",
+ "uuid": "47491020-6a78-4f63-9475-23195ac4515c",
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "key_name": null,
+ "adminPass": "ZWuHcmTMQ7eXoHeM",
+ "flavor": {
+ "id": "100",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100",
+ "rel": "bookmark"
+ }]
+ },
+ "config_drive": "",
+ "id": 71752,
+ "metadata": {},
+ "OS-DCF:diskConfig": "MANUAL"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_in_zone.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_in_zone.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_in_zone.json
new file mode 100644
index 0000000..71fb1f2
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_in_zone.json
@@ -0,0 +1,41 @@
+{
+ "server": {
+ "status": "BUILD(scheduling)",
+ "updated": "2012-03-19T06:21:13Z",
+ "hostId": "",
+ "user_id": "54297837463082",
+ "name": "test-e92",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752",
+ "rel": "self"
+ }, {
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752",
+ "rel": "bookmark"
+ }],
+ "addresses": {},
+ "tenant_id": "37936628937291",
+ "image": {
+ "id": "1241",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241",
+ "rel": "bookmark"
+ }]
+ },
+ "created": "2012-03-19T06:21:13Z",
+ "uuid": "47491020-6a78-4f63-9475-23195ac4515c",
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "key_name": null,
+ "adminPass": "ZWuHcmTMQ7eXoHeM",
+ "flavor": {
+ "id": "100",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100",
+ "rel": "bookmark"
+ }]
+ },
+ "config_drive": "",
+ "id": 71752,
+ "metadata": {}
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_networks_response.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_networks_response.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_networks_response.json
new file mode 100644
index 0000000..7238333
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_networks_response.json
@@ -0,0 +1,42 @@
+{
+ "server": {
+ "status": "BUILD(scheduling)",
+ "updated": "2012-03-19T06:21:13Z",
+ "hostId": "",
+ "user_id": "54297837463082",
+ "name": "test-e92",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752",
+ "rel": "self"
+ }, {
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752",
+ "rel": "bookmark"
+ }],
+ "addresses": {},
+ "tenant_id": "37936628937291",
+ "image": {
+ "id": "1241",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241",
+ "rel": "bookmark"
+ }]
+ },
+ "created": "2012-03-19T06:21:13Z",
+ "uuid": "47491020-6a78-4f63-9475-23195ac4515c",
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "key_name": null,
+ "adminPass": "ZWuHcmTMQ7eXoHeM",
+ "flavor": {
+ "id": "100",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100",
+ "rel": "bookmark"
+ }]
+ },
+ "config_drive": "",
+ "id": 71752,
+ "metadata": {},
+ "OS-DCF:diskConfig": "AUTO"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_no_adminpass.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_no_adminpass.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_no_adminpass.json
new file mode 100644
index 0000000..a89e48f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_no_adminpass.json
@@ -0,0 +1,40 @@
+{
+ "server": {
+ "status": "BUILD(scheduling)",
+ "updated": "2012-03-19T06:21:13Z",
+ "hostId": "",
+ "user_id": "54297837463082",
+ "name": "test-e92",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752",
+ "rel": "self"
+ }, {
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752",
+ "rel": "bookmark"
+ }],
+ "addresses": {},
+ "tenant_id": "37936628937291",
+ "image": {
+ "id": "1241",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241",
+ "rel": "bookmark"
+ }]
+ },
+ "created": "2012-03-19T06:21:13Z",
+ "uuid": "47491020-6a78-4f63-9475-23195ac4515c",
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "key_name": null,
+ "flavor": {
+ "id": "100",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100",
+ "rel": "bookmark"
+ }]
+ },
+ "config_drive": "",
+ "id": 71752,
+ "metadata": {}
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_nova_networks.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_nova_networks.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_nova_networks.json
new file mode 100644
index 0000000..d0f4322
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/new_server_nova_networks.json
@@ -0,0 +1,41 @@
+{
+ "server": {
+ "status": "BUILD(scheduling)",
+ "updated": "2012-03-19T06:21:13Z",
+ "hostId": "",
+ "user_id": "54297837463082",
+ "name": "test-e92",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752",
+ "rel": "self"
+ }, {
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752",
+ "rel": "bookmark"
+ }],
+ "addresses": {},
+ "tenant_id": "37936628937291",
+ "image": {
+ "id": "1241",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241",
+ "rel": "bookmark"
+ }]
+ },
+ "created": "2012-03-19T06:21:13Z",
+ "uuid": "47491020-6a78-4f63-9475-23195ac4515c",
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "key_name": null,
+ "adminPass": "ZWuHcmTMQ7eXoHeM",
+ "flavor": {
+ "id": "100",
+ "links": [{
+ "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100",
+ "rel": "bookmark"
+ }]
+ },
+ "id": 71752,
+ "metadata": {},
+ "OS-DCF:diskConfig": "AUTO"
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/quota_class.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/quota_class.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/quota_class.json
new file mode 100644
index 0000000..837b9cc
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/quota_class.json
@@ -0,0 +1,15 @@
+{"quota_class_set": {
+ "metadata_items": 128,
+ "injected_file_content_bytes": 10240,
+ "injected_files": 5,
+ "gigabytes": 1000,
+ "ram": 4096,
+ "floating_ips": 10,
+ "security_group_rules": 20,
+ "instances": 5,
+ "key_pairs": 100,
+ "volumes": 5,
+ "cores": 10,
+ "id": "jcloudstestquotas",
+ "security_groups": 10
+}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/quotas.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/quotas.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/quotas.json
new file mode 100644
index 0000000..dcf2869
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/quotas.json
@@ -0,0 +1,15 @@
+{"quota_set": {
+ "metadata_items": 128,
+ "injected_file_content_bytes": 10240,
+ "injected_files": 5,
+ "gigabytes": 1000,
+ "ram": 51200,
+ "floating_ips": 10,
+ "security_group_rules": 20,
+ "instances": 10,
+ "key_pairs": 100,
+ "volumes": 10,
+ "cores": 20,
+ "id": "demo",
+ "security_groups": 10
+}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_created.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_created.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_created.json
new file mode 100644
index 0000000..fee9b4d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_created.json
@@ -0,0 +1,9 @@
+{
+ "security_group": {
+ "rules": [ ],
+ "tenant_id": "dev_16767499955063",
+ "id": 160,
+ "name": "jclouds-test",
+ "description": "jclouds-test"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details.json
new file mode 100644
index 0000000..840de6c
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details.json
@@ -0,0 +1,34 @@
+{
+ "security_group":
+ {
+ "rules": [
+ {
+ "from_port": 22,
+ "group": {},
+ "ip_protocol": "tcp",
+ "to_port": 22,
+ "parent_group_id": 28,
+ "ip_range": {
+ "cidr": "10.2.6.0/24"
+ },
+ "id": 108
+ },
+ {
+ "from_port": 22,
+ "group": {
+ "tenant_id": "admin",
+ "name": "11111"
+ },
+ "ip_protocol": "tcp",
+ "to_port": 22,
+ "parent_group_id": 28,
+ "ip_range": {},
+ "id": 109
+ }
+ ],
+ "tenant_id": "tenant0",
+ "id": 0,
+ "name": "name0",
+ "description": "description0"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_computeservice_typical.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_computeservice_typical.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_computeservice_typical.json
new file mode 100644
index 0000000..0da1902
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_computeservice_typical.json
@@ -0,0 +1,51 @@
+{
+ "security_group": {
+ "rules": [{
+ "from_port": 22,
+ "group": {},
+ "ip_protocol": "tcp",
+ "to_port": 22,
+ "parent_group_id": 2769,
+ "ip_range": {
+ "cidr": "0.0.0.0/0"
+ },
+ "id": 10331
+ }, {
+ "from_port": 22,
+ "group": {
+ "tenant_id": "37936628937291",
+ "name": "jclouds_mygroup"
+ },
+ "ip_protocol": "tcp",
+ "to_port": 22,
+ "parent_group_id": 2769,
+ "ip_range": {},
+ "id": 10332
+ }, {
+ "from_port": 8080,
+ "group": {},
+ "ip_protocol": "tcp",
+ "to_port": 8080,
+ "parent_group_id": 2769,
+ "ip_range": {
+ "cidr": "0.0.0.0/0"
+ },
+ "id": 10333
+ }, {
+ "from_port": 8080,
+ "group": {
+ "tenant_id": "37936628937291",
+ "name": "jclouds_mygroup"
+ },
+ "ip_protocol": "tcp",
+ "to_port": 8080,
+ "parent_group_id": 2769,
+ "ip_range": {},
+ "id": 10334
+ }],
+ "tenant_id": "37936628937291",
+ "id": 2769,
+ "name": "jclouds_mygroup",
+ "description": "jclouds_mygroup"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension.json
new file mode 100644
index 0000000..0c5b316
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension.json
@@ -0,0 +1,34 @@
+{
+ "security_group":
+ {
+ "rules": [
+ {
+ "from_port": 22,
+ "group": {},
+ "ip_protocol": "tcp",
+ "to_port": 22,
+ "parent_group_id": 160,
+ "ip_range": {
+ "cidr": "10.2.6.0/24"
+ },
+ "id": 108
+ },
+ {
+ "from_port": 22,
+ "group": {
+ "tenant_id": "tenant0",
+ "name": "name0"
+ },
+ "ip_protocol": "tcp",
+ "to_port": 22,
+ "parent_group_id": 160,
+ "ip_range": {},
+ "id": 109
+ }
+ ],
+ "tenant_id": "tenant0",
+ "id": 160,
+ "name": "name0",
+ "description": "description0"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension_norules.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension_norules.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension_norules.json
new file mode 100644
index 0000000..27aca88
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension_norules.json
@@ -0,0 +1,10 @@
+{
+ "security_group":
+ {
+ "rules": [],
+ "tenant_id": "tenant0",
+ "id": 160,
+ "name": "name0",
+ "description": "description0"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_port22.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_port22.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_port22.json
new file mode 100644
index 0000000..5ee82bc
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_port22.json
@@ -0,0 +1,19 @@
+{
+ "security_group": {
+ "rules": [{
+ "from_port": 22,
+ "group": {},
+ "ip_protocol": "tcp",
+ "to_port": 22,
+ "parent_group_id": 2769,
+ "ip_range": {
+ "cidr": "0.0.0.0/0"
+ },
+ "id": 10331
+ }],
+ "tenant_id": "37936628937291",
+ "id": 2769,
+ "name": "jclouds-test",
+ "description": "jclouds-test"
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list.json
new file mode 100644
index 0000000..b5a1ed1
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list.json
@@ -0,0 +1,51 @@
+{
+ "security_groups":[
+ {
+ "rules":[
+ {
+ "from_port":22,
+ "group":{
+
+ },
+ "ip_protocol":"tcp",
+ "to_port":22,
+ "parent_group_id":3,
+ "ip_range":{
+ "cidr":"0.0.0.0/0"
+ },
+ "id":107
+ },
+ {
+ "from_port":7600,
+ "group":{
+
+ },
+ "ip_protocol":"tcp",
+ "to_port":7600,
+ "parent_group_id":3,
+ "ip_range":{
+ "cidr":"0.0.0.0/0"
+ },
+ "id":118
+ },
+ {
+ "from_port":8084,
+ "group":{
+
+ },
+ "ip_protocol":"tcp",
+ "to_port":8084,
+ "parent_group_id":3,
+ "ip_range":{
+ "cidr":"0.0.0.0/0"
+ },
+ "id":119
+ }
+ ],
+ "tenant_id":"tenant1",
+ "id":1,
+ "name":"name1",
+ "description":"description1"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_details_computeservice_typical.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_details_computeservice_typical.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_details_computeservice_typical.json
new file mode 100644
index 0000000..7e58c51
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_details_computeservice_typical.json
@@ -0,0 +1,53 @@
+{
+ "security_groups":[
+ {
+ "rules": [{
+ "from_port": 22,
+ "group": {},
+ "ip_protocol": "tcp",
+ "to_port": 22,
+ "parent_group_id": 2769,
+ "ip_range": {
+ "cidr": "0.0.0.0/0"
+ },
+ "id": 10331
+ }, {
+ "from_port": 22,
+ "group": {
+ "tenant_id": "37936628937291",
+ "name": "jclouds_mygroup"
+ },
+ "ip_protocol": "tcp",
+ "to_port": 22,
+ "parent_group_id": 2769,
+ "ip_range": {},
+ "id": 10332
+ }, {
+ "from_port": 8080,
+ "group": {},
+ "ip_protocol": "tcp",
+ "to_port": 8080,
+ "parent_group_id": 2769,
+ "ip_range": {
+ "cidr": "0.0.0.0/0"
+ },
+ "id": 10333
+ }, {
+ "from_port": 8080,
+ "group": {
+ "tenant_id": "37936628937291",
+ "name": "jclouds_mygroup"
+ },
+ "ip_protocol": "tcp",
+ "to_port": 8080,
+ "parent_group_id": 2769,
+ "ip_range": {},
+ "id": 10334
+ }],
+ "tenant_id": "37936628937291",
+ "id": 2769,
+ "name": "jclouds_mygroup",
+ "description": "jclouds_mygroup"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_extension.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_extension.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_extension.json
new file mode 100644
index 0000000..4a19a36
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_extension.json
@@ -0,0 +1,51 @@
+{
+ "security_groups":[
+ {
+ "rules":[
+ {
+ "from_port":22,
+ "group":{
+
+ },
+ "ip_protocol":"tcp",
+ "to_port":22,
+ "parent_group_id":3,
+ "ip_range":{
+ "cidr":"0.0.0.0/0"
+ },
+ "id":107
+ },
+ {
+ "from_port":7600,
+ "group":{
+
+ },
+ "ip_protocol":"tcp",
+ "to_port":7600,
+ "parent_group_id":3,
+ "ip_range":{
+ "cidr":"0.0.0.0/0"
+ },
+ "id":118
+ },
+ {
+ "from_port":8084,
+ "group":{
+
+ },
+ "ip_protocol":"tcp",
+ "to_port":8084,
+ "parent_group_id":3,
+ "ip_range":{
+ "cidr":"0.0.0.0/0"
+ },
+ "id":119
+ }
+ ],
+ "tenant_id": "tenant0",
+ "id": 160,
+ "name": "name0",
+ "description": "description0"
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created.json
new file mode 100644
index 0000000..1e8b9fd
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created.json
@@ -0,0 +1,12 @@
+{
+ "security_group_rule": {
+ "from_port": 80,
+ "group": {},
+ "ip_protocol": "tcp",
+ "to_port": 8080,
+ "parent_group_id": 161,
+ "ip_range": {
+ "cidr": "0.0.0.0/0"
+ },
+ "id": 218 }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created_cidr.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created_cidr.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created_cidr.json
new file mode 100644
index 0000000..cc91ac7
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created_cidr.json
@@ -0,0 +1,13 @@
+{
+ "security_group_rule": {
+ "from_port": 22,
+ "group": {},
+ "ip_protocol": "tcp",
+ "to_port": 22,
+ "parent_group_id": 160,
+ "ip_range": {
+ "cidr": "10.2.6.0/24"
+ },
+ "id": 108
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created_group.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created_group.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created_group.json
new file mode 100644
index 0000000..ff17bcd
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created_group.json
@@ -0,0 +1,14 @@
+{
+ "security_group_rule": {
+ "from_port": 22,
+ "group": {
+ "tenant_id": "admin",
+ "name": "11111"
+ },
+ "ip_protocol": "tcp",
+ "to_port": 22,
+ "parent_group_id": 160,
+ "ip_range": {},
+ "id": 109
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_details.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_details.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_details.json
new file mode 100644
index 0000000..f548785
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_details.json
@@ -0,0 +1,86 @@
+{
+ "server": {
+ "id": "52415800-8b69-11e0-9b19-734f000004d2",
+ "tenant_id": "1234",
+ "user_id": "5678",
+ "name": "sample-f352",
+ "updated": "2010-10-10T12:00:00Z",
+ "created": "2010-08-10T12:00:00Z",
+ "hostId": "e4d909c290d0fb1ca068ffaddf22cbd0",
+ "accessIPv4" : "67.23.10.132",
+ "accessIPv6" : "::babe:67.23.10.132",
+ "status": "BUILD(scheduling)",
+ "progress": 60,
+ "OS-DCF:diskConfig": "AUTO",
+ "image" : {
+ "id": "52415800-8b69-11e0-9b19-734f6f006e54",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"
+ }
+ ]
+ },
+ "flavor" : {
+ "id": "52415800-8b69-11e0-9b19-734f216543fd",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"
+ }
+ ]
+ },
+ "addresses": {
+ "public" : [
+ {
+ "version": 4,
+ "addr": "67.23.10.132"
+ },
+ {
+ "version": 6,
+ "addr": "::babe:67.23.10.132"
+ },
+ {
+ "version": 4,
+ "addr": "67.23.10.131"
+ },
+ {
+ "version": 6,
+ "addr": "::babe:4317:0A83"
+ }
+ ],
+ "private" : [
+ {
+ "version": 4,
+ "addr": "10.176.42.16"
+ },
+ {
+ "version": 6,
+ "addr": "::babe:10.176.42.16"
+ }
+ ]
+ },
+ "metadata": {
+ "Server Label": "Web Head 1",
+ "Image Version": "2.1"
+ },
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54"
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54"
+ }
+ ]
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_details_devstack.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_details_devstack.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_details_devstack.json
new file mode 100644
index 0000000..e41095f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_details_devstack.json
@@ -0,0 +1,44 @@
+{"server": {
+ "OS-EXT-STS:task_state": null,
+ "addresses": {
+ "private": [{"version": 4, "addr": "10.0.0.8"}]
+ },
+ "links":
+ [
+ {
+ "href": "http://172.16.89.149:8774/v2/7f312675f9b84c97bff8f5054e181419/servers/141b775f-7ac1-45f0-9a95-146260f33a53", "rel": "self"
+ },
+ {
+ "href": "http://172.16.89.149:8774/7f312675f9b84c97bff8f5054e181419/servers/141b775f-7ac1-45f0-9a95-146260f33a53", "rel": "bookmark"
+ }
+ ],
+ "image": {
+ "id": "8e6f5bc4-a210-45b2-841f-c510eae14300", "links": [
+ {
+ "href": "http://172.16.89.149:8774/7f312675f9b84c97bff8f5054e181419/images/8e6f5bc4-a210-45b2-841f-c510eae14300", "rel": "bookmark"
+ }]
+ },
+ "OS-EXT-STS:vm_state": "paused",
+ "OS-EXT-SRV-ATTR:instance_name": "instance-00000014",
+ "flavor": {
+ "id": "1",
+ "links": [{"href": "http://172.16.89.149:8774/7f312675f9b84c97bff8f5054e181419/flavors/1", "rel": "bookmark"}]
+ },
+ "id": "141b775f-7ac1-45f0-9a95-146260f33a53",
+ "user_id": "89c01b67395d4bea945f7f5bfd7f344a",
+ "OS-DCF:diskConfig": "MANUAL",
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "OS-EXT-STS:power_state": 3,
+ "config_drive": "",
+ "status": "PAUSED",
+ "updated": "2012-05-04T15:07:48Z",
+ "hostId": "eab9a77d1c44b8833e4a3dc6d2d9d50de556e780a319f184d8c82d9b",
+ "OS-EXT-SRV-ATTR:host": "ubuntu",
+ "key_name": "",
+ "OS-EXT-SRV-ATTR:hypervisor_hostname": null,
+ "name": "test",
+ "created": "2012-05-04T15:07:36Z",
+ "tenant_id": "7f312675f9b84c97bff8f5054e181419",
+ "metadata": {}
+}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_details_openstack.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_details_openstack.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_details_openstack.json
new file mode 100644
index 0000000..10b7a7d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_details_openstack.json
@@ -0,0 +1,46 @@
+{
+ "server": {
+ "status": "ACTIVE",
+ "updated": "2012-03-23T01:30:26Z",
+ "hostId": "881706597197955ac7cc4b353bc7ec884e13fa280de9cc82057796cb",
+ "user_id": "508151008",
+ "name": "mygroup-72c",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/v1.1/37/servers/1459",
+ "rel": "self"
+ }, {
+ "href": "https://nova-api.openstack.org:9774/37/servers/1459",
+ "rel": "bookmark"
+ }],
+ "addresses": {
+ "internet": [{
+ "version": 4,
+ "addr": "8.21.28.47"
+ }]
+ },
+ "tenant_id": "37",
+ "image": {
+ "id": "14",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/37/images/14",
+ "rel": "bookmark"
+ }]
+ },
+ "created": "2012-03-23T01:30:26Z",
+ "uuid": "2443c9c7-9791-412e-ac09-a6d55ec25335",
+ "accessIPv4": "",
+ "accessIPv6": "",
+ "key_name": null,
+ "progress": 100,
+ "flavor": {
+ "id": "1",
+ "links": [{
+ "href": "https://nova-api.openstack.org:9774/37/flavors/1",
+ "rel": "bookmark"
+ }]
+ },
+ "config_drive": "",
+ "id": 1459,
+ "metadata": {}
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_diagnostics.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_diagnostics.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_diagnostics.json
new file mode 100644
index 0000000..d35988d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_diagnostics.json
@@ -0,0 +1,17 @@
+{
+ "vnet0_tx_errors": 0,
+ "vda_read": 77364736,
+ "vda_write": 415446016,
+ "vnet0_tx_packets": 9701,
+ "vda_write_req": 47278,
+ "cpu0_time": 143150000000,
+ "vnet0_tx": 1691221,
+ "vnet0_rx_drop": 0,
+ "vda_errors": -1,
+ "vnet0_rx_errors": 0,
+ "memory": 524288,
+ "vnet0_rx_packets": 11271,
+ "vda_read_req": 9551,
+ "vnet0_rx": 1805288,
+ "vnet0_tx_drop": 0
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_list.json
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_list.json b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_list.json
new file mode 100644
index 0000000..aa6cf0d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/resources/server_list.json
@@ -0,0 +1,32 @@
+{
+ "servers": [
+ {
+ "id": "52415800-8b69-11e0-9b19-734f6af67565",
+ "name": "sample-server",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6af67565"
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f6af67565"
+ }
+ ]
+ },
+ {
+ "id": "52415800-8b69-11e0-9b19-734f1f1350e5",
+ "name": "sample-server2",
+ "links": [
+ {
+ "rel": "self",
+ "href": "http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5"
+ },
+ {
+ "rel": "bookmark",
+ "href": "http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5"
+ }
+ ]
+ }
+ ]
+}
[18/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadata.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadata.java
new file mode 100644
index 0000000..23035c2
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadata.java
@@ -0,0 +1,199 @@
+/*
+ * 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.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Predicates.not;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.find;
+import static com.google.common.collect.Iterables.transform;
+import static com.google.common.collect.Sets.newHashSet;
+import static org.jclouds.compute.util.ComputeServiceUtils.addMetadataAndParseTagsFromCommaDelimitedValue;
+import static org.jclouds.compute.util.ComputeServiceUtils.groupFromMapOrName;
+import static org.jclouds.openstack.nova.v2_0.domain.Address.createV4;
+import static org.jclouds.openstack.nova.v2_0.domain.Address.createV6;
+
+import java.net.Inet4Address;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.domain.ComputeMetadata;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.NodeMetadataBuilder;
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.logging.Logger;
+import org.jclouds.openstack.nova.v2_0.domain.Address;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.util.InetAddresses2;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.net.InetAddresses;
+
+/**
+ * A function for transforming a nova-specific Server into a generic
+ * NodeMetadata object.
+ *
+ * @author Matt Stephenson, Adam Lowe, Adrian Cole
+ */
+public class ServerInZoneToNodeMetadata implements Function<ServerInZone, NodeMetadata> {
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ protected Map<Status, org.jclouds.compute.domain.NodeMetadata.Status> toPortableNodeStatus;
+ protected final Supplier<Map<String, Location>> locationIndex;
+ protected final Supplier<Set<? extends Image>> images;
+ protected final Supplier<Set<? extends Hardware>> hardwares;
+ protected final GroupNamingConvention nodeNamingConvention;
+
+ @Inject
+ public ServerInZoneToNodeMetadata(Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus,
+ Supplier<Map<String, Location>> locationIndex, @Memoized Supplier<Set<? extends Image>> images,
+ @Memoized Supplier<Set<? extends Hardware>> hardwares, GroupNamingConvention.Factory namingConvention) {
+ this.toPortableNodeStatus = checkNotNull(toPortableNodeStatus, "toPortableNodeStatus");
+ this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
+ this.locationIndex = checkNotNull(locationIndex, "locationIndex");
+ this.images = checkNotNull(images, "images");
+ this.hardwares = checkNotNull(hardwares, "hardwares");
+ }
+
+ @Override
+ public NodeMetadata apply(ServerInZone serverInZone) {
+ Location zone = locationIndex.get().get(serverInZone.getZone());
+ checkState(zone != null, "location %s not in locationIndex: %s", serverInZone.getZone(), locationIndex.get());
+ Server from = serverInZone.getServer();
+
+ NodeMetadataBuilder builder = new NodeMetadataBuilder();
+ builder.id(serverInZone.slashEncode());
+ builder.providerId(from.getId());
+ builder.name(from.getName());
+ builder.hostname(from.getName());
+ builder.location(from.getHostId() != null ? new LocationBuilder().scope(LocationScope.HOST).id(from.getHostId())
+ .description(from.getHostId()).parent(zone).build() : zone);
+ builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention));
+ addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata());
+ builder.imageId(ZoneAndId.fromZoneAndId(serverInZone.getZone(), from.getImage().getId()).slashEncode());
+ builder.operatingSystem(findOperatingSystemForServerOrNull(serverInZone));
+ builder.hardware(findHardwareForServerOrNull(serverInZone));
+ builder.status(toPortableNodeStatus.get(from.getStatus()));
+
+ Set<Address> addresses = newHashSet(from.getAddresses().values());
+ if (from.getAccessIPv4() != null) {
+ addresses.add(createV4(from.getAccessIPv4()));
+ }
+ if (from.getAccessIPv6() != null) {
+ addresses.add(createV6(from.getAccessIPv6()));
+ }
+
+ builder.publicAddresses(
+ filter(
+ transform(
+ filter(addresses, not(isPrivateAddress)),
+ AddressToStringTransformationFunction.INSTANCE),
+ isInet4Address));
+
+ builder.privateAddresses(
+ filter(
+ transform(
+ filter(addresses, isPrivateAddress),
+ AddressToStringTransformationFunction.INSTANCE),
+ isInet4Address));
+
+ for (Link link: from.getLinks()) {
+ if (link.getRelation().equals(Link.Relation.SELF)) {
+ builder.uri(link.getHref());
+ }
+ }
+
+ return builder.build();
+ }
+
+ private static final Predicate<Address> isPrivateAddress = new Predicate<Address>() {
+ public boolean apply(Address in) {
+ return InetAddresses2.IsPrivateIPAddress.INSTANCE.apply(in.getAddr());
+ }
+ };
+
+ public static final Predicate<String> isInet4Address = new Predicate<String>() {
+ @Override
+ public boolean apply(String input) {
+ try {
+ // Note we can do this, as InetAddress is now on the white list
+ return InetAddresses.forString(input) instanceof Inet4Address;
+ } catch (IllegalArgumentException e) {
+ // could be a hostname
+ return true;
+ }
+ }
+
+ };
+
+ private enum AddressToStringTransformationFunction implements Function<Address, String> {
+ INSTANCE;
+ @Override
+ public String apply(Address address) {
+ return address.getAddr();
+ }
+ }
+
+ protected Hardware findHardwareForServerOrNull(ServerInZone serverInZone) {
+ return findObjectOfTypeForServerOrNull(hardwares.get(), "hardware", serverInZone.getServer().getFlavor().getId(),
+ serverInZone);
+ }
+
+ protected OperatingSystem findOperatingSystemForServerOrNull(ServerInZone serverInZone) {
+ Image image = findObjectOfTypeForServerOrNull(images.get(), "image", serverInZone.getServer().getImage().getId(),
+ serverInZone);
+ return (image != null) ? image.getOperatingSystem() : null;
+ }
+
+ public <T extends ComputeMetadata> T findObjectOfTypeForServerOrNull(Set<? extends T> supply, String type,
+ final String objectId, final ZoneAndId serverInZone) {
+ try {
+ return find(supply, new Predicate<T>() {
+ @Override
+ public boolean apply(T input) {
+ return input.getId().equals(ZoneAndId.fromZoneAndId(serverInZone.getZone(), objectId).slashEncode());
+ }
+ });
+ } catch (NoSuchElementException e) {
+ logger.trace("could not find %s with id(%s) for server(%s)", type, objectId, serverInZone);
+ }
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPair.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPair.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPair.java
new file mode 100644
index 0000000..18096fe
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPair.java
@@ -0,0 +1,79 @@
+/*
+ * 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.loaders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.annotation.Resource;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.logging.Logger;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
+
+import com.google.common.base.Optional;
+import com.google.common.cache.CacheLoader;
+import com.google.inject.Inject;
+
+/**
+ * @author Adam Lowe
+ */
+@Singleton
+public class CreateUniqueKeyPair extends CacheLoader<ZoneAndName, KeyPair> {
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+ protected final NovaApi novaApi;
+ protected final GroupNamingConvention.Factory namingConvention;
+
+ @Inject
+ public CreateUniqueKeyPair(NovaApi novaApi, GroupNamingConvention.Factory namingConvention) {
+ this.novaApi = checkNotNull(novaApi, "novaApi");
+ this.namingConvention = checkNotNull(namingConvention, "namingConvention");
+ }
+
+ @Override
+ public KeyPair load(ZoneAndName zoneAndName) {
+ String zoneId = checkNotNull(zoneAndName, "zoneAndName").getZone();
+ String prefix = zoneAndName.getName();
+
+ Optional<? extends KeyPairApi> api = novaApi.getKeyPairExtensionForZone(zoneId);
+ checkArgument(api.isPresent(), "Key pairs are required, but the extension is not available in zone %s!",
+ zoneId);
+
+ logger.debug(">> creating keyPair zone(%s) prefix(%s)", zoneId, prefix);
+
+ KeyPair keyPair = null;
+ while (keyPair == null) {
+ try {
+ keyPair = api.get().create(namingConvention.createWithoutPrefix().uniqueNameForGroup(prefix));
+ } catch (IllegalStateException e) {
+
+ }
+ }
+
+ logger.debug("<< created keyPair(%s)", keyPair.getName());
+ return keyPair;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreate.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreate.java
new file mode 100644
index 0000000..71951cd
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreate.java
@@ -0,0 +1,86 @@
+/*
+ * 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.loaders;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.cache.CacheLoader;
+import com.google.common.util.concurrent.Atomics;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class FindSecurityGroupOrCreate extends CacheLoader<ZoneAndName, SecurityGroupInZone> {
+
+ protected final Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone;
+ protected final Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator;
+
+ @Inject
+ public FindSecurityGroupOrCreate(
+ @Named("SECURITYGROUP_PRESENT") Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone,
+ Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> groupCreator) {
+ this.returnSecurityGroupExistsInZone = checkNotNull(returnSecurityGroupExistsInZone,
+ "returnSecurityGroupExistsInZone");
+ this.groupCreator = checkNotNull(groupCreator, "groupCreator");
+ }
+
+ @Override
+ public SecurityGroupInZone load(ZoneAndName in) {
+ AtomicReference<ZoneAndName> securityGroupInZoneRef = Atomics.newReference(checkNotNull(in,
+ "zoneSecurityGroupNameAndPorts"));
+ if (returnSecurityGroupExistsInZone.apply(securityGroupInZoneRef)) {
+ return returnExistingSecurityGroup(securityGroupInZoneRef);
+ } else {
+ return createNewSecurityGroup(in);
+ }
+ }
+
+ private SecurityGroupInZone returnExistingSecurityGroup(AtomicReference<ZoneAndName> securityGroupInZoneRef) {
+ ZoneAndName securityGroupInZone = securityGroupInZoneRef.get();
+ checkState(securityGroupInZone instanceof SecurityGroupInZone,
+ "programming error: predicate %s should update the atomic reference to the actual security group found",
+ returnSecurityGroupExistsInZone);
+ return SecurityGroupInZone.class.cast(securityGroupInZone);
+ }
+
+ private SecurityGroupInZone createNewSecurityGroup(ZoneAndName in) {
+ checkState(
+ checkNotNull(in, "zoneSecurityGroupNameAndPorts") instanceof ZoneSecurityGroupNameAndPorts,
+ "programming error: when issuing get to this cacheloader, you need to pass an instance of ZoneSecurityGroupNameAndPorts, not %s",
+ in);
+ ZoneSecurityGroupNameAndPorts zoneSecurityGroupNameAndPorts = ZoneSecurityGroupNameAndPorts.class.cast(in);
+ return groupCreator.apply(zoneSecurityGroupNameAndPorts);
+ }
+
+ @Override
+ public String toString() {
+ return "returnExistingSecurityGroupInZoneOrCreateAsNeeded()";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstance.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstance.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstance.java
new file mode 100644
index 0000000..1c0ae8a
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstance.java
@@ -0,0 +1,63 @@
+/*
+ * 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.loaders;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
+import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.cache.CacheLoader;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Each zone may or may not have the floating ip function present. In order to safely proceed, we
+ * must allow the user to determine if a zone has floating ip services before attempting to use
+ * them.
+ *
+ * @author Adam Lowe
+ */
+@Singleton
+public class LoadFloatingIpsForInstance extends CacheLoader<ZoneAndId, Iterable<? extends FloatingIP>> {
+ private final NovaApi api;
+
+ @Inject
+ public LoadFloatingIpsForInstance(NovaApi api) {
+ this.api = api;
+ }
+
+ @Override
+ public Iterable<? extends FloatingIP> load(final ZoneAndId key) throws Exception {
+ String zone = key.getZone();
+ Optional<? extends FloatingIPApi> ipApiOptional = api.getFloatingIPExtensionForZone(zone);
+ if (ipApiOptional.isPresent()) {
+ return ipApiOptional.get().list().filter(
+ new Predicate<FloatingIP>() {
+ @Override
+ public boolean apply(FloatingIP input) {
+ return key.getId().equals(input.getInstanceId());
+ }
+ });
+ }
+ return ImmutableSet.of();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java
new file mode 100644
index 0000000..e5f5794
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java
@@ -0,0 +1,620 @@
+/*
+ * 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.options;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Strings.emptyToNull;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Set;
+
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.openstack.nova.v2_0.domain.Network;
+import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions;
+import org.jclouds.scriptbuilder.domain.Statement;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Contains options supported in the {@code ComputeService#runNode} operation on the
+ * "openstack-nova" provider. <h2>Usage</h2> The recommended way to instantiate a
+ * NovaTemplateOptions object is to statically import NovaTemplateOptions.* and invoke a static
+ * creation method followed by an instance mutator (if needed):
+ * <p/>
+ * <code>
+ * import static org.jclouds.aws.ec2.compute.options.NovaTemplateOptions.Builder.*;
+ * <p/>
+ * ComputeService api = // get connection
+ * templateBuilder.options(inboundPorts(22, 80, 8080, 443));
+ * Set<? extends NodeMetadata> set = api.createNodesInGroup(tag, 2, templateBuilder.build());
+ * <code>
+ *
+ * @author Adam Lowe
+ */
+public class NovaTemplateOptions extends TemplateOptions implements Cloneable {
+ @Override
+ public NovaTemplateOptions clone() {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ copyTo(options);
+ return options;
+ }
+
+ @Override
+ public void copyTo(TemplateOptions to) {
+ super.copyTo(to);
+ if (to instanceof NovaTemplateOptions) {
+ NovaTemplateOptions eTo = NovaTemplateOptions.class.cast(to);
+ eTo.autoAssignFloatingIp(shouldAutoAssignFloatingIp());
+ if (getSecurityGroupNames().isPresent())
+ eTo.securityGroupNames(getSecurityGroupNames().get());
+ eTo.generateKeyPair(shouldGenerateKeyPair());
+ eTo.keyPairName(getKeyPairName());
+ if (getUserData() != null) {
+ eTo.userData(getUserData());
+ }
+ if (getDiskConfig() != null) {
+ eTo.diskConfig(getDiskConfig());
+ }
+
+ eTo.configDrive(getConfigDrive());
+ eTo.novaNetworks(getNovaNetworks());
+ }
+ }
+
+ protected boolean autoAssignFloatingIp = false;
+ protected Optional<Set<String>> securityGroupNames = Optional.absent();
+ protected boolean generateKeyPair = false;
+ protected String keyPairName;
+ protected byte[] userData;
+ protected String diskConfig;
+ protected boolean configDrive;
+ protected Set<Network> novaNetworks;
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ NovaTemplateOptions that = NovaTemplateOptions.class.cast(o);
+ return super.equals(that) && equal(this.autoAssignFloatingIp, that.autoAssignFloatingIp)
+ && equal(this.securityGroupNames, that.securityGroupNames)
+ && equal(this.generateKeyPair, that.generateKeyPair)
+ && equal(this.keyPairName, that.keyPairName)
+ && Arrays.equals(this.userData, that.userData)
+ && equal(this.diskConfig, that.diskConfig)
+ && equal(this.configDrive, that.configDrive)
+ && equal(this.novaNetworks, that.novaNetworks);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(super.hashCode(), autoAssignFloatingIp, securityGroupNames, generateKeyPair, keyPairName, userData, diskConfig, configDrive, novaNetworks);
+ }
+
+ @Override
+ public ToStringHelper string() {
+ ToStringHelper toString = super.string();
+ if (!autoAssignFloatingIp)
+ toString.add("autoAssignFloatingIp", autoAssignFloatingIp);
+ if (securityGroupNames.isPresent())
+ toString.add("securityGroupNames", securityGroupNames.get());
+ if (generateKeyPair)
+ toString.add("generateKeyPair", generateKeyPair);
+ toString.add("keyPairName", keyPairName);
+ toString.add("userData", userData);
+ toString.add("diskConfig", diskConfig);
+ toString.add("configDrive", configDrive);
+ toString.add("novaNetworks", novaNetworks);
+ return toString;
+ }
+
+ public static final NovaTemplateOptions NONE = new NovaTemplateOptions();
+
+ /**
+ * @see #shouldAutoAssignFloatingIp()
+ */
+ public NovaTemplateOptions autoAssignFloatingIp(boolean enable) {
+ this.autoAssignFloatingIp = enable;
+ return this;
+ }
+
+ /**
+ * @see #shouldGenerateKeyPair()
+ */
+ public NovaTemplateOptions generateKeyPair(boolean enable) {
+ this.generateKeyPair = enable;
+ return this;
+ }
+
+ /**
+ * @see #shouldGenerateKeyPair()
+ */
+ public NovaTemplateOptions keyPairName(String keyPairName) {
+ this.keyPairName = keyPairName;
+ return this;
+ }
+
+ /**
+ *
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getSecurityGroupNames
+ */
+ public NovaTemplateOptions securityGroupNames(String... securityGroupNames) {
+ return securityGroupNames(ImmutableSet.copyOf(checkNotNull(securityGroupNames, "securityGroupNames")));
+ }
+
+ /**
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getSecurityGroupNames
+ */
+ public NovaTemplateOptions securityGroupNames(Iterable<String> securityGroupNames) {
+ for (String groupName : checkNotNull(securityGroupNames, "securityGroupNames"))
+ checkNotNull(emptyToNull(groupName), "all security groups must be non-empty");
+ this.securityGroupNames = Optional.<Set<String>> of(ImmutableSet.copyOf(securityGroupNames));
+ return this;
+ }
+
+ /**
+ * <h3>Note</h3>
+ *
+ * This requires that {@link NovaApi#getExtensionForZone(String)} to return
+ * {@link Optional#isPresent present}
+ *
+ * @return true if auto assignment of a floating ip to each vm is enabled
+ */
+ public boolean shouldAutoAssignFloatingIp() {
+ return autoAssignFloatingIp;
+ }
+
+ /**
+ * Specifies the keypair used to run instances with
+ * @return the keypair to be used
+ */
+ public String getKeyPairName() {
+ return keyPairName;
+ }
+
+ /**
+ * <h3>Note</h3>
+ *
+ * This requires that {@link NovaApi#getKeyPairExtensionForZone(String)} to return
+ * {@link Optional#isPresent present}
+ *
+ * @return true if auto generation of keypairs is enabled
+ */
+ public boolean shouldGenerateKeyPair() {
+ return generateKeyPair;
+ }
+
+ /**
+ * if unset, generate a default group prefixed with {@link jclouds#} according
+ * to {@link #getInboundPorts()}
+ *
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getSecurityGroupNames
+ */
+ public Optional<Set<String>> getSecurityGroupNames() {
+ return securityGroupNames;
+ }
+
+ public byte[] getUserData() {
+ return userData;
+ }
+
+ /**
+ * @see CreateServerOptions#getDiskConfig()
+ */
+ public String getDiskConfig() {
+ return diskConfig;
+ }
+
+ /**
+ * @see CreateServerOptions#getConfigDrive()
+ */
+ public boolean getConfigDrive() {
+ return configDrive;
+ }
+
+ /**
+ * @see CreateServerOptions#getNetworks()
+ */
+ public Set<Network> getNovaNetworks() {
+ return novaNetworks;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see NovaTemplateOptions#shouldAutoAssignFloatingIp()
+ */
+ public static NovaTemplateOptions autoAssignFloatingIp(boolean enable) {
+ return new NovaTemplateOptions().autoAssignFloatingIp(enable);
+ }
+
+ /**
+ * @see NovaTemplateOptions#shouldGenerateKeyPair()
+ */
+ public static NovaTemplateOptions generateKeyPair(boolean enable) {
+ return new NovaTemplateOptions().generateKeyPair(enable);
+ }
+
+ /**
+ * @see NovaTemplateOptions#getKeyPairName()
+ */
+ public static NovaTemplateOptions keyPairName(String keyPairName) {
+ return new NovaTemplateOptions().keyPairName(keyPairName);
+ }
+
+ /**
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getSecurityGroupNames
+ */
+ public static NovaTemplateOptions securityGroupNames(String... groupNames) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.securityGroupNames(groupNames));
+ }
+
+ /**
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getSecurityGroupNames
+ */
+ public static NovaTemplateOptions securityGroupNames(Iterable<String> groupNames) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.securityGroupNames(groupNames));
+ }
+
+ // methods that only facilitate returning the correct object type
+
+ /**
+ * @see TemplateOptions#inboundPorts
+ */
+ public static NovaTemplateOptions inboundPorts(int... ports) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.inboundPorts(ports));
+ }
+
+ /**
+ * @see TemplateOptions#port
+ */
+ public static NovaTemplateOptions blockOnPort(int port, int seconds) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.blockOnPort(port, seconds));
+ }
+
+ /**
+ * @see TemplateOptions#installPrivateKey
+ */
+ public static NovaTemplateOptions installPrivateKey(String rsaKey) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.installPrivateKey(rsaKey));
+ }
+
+ /**
+ * @see TemplateOptions#authorizePublicKey
+ */
+ public static NovaTemplateOptions authorizePublicKey(String rsaKey) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.authorizePublicKey(rsaKey));
+ }
+
+ /**
+ * @see TemplateOptions#userMetadata
+ */
+ public static NovaTemplateOptions userMetadata(Map<String, String> userMetadata) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.userMetadata(userMetadata));
+ }
+
+ /**
+ * @see TemplateOptions#nodeNames(Iterable)
+ */
+ public static NovaTemplateOptions nodeNames(Iterable<String> nodeNames) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.nodeNames(nodeNames));
+ }
+
+ /**
+ * @see TemplateOptions#networks(Iterable)
+ */
+ public static NovaTemplateOptions networks(Iterable<String> networks) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.networks(networks));
+ }
+
+ /**
+ * @see TemplateOptions#overrideLoginUser
+ */
+ public static NovaTemplateOptions overrideLoginUser(String user) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return options.overrideLoginUser(user);
+ }
+
+ /**
+ * @see TemplateOptions#overrideLoginPassword
+ */
+ public static NovaTemplateOptions overrideLoginPassword(String password) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return options.overrideLoginPassword(password);
+ }
+
+ /**
+ * @see TemplateOptions#overrideLoginPrivateKey
+ */
+ public static NovaTemplateOptions overrideLoginPrivateKey(String privateKey) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return options.overrideLoginPrivateKey(privateKey);
+ }
+
+ /**
+ * @see TemplateOptions#overrideAuthenticateSudo
+ */
+ public static NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return options.overrideAuthenticateSudo(authenticateSudo);
+ }
+
+ /**
+ * @see TemplateOptions#overrideLoginCredentials
+ */
+ public static NovaTemplateOptions overrideLoginCredentials(LoginCredentials credentials) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return options.overrideLoginCredentials(credentials);
+ }
+
+ /**
+ * @see TemplateOptions#blockUntilRunning
+ */
+ public static NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return options.blockUntilRunning(blockUntilRunning);
+ }
+
+ /**
+ * @see NovaTemplateOptions#userData
+ */
+ public static NovaTemplateOptions userData(byte[] userData) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.userData(userData));
+ }
+
+ /**
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getDiskConfig()
+ */
+ public static NovaTemplateOptions diskConfig(String diskConfig) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.diskConfig(diskConfig));
+ }
+
+ /**
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getConfigDrive()
+ */
+ public static NovaTemplateOptions configDrive(boolean configDrive) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.configDrive(configDrive));
+ }
+
+ /**
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getNetworks()
+ */
+ public static NovaTemplateOptions novaNetworks(Set<Network> novaNetworks) {
+ NovaTemplateOptions options = new NovaTemplateOptions();
+ return NovaTemplateOptions.class.cast(options.novaNetworks(novaNetworks));
+ }
+ }
+
+ // methods that only facilitate returning the correct object type
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions blockOnPort(int port, int seconds) {
+ return NovaTemplateOptions.class.cast(super.blockOnPort(port, seconds));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions inboundPorts(int... ports) {
+ return NovaTemplateOptions.class.cast(super.inboundPorts(ports));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions authorizePublicKey(String publicKey) {
+ return NovaTemplateOptions.class.cast(super.authorizePublicKey(publicKey));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions installPrivateKey(String privateKey) {
+ return NovaTemplateOptions.class.cast(super.installPrivateKey(privateKey));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning) {
+ return NovaTemplateOptions.class.cast(super.blockUntilRunning(blockUntilRunning));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions dontAuthorizePublicKey() {
+ return NovaTemplateOptions.class.cast(super.dontAuthorizePublicKey());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions nameTask(String name) {
+ return NovaTemplateOptions.class.cast(super.nameTask(name));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions runAsRoot(boolean runAsRoot) {
+ return NovaTemplateOptions.class.cast(super.runAsRoot(runAsRoot));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions runScript(Statement script) {
+ return NovaTemplateOptions.class.cast(super.runScript(script));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions overrideLoginCredentials(LoginCredentials overridingCredentials) {
+ return NovaTemplateOptions.class.cast(super.overrideLoginCredentials(overridingCredentials));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions overrideLoginPassword(String password) {
+ return NovaTemplateOptions.class.cast(super.overrideLoginPassword(password));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions overrideLoginPrivateKey(String privateKey) {
+ return NovaTemplateOptions.class.cast(super.overrideLoginPrivateKey(privateKey));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions overrideLoginUser(String loginUser) {
+ return NovaTemplateOptions.class.cast(super.overrideLoginUser(loginUser));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions overrideAuthenticateSudo(boolean authenticateSudo) {
+ return NovaTemplateOptions.class.cast(super.overrideAuthenticateSudo(authenticateSudo));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions userMetadata(Map<String, String> userMetadata) {
+ return NovaTemplateOptions.class.cast(super.userMetadata(userMetadata));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions userMetadata(String key, String value) {
+ return NovaTemplateOptions.class.cast(super.userMetadata(key, value));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public NovaTemplateOptions nodeNames(Iterable<String> nodeNames) {
+ return NovaTemplateOptions.class.cast(super.nodeNames(nodeNames));
+ }
+
+ /**
+ * <br>Ensures NovaTemplateOptions can work with networks specified as Strings.
+ * Also provides for compatibility with the abstraction layer.
+ */
+ @Override
+ public NovaTemplateOptions networks(Iterable<String> networks) {
+ return NovaTemplateOptions.class.cast(super.networks(networks));
+ }
+
+ /**
+ * <br>Ensures NovaTemplateOptions can work with networks specified as Strings.
+ * Also provides for compatibility with the abstraction layer.
+ */
+ @Override
+ public NovaTemplateOptions networks(String... networks) {
+ return NovaTemplateOptions.class.cast(super.networks(networks));
+ }
+
+ /**
+ * User data as bytes (not base64-encoded)
+ */
+ public NovaTemplateOptions userData(byte[] userData) {
+ // This limit may not be needed for nova
+ checkArgument(checkNotNull(userData, "userData").length <= 16 * 1024,
+ "userData cannot be larger than 16kb");
+ this.userData = userData;
+ return this;
+ }
+
+ /**
+ * @see CreateServerOptions#getDiskConfig()
+ */
+ public NovaTemplateOptions diskConfig(String diskConfig) {
+ this.diskConfig = diskConfig;
+ return this;
+ }
+
+ /**
+ * OpenStack can be configured to write metadata to a special configuration drive that will be
+ * attached to the instance when it boots. The instance can retrieve any information that would
+ * normally be available through the metadata service by mounting this disk and reading files from it.
+ * To enable the config drive, set this parameter to "true".
+ * This has to be enabled for user data cases.
+ * @see CreateServerOptions#getConfigDrive()
+ */
+ public NovaTemplateOptions configDrive(boolean configDrive) {
+ this.configDrive = configDrive;
+ return this;
+ }
+
+ /**
+ * @param novaNetworks The list of network declarations.
+ * Nova-specific network declarations allow for specifying network UUIDs, port UUIDs, and fixed IPs.
+ * Unline {@link #networks(Iterable)} this supports setting additional network parameters and not just network UUIDs.
+ * @see CreateServerOptions#getNetworks()
+ */
+ public NovaTemplateOptions novaNetworks(Set<Network> novaNetworks) {
+ this.novaNetworks = novaNetworks;
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java
new file mode 100644
index 0000000..680a82c
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java
@@ -0,0 +1,56 @@
+/*
+ * 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.predicates;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Predicates.and;
+import static com.google.common.collect.Iterables.all;
+import static org.jclouds.compute.predicates.NodePredicates.TERMINATED;
+import static org.jclouds.compute.predicates.NodePredicates.inGroup;
+import static org.jclouds.compute.predicates.NodePredicates.locationId;
+import static org.jclouds.compute.predicates.NodePredicates.parentLocationId;
+
+import javax.inject.Inject;
+
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.domain.ComputeMetadata;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
+/**
+ * @author Adrian Cole
+ */
+public class AllNodesInGroupTerminated implements Predicate<ZoneAndName> {
+ private final ComputeService computeService;
+
+
+ //TODO: TESTME
+ @Inject
+ public AllNodesInGroupTerminated(ComputeService computeService) {
+ this.computeService = checkNotNull(computeService, "computeService");
+ }
+
+ @Override
+ public boolean apply(ZoneAndName input) {
+ // new nodes can have the zone as their location, existing nodes, the parent is the
+ // location
+ return all(computeService.listNodesDetailsMatching(Predicates.<ComputeMetadata> or(locationId(input.getZone()),
+ parentLocationId(input.getZone()))), and(inGroup(input.getName()), TERMINATED));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java
new file mode 100644
index 0000000..e3ea4cc
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java
@@ -0,0 +1,165 @@
+/*
+ * 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.strategy;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.ssh.SshKeys.fingerprintPrivateKey;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.Constants;
+import org.jclouds.compute.config.CustomizationResponse;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.compute.strategy.CreateNodeWithGroupEncodedIntoName;
+import org.jclouds.compute.strategy.CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap;
+import org.jclouds.compute.strategy.ListNodesStrategy;
+import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.compute.functions.AllocateAndAddFloatingIpToNode;
+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.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
+
+import com.google.common.base.Throwables;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.Multimap;
+import com.google.common.primitives.Ints;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet extends
+ CreateNodesWithGroupEncodedIntoNameThenAddToSet {
+
+ private final AllocateAndAddFloatingIpToNode createAndAddFloatingIpToNode;
+ private final LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache;
+ private final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
+ private final NovaApi novaApi;
+
+ @Inject
+ protected ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet(
+ CreateNodeWithGroupEncodedIntoName addNodeWithTagStrategy,
+ ListNodesStrategy listNodesStrategy,
+ GroupNamingConvention.Factory namingConvention,
+ CustomizeNodeAndAddToGoodMapOrPutExceptionIntoBadMap.Factory customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory,
+ @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
+ AllocateAndAddFloatingIpToNode createAndAddFloatingIpToNode,
+ LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupCache,
+ LoadingCache<ZoneAndName, KeyPair> keyPairCache, NovaApi novaApi) {
+ super(addNodeWithTagStrategy, listNodesStrategy, namingConvention, userExecutor,
+ customizeNodeAndAddToGoodMapOrPutExceptionIntoBadMapFactory);
+ this.securityGroupCache = checkNotNull(securityGroupCache, "securityGroupCache");
+ this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
+ this.createAndAddFloatingIpToNode = checkNotNull(createAndAddFloatingIpToNode,
+ "createAndAddFloatingIpToNode");
+ this.novaApi = checkNotNull(novaApi, "novaApi");
+ }
+
+ @Override
+ public Map<?, ListenableFuture<Void>> execute(String group, int count, Template template, Set<NodeMetadata> goodNodes,
+ Map<NodeMetadata, Exception> badNodes, Multimap<NodeMetadata, CustomizationResponse> customizationResponses) {
+
+ Template mutableTemplate = template.clone();
+
+ NovaTemplateOptions templateOptions = NovaTemplateOptions.class.cast(mutableTemplate.getOptions());
+
+ assert template.getOptions().equals(templateOptions) : "options didn't clone properly";
+
+ String zone = mutableTemplate.getLocation().getId();
+
+ if (templateOptions.shouldAutoAssignFloatingIp()) {
+ checkArgument(novaApi.getFloatingIPExtensionForZone(zone).isPresent(),
+ "Floating IPs are required by options, but the extension is not available! options: %s",
+ templateOptions);
+ }
+
+ boolean keyPairExtensionPresent = novaApi.getKeyPairExtensionForZone(zone).isPresent();
+ if (templateOptions.shouldGenerateKeyPair()) {
+ checkArgument(keyPairExtensionPresent,
+ "Key Pairs are required by options, but the extension is not available! options: %s", templateOptions);
+ KeyPair keyPair = keyPairCache.getUnchecked(ZoneAndName.fromZoneAndName(zone, namingConvention.create()
+ .sharedNameForGroup(group)));
+ keyPairCache.asMap().put(ZoneAndName.fromZoneAndName(zone, keyPair.getName()), keyPair);
+ templateOptions.keyPairName(keyPair.getName());
+ } else if (templateOptions.getKeyPairName() != null) {
+ checkArgument(keyPairExtensionPresent,
+ "Key Pairs are required by options, but the extension is not available! options: %s", templateOptions);
+ if (templateOptions.getLoginPrivateKey() != null) {
+ String pem = templateOptions.getLoginPrivateKey();
+ KeyPair keyPair = KeyPair.builder().name(templateOptions.getKeyPairName())
+ .fingerprint(fingerprintPrivateKey(pem)).privateKey(pem).build();
+ keyPairCache.asMap().put(ZoneAndName.fromZoneAndName(zone, keyPair.getName()), keyPair);
+ }
+ }
+
+ boolean securityGroupExtensionPresent = novaApi.getSecurityGroupExtensionForZone(zone).isPresent();
+ List<Integer> inboundPorts = Ints.asList(templateOptions.getInboundPorts());
+ if (templateOptions.getSecurityGroupNames().isPresent()
+ && templateOptions.getSecurityGroupNames().get().size() > 0) {
+ checkArgument(securityGroupExtensionPresent,
+ "Security groups are required by options, but the extension is not available! options: %s",
+ templateOptions);
+ } else if (securityGroupExtensionPresent) {
+ if (!templateOptions.getSecurityGroupNames().isPresent() && inboundPorts.size() > 0) {
+ String securityGroupName = namingConvention.create().sharedNameForGroup(group);
+ try {
+ securityGroupCache.get(new ZoneSecurityGroupNameAndPorts(zone, securityGroupName, inboundPorts));
+ } catch (ExecutionException e) {
+ throw Throwables.propagate(e.getCause());
+ }
+ templateOptions.securityGroupNames(securityGroupName);
+ }
+ }
+ templateOptions.userMetadata(ComputeServiceConstants.NODE_GROUP_KEY, group);
+
+ return super.execute(group, count, mutableTemplate, goodNodes, badNodes, customizationResponses);
+ }
+
+ @Override
+ protected ListenableFuture<AtomicReference<NodeMetadata>> createNodeInGroupWithNameAndTemplate(String group,
+ final String name, Template template) {
+
+ ListenableFuture<AtomicReference<NodeMetadata>> future = super.createNodeInGroupWithNameAndTemplate(group, name, template);
+ NovaTemplateOptions templateOptions = NovaTemplateOptions.class.cast(template.getOptions());
+
+ if (templateOptions.shouldAutoAssignFloatingIp()) {
+ return Futures.transform(future, createAndAddFloatingIpToNode, userExecutor);
+ } else {
+ return future;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java
new file mode 100644
index 0000000..7f31c27
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java
@@ -0,0 +1,159 @@
+/*
+ * 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.config;
+
+import java.beans.ConstructorProperties;
+import java.lang.reflect.Type;
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Singleton;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.json.config.GsonModule.DateAdapter;
+import org.jclouds.openstack.nova.v2_0.domain.Address;
+import org.jclouds.openstack.nova.v2_0.domain.HostResourceUsage;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.ServerExtendedAttributes;
+import org.jclouds.openstack.nova.v2_0.domain.ServerExtendedStatus;
+import org.jclouds.openstack.nova.v2_0.domain.ServerWithSecurityGroups;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Sets;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+
+/**
+ * @author Adrian Cole
+ * @author Adam Lowe
+ */
+public class NovaParserModule extends AbstractModule {
+
+ @Provides
+ @Singleton
+ public Map<Type, Object> provideCustomAdapterBindings() {
+ return ImmutableMap.<Type, Object>of(
+ HostResourceUsage.class, new HostResourceUsageAdapter(),
+ ServerWithSecurityGroups.class, new ServerWithSecurityGroupsAdapter(),
+ Server.class, new ServerAdapter()
+ );
+ }
+
+ @Override
+ protected void configure() {
+ bind(DateAdapter.class).to(GsonModule.Iso8601DateAdapter.class);
+ }
+
+ @Singleton
+ public static class HostResourceUsageAdapter implements JsonSerializer<HostResourceUsage>, JsonDeserializer<HostResourceUsage> {
+ public HostResourceUsage apply(HostResourceUsageView in) {
+ return in.resource.toBuilder().build();
+ }
+
+ @Override
+ public HostResourceUsage deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException {
+ return apply((HostResourceUsageView) context.deserialize(jsonElement, HostResourceUsageView.class));
+ }
+
+ @Override
+ public JsonElement serialize(HostResourceUsage hostResourceUsage, Type type, JsonSerializationContext context) {
+ return context.serialize(hostResourceUsage);
+ }
+
+ private static class HostResourceUsageView {
+ protected HostResourceUsageInternal resource;
+ }
+
+ private static class HostResourceUsageInternal extends HostResourceUsage {
+
+ @ConstructorProperties({
+ "host", "project", "memory_mb", "cpu", "disk_gb"
+ })
+ protected HostResourceUsageInternal(String host, @Nullable String project, int memoryMb, int cpu, int diskGb) {
+ super(host, project, memoryMb, cpu, diskGb);
+ }
+ }
+ }
+
+ @Singleton
+ public static class ServerWithSecurityGroupsAdapter implements JsonDeserializer<ServerWithSecurityGroups> {
+ @Override
+ public ServerWithSecurityGroups deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context)
+ throws JsonParseException {
+ Server server = context.deserialize(jsonElement, Server.class);
+ ServerWithSecurityGroups.Builder<?> result = ServerWithSecurityGroups.builder().fromServer(server);
+ Set<String> names = Sets.newLinkedHashSet();
+ if (jsonElement.getAsJsonObject().get("security_groups") != null) {
+ JsonArray x = jsonElement.getAsJsonObject().get("security_groups").getAsJsonArray();
+ for (JsonElement y : x) {
+ names.add(y.getAsJsonObject().get("name").getAsString());
+ }
+ result.securityGroupNames(names);
+ }
+ return result.build();
+ }
+ }
+
+ @Singleton
+ public static class ServerAdapter implements JsonDeserializer<Server> {
+ @Override
+ public Server deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context)
+ throws JsonParseException {
+ Server serverBase = apply((ServerInternal) context.deserialize(jsonElement, ServerInternal.class));
+ Server.Builder<?> result = Server.builder().fromServer(serverBase);
+ ServerExtendedStatus extendedStatus = context.deserialize(jsonElement, ServerExtendedStatus.class);
+ if (!Objects.equal(extendedStatus, ServerExtendedStatus.builder().build())) {
+ result.extendedStatus(extendedStatus);
+ }
+ ServerExtendedAttributes extraAttributes = context.deserialize(jsonElement, ServerExtendedAttributes.class);
+ if (!Objects.equal(extraAttributes, ServerExtendedAttributes.builder().build())) {
+ result.extendedAttributes(extraAttributes);
+ }
+ return result.build();
+ }
+
+ public Server apply(ServerInternal in) {
+ return in.toBuilder().build();
+ }
+
+ private static class ServerInternal extends Server {
+ @ConstructorProperties({
+ "id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "image", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig"
+ })
+ protected ServerInternal(String id, @Nullable String name, java.util.Set<Link> links, @Nullable String uuid, String tenantId,
+ String userId, Date updated, Date created, @Nullable String hostId, @Nullable String accessIPv4,
+ @Nullable String accessIPv6, Server.Status status, Resource image, Resource flavor, @Nullable String keyName,
+ @Nullable String configDrive, Multimap<String, Address> addresses, Map<String, String> metadata,
+ @Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes, @Nullable String diskConfig) {
+ super(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6, status, image, flavor, keyName, configDrive, addresses, metadata, extendedStatus, extendedAttributes, diskConfig);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.java
new file mode 100644
index 0000000..9b55439
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.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.config;
+
+/**
+ * Configuration properties and constants used in openstack Nova connections.
+ *
+ * @author Adam Lowe
+ */
+public class NovaProperties {
+
+ /**
+ * Eventual consistency delay for retrieving a security group after it is created (in ms)
+ */
+ public static final String TIMEOUT_SECURITYGROUP_PRESENT = "jclouds.openstack-nova.timeout.securitygroup-present";
+
+ /**
+ * Whenever a node is created, automatically create and assign a floating ip address, also
+ * delete when the node is destroyed.
+ */
+ public static final String AUTO_ALLOCATE_FLOATING_IPS = "jclouds.openstack-nova.auto-create-floating-ips";
+
+ /**
+ * Whenever a node is created, automatically generate keypairs for groups, as needed, also
+ * delete the keypair(s) when the last node in the group is destroyed.
+ */
+ public static final String AUTO_GENERATE_KEYPAIRS = "jclouds.openstack-nova.auto-generate-keypairs";
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java
new file mode 100644
index 0000000..556ec60
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java
@@ -0,0 +1,191 @@
+/*
+ * 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.config;
+import static org.jclouds.reflect.Reflection2.typeToken;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.annotation.ClientError;
+import org.jclouds.http.annotation.Redirection;
+import org.jclouds.http.annotation.ServerError;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneAPI;
+import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces;
+import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsApi;
+import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
+import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationApi;
+import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateApi;
+import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
+import org.jclouds.openstack.nova.v2_0.extensions.KeyPairAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.QuotaApi;
+import org.jclouds.openstack.nova.v2_0.extensions.QuotaAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassApi;
+import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
+import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ServerAdminApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ServerAdminAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageApi;
+import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeAttachmentApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeAttachmentAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeAsyncApi;
+import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
+import org.jclouds.openstack.nova.v2_0.features.FlavorAsyncApi;
+import org.jclouds.openstack.nova.v2_0.features.ImageApi;
+import org.jclouds.openstack.nova.v2_0.features.ImageAsyncApi;
+import org.jclouds.openstack.nova.v2_0.features.ServerApi;
+import org.jclouds.openstack.nova.v2_0.features.ServerAsyncApi;
+import org.jclouds.openstack.nova.v2_0.handlers.NovaErrorHandler;
+import org.jclouds.openstack.v2_0.domain.Extension;
+import org.jclouds.openstack.v2_0.features.ExtensionApi;
+import org.jclouds.openstack.v2_0.features.ExtensionAsyncApi;
+import org.jclouds.openstack.v2_0.functions.PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet;
+import org.jclouds.rest.ConfiguresRestClient;
+import org.jclouds.rest.config.RestClientModule;
+import org.jclouds.rest.functions.ImplicitOptionalConverter;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.Multimap;
+import com.google.common.reflect.TypeToken;
+import com.google.inject.Provides;
+
+/**
+ * Configures the Nova connection.
+ *
+ * @author Adrian Cole
+ */
+@ConfiguresRestClient
+public class NovaRestClientModule<S extends NovaApi, A extends NovaAsyncApi> extends RestClientModule<S, A> {
+
+ public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()
+ .put(ServerApi.class, ServerAsyncApi.class)
+ .put(FlavorApi.class, FlavorAsyncApi.class)
+ .put(ImageApi.class, ImageAsyncApi.class)
+ .put(ExtensionApi.class, ExtensionAsyncApi.class)
+ .put(FloatingIPApi.class, FloatingIPAsyncApi.class)
+ .put(AvailabilityZoneAPI.class, AvailabilityZoneAsyncApi.class)
+ .put(SecurityGroupApi.class, SecurityGroupAsyncApi.class)
+ .put(KeyPairApi.class, KeyPairAsyncApi.class)
+ .put(HostAdministrationApi.class, HostAdministrationAsyncApi.class)
+ .put(SimpleTenantUsageApi.class, SimpleTenantUsageAsyncApi.class)
+ .put(VirtualInterfaceApi.class, VirtualInterfaceAsyncApi.class)
+ .put(ServerWithSecurityGroupsApi.class, ServerWithSecurityGroupsAsyncApi.class)
+ .put(ServerAdminApi.class, ServerAdminAsyncApi.class)
+ .put(HostAggregateApi.class, HostAggregateAsyncApi.class)
+ .put(FlavorExtraSpecsApi.class, FlavorExtraSpecsAsyncApi.class)
+ .put(QuotaApi.class, QuotaAsyncApi.class)
+ .put(QuotaClassApi.class, QuotaClassAsyncApi.class)
+ .put(VolumeApi.class, VolumeAsyncApi.class)
+ .put(VolumeAttachmentApi.class, VolumeAttachmentAsyncApi.class)
+ .put(VolumeTypeApi.class, VolumeTypeAsyncApi.class)
+ .build();
+
+ @SuppressWarnings("unchecked")
+ public NovaRestClientModule() {
+ super(TypeToken.class.cast(typeToken(NovaApi.class)), TypeToken.class.cast(typeToken(NovaAsyncApi.class)), DELEGATE_MAP);
+ }
+
+ protected NovaRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType,
+ Map<Class<?>, Class<?>> sync2Async) {
+ super(syncClientType, asyncClientType, sync2Async);
+ }
+
+ @Override
+ protected void configure() {
+ bind(ImplicitOptionalConverter.class).to(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class);
+ super.configure();
+ }
+
+ @Provides
+ @Singleton
+ public Multimap<URI, URI> aliases() {
+ return ImmutableMultimap.<URI, URI>builder()
+ .put(URI.create(ExtensionNamespaces.SECURITY_GROUPS),
+ URI.create("http://docs.openstack.org/compute/ext/securitygroups/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.FLOATING_IPS),
+ URI.create("http://docs.openstack.org/compute/ext/floating_ips/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.KEYPAIRS),
+ URI.create("http://docs.openstack.org/compute/ext/keypairs/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.SIMPLE_TENANT_USAGE),
+ URI.create("http://docs.openstack.org/compute/ext/os-simple-tenant-usage/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.HOSTS),
+ URI.create("http://docs.openstack.org/compute/ext/hosts/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.VOLUMES),
+ URI.create("http://docs.openstack.org/compute/ext/volumes/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.VIRTUAL_INTERFACES),
+ URI.create("http://docs.openstack.org/compute/ext/virtual_interfaces/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.CREATESERVEREXT),
+ URI.create("http://docs.openstack.org/compute/ext/createserverext/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.ADMIN_ACTIONS),
+ URI.create("http://docs.openstack.org/compute/ext/admin-actions/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.AGGREGATES),
+ URI.create("http://docs.openstack.org/compute/ext/aggregates/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.FLAVOR_EXTRA_SPECS),
+ URI.create("http://docs.openstack.org/compute/ext/flavor_extra_specs/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.QUOTAS),
+ URI.create("http://docs.openstack.org/compute/ext/quotas-sets/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.QUOTA_CLASSES),
+ URI.create("http://docs.openstack.org/compute/ext/quota-classes-sets/api/v1.1"))
+ .put(URI.create(ExtensionNamespaces.VOLUME_TYPES),
+ URI.create("http://docs.openstack.org/compute/ext/volume_types/api/v1.1"))
+ .build();
+ }
+
+ @Provides
+ @Singleton
+ public LoadingCache<String, Set<? extends Extension>> provideExtensionsByZone(final Provider<NovaApi> novaApi) {
+ return CacheBuilder.newBuilder().expireAfterWrite(23, TimeUnit.HOURS)
+ .build(new CacheLoader<String, Set<? extends Extension>>() {
+ @Override
+ public Set<? extends Extension> load(String key) throws Exception {
+ return novaApi.get().getExtensionApiForZone(key).list();
+ }
+ });
+ }
+
+ @Override
+ protected void bindErrorHandlers() {
+ bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(NovaErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(NovaErrorHandler.class);
+ bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(NovaErrorHandler.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.java
new file mode 100644
index 0000000..38c744d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.java
@@ -0,0 +1,138 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * IP address
+ *
+ * @author AdrianCole
+*/
+public class Address {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromAddress(this);
+ }
+
+ public static Address createV4(String addr) {
+ return builder().version(4).addr(addr).build();
+ }
+
+ public static Address createV6(String addr) {
+ return builder().version(6).addr(addr).build();
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String addr;
+ protected int version;
+
+ /**
+ * @see Address#getAddr()
+ */
+ public T addr(String addr) {
+ this.addr = addr;
+ return self();
+ }
+
+ /**
+ * @see Address#getVersion()
+ */
+ public T version(int version) {
+ this.version = version;
+ return self();
+ }
+
+ public Address build() {
+ return new Address(addr, version);
+ }
+
+ public T fromAddress(Address in) {
+ return this
+ .addr(in.getAddr())
+ .version(in.getVersion());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String addr;
+ private final int version;
+
+ @ConstructorProperties({
+ "addr", "version"
+ })
+ protected Address(String addr, int version) {
+ this.addr = checkNotNull(addr, "addr");
+ this.version = version;
+ }
+
+ /**
+ * @return the ip address
+ */
+ public String getAddr() {
+ return this.addr;
+ }
+
+ /**
+ * @return the IP version, ex. 4
+ */
+ public int getVersion() {
+ return this.version;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(addr, version);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Address that = Address.class.cast(obj);
+ return Objects.equal(this.addr, that.addr)
+ && Objects.equal(this.version, that.version);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("addr", addr).add("version", version);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java
new file mode 100644
index 0000000..97460d8
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java
@@ -0,0 +1,41 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.CaseFormat;
+
+/**
+ * @author Adam Lowe
+ */
+public enum BackupType {
+ DAILY, WEEKLY;
+
+ public String value() {
+ return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static BackupType fromValue(String backupType) {
+ return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(backupType, "backupType")));
+ }
+}
[19/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java
new file mode 100644
index 0000000..311d4ab
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java
@@ -0,0 +1,286 @@
+/*
+ * 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.config;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS;
+import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.AUTO_GENERATE_KEYPAIRS;
+import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.TIMEOUT_SECURITYGROUP_PRESENT;
+import static org.jclouds.util.Predicates2.retry;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.ComputeServiceAdapter;
+import org.jclouds.compute.config.ComputeServiceAdapterContextModule;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.compute.extensions.ImageExtension;
+import org.jclouds.compute.extensions.SecurityGroupExtension;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.functions.IdentityFunction;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.openstack.nova.v2_0.compute.NovaComputeService;
+import org.jclouds.openstack.nova.v2_0.compute.NovaComputeServiceAdapter;
+import org.jclouds.openstack.nova.v2_0.compute.extensions.NovaImageExtension;
+import org.jclouds.openstack.nova.v2_0.compute.extensions.NovaSecurityGroupExtension;
+import org.jclouds.openstack.nova.v2_0.compute.functions.CreateSecurityGroupIfNeeded;
+import org.jclouds.openstack.nova.v2_0.compute.functions.FlavorInZoneToHardware;
+import org.jclouds.openstack.nova.v2_0.compute.functions.ImageInZoneToImage;
+import org.jclouds.openstack.nova.v2_0.compute.functions.ImageToOperatingSystem;
+import org.jclouds.openstack.nova.v2_0.compute.functions.NovaSecurityGroupInZoneToSecurityGroup;
+import org.jclouds.openstack.nova.v2_0.compute.functions.NovaSecurityGroupToSecurityGroup;
+import org.jclouds.openstack.nova.v2_0.compute.functions.OrphanedGroupsByZoneId;
+import org.jclouds.openstack.nova.v2_0.compute.functions.SecurityGroupRuleToIpPermission;
+import org.jclouds.openstack.nova.v2_0.compute.functions.ServerInZoneToNodeMetadata;
+import org.jclouds.openstack.nova.v2_0.compute.loaders.CreateUniqueKeyPair;
+import org.jclouds.openstack.nova.v2_0.compute.loaders.FindSecurityGroupOrCreate;
+import org.jclouds.openstack.nova.v2_0.compute.loaders.LoadFloatingIpsForInstance;
+import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
+import org.jclouds.openstack.nova.v2_0.compute.strategy.ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet;
+import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
+import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.FlavorInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ImageInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
+import org.jclouds.openstack.nova.v2_0.predicates.FindSecurityGroupWithNameAndReturnTrue;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import com.google.inject.Provides;
+import com.google.inject.TypeLiteral;
+import com.google.inject.name.Names;
+
+/**
+ * Module for building a compute service context for Nova
+ *
+ * @author Matt Stephenson
+ */
+public class NovaComputeServiceContextModule extends
+ ComputeServiceAdapterContextModule<ServerInZone, FlavorInZone, ImageInZone, Location> {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void configure() {
+ super.configure();
+ bind(new TypeLiteral<ComputeServiceAdapter<ServerInZone, FlavorInZone, ImageInZone, Location>>() {
+ }).to(NovaComputeServiceAdapter.class);
+
+ bind(ComputeService.class).to(NovaComputeService.class);
+
+ bind(new TypeLiteral<Function<ServerInZone, NodeMetadata>>() {
+ }).to(ServerInZoneToNodeMetadata.class);
+
+ bind(new TypeLiteral<Function<SecurityGroupRule, IpPermission>>() {
+ }).to(SecurityGroupRuleToIpPermission.class);
+
+ bind(new TypeLiteral<Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroup>>() {
+ }).to(NovaSecurityGroupToSecurityGroup.class);
+
+ bind(new TypeLiteral<Function<SecurityGroupInZone, SecurityGroup>>() {
+ }).to(NovaSecurityGroupInZoneToSecurityGroup.class);
+
+ bind(new TypeLiteral<Function<Set<? extends NodeMetadata>, Multimap<String, String>>>() {
+ }).to(OrphanedGroupsByZoneId.class);
+
+ bind(new TypeLiteral<Function<ImageInZone, Image>>() {
+ }).to(ImageInZoneToImage.class);
+ bind(new TypeLiteral<Function<org.jclouds.openstack.nova.v2_0.domain.Image, OperatingSystem>>() {
+ }).to(ImageToOperatingSystem.class);
+
+ bind(new TypeLiteral<Function<FlavorInZone, Hardware>>() {
+ }).to(FlavorInZoneToHardware.class);
+
+ // we aren't converting location from a provider-specific type
+ bind(new TypeLiteral<Function<Location, Location>>() {
+ }).to(Class.class.cast(IdentityFunction.class));
+
+ bind(TemplateOptions.class).to(NovaTemplateOptions.class);
+
+ bind(new TypeLiteral<CacheLoader<ZoneAndId, Iterable<? extends FloatingIP>>>() {
+ }).annotatedWith(Names.named("FLOATINGIP")).to(LoadFloatingIpsForInstance.class);
+
+ bind(new TypeLiteral<Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone>>() {
+ }).to(CreateSecurityGroupIfNeeded.class);
+
+ bind(new TypeLiteral<CacheLoader<ZoneAndName, SecurityGroupInZone>>() {
+ }).to(FindSecurityGroupOrCreate.class);
+
+ bind(CreateNodesWithGroupEncodedIntoNameThenAddToSet.class).to(
+ ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.class);
+
+ bind(new TypeLiteral<CacheLoader<ZoneAndName, KeyPair>>() {
+ }).to(CreateUniqueKeyPair.class);
+
+ bind(new TypeLiteral<ImageExtension>() {
+ }).to(NovaImageExtension.class);
+
+ bind(new TypeLiteral<SecurityGroupExtension>() {
+ }).to(NovaSecurityGroupExtension.class);
+ }
+
+ @Override
+ protected TemplateOptions provideTemplateOptions(Injector injector, TemplateOptions options) {
+ return options.as(NovaTemplateOptions.class)
+ .autoAssignFloatingIp(injector.getInstance(
+ Key.get(boolean.class, Names.named(AUTO_ALLOCATE_FLOATING_IPS))))
+ .generateKeyPair(injector.getInstance(
+ Key.get(boolean.class, Names.named(AUTO_GENERATE_KEYPAIRS))));
+ }
+
+ @Provides
+ @Singleton
+ @Named("FLOATINGIP")
+ protected LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> instanceToFloatingIps(
+ @Named("FLOATINGIP") CacheLoader<ZoneAndId, Iterable<? extends FloatingIP>> in) {
+ return CacheBuilder.newBuilder().build(in);
+ }
+
+ @Provides
+ @Singleton
+ protected LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupMap(
+ CacheLoader<ZoneAndName, SecurityGroupInZone> in) {
+ return CacheBuilder.newBuilder().build(in);
+ }
+
+ @Override
+ protected Map<OsFamily, LoginCredentials> osFamilyToCredentials(Injector injector) {
+ return ImmutableMap.of(OsFamily.WINDOWS, LoginCredentials.builder().user("Administrator").build(),
+ OsFamily.UBUNTU, LoginCredentials.builder().user("ubuntu").build());
+ }
+
+ @Provides
+ @Singleton
+ @Named("SECURITYGROUP_PRESENT")
+ protected Predicate<AtomicReference<ZoneAndName>> securityGroupEventualConsistencyDelay(
+ FindSecurityGroupWithNameAndReturnTrue in,
+ @Named(TIMEOUT_SECURITYGROUP_PRESENT) long msDelay) {
+ return retry(in, msDelay, 100l, MILLISECONDS);
+ }
+
+ @Provides
+ @Singleton
+ protected LoadingCache<ZoneAndName, KeyPair> keyPairMap(
+ CacheLoader<ZoneAndName, KeyPair> in) {
+ return CacheBuilder.newBuilder().build(in);
+ }
+
+ @Provides
+ @Singleton
+ protected Supplier<Map<String, Location>> createLocationIndexedById(
+ @Memoized Supplier<Set<? extends Location>> locations) {
+ return Suppliers.compose(new Function<Set<? extends Location>, Map<String, Location>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Map<String, Location> apply(Set<? extends Location> arg0) {
+ // TODO: find a nice way to get rid of this cast.
+ Iterable<Location> locations = (Iterable<Location>) arg0;
+ return Maps.uniqueIndex(locations, new Function<Location, String>() {
+
+ @Override
+ public String apply(Location arg0) {
+ return arg0.getId();
+ }
+
+ });
+ }
+ }, locations);
+
+ }
+
+ @VisibleForTesting
+ public static final Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus = ImmutableMap
+ .<Server.Status, NodeMetadata.Status> builder().put(Server.Status.ACTIVE, NodeMetadata.Status.RUNNING)//
+ .put(Server.Status.SUSPENDED, NodeMetadata.Status.SUSPENDED)//
+ .put(Server.Status.DELETED, NodeMetadata.Status.TERMINATED)//
+ .put(Server.Status.PAUSED, NodeMetadata.Status.SUSPENDED)//
+ .put(Server.Status.RESIZE, NodeMetadata.Status.PENDING)//
+ .put(Server.Status.VERIFY_RESIZE, NodeMetadata.Status.PENDING)//
+ .put(Server.Status.REVERT_RESIZE, NodeMetadata.Status.PENDING)//
+ .put(Server.Status.BUILD, NodeMetadata.Status.PENDING)//
+ .put(Server.Status.PASSWORD, NodeMetadata.Status.PENDING)//
+ .put(Server.Status.REBUILD, NodeMetadata.Status.PENDING)//
+ .put(Server.Status.ERROR, NodeMetadata.Status.ERROR)//
+ .put(Server.Status.REBOOT, NodeMetadata.Status.PENDING)//
+ .put(Server.Status.HARD_REBOOT, NodeMetadata.Status.PENDING)//
+ .put(Server.Status.UNKNOWN, NodeMetadata.Status.UNRECOGNIZED)//
+ .put(Server.Status.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED).build();
+
+ @Singleton
+ @Provides
+ protected Map<Server.Status, NodeMetadata.Status> toPortableNodeStatus() {
+ return toPortableNodeStatus;
+ }
+
+ @VisibleForTesting
+ public static final Map<org.jclouds.openstack.nova.v2_0.domain.Image.Status, Image.Status> toPortableImageStatus = ImmutableMap
+ .<org.jclouds.openstack.nova.v2_0.domain.Image.Status, Image.Status> builder()
+ .put(org.jclouds.openstack.nova.v2_0.domain.Image.Status.ACTIVE, Image.Status.AVAILABLE)
+ .put(org.jclouds.openstack.nova.v2_0.domain.Image.Status.SAVING, Image.Status.PENDING)
+ .put(org.jclouds.openstack.nova.v2_0.domain.Image.Status.DELETED, Image.Status.DELETED)
+ .put(org.jclouds.openstack.nova.v2_0.domain.Image.Status.ERROR, Image.Status.ERROR)
+ .put(org.jclouds.openstack.nova.v2_0.domain.Image.Status.UNKNOWN, Image.Status.UNRECOGNIZED)
+ .put(org.jclouds.openstack.nova.v2_0.domain.Image.Status.UNRECOGNIZED, Image.Status.UNRECOGNIZED).build();
+
+ @Singleton
+ @Provides
+ protected Map<org.jclouds.openstack.nova.v2_0.domain.Image.Status, Image.Status> toPortableImageStatus() {
+ return toPortableImageStatus;
+ }
+
+ @Override
+ protected Optional<ImageExtension> provideImageExtension(Injector i) {
+ return Optional.of(i.getInstance(ImageExtension.class));
+ }
+
+ @Override
+ protected Optional<SecurityGroupExtension> provideSecurityGroupExtension(Injector i) {
+ return Optional.of(i.getInstance(SecurityGroupExtension.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java
new file mode 100644
index 0000000..f8fd4d9
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java
@@ -0,0 +1,140 @@
+/*
+ * 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 com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.Iterables.find;
+import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_IMAGE_AVAILABLE;
+import static org.jclouds.location.predicates.LocationPredicates.idEquals;
+
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.Constants;
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.domain.CloneImageTemplate;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.ImageBuilder;
+import org.jclouds.compute.domain.ImageTemplate;
+import org.jclouds.compute.domain.ImageTemplateBuilder;
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.compute.extensions.ImageExtension;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.domain.Location;
+import org.jclouds.logging.Logger;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.util.concurrent.Atomics;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.UncheckedTimeoutException;
+
+/**
+ * Nova implementation of {@link ImageExtension}
+ *
+ * @author David Alves
+ *
+ */
+@Singleton
+public class NovaImageExtension implements ImageExtension {
+
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ private final NovaApi novaApi;
+ private final ListeningExecutorService userExecutor;
+ private final Supplier<Set<? extends Location>> locations;
+ private final Predicate<AtomicReference<Image>> imageAvailablePredicate;
+
+ @Inject
+ public NovaImageExtension(NovaApi novaApi, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
+ @Memoized Supplier<Set<? extends Location>> locations,
+ @Named(TIMEOUT_IMAGE_AVAILABLE) Predicate<AtomicReference<Image>> imageAvailablePredicate) {
+ this.novaApi = checkNotNull(novaApi, "novaApi");
+ this.userExecutor = checkNotNull(userExecutor, "userExecutor");
+ this.locations = checkNotNull(locations, "locations");
+ this.imageAvailablePredicate = checkNotNull(imageAvailablePredicate, "imageAvailablePredicate");
+ }
+
+ @Override
+ public ImageTemplate buildImageTemplateFromNode(String name, final String id) {
+ ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
+ Server server = novaApi.getServerApiForZone(zoneAndId.getZone()).get(zoneAndId.getId());
+ if (server == null)
+ throw new NoSuchElementException("Cannot find server with id: " + zoneAndId);
+ CloneImageTemplate template = new ImageTemplateBuilder.CloneImageTemplateBuilder().nodeId(id).name(name).build();
+ return template;
+ }
+
+ @Override
+ public ListenableFuture<Image> createImage(ImageTemplate template) {
+ checkState(template instanceof CloneImageTemplate,
+ " openstack-nova only supports creating images through cloning.");
+ CloneImageTemplate cloneTemplate = (CloneImageTemplate) template;
+ ZoneAndId sourceImageZoneAndId = ZoneAndId.fromSlashEncoded(cloneTemplate.getSourceNodeId());
+
+ String newImageId = novaApi.getServerApiForZone(sourceImageZoneAndId.getZone()).createImageFromServer(
+ cloneTemplate.getName(), sourceImageZoneAndId.getId());
+
+ final ZoneAndId targetImageZoneAndId = ZoneAndId.fromZoneAndId(sourceImageZoneAndId.getZone(), newImageId);
+
+ logger.info(">> Registered new Image %s, waiting for it to become available.", newImageId);
+
+ final AtomicReference<Image> image = Atomics.newReference(new ImageBuilder()
+ .location(find(locations.get(), idEquals(targetImageZoneAndId.getZone())))
+ .id(targetImageZoneAndId.slashEncode())
+ .providerId(targetImageZoneAndId.getId())
+ .description(cloneTemplate.getName())
+ .operatingSystem(OperatingSystem.builder().description(cloneTemplate.getName()).build())
+ .status(Image.Status.PENDING).build());
+
+ return userExecutor.submit(new Callable<Image>() {
+ @Override
+ public Image call() throws Exception {
+ if (imageAvailablePredicate.apply(image))
+ return image.get();
+ // TODO: get rid of the expectation that the image will be available, as it is very brittle
+ throw new UncheckedTimeoutException("Image was not created within the time limit: " + image.get());
+ }
+ });
+ }
+
+ @Override
+ public boolean deleteImage(String id) {
+ ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
+ try {
+ this.novaApi.getImageApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
+ } catch (Exception e) {
+ return false;
+ }
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtension.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtension.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtension.java
new file mode 100644
index 0000000..8b36fc9
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtension.java
@@ -0,0 +1,373 @@
+/*
+ * 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 com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Predicates.and;
+import static com.google.common.base.Predicates.notNull;
+import static com.google.common.collect.Iterables.concat;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.transform;
+import static org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates.nameIn;
+import static org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates.ruleCidr;
+import static org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates.ruleEndPort;
+import static org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates.ruleGroup;
+import static org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates.ruleProtocol;
+import static org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates.ruleStartPort;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.Constants;
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.compute.extensions.SecurityGroupExtension;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.domain.Location;
+import org.jclouds.location.Zone;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.Ingress;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+import org.jclouds.openstack.nova.v2_0.domain.ServerWithSecurityGroups;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
+import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsApi;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.base.Supplier;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Multimap;
+import com.google.common.util.concurrent.ListeningExecutorService;
+
+/**
+ * An extension to compute service to allow for the manipulation of {@link org.jclouds.compute.domain.SecurityGroup}s. Implementation
+ * is optional by providers.
+ *
+ * @author Andrew Bayer
+ */
+public class NovaSecurityGroupExtension implements SecurityGroupExtension {
+
+ protected final NovaApi api;
+ protected final ListeningExecutorService userExecutor;
+ protected final Supplier<Set<String>> zoneIds;
+ protected final Function<SecurityGroupInZone, SecurityGroup> groupConverter;
+ protected final LoadingCache<ZoneAndName, SecurityGroupInZone> groupCreator;
+ protected final GroupNamingConvention.Factory namingConvention;
+
+ @Inject
+ public NovaSecurityGroupExtension(NovaApi api,
+ @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
+ @Zone Supplier<Set<String>> zoneIds,
+ Function<SecurityGroupInZone, SecurityGroup> groupConverter,
+ LoadingCache<ZoneAndName, SecurityGroupInZone> groupCreator,
+ GroupNamingConvention.Factory namingConvention) {
+
+ this.api = checkNotNull(api, "api");
+ this.userExecutor = checkNotNull(userExecutor, "userExecutor");
+ this.zoneIds = checkNotNull(zoneIds, "zoneIds");
+ this.groupConverter = checkNotNull(groupConverter, "groupConverter");
+ this.groupCreator = checkNotNull(groupCreator, "groupCreator");
+ this.namingConvention = checkNotNull(namingConvention, "namingConvention");
+ }
+
+ @Override
+ public Set<SecurityGroup> listSecurityGroups() {
+ Iterable<? extends SecurityGroupInZone> rawGroups = pollSecurityGroups();
+ Iterable<SecurityGroup> groups = transform(filter(rawGroups, notNull()),
+ groupConverter);
+ return ImmutableSet.copyOf(groups);
+ }
+
+
+ @Override
+ public Set<SecurityGroup> listSecurityGroupsInLocation(final Location location) {
+ String zone = location.getId();
+ if (zone == null) {
+ return ImmutableSet.of();
+ }
+ return listSecurityGroupsInLocation(zone);
+ }
+
+ public Set<SecurityGroup> listSecurityGroupsInLocation(String zone) {
+ Iterable<? extends SecurityGroupInZone> rawGroups = pollSecurityGroupsByZone(zone);
+ Iterable<SecurityGroup> groups = transform(filter(rawGroups, notNull()),
+ groupConverter);
+ return ImmutableSet.copyOf(groups);
+ }
+
+ @Override
+ public Set<SecurityGroup> listSecurityGroupsForNode(String id) {
+ ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(checkNotNull(id, "id"));
+ String zone = zoneAndId.getZone();
+ String instanceId = zoneAndId.getId();
+
+ Optional<? extends ServerWithSecurityGroupsApi> serverApi = api.getServerWithSecurityGroupsExtensionForZone(zone);
+ Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupExtensionForZone(zone);
+
+ if (!serverApi.isPresent() || !sgApi.isPresent()) {
+ return ImmutableSet.of();
+ }
+
+ ServerWithSecurityGroups instance = serverApi.get().get(instanceId);
+ if (instance == null) {
+ return ImmutableSet.of();
+ }
+
+ Set<String> groupNames = instance.getSecurityGroupNames();
+ Set<? extends SecurityGroupInZone> rawGroups =
+ sgApi.get().list().filter(nameIn(groupNames)).transform(groupToGroupInZone(zone)).toSet();
+
+ return ImmutableSet.copyOf(transform(filter(rawGroups, notNull()), groupConverter));
+ }
+
+ @Override
+ public SecurityGroup getSecurityGroupById(String id) {
+ ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(checkNotNull(id, "id"));
+ String zone = zoneAndId.getZone();
+ String groupId = zoneAndId.getId();
+
+ Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupExtensionForZone(zone);
+
+ if (!sgApi.isPresent()) {
+ return null;
+ }
+
+ SecurityGroupInZone rawGroup = new SecurityGroupInZone(sgApi.get().get(groupId), zone);
+
+ return groupConverter.apply(rawGroup);
+ }
+
+ @Override
+ public SecurityGroup createSecurityGroup(String name, Location location) {
+ String zone = location.getId();
+ if (zone == null) {
+ return null;
+ }
+ return createSecurityGroup(name, zone);
+ }
+
+ public SecurityGroup createSecurityGroup(String name, String zone) {
+ String markerGroup = namingConvention.create().sharedNameForGroup(name);
+ ZoneSecurityGroupNameAndPorts zoneAndName = new ZoneSecurityGroupNameAndPorts(zone, markerGroup, ImmutableSet.<Integer> of());
+
+ SecurityGroupInZone rawGroup = groupCreator.apply(zoneAndName);
+ return groupConverter.apply(rawGroup);
+ }
+
+ @Override
+ public boolean removeSecurityGroup(String id) {
+ checkNotNull(id, "id");
+ ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
+ String zone = zoneAndId.getZone();
+ String groupId = zoneAndId.getId();
+
+ Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupExtensionForZone(zone);
+
+ if (!sgApi.isPresent()) {
+ return false;
+ }
+
+ if (sgApi.get().get(groupId) == null) {
+ return false;
+ }
+
+ sgApi.get().delete(groupId);
+ // TODO: test this clear happens
+ groupCreator.invalidate(new ZoneSecurityGroupNameAndPorts(zone, groupId, ImmutableSet.<Integer> of()));
+ return true;
+ }
+
+ @Override
+ public SecurityGroup addIpPermission(IpPermission ipPermission, SecurityGroup group) {
+ String zone = group.getLocation().getId();
+ ZoneAndId groupZoneAndId = ZoneAndId.fromSlashEncoded(group.getId());
+ String id = groupZoneAndId.getId();
+ Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupExtensionForZone(zone);
+
+ if (!sgApi.isPresent()) {
+ return null;
+ }
+
+ if (ipPermission.getCidrBlocks().size() > 0) {
+ for (String cidr : ipPermission.getCidrBlocks()) {
+ sgApi.get().createRuleAllowingCidrBlock(id,
+ Ingress.builder()
+ .ipProtocol(ipPermission.getIpProtocol())
+ .fromPort(ipPermission.getFromPort())
+ .toPort(ipPermission.getToPort())
+ .build(),
+ cidr);
+ }
+ }
+
+ if (ipPermission.getGroupIds().size() > 0) {
+ for (String zoneAndGroupRaw : ipPermission.getGroupIds()) {
+ ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(zoneAndGroupRaw);
+ String groupId = zoneAndId.getId();
+ sgApi.get().createRuleAllowingSecurityGroupId(id,
+ Ingress.builder()
+ .ipProtocol(ipPermission.getIpProtocol())
+ .fromPort(ipPermission.getFromPort())
+ .toPort(ipPermission.getToPort())
+ .build(),
+ groupId);
+ }
+ }
+
+ return getSecurityGroupById(ZoneAndId.fromZoneAndId(zone, id).slashEncode());
+ }
+
+ @Override
+ public SecurityGroup addIpPermission(IpProtocol protocol, int startPort, int endPort,
+ Multimap<String, String> tenantIdGroupNamePairs,
+ Iterable<String> ipRanges,
+ Iterable<String> groupIds, SecurityGroup group) {
+ IpPermission.Builder permBuilder = IpPermission.builder();
+ permBuilder.ipProtocol(protocol);
+ permBuilder.fromPort(startPort);
+ permBuilder.toPort(endPort);
+ permBuilder.tenantIdGroupNamePairs(tenantIdGroupNamePairs);
+ permBuilder.cidrBlocks(ipRanges);
+ permBuilder.groupIds(groupIds);
+
+ return addIpPermission(permBuilder.build(), group);
+ }
+
+ @Override
+ public SecurityGroup removeIpPermission(IpPermission ipPermission, SecurityGroup group) {
+ String zone = group.getLocation().getId();
+ ZoneAndId groupZoneAndId = ZoneAndId.fromSlashEncoded(group.getId());
+ String id = groupZoneAndId.getId();
+
+ Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupExtensionForZone(zone);
+
+ if (!sgApi.isPresent()) {
+ return null;
+ }
+
+ org.jclouds.openstack.nova.v2_0.domain.SecurityGroup securityGroup = sgApi.get().get(id);
+
+ if (ipPermission.getCidrBlocks().size() > 0) {
+ for (String cidr : ipPermission.getCidrBlocks()) {
+ for (SecurityGroupRule rule : filter(securityGroup.getRules(),
+ and(ruleCidr(cidr), ruleProtocol(ipPermission.getIpProtocol()),
+ ruleStartPort(ipPermission.getFromPort()),
+ ruleEndPort(ipPermission.getToPort())))) {
+ sgApi.get().deleteRule(rule.getId());
+ }
+ }
+ }
+
+ if (ipPermission.getGroupIds().size() > 0) {
+ for (String groupId : ipPermission.getGroupIds()) {
+ for (SecurityGroupRule rule : filter(securityGroup.getRules(),
+ and(ruleGroup(groupId), ruleProtocol(ipPermission.getIpProtocol()),
+ ruleStartPort(ipPermission.getFromPort()),
+ ruleEndPort(ipPermission.getToPort())))) {
+ sgApi.get().deleteRule(rule.getId());
+ }
+
+ }
+ }
+
+ return getSecurityGroupById(ZoneAndId.fromZoneAndId(zone, id).slashEncode());
+ }
+
+ @Override
+ public SecurityGroup removeIpPermission(IpProtocol protocol, int startPort, int endPort,
+ Multimap<String, String> tenantIdGroupNamePairs,
+ Iterable<String> ipRanges,
+ Iterable<String> groupIds, SecurityGroup group) {
+ IpPermission.Builder permBuilder = IpPermission.builder();
+ permBuilder.ipProtocol(protocol);
+ permBuilder.fromPort(startPort);
+ permBuilder.toPort(endPort);
+ permBuilder.tenantIdGroupNamePairs(tenantIdGroupNamePairs);
+ permBuilder.cidrBlocks(ipRanges);
+ permBuilder.groupIds(groupIds);
+
+ return removeIpPermission(permBuilder.build(), group);
+ }
+
+ @Override
+ public boolean supportsTenantIdGroupNamePairs() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsTenantIdGroupIdPairs() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsGroupIds() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsPortRangesForGroups() {
+ return false;
+ }
+
+ protected Iterable<? extends SecurityGroupInZone> pollSecurityGroups() {
+ Iterable<? extends Set<? extends SecurityGroupInZone>> groups
+ = transform(zoneIds.get(), allSecurityGroupsInZone());
+
+ return concat(groups);
+ }
+
+
+ protected Iterable<? extends SecurityGroupInZone> pollSecurityGroupsByZone(String zone) {
+ return allSecurityGroupsInZone().apply(zone);
+ }
+
+ protected Function<String, Set<? extends SecurityGroupInZone>> allSecurityGroupsInZone() {
+ return new Function<String, Set<? extends SecurityGroupInZone>>() {
+
+ @Override
+ public Set<? extends SecurityGroupInZone> apply(final String from) {
+ Optional<? extends SecurityGroupApi> sgApi = api.getSecurityGroupExtensionForZone(from);
+
+ if (!sgApi.isPresent()) {
+ return ImmutableSet.of();
+ }
+
+
+ return sgApi.get().list().transform(groupToGroupInZone(from)).toSet();
+ }
+
+ };
+ }
+
+ protected Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroupInZone> groupToGroupInZone(final String zone) {
+ return new Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroupInZone>() {
+ @Override
+ public SecurityGroupInZone apply(org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group) {
+ return new SecurityGroupInZone(group, zone);
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNode.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNode.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNode.java
new file mode 100644
index 0000000..f7c18ee
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNode.java
@@ -0,0 +1,112 @@
+/*
+ * 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.functions;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.NodeMetadataBuilder;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.logging.Logger;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
+import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
+import org.jclouds.rest.InsufficientResourcesException;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.base.Predicate;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
+/**
+ * A function for adding and allocating an ip to a node
+ *
+ * @author Adrian Cole
+ */
+public class AllocateAndAddFloatingIpToNode implements
+ Function<AtomicReference<NodeMetadata>, AtomicReference<NodeMetadata>> {
+
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ private final Predicate<AtomicReference<NodeMetadata>> nodeRunning;
+ private final NovaApi novaApi;
+ private final LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache;
+
+ @Inject
+ public AllocateAndAddFloatingIpToNode(@Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
+ NovaApi novaApi, @Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache) {
+ this.nodeRunning = checkNotNull(nodeRunning, "nodeRunning");
+ this.novaApi = checkNotNull(novaApi, "novaApi");
+ this.floatingIpCache = checkNotNull(floatingIpCache, "floatingIpCache");
+ }
+
+ @Override
+ public AtomicReference<NodeMetadata> apply(AtomicReference<NodeMetadata> input) {
+ checkState(nodeRunning.apply(input), "node never achieved state running %s", input.get());
+ NodeMetadata node = input.get();
+ // node's location is a host
+ String zoneId = node.getLocation().getParent().getId();
+ FloatingIPApi floatingIpApi = novaApi.getFloatingIPExtensionForZone(zoneId).get();
+
+ FloatingIP ip = null;
+ try {
+ logger.debug(">> allocating or reassigning floating ip for node(%s)", node.getId());
+ ip = floatingIpApi.create();
+ } catch (InsufficientResourcesException e) {
+ logger.trace("<< [%s] allocating a new floating ip for node(%s)", e.getMessage(), node.getId());
+ logger.trace(">> searching for existing, unassigned floating ip for node(%s)", node.getId());
+ ArrayList<FloatingIP> unassignedIps = Lists.newArrayList(Iterables.filter(floatingIpApi.list(),
+ new Predicate<FloatingIP>() {
+
+ @Override
+ public boolean apply(FloatingIP arg0) {
+ return arg0.getFixedIp() == null;
+ }
+
+ }));
+ // try to prevent multiple parallel launches from choosing the same ip.
+ Collections.shuffle(unassignedIps);
+ ip = Iterables.getLast(unassignedIps);
+ }
+ logger.debug(">> adding floatingIp(%s) to node(%s)", ip.getIp(), node.getId());
+
+ floatingIpApi.addToServer(ip.getIp(), node.getProviderId());
+ input.set(NodeMetadataBuilder.fromNodeMetadata(node).publicAddresses(ImmutableSet.of(ip.getIp())).build());
+ floatingIpCache.invalidate(ZoneAndId.fromSlashEncoded(node.getId()));
+ return input;
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper("AllocateAndAddFloatingIpToNode").toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/CreateSecurityGroupIfNeeded.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/CreateSecurityGroupIfNeeded.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/CreateSecurityGroupIfNeeded.java
new file mode 100644
index 0000000..6b5d519
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/CreateSecurityGroupIfNeeded.java
@@ -0,0 +1,93 @@
+/*
+ * 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.functions;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.find;
+import static org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates.nameEquals;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.logging.Logger;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.Ingress;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
+import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class CreateSecurityGroupIfNeeded implements Function<ZoneSecurityGroupNameAndPorts, SecurityGroupInZone> {
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+ protected final NovaApi novaApi;
+
+ @Inject
+ public CreateSecurityGroupIfNeeded(NovaApi novaApi) {
+ this.novaApi = checkNotNull(novaApi, "novaApi");
+ }
+
+ @Override
+ public SecurityGroupInZone apply(ZoneSecurityGroupNameAndPorts zoneSecurityGroupNameAndPorts) {
+ checkNotNull(zoneSecurityGroupNameAndPorts, "zoneSecurityGroupNameAndPorts");
+
+ String zoneId = zoneSecurityGroupNameAndPorts.getZone();
+ Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(zoneId);
+ checkArgument(api.isPresent(), "Security groups are required, but the extension is not availablein zone %s!", zoneId);
+ logger.debug(">> creating securityGroup %s", zoneSecurityGroupNameAndPorts);
+ try {
+
+ SecurityGroup securityGroup = api.get().createWithDescription(
+ zoneSecurityGroupNameAndPorts.getName(), zoneSecurityGroupNameAndPorts.getName());
+
+ logger.debug("<< created securityGroup(%s)", securityGroup);
+ for (int port : zoneSecurityGroupNameAndPorts.getPorts()) {
+ authorizeGroupToItselfAndAllIPsToTCPPort(api.get(), securityGroup, port);
+ }
+ return new SecurityGroupInZone(api.get().get(securityGroup.getId()), zoneId);
+ } catch (IllegalStateException e) {
+ logger.trace("<< trying to find securityGroup(%s): %s", zoneSecurityGroupNameAndPorts, e.getMessage());
+ SecurityGroup group = find(api.get().list(), nameEquals(zoneSecurityGroupNameAndPorts
+ .getName()));
+ logger.debug("<< reused securityGroup(%s)", group.getId());
+ return new SecurityGroupInZone(group, zoneId);
+ }
+ }
+
+ private void authorizeGroupToItselfAndAllIPsToTCPPort(SecurityGroupApi securityGroupApi,
+ SecurityGroup securityGroup, int port) {
+ logger.debug(">> authorizing securityGroup(%s) permission to 0.0.0.0/0 on port %d", securityGroup, port);
+ securityGroupApi.createRuleAllowingCidrBlock(securityGroup.getId(), Ingress.builder().ipProtocol(
+ IpProtocol.TCP).fromPort(port).toPort(port).build(), "0.0.0.0/0");
+ logger.debug("<< authorized securityGroup(%s) permission to 0.0.0.0/0 on port %d", securityGroup, port);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardware.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardware.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardware.java
new file mode 100644
index 0000000..160944b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardware.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.compute.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.HardwareBuilder;
+import org.jclouds.compute.domain.Processor;
+import org.jclouds.compute.domain.internal.VolumeImpl;
+import org.jclouds.domain.Location;
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.FlavorInZone;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+
+/**
+ * A function for transforming the nova specific FlavorInZone object to the generic Hardware object.
+ *
+ * @author Matt Stephenson
+ */
+public class FlavorInZoneToHardware implements Function<FlavorInZone, Hardware> {
+
+ private final Supplier<Map<String, Location>> locationIndex;
+
+ @Inject
+ public FlavorInZoneToHardware(Supplier<Map<String, Location>> locationIndex) {
+ this.locationIndex = checkNotNull(locationIndex, "locationIndex");
+ }
+
+ @Override
+ public Hardware apply(FlavorInZone flavorInZone) {
+ Location location = locationIndex.get().get(flavorInZone.getZone());
+ checkState(location != null, "location %s not in locationIndex: %s", flavorInZone.getZone(), locationIndex.get());
+ Flavor flavor = flavorInZone.getFlavor();
+ return new HardwareBuilder().id(flavorInZone.slashEncode()).providerId(flavor.getId()).name(flavor.getName())
+ .ram(flavor.getRam()).processor(new Processor(flavor.getVcpus(), 1.0)).volume(
+ new VolumeImpl(Float.valueOf(flavor.getDisk()), true, true)).location(location).build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImage.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImage.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImage.java
new file mode 100644
index 0000000..109da29
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImage.java
@@ -0,0 +1,70 @@
+/*
+ * 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.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.ImageBuilder;
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.domain.Location;
+import org.jclouds.openstack.nova.v2_0.domain.Image.Status;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ImageInZone;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.base.Supplier;
+
+/**
+ * A function for transforming a nova-specific Image into a generic Image object.
+ *
+ * @author Matt Stephenson
+ */
+public class ImageInZoneToImage implements Function<ImageInZone, Image> {
+ private final Map<Status, org.jclouds.compute.domain.Image.Status> toPortableImageStatus;
+ private final Function<org.jclouds.openstack.nova.v2_0.domain.Image, OperatingSystem> imageToOs;
+ private final Supplier<Map<String, Location>> locationIndex;
+
+ @Inject
+ public ImageInZoneToImage(Map<org.jclouds.openstack.nova.v2_0.domain.Image.Status, Image.Status> toPortableImageStatus,
+ Function<org.jclouds.openstack.nova.v2_0.domain.Image, OperatingSystem> imageToOs,
+ Supplier<Map<String, Location>> locationIndex) {
+ this.toPortableImageStatus = checkNotNull(toPortableImageStatus, "toPortableImageStatus");
+ this.imageToOs = checkNotNull(imageToOs, "imageToOs");
+ this.locationIndex = checkNotNull(locationIndex, "locationIndex");
+ }
+
+ @Override
+ public Image apply(ImageInZone imageInZone) {
+ Location location = locationIndex.get().get(imageInZone.getZone());
+ checkState(location != null, "location %s not in locationIndex: %s", imageInZone.getZone(), locationIndex.get());
+ org.jclouds.openstack.nova.v2_0.domain.Image image = imageInZone.getImage();
+ return new ImageBuilder().id(imageInZone.slashEncode()).providerId(image.getId()).name(image.getName())
+ .userMetadata(image.getMetadata()).operatingSystem(imageToOs.apply(image)).description(image.getName())
+ .location(location).status(toPortableImageStatus.get(image.getStatus())).build();
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper(this).toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystem.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystem.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystem.java
new file mode 100644
index 0000000..f26c4e0
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystem.java
@@ -0,0 +1,128 @@
+/*
+ * 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.functions;
+
+import static com.google.common.base.Predicates.containsPattern;
+import static com.google.common.base.Predicates.equalTo;
+import static com.google.common.base.Predicates.not;
+import static com.google.common.collect.Iterables.any;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.find;
+
+import java.util.Arrays;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.compute.util.ComputeServiceUtils;
+import org.jclouds.logging.Logger;
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+
+import com.google.common.base.CharMatcher;
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.base.Predicate;
+import com.google.common.base.Splitter;
+
+/**
+ * A function for transforming a nova specific Image into a generic OperatingSystem object.
+ *
+ * @author Matt Stephenson
+ */
+public class ImageToOperatingSystem implements Function<Image, OperatingSystem> {
+ public static final Pattern DEFAULT_PATTERN = Pattern.compile("(([^ ]*) ([0-9.]+) ?.*)");
+ // Windows Server 2008 R2 x64
+ public static final Pattern WINDOWS_PATTERN = Pattern.compile("Windows (.*) (x[86][64])");
+
+ @javax.annotation.Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ private final Map<OsFamily, Map<String, String>> osVersionMap;
+
+ @Inject
+ public ImageToOperatingSystem(Map<OsFamily, Map<String, String>> osVersionMap) {
+ this.osVersionMap = osVersionMap;
+ }
+
+ public OperatingSystem apply(final Image from) {
+ OsFamily osFamily = null;
+ String osVersion = null;
+
+ String imageName = Objects.firstNonNull(from.getName(), "unspecified");
+
+ boolean is64Bit = true;
+
+ if (imageName.indexOf("Windows") != -1) {
+ osFamily = OsFamily.WINDOWS;
+ Matcher matcher = WINDOWS_PATTERN.matcher(from.getName());
+ if (matcher.find()) {
+ osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(1), osVersionMap);
+ is64Bit = matcher.group(2).equals("x64");
+ }
+ } else {
+ if (imageName.contains("Red Hat EL")) {
+ osFamily = OsFamily.RHEL;
+ } else if (imageName.contains("Oracle EL")) {
+ osFamily = OsFamily.OEL;
+ } else {
+ final Iterable<String> imageNameParts = Splitter.on(CharMatcher.WHITESPACE).trimResults().split(
+ imageName.toLowerCase());
+
+ try {
+ osFamily = find(Arrays.asList(OsFamily.values()), new Predicate<OsFamily>() {
+ @Override
+ public boolean apply(OsFamily osFamily) {
+ return any(imageNameParts, equalTo(osFamily.name().toLowerCase()));
+ }
+ });
+ } catch (NoSuchElementException e) {
+ String ubuntuVersion = startsWithUbuntuVersion(imageNameParts);
+ if (ubuntuVersion != null) {
+ osFamily = OsFamily.UBUNTU;
+ osVersion = ubuntuVersion;
+ } else {
+ logger.trace("could not parse operating system family for image(%s): %s", from.getId(), imageNameParts);
+ osFamily = OsFamily.UNRECOGNIZED;
+ }
+ }
+ }
+ Matcher matcher = DEFAULT_PATTERN.matcher(imageName);
+ if (matcher.find() && matcher.groupCount() >= 3) {
+ osVersion = ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, matcher.group(3), osVersionMap);
+ }
+ }
+ return new OperatingSystem(osFamily, imageName, osVersion, null, imageName, is64Bit);
+ }
+
+ String startsWithUbuntuVersion(final Iterable<String> imageNameParts) {
+ Map<String, String> ubuntuVersions = osVersionMap.get(OsFamily.UBUNTU);
+ for (String ubuntuKey : filter(ubuntuVersions.keySet(), not(equalTo("")))) {
+ if (any(imageNameParts, containsPattern("^" + ubuntuKey + ".*"))) {
+ return ubuntuVersions.get(ubuntuKey);
+ }
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroup.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroup.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroup.java
new file mode 100644
index 0000000..fc772df
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroup.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.compute.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.compute.domain.SecurityGroupBuilder;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.domain.Location;
+import org.jclouds.logging.Logger;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.inject.Inject;
+
+
+/**
+ * A function for transforming a Nova-specific SecurityGroup into a generic
+ * SecurityGroup object.
+ *
+ * @author Andrew Bayer
+ */
+@Singleton
+public class NovaSecurityGroupInZoneToSecurityGroup implements Function<SecurityGroupInZone, SecurityGroup> {
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ protected final Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroup> baseConverter;
+ protected final Supplier<Map<String, Location>> locationIndex;
+
+ @Inject
+ public NovaSecurityGroupInZoneToSecurityGroup(Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroup> baseConverter,
+ Supplier<Map<String, Location>> locationIndex) {
+ this.baseConverter = checkNotNull(baseConverter, "baseConverter");
+ this.locationIndex = checkNotNull(locationIndex, "locationIndex");
+ }
+
+ @Override
+ public SecurityGroup apply(SecurityGroupInZone group) {
+ SecurityGroupBuilder builder = SecurityGroupBuilder.fromSecurityGroup(baseConverter.apply(group.getSecurityGroup()));
+
+ Location zone = locationIndex.get().get(group.getZone());
+ checkState(zone != null, "location %s not in locationIndex: %s", group.getZone(), locationIndex.get());
+
+ builder.location(zone);
+
+ builder.id(group.getZone() + "/" + group.getSecurityGroup().getId());
+
+ return builder.build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroup.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroup.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroup.java
new file mode 100644
index 0000000..d39f849
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroup.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.compute.functions;
+
+import static com.google.common.collect.Iterables.transform;
+
+import javax.annotation.Resource;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.compute.domain.SecurityGroupBuilder;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.logging.Logger;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+
+import com.google.common.base.Function;
+import com.google.inject.Inject;
+
+
+/**
+ * A function for transforming a Nova-specific SecurityGroup into a generic
+ * SecurityGroup object.
+ *
+ * @author Andrew Bayer
+ */
+@Singleton
+public class NovaSecurityGroupToSecurityGroup implements Function<org.jclouds.openstack.nova.v2_0.domain.SecurityGroup, SecurityGroup> {
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ protected Function<SecurityGroupRule,IpPermission> ruleToPermission;
+
+ @Inject
+ public NovaSecurityGroupToSecurityGroup(Function<SecurityGroupRule,IpPermission> ruleToPermission) {
+ this.ruleToPermission = ruleToPermission;
+ }
+
+ @Override
+ public SecurityGroup apply(org.jclouds.openstack.nova.v2_0.domain.SecurityGroup group) {
+ SecurityGroupBuilder builder = new SecurityGroupBuilder();
+
+ builder.id(group.getId());
+ builder.providerId(group.getId());
+ builder.ownerId(group.getTenantId());
+ builder.name(group.getName());
+ if (group.getRules() != null) {
+ builder.ipPermissions(transform(group.getRules(), ruleToPermission));
+ }
+
+ return builder.build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneId.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneId.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneId.java
new file mode 100644
index 0000000..4993f0c
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneId.java
@@ -0,0 +1,77 @@
+/*
+ * 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.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.transform;
+import static com.google.common.collect.Sets.filter;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.predicates.NodePredicates;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.openstack.nova.v2_0.compute.predicates.AllNodesInGroupTerminated;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Multimaps;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public class OrphanedGroupsByZoneId implements Function<Set<? extends NodeMetadata>, Multimap<String, String>> {
+ private final Predicate<ZoneAndName> allNodesInGroupTerminated;
+
+ @Inject
+ protected OrphanedGroupsByZoneId(ComputeService computeService) {
+ this(new AllNodesInGroupTerminated(checkNotNull(computeService, "computeService")));
+ }
+
+ @VisibleForTesting
+ OrphanedGroupsByZoneId(Predicate<ZoneAndName> allNodesInGroupTerminated) {
+ this.allNodesInGroupTerminated = checkNotNull(allNodesInGroupTerminated, "allNodesInGroupTerminated");
+ }
+
+ public Multimap<String, String> apply(Set<? extends NodeMetadata> deadNodes) {
+ Iterable<? extends NodeMetadata> nodesWithGroup = filter(deadNodes, NodePredicates.hasGroup());
+ Set<ZoneAndName> zoneAndGroupNames = ImmutableSet.copyOf(filter(transform(nodesWithGroup,
+ new Function<NodeMetadata, ZoneAndName>() {
+
+ @Override
+ public ZoneAndName apply(NodeMetadata input) {
+ String zoneId = input.getLocation().getScope() == LocationScope.HOST ? input.getLocation()
+ .getParent().getId() : input.getLocation().getId();
+ return ZoneAndName.fromZoneAndName(zoneId, input.getGroup());
+ }
+
+ }), allNodesInGroupTerminated));
+ Multimap<String, String> zoneToZoneAndGroupNames = Multimaps.transformValues(Multimaps.index(zoneAndGroupNames,
+ ZoneAndName.ZONE_FUNCTION), ZoneAndName.NAME_FUNCTION);
+ return zoneToZoneAndGroupNames;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/RemoveFloatingIpFromNodeAndDeallocate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/RemoveFloatingIpFromNodeAndDeallocate.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/RemoveFloatingIpFromNodeAndDeallocate.java
new file mode 100644
index 0000000..269a333
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/RemoveFloatingIpFromNodeAndDeallocate.java
@@ -0,0 +1,74 @@
+/*
+ * 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.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.logging.Logger;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
+import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.cache.LoadingCache;
+
+/**
+ * A function for removing and deallocating an ip address from a node
+ *
+ * @author Adrian Cole
+ */
+public class RemoveFloatingIpFromNodeAndDeallocate implements Function<ZoneAndId, ZoneAndId> {
+
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ private final NovaApi novaApi;
+ private final LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache;
+
+ @Inject
+ public RemoveFloatingIpFromNodeAndDeallocate(NovaApi novaApi,
+ @Named("FLOATINGIP") LoadingCache<ZoneAndId, Iterable<? extends FloatingIP>> floatingIpCache) {
+ this.novaApi = checkNotNull(novaApi, "novaApi");
+ this.floatingIpCache = checkNotNull(floatingIpCache, "floatingIpCache");
+ }
+
+ @Override
+ public ZoneAndId apply(ZoneAndId id) {
+ FloatingIPApi floatingIpApi = novaApi.getFloatingIPExtensionForZone(id.getZone()).get();
+ for (FloatingIP ip : floatingIpCache.getUnchecked(id)) {
+ logger.debug(">> removing floatingIp(%s) from node(%s)", ip, id);
+ floatingIpApi.removeFromServer(ip.getIp(), id.getId());
+ logger.debug(">> deallocating floatingIp(%s)", ip);
+ floatingIpApi.delete(ip.getId());
+ }
+ floatingIpCache.invalidate(id);
+ return id;
+ }
+
+ @Override
+ public String toString() {
+ return Objects.toStringHelper("RemoveFloatingIpFromNodeAndDecreate").toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermission.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermission.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermission.java
new file mode 100644
index 0000000..a98a62b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermission.java
@@ -0,0 +1,99 @@
+/*
+ * 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.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.getFirst;
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.domain.Location;
+import org.jclouds.logging.Logger;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.cache.LoadingCache;
+import com.google.common.util.concurrent.Atomics;
+
+
+/**
+ * A function for transforming a nova-specific SecurityGroupRule into a generic
+ * IpPermission object.
+ *
+ * @author Andrew Bayer
+ */
+public class SecurityGroupRuleToIpPermission implements Function<SecurityGroupRule, IpPermission> {
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+ protected final Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone;
+ protected final Supplier<Map<String, Location>> locationIndex;
+ LoadingCache<ZoneAndName, SecurityGroupInZone> groupMap;
+
+ @Inject
+ public SecurityGroupRuleToIpPermission(@Named("SECURITYGROUP_PRESENT") Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone,
+ Supplier<Map<String, Location>> locationIndex,
+ LoadingCache<ZoneAndName, SecurityGroupInZone> groupMap) {
+ this.returnSecurityGroupExistsInZone = checkNotNull(returnSecurityGroupExistsInZone,
+ "returnSecurityGroupExistsInZone");
+ this.locationIndex = checkNotNull(locationIndex, "locationIndex");
+ this.groupMap = checkNotNull(groupMap, "groupMap");
+ }
+
+ @Override
+ public IpPermission apply(SecurityGroupRule rule) {
+ IpPermission.Builder builder = IpPermission.builder();
+ builder.ipProtocol(rule.getIpProtocol());
+ builder.fromPort(rule.getFromPort());
+ builder.toPort(rule.getToPort());
+ if (rule.getGroup() != null) {
+ String zone = getFirst(filter(locationIndex.get().keySet(), isSecurityGroupInZone(rule.getGroup().getName())),
+ null);
+ if (zone != null) {
+ SecurityGroupInZone group = groupMap.getUnchecked(ZoneAndName.fromZoneAndName(zone, rule.getGroup().getName()));
+ builder.groupId(zone + "/" + group.getSecurityGroup().getId());
+ }
+ }
+ if (rule.getIpRange() != null)
+ builder.cidrBlock(rule.getIpRange());
+
+ return builder.build();
+ }
+
+ protected Predicate<String> isSecurityGroupInZone(final String groupName) {
+ return new Predicate<String>() {
+
+ @Override
+ public boolean apply(String zone) {
+ AtomicReference<ZoneAndName> securityGroupInZoneRef = Atomics.newReference(ZoneAndName.fromZoneAndName(zone, groupName));
+ return returnSecurityGroupExistsInZone.apply(securityGroupInZoneRef);
+ }
+ };
+ }
+}
[10/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
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/NovaSecurityGroupExtensionExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionExpectTest.java
new file mode 100644
index 0000000..809b4da
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionExpectTest.java
@@ -0,0 +1,433 @@
+/*
+ * 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 static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.Properties;
+import java.util.Set;
+
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.compute.extensions.SecurityGroupExtension;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaComputeServiceExpectTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.LinkedHashMultimap;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Sets;
+
+/**
+ *
+ * @author Andrew Bayer
+ */
+@Test(groups = "unit", testName = "NovaSecurityGroupExtensionExpectTest")
+public class NovaSecurityGroupExtensionExpectTest extends BaseNovaComputeServiceExpectTest {
+
+ protected String zone = "az-1.region-a.geo-1";
+ protected HttpRequest list = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ protected HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_list_extension.json")).build();
+
+ @Override
+ protected Properties setupProperties() {
+ Properties overrides = super.setupProperties();
+ overrides.setProperty("jclouds.zones", zone);
+ return overrides;
+ }
+
+ public void testListSecurityGroups() {
+
+
+ Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+ requestResponseMap.put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess);
+ requestResponseMap.put(extensionsOfNovaRequest, extensionsOfNovaResponse);
+ requestResponseMap.put(list, listResponse).build();
+
+ SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
+
+ Set<SecurityGroup> groups = extension.listSecurityGroups();
+ assertEquals(groups.size(), 1);
+ }
+
+ public void testListSecurityGroupsInLocation() {
+ HttpRequest list = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_list.json")).build();
+
+
+ Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+ requestResponseMap.put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess);
+ requestResponseMap.put(extensionsOfNovaRequest, extensionsOfNovaResponse);
+ requestResponseMap.put(list, listResponse).build();
+
+ SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
+
+ Set<SecurityGroup> groups = extension.listSecurityGroupsInLocation(new LocationBuilder()
+ .scope(LocationScope.ZONE)
+ .id(zone)
+ .description("zone")
+ .build());
+ assertEquals(groups.size(), 1);
+ }
+
+ public void testListSecurityGroupsForNode() {
+ HttpRequest serverReq = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-create-server-ext/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb"))
+ .headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse serverResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/server_with_security_groups_extension.json")).build();
+
+ HttpRequest list = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_list.json")).build();
+
+
+ Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+ requestResponseMap.put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess);
+ requestResponseMap.put(extensionsOfNovaRequest, extensionsOfNovaResponse);
+ requestResponseMap.put(serverReq, serverResponse);
+ requestResponseMap.put(list, listResponse).build();
+
+ SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
+
+ Set<SecurityGroup> groups = extension.listSecurityGroupsForNode(zone + "/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb");
+ assertEquals(groups.size(), 1);
+ }
+
+ public void testGetSecurityGroupById() {
+ HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_details_extension.json")).build();
+
+ Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+ requestResponseMap.put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess);
+ requestResponseMap.put(extensionsOfNovaRequest, extensionsOfNovaResponse);
+ requestResponseMap.put(getSecurityGroup, getSecurityGroupResponse);
+ requestResponseMap.put(list, listResponse).build();
+
+ SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
+
+ SecurityGroup group = extension.getSecurityGroupById(zone + "/160");
+ assertEquals(group.getId(), zone + "/160");
+ }
+
+ public void testCreateSecurityGroup() {
+ HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_details_extension.json")).build();
+
+ HttpRequest create = HttpRequest.builder().method("POST").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build())
+ .payload(
+ payloadFromStringWithContentType(
+ "{\"security_group\":{\"name\":\"jclouds-test\",\"description\":\"jclouds-test\"}}",
+ "application/json")).build();
+
+ HttpResponse createResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_created.json")).build();
+
+ HttpRequest list = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String>builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_list_extension.json")).build();
+
+ Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+ requestResponseMap.put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess);
+ requestResponseMap.put(extensionsOfNovaRequest, extensionsOfNovaResponse);
+ requestResponseMap.put(create, createResponse);
+ requestResponseMap.put(list, listResponse);
+ requestResponseMap.put(getSecurityGroup, getSecurityGroupResponse).build();
+
+ SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
+
+ SecurityGroup group = extension.createSecurityGroup("test", new LocationBuilder()
+ .scope(LocationScope.ZONE)
+ .id(zone)
+ .description("zone")
+ .build());
+ assertEquals(group.getId(), zone + "/160");
+ }
+
+ public void testRemoveSecurityGroup() {
+ HttpRequest delete = HttpRequest.builder().method("DELETE").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160"))
+ .headers(
+ ImmutableMultimap.<String, String>builder().put("Accept", "application/json")
+ .put("X-Auth-Token", authToken).build()).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(202).build();
+
+ HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_details_extension.json")).build();
+
+ Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
+ requestResponseMap.put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess);
+ requestResponseMap.put(extensionsOfNovaRequest, extensionsOfNovaResponse);
+ requestResponseMap.put(getSecurityGroup, getSecurityGroupResponse);
+ requestResponseMap.put(delete, deleteResponse).build();
+
+ SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get();
+
+ assertTrue(extension.removeSecurityGroup(zone + "/160"), "Expected removal of securitygroup to be successful");
+ }
+
+ public void testAddIpPermissionCidrFromIpPermission() {
+ HttpRequest createRule = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/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\":\"10.2.6.0/24\",\"ip_protocol\":\"tcp\",\"from_port\":\"22\",\"to_port\":\"22\"}}",
+ "application/json")).build();
+
+ HttpResponse createRuleResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygrouprule_created_cidr.json")).build();
+
+ HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse getSecurityGroupNoRulesResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_details_extension_norules.json")).build();
+
+ HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_details_extension.json")).build();
+
+
+ SecurityGroupExtension extension = orderedRequestsSendResponses(ImmutableList.of(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ extensionsOfNovaRequest, getSecurityGroup, createRule, getSecurityGroup, list, list),
+ ImmutableList.of(responseWithKeystoneAccess, extensionsOfNovaResponse, getSecurityGroupNoRulesResponse,
+ createRuleResponse, getSecurityGroupResponse, listResponse, listResponse)).getSecurityGroupExtension().get();
+
+ IpPermission.Builder builder = IpPermission.builder();
+
+ builder.ipProtocol(IpProtocol.TCP);
+ builder.fromPort(22);
+ builder.toPort(22);
+ builder.cidrBlock("10.2.6.0/24");
+
+ IpPermission perm = builder.build();
+
+ SecurityGroup origGroup = extension.getSecurityGroupById(zone + "/160");
+
+ assertNotNull(origGroup);
+ SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);
+
+ assertNotNull(newGroup);
+ }
+
+ public void testAddIpPermissionCidrFromParams() {
+ HttpRequest createRule = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/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\":\"10.2.6.0/24\",\"ip_protocol\":\"tcp\",\"from_port\":\"22\",\"to_port\":\"22\"}}",
+ "application/json")).build();
+
+ HttpResponse createRuleResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygrouprule_created_cidr.json")).build();
+
+ HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse getSecurityGroupNoRulesResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_details_extension_norules.json")).build();
+
+ HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_details_extension.json")).build();
+
+
+ SecurityGroupExtension extension = orderedRequestsSendResponses(ImmutableList.of(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ extensionsOfNovaRequest, getSecurityGroup, createRule, getSecurityGroup, list, list),
+ ImmutableList.of(responseWithKeystoneAccess, extensionsOfNovaResponse, getSecurityGroupNoRulesResponse,
+ createRuleResponse, getSecurityGroupResponse, listResponse, listResponse)).getSecurityGroupExtension().get();
+
+ SecurityGroup origGroup = extension.getSecurityGroupById(zone + "/160");
+
+ assertNotNull(origGroup);
+ SecurityGroup newGroup = extension.addIpPermission(IpProtocol.TCP,
+ 22,
+ 22,
+ emptyMultimap(),
+ ImmutableSet.of("10.2.6.0/24"),
+ emptyStringSet(),
+ origGroup);
+
+ assertNotNull(newGroup);
+ }
+
+ public void testAddIpPermissionGroupFromIpPermission() {
+ HttpRequest createRule = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(
+ payloadFromStringWithContentType(
+ "{\"security_group_rule\":{\"group_id\":\"11111\",\"parent_group_id\":\"160\",\"ip_protocol\":\"tcp\",\"from_port\":\"22\",\"to_port\":\"22\"}}",
+ "application/json")).build();
+
+ HttpResponse createRuleResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygrouprule_created_group.json")).build();
+
+ HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse getSecurityGroupNoRulesResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_details_extension_norules.json")).build();
+
+ HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_details_extension.json")).build();
+
+
+ SecurityGroupExtension extension = orderedRequestsSendResponses(ImmutableList.of(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ extensionsOfNovaRequest, getSecurityGroup, createRule, getSecurityGroup, list, list),
+ ImmutableList.of(responseWithKeystoneAccess, extensionsOfNovaResponse, getSecurityGroupNoRulesResponse,
+ createRuleResponse, getSecurityGroupResponse, listResponse, listResponse)).getSecurityGroupExtension().get();
+
+ IpPermission.Builder builder = IpPermission.builder();
+
+ builder.ipProtocol(IpProtocol.TCP);
+ builder.fromPort(22);
+ builder.toPort(22);
+ builder.groupId("admin/11111");
+
+ IpPermission perm = builder.build();
+
+ SecurityGroup origGroup = extension.getSecurityGroupById(zone + "/160");
+
+ assertNotNull(origGroup);
+ SecurityGroup newGroup = extension.addIpPermission(perm, origGroup);
+
+ assertNotNull(newGroup);
+ }
+
+ public void testAddIpPermissionGroupFromParams() {
+ HttpRequest createRule = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(
+ payloadFromStringWithContentType(
+ "{\"security_group_rule\":{\"group_id\":\"11111\",\"parent_group_id\":\"160\",\"ip_protocol\":\"tcp\",\"from_port\":\"22\",\"to_port\":\"22\"}}",
+ "application/json")).build();
+
+ HttpResponse createRuleResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygrouprule_created_group.json")).build();
+
+ HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse getSecurityGroupNoRulesResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_details_extension_norules.json")).build();
+
+ HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_details_extension.json")).build();
+
+
+ SecurityGroupExtension extension = orderedRequestsSendResponses(ImmutableList.of(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ extensionsOfNovaRequest, getSecurityGroup, createRule, getSecurityGroup, list, list),
+ ImmutableList.of(responseWithKeystoneAccess, extensionsOfNovaResponse, getSecurityGroupNoRulesResponse,
+ createRuleResponse, getSecurityGroupResponse, listResponse, listResponse)).getSecurityGroupExtension().get();
+
+ SecurityGroup origGroup = extension.getSecurityGroupById(zone + "/160");
+
+ assertNotNull(origGroup);
+ SecurityGroup newGroup = extension.addIpPermission(IpProtocol.TCP,
+ 22,
+ 22,
+ emptyMultimap(),
+ emptyStringSet(),
+ ImmutableSet.of("admin/11111"),
+ origGroup);
+
+ assertNotNull(newGroup);
+ }
+
+ private Multimap<String, String> emptyMultimap() {
+ return LinkedHashMultimap.create();
+ }
+
+ private Set<String> emptyStringSet() {
+ return Sets.newLinkedHashSet();
+ }
+
+}
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/NovaSecurityGroupExtensionLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionLiveTest.java
new file mode 100644
index 0000000..4a7dbed
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionLiveTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.BaseSecurityGroupExtensionLiveTest;
+import org.testng.annotations.Test;
+
+/**
+ * Live test for openstack-nova {@link org.jclouds.compute.extensions.SecurityGroupExtension} implementation.
+ *
+ * @author Andrew Bayer
+ *
+ */
+@Test(groups = "live", singleThreaded = true, testName = "NovaSecurityGroupExtensionLiveTest")
+public class NovaSecurityGroupExtensionLiveTest extends BaseSecurityGroupExtensionLiveTest {
+
+ public NovaSecurityGroupExtensionLiveTest() {
+ provider = "openstack-nova";
+ }
+
+}
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/functions/AllocateAndAddFloatingIpToNodeExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNodeExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNodeExpectTest.java
new file mode 100644
index 0000000..a5631ca
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNodeExpectTest.java
@@ -0,0 +1,133 @@
+/*
+ * 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.functions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import java.net.URI;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.NodeMetadata.Status;
+import org.jclouds.compute.domain.NodeMetadataBuilder;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.domain.LoginCredentials;
+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.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.util.concurrent.Atomics;
+
+/**
+ * Tests the compute service abstraction of the nova api.
+ *
+ * @author Matt Stephenson
+ */
+@Test(groups = "unit", testName = "AllocateAndAddFloatingIpToNodeTest")
+public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeServiceExpectTest {
+ final Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova").description(
+ "openstack-nova").build();
+ final Location zone = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1").scope(
+ LocationScope.ZONE).parent(provider).build();
+ final Location host = new LocationBuilder().scope(LocationScope.HOST).id("hostId").description("hostId")
+ .parent(zone).build();
+ final NodeMetadata node = new NodeMetadataBuilder().id("az-1.region-a.geo-1/71592").providerId("71592").location(
+ host).name("Server 71592").status(Status.RUNNING).privateAddresses(ImmutableSet.of("10.4.27.237"))
+ .credentials(LoginCredentials.builder().password("foo").build()).build();
+
+ HttpRequest createFloatingIP = HttpRequest.builder().method("POST").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).payload(payloadFromStringWithContentType("{}", "application/json")).build();
+
+ HttpResponse addFloatingIPResponse = HttpResponse.builder().statusCode(200).build();
+
+ public void testAllocateWhenAllocationReturnsIpIsAddedToServerAndUpdatesNodeMetadataButSavesCredentials() throws Exception {
+ HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/floatingip_details.json")).build();
+
+ HttpRequest addFloatingIPRequest = addFloatingIPForAddress("10.0.0.3");
+
+ AllocateAndAddFloatingIpToNode fn = requestsSendResponses(
+ ImmutableMap.<HttpRequest, HttpResponse> builder().put(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess).put(extensionsOfNovaRequest, extensionsOfNovaResponse).put(
+ createFloatingIP, createFloatingIPResponse)
+ .put(addFloatingIPRequest, addFloatingIPResponse).build()).getContext().utils().injector()
+ .getInstance(AllocateAndAddFloatingIpToNode.class);
+
+ AtomicReference<NodeMetadata> nodeRef = Atomics.newReference(node);
+ fn.apply(nodeRef);
+ NodeMetadata node1 = nodeRef.get();
+ assertNotNull(node1);
+ assertEquals(node1.getPublicAddresses(), ImmutableSet.of("10.0.0.3"));
+ assertEquals(node1.getCredentials(), node.getCredentials());
+
+ }
+
+ private HttpRequest addFloatingIPForAddress(String address) {
+ HttpRequest addFloatingIPRequest = HttpRequest.builder().method("POST").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/71592/action"))
+ .headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "*/*")
+ .put("X-Auth-Token", authToken).build()).payload(
+ payloadFromStringWithContentType("{\"addFloatingIp\":{\"address\":\"" + address + "\"}}",
+ "application/json")).build();
+ return addFloatingIPRequest;
+ }
+
+ public void testAllocateWhenAllocationFailsLookupUnusedIpAddToServerAndUpdatesNodeMetadata() throws Exception {
+ HttpResponse createFloatingIPResponse = HttpResponse
+ .builder()
+ .statusCode(400)
+ .payload(
+ payloadFromStringWithContentType(
+ "{\"badRequest\": {\"message\": \"AddressLimitExceeded: Address quota exceeded. You cannot create any more addresses\", \"code\": 400}}",
+ "application/json")).build();
+
+ HttpRequest list = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse listResponseForUnassigned = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/floatingip_list.json")).build();
+
+ HttpRequest addFloatingIPRequest = addFloatingIPForAddress("10.0.0.5");
+
+ AllocateAndAddFloatingIpToNode fn = requestsSendResponses(
+ ImmutableMap.<HttpRequest, HttpResponse> builder().put(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess).put(extensionsOfNovaRequest, extensionsOfNovaResponse).put(
+ createFloatingIP, createFloatingIPResponse)
+ .put(addFloatingIPRequest, addFloatingIPResponse).put(list,
+ listResponseForUnassigned).build()).getContext().utils().injector()
+ .getInstance(AllocateAndAddFloatingIpToNode.class);
+
+ AtomicReference<NodeMetadata> nodeRef = Atomics.newReference(node);
+ fn.apply(nodeRef);
+ NodeMetadata node1 = nodeRef.get();
+ assertNotNull(node1);
+ assertEquals(node1.getPublicAddresses(), ImmutableSet.of("10.0.0.5"));
+
+ }
+}
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/functions/FlavorInZoneToHardwareTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardwareTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardwareTest.java
new file mode 100644
index 0000000..b3a0e30
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardwareTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.functions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Map;
+import java.util.UUID;
+
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.FlavorInZone;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests the function used to transform Flavor objects into Hardware objects
+ *
+ * @author Matt Stephenson, Adrian Cole
+ */
+@Test(testName = "FlavorInZoneToHardwareTest")
+public class FlavorInZoneToHardwareTest {
+ Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova").description(
+ "openstack-nova").build();
+ Location zone = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1").scope(
+ LocationScope.ZONE).parent(provider).build();
+ Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
+ .<String, Location> of("az-1.region-a.geo-1", zone));
+
+ @Test
+ public void testConversionWhereLocationFound() {
+
+ UUID id = UUID.randomUUID();
+
+ FlavorInZone flavorInZoneToConvert = new FlavorInZone(Flavor.builder().id(id.toString())
+ .name("Test Flavor " + id).ram(262144).disk(10000).vcpus(16).build(), "az-1.region-a.geo-1");
+
+ Hardware converted = new FlavorInZoneToHardware(locationIndex).apply(flavorInZoneToConvert);
+
+ Flavor flavorToConvert = flavorInZoneToConvert.getFlavor();
+ assertEquals(converted.getName(), flavorToConvert.getName());
+ assertEquals(converted.getId(), flavorInZoneToConvert.slashEncode());
+ assertEquals(converted.getProviderId(), flavorToConvert.getId());
+ assertEquals(converted.getLocation(), locationIndex.get().get("az-1.region-a.geo-1"));
+
+ assertEquals(converted.getRam(), flavorToConvert.getRam());
+
+ assertNotNull(converted.getProcessors());
+ assertFalse(converted.getProcessors().isEmpty());
+ assertEquals(converted.getProcessors().iterator().next().getCores(), (double) flavorToConvert.getVcpus());
+
+ assertNotNull(converted.getVolumes());
+ assertFalse(converted.getVolumes().isEmpty());
+ assertEquals(converted.getVolumes().iterator().next().getSize(), Float.valueOf(flavorToConvert.getDisk()));
+
+ }
+
+ @Test(expectedExceptions = IllegalStateException.class)
+ public void testConversionWhereLocationNotFound() {
+
+ UUID id = UUID.randomUUID();
+
+ FlavorInZone flavorInZoneToConvert = new FlavorInZone(Flavor.builder().id(id.toString())
+ .name("Test Flavor " + id).ram(262144).disk(10000).vcpus(16).build(), "South");
+ new FlavorInZoneToHardware(locationIndex).apply(flavorInZoneToConvert);
+ }
+
+}
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/functions/ImageInZoneToImageTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImageTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImageTest.java
new file mode 100644
index 0000000..dfc15f4
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImageTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.functions;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Map;
+import java.util.UUID;
+
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ImageInZone;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.base.Functions;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests the function that transforms nova-specific images to generic images.
+ *
+ * @author Matt Stephenson, Adrian Cole
+ */
+@Test(testName = "ImageInZoneToHardwareTest")
+public class ImageInZoneToImageTest {
+
+ Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova").description(
+ "openstack-nova").build();
+ Location zone = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1").scope(
+ LocationScope.ZONE).parent(provider).build();
+ Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
+ .<String, Location> of("az-1.region-a.geo-1", zone));
+
+ @Test
+ public void testConversionWhereLocationFound() {
+ UUID id = UUID.randomUUID();
+ Image novaImageToConvert = Image.builder().id(id.toString()).name("Test Image " + id).status(Image.Status.DELETED).build();
+ OperatingSystem operatingSystem = new OperatingSystem(OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86",
+ "My Test OS", true);
+ ImageInZoneToImage converter = new ImageInZoneToImage(NovaComputeServiceContextModule.toPortableImageStatus,
+ constant(operatingSystem), locationIndex);
+
+ ImageInZone novaImageInZoneToConvert = new ImageInZone(novaImageToConvert, "az-1.region-a.geo-1");
+
+ org.jclouds.compute.domain.Image convertedImage = converter.apply(novaImageInZoneToConvert);
+
+ assertEquals(convertedImage.getId(), novaImageInZoneToConvert.slashEncode());
+ assertEquals(convertedImage.getProviderId(), novaImageToConvert.getId());
+ assertEquals(convertedImage.getLocation(), locationIndex.get().get("az-1.region-a.geo-1"));
+
+ assertEquals(convertedImage.getName(), novaImageToConvert.getName());
+ assertEquals(convertedImage.getStatus(), org.jclouds.compute.domain.Image.Status.DELETED);
+ assertEquals(convertedImage.getOperatingSystem(), operatingSystem);
+ }
+
+ @Test(expectedExceptions = IllegalStateException.class)
+ public void testConversionWhereLocationNotFound() {
+ UUID id = UUID.randomUUID();
+ Image novaImageToConvert = Image.builder().id(id.toString()).name("Test Image " + id).build();
+ OperatingSystem operatingSystem = new OperatingSystem(OsFamily.UBUNTU, "My Test OS", "My Test Version", "x86",
+ "My Test OS", true);
+ ImageInZoneToImage converter = new ImageInZoneToImage(NovaComputeServiceContextModule.toPortableImageStatus,
+ constant(operatingSystem), locationIndex);
+
+ ImageInZone novaImageInZoneToConvert = new ImageInZone(novaImageToConvert, "South");
+
+ converter.apply(novaImageInZoneToConvert);
+ }
+
+ @SuppressWarnings("unchecked")
+ private static Function<Image, OperatingSystem> constant(OperatingSystem operatingSystem) {
+ return Function.class.cast(Functions.constant(operatingSystem));
+ }
+}
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/functions/ImageToOperatingSystemTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystemTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystemTest.java
new file mode 100644
index 0000000..2fdc0a4
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystemTest.java
@@ -0,0 +1,192 @@
+/*
+ * 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.functions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jclouds.compute.domain.OperatingSystem;
+import org.jclouds.compute.domain.OsFamily;
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+
+/**
+ * Tests for the function for transforming a nova specific Image into a generic
+ * OperatingSystem object.
+ *
+ * @author Matt Stephenson
+ */
+public class ImageToOperatingSystemTest {
+
+ @Test(dataProvider = "getOsFamilyValues")
+ public void testOsFamilyValues(OsFamily family) {
+
+ Image imageToConvert = Image.builder().id("id-" + family.name()).name(family.name()).build();
+
+ ImageToOperatingSystem converter = new ImageToOperatingSystem(
+ new HashMap<OsFamily, Map<String, String>>());
+
+ OperatingSystem convertedOs = converter.apply(imageToConvert);
+
+ assertEquals(convertedOs.getName(), imageToConvert.getName());
+ assertEquals(convertedOs.getFamily(), family);
+ assertEquals(convertedOs.getDescription(), imageToConvert.getName());
+ assertEquals(convertedOs.getVersion(), null);
+ assertEquals(convertedOs.getArch(), null);
+ assertTrue(convertedOs.is64Bit());
+ }
+
+ @DataProvider
+ public Object[][] getOsFamilyValues() {
+ return Iterables.toArray(
+ Iterables.transform(Arrays.asList(OsFamily.values()), new Function<OsFamily, Object[]>() {
+ @Override
+ public Object[] apply(OsFamily osFamily) {
+ return new Object[] { osFamily };
+ }
+ }), Object[].class);
+ }
+
+ @Test
+ public void testWindowsServer2008R2x64() {
+ String name = "Windows Server 2008 R2 x64";
+
+ Image imageToConvert = Image.builder().id("id-" + name).name(name).build();
+
+ Map<OsFamily, Map<String, String>> osFamilyMap = Maps.newHashMap();
+ osFamilyMap.put(OsFamily.WINDOWS, ImmutableMap.of("Server 2008 R2", "Server-2008-R2"));
+
+ ImageToOperatingSystem converter = new ImageToOperatingSystem(osFamilyMap);
+
+ OperatingSystem convertedOs = converter.apply(imageToConvert);
+
+ assertEquals(convertedOs.getName(), imageToConvert.getName());
+ assertEquals(convertedOs.getFamily(), OsFamily.WINDOWS);
+ assertEquals(convertedOs.getDescription(), imageToConvert.getName());
+ assertEquals(convertedOs.getVersion(), "Server-2008-R2");
+ assertEquals(convertedOs.getArch(), null);
+ assertTrue(convertedOs.is64Bit());
+ }
+
+ @Test
+ public void testWindows98x86() {
+ String name = "Windows 98 x86";
+
+ Image imageToConvert = Image.builder().id("id-" + name).name(name).build();
+
+ Map<OsFamily, Map<String, String>> osFamilyMap = Maps.newHashMap();
+ osFamilyMap.put(OsFamily.WINDOWS, ImmutableMap.of("98", "98"));
+
+ ImageToOperatingSystem converter = new ImageToOperatingSystem(osFamilyMap);
+
+ OperatingSystem convertedOs = converter.apply(imageToConvert);
+
+ assertEquals(convertedOs.getName(), imageToConvert.getName());
+ assertEquals(convertedOs.getFamily(), OsFamily.WINDOWS);
+ assertEquals(convertedOs.getDescription(), imageToConvert.getName());
+ assertEquals(convertedOs.getVersion(), "98");
+ assertEquals(convertedOs.getArch(), null);
+ assertFalse(convertedOs.is64Bit());
+ }
+
+ @Test
+ public void testRHEL() {
+ String name = "Red Hat EL";
+
+ Image imageToConvert = Image.builder().id("id-" + name).name(name).build();
+
+ ImageToOperatingSystem converter = new ImageToOperatingSystem(
+ new HashMap<OsFamily, Map<String, String>>());
+
+ OperatingSystem convertedOs = converter.apply(imageToConvert);
+
+ assertEquals(convertedOs.getName(), imageToConvert.getName());
+ assertEquals(convertedOs.getFamily(), OsFamily.RHEL);
+ assertEquals(convertedOs.getDescription(), imageToConvert.getName());
+ assertEquals(convertedOs.getVersion(), null);
+ assertEquals(convertedOs.getArch(), null);
+ assertTrue(convertedOs.is64Bit());
+ }
+
+ @Test
+ public void testOEL() {
+ String name = "Oracle EL";
+
+ Image imageToConvert = Image.builder().id("id-" + name).name(name).build();
+
+ ImageToOperatingSystem converter = new ImageToOperatingSystem(
+ new HashMap<OsFamily, Map<String, String>>());
+
+ OperatingSystem convertedOs = converter.apply(imageToConvert);
+
+ assertEquals(convertedOs.getName(), imageToConvert.getName());
+ assertEquals(convertedOs.getFamily(), OsFamily.OEL);
+ assertEquals(convertedOs.getDescription(), imageToConvert.getName());
+ assertEquals(convertedOs.getVersion(), null);
+ assertEquals(convertedOs.getArch(), null);
+ assertTrue(convertedOs.is64Bit());
+ }
+
+
+ ImageToOperatingSystem converterForUbuntu = new ImageToOperatingSystem(ImmutableMap.<OsFamily, Map<String, String>> of(
+ OsFamily.UBUNTU, ImmutableMap.of("lucid", "10.04", "maverick", "10.10", "natty", "11.04", "oneiric",
+ "11.10")));
+ @Test
+ public void testTryStackOneric() {
+
+ String name = "oneiric-server-cloudimg-amd64";
+
+ Image imageToConvert = Image.builder().id("id-" + name).name(name).build();
+
+ OperatingSystem convertedOs = converterForUbuntu.apply(imageToConvert);
+
+ assertEquals(convertedOs.getName(), imageToConvert.getName());
+ assertEquals(convertedOs.getFamily(), OsFamily.UBUNTU);
+ assertEquals(convertedOs.getDescription(), imageToConvert.getName());
+ assertEquals(convertedOs.getVersion(), "11.10");
+ assertEquals(convertedOs.getArch(), null);
+ assertTrue(convertedOs.is64Bit());
+ }
+
+ @Test
+ public void testTryStackNatty() {
+
+ String name = "natty-server-cloudimg-amd64";
+
+ Image imageToConvert = Image.builder().id("id-" + name).name(name).build();
+
+ OperatingSystem convertedOs = converterForUbuntu.apply(imageToConvert);
+
+ assertEquals(convertedOs.getName(), imageToConvert.getName());
+ assertEquals(convertedOs.getFamily(), OsFamily.UBUNTU);
+ assertEquals(convertedOs.getDescription(), imageToConvert.getName());
+ assertEquals(convertedOs.getVersion(), "11.04");
+ assertEquals(convertedOs.getArch(), null);
+ assertTrue(convertedOs.is64Bit());
+ }
+}
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/functions/NovaSecurityGroupInZoneToSecurityGroupTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroupTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroupTest.java
new file mode 100644
index 0000000..c884987
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroupTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.functions;
+
+import static com.google.common.collect.Iterables.transform;
+import static org.jclouds.openstack.nova.v2_0.compute.functions.NovaSecurityGroupToSecurityGroupTest.securityGroupWithCidr;
+import static org.jclouds.openstack.nova.v2_0.compute.functions.NovaSecurityGroupToSecurityGroupTest.securityGroupWithGroup;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Map;
+
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Andrew Bayer
+ */
+@Test(groups = "unit", testName = "NovaSecurityGroupInZoneToSecurityGroupTest")
+public class NovaSecurityGroupInZoneToSecurityGroupTest {
+
+ Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova")
+ .description("openstack-nova").build();
+ Location zone = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1")
+ .scope(LocationScope.ZONE).parent(provider).build();
+ Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
+ .<String, Location>of("az-1.region-a.geo-1", zone));
+
+
+ @Test
+ public void testApplyWithGroup() {
+ NovaSecurityGroupInZoneToSecurityGroup parser = createGroupParser();
+
+ SecurityGroupInZone origGroup = new SecurityGroupInZone(securityGroupWithGroup(), zone.getId());
+
+ SecurityGroup newGroup = parser.apply(origGroup);
+
+ assertEquals(newGroup.getId(), origGroup.getZone() + "/" + origGroup.getSecurityGroup().getId());
+ assertEquals(newGroup.getProviderId(), origGroup.getSecurityGroup().getId());
+ assertEquals(newGroup.getName(), origGroup.getSecurityGroup().getName());
+ assertEquals(newGroup.getOwnerId(), origGroup.getSecurityGroup().getTenantId());
+ assertEquals(newGroup.getIpPermissions(), ImmutableSet.copyOf(transform(origGroup.getSecurityGroup().getRules(),
+ NovaSecurityGroupToSecurityGroupTest.ruleConverter)));
+ assertEquals(newGroup.getLocation().getId(), origGroup.getZone());
+ }
+
+ @Test
+ public void testApplyWithCidr() {
+
+ NovaSecurityGroupInZoneToSecurityGroup parser = createGroupParser();
+
+ SecurityGroupInZone origGroup = new SecurityGroupInZone(securityGroupWithCidr(), zone.getId());
+
+ SecurityGroup newGroup = parser.apply(origGroup);
+
+ assertEquals(newGroup.getId(), origGroup.getZone() + "/" + origGroup.getSecurityGroup().getId());
+ assertEquals(newGroup.getProviderId(), origGroup.getSecurityGroup().getId());
+ assertEquals(newGroup.getName(), origGroup.getSecurityGroup().getName());
+ assertEquals(newGroup.getOwnerId(), origGroup.getSecurityGroup().getTenantId());
+ assertEquals(newGroup.getIpPermissions(), ImmutableSet.copyOf(transform(origGroup.getSecurityGroup().getRules(),
+ NovaSecurityGroupToSecurityGroupTest.ruleConverter)));
+ assertEquals(newGroup.getLocation().getId(), origGroup.getZone());
+ }
+
+ private NovaSecurityGroupInZoneToSecurityGroup createGroupParser() {
+ NovaSecurityGroupToSecurityGroup baseParser = new NovaSecurityGroupToSecurityGroup(NovaSecurityGroupToSecurityGroupTest.ruleConverter);
+
+ NovaSecurityGroupInZoneToSecurityGroup parser = new NovaSecurityGroupInZoneToSecurityGroup(baseParser, locationIndex);
+
+ return parser;
+ }
+}
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/functions/NovaSecurityGroupToSecurityGroupTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroupTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroupTest.java
new file mode 100644
index 0000000..6754087
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroupTest.java
@@ -0,0 +1,155 @@
+/*
+ * 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.functions;
+
+import static com.google.common.collect.Iterables.transform;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+import org.jclouds.openstack.nova.v2_0.domain.TenantIdAndName;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Functions;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * @author Andrew Bayer
+ */
+@Test(groups = "unit", testName = "NovaSecurityGroupToSecurityGroupTest")
+public class NovaSecurityGroupToSecurityGroupTest {
+
+ private static final Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova")
+ .description("openstack-nova").build();
+ private static final Location zone = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1")
+ .scope(LocationScope.ZONE).parent(provider).build();
+ private static final Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
+ .<String, Location>of("az-1.region-a.geo-1", zone));
+
+
+ private static final Predicate<AtomicReference<ZoneAndName>> returnSecurityGroupExistsInZone = Predicates.alwaysTrue();
+
+ private static final Map<ZoneAndName, SecurityGroupInZone> groupMap = ImmutableMap.of(
+ ZoneAndName.fromZoneAndName("az-1.region-a.geo-1", "some-group"), new SecurityGroupInZone(securityGroupWithGroup(), "az-1.region-a.geo-1"),
+ ZoneAndName.fromZoneAndName("az-1.region-a.geo-1", "some-other-group"), new SecurityGroupInZone(securityGroupWithCidr(), "az-1.region-a.geo-1"));
+
+ // weird compilation error means have to declare extra generics for call to build() - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818
+ private static final Supplier <LoadingCache<ZoneAndName, SecurityGroupInZone>> groupCache = Suppliers.<LoadingCache<ZoneAndName,SecurityGroupInZone>> ofInstance(
+ CacheBuilder.newBuilder().<ZoneAndName, SecurityGroupInZone>build(CacheLoader.from(Functions.forMap(groupMap))));
+
+ public static final SecurityGroupRuleToIpPermission ruleConverter = new SecurityGroupRuleToIpPermission(returnSecurityGroupExistsInZone, locationIndex,
+ groupCache.get());
+
+ public static org.jclouds.openstack.nova.v2_0.domain.SecurityGroup securityGroupWithGroup() {
+ TenantIdAndName group = TenantIdAndName.builder().tenantId("tenant").name("some-other-group").build();
+
+ SecurityGroupRule ruleToConvert = SecurityGroupRule.builder()
+ .id("some-id")
+ .ipProtocol(IpProtocol.TCP)
+ .fromPort(10)
+ .toPort(20)
+ .group(group)
+ .parentGroupId("some-other-id")
+ .build();
+
+ org.jclouds.openstack.nova.v2_0.domain.SecurityGroup origGroup = org.jclouds.openstack.nova.v2_0.domain.SecurityGroup.builder()
+ .tenantId("tenant")
+ .id("some-id")
+ .name("some-group")
+ .description("some-description")
+ .rules(ruleToConvert)
+ .build();
+
+ return origGroup;
+ }
+
+ public static org.jclouds.openstack.nova.v2_0.domain.SecurityGroup securityGroupWithCidr() {
+ SecurityGroupRule ruleToConvert = SecurityGroupRule.builder()
+ .id("some-id")
+ .ipProtocol(IpProtocol.TCP)
+ .fromPort(10)
+ .toPort(20)
+ .ipRange("0.0.0.0/0")
+ .parentGroupId("some-other-id")
+ .build();
+
+ org.jclouds.openstack.nova.v2_0.domain.SecurityGroup origGroup = org.jclouds.openstack.nova.v2_0.domain.SecurityGroup.builder()
+ .tenantId("tenant")
+ .id("some-id")
+ .name("some-other-group")
+ .description("some-description")
+ .rules(ruleToConvert)
+ .build();
+
+ return origGroup;
+ }
+
+ @Test
+ public void testApplyWithGroup() {
+ NovaSecurityGroupToSecurityGroup parser = createGroupParser();
+
+ org.jclouds.openstack.nova.v2_0.domain.SecurityGroup origGroup = securityGroupWithGroup();
+
+ SecurityGroup newGroup = parser.apply(origGroup);
+
+ assertEquals(newGroup.getId(), origGroup.getId());
+ assertEquals(newGroup.getProviderId(), origGroup.getId());
+ assertEquals(newGroup.getName(), origGroup.getName());
+ assertEquals(newGroup.getOwnerId(), origGroup.getTenantId());
+ assertEquals(newGroup.getIpPermissions(), ImmutableSet.copyOf(transform(origGroup.getRules(), ruleConverter)));
+ }
+
+ @Test
+ public void testApplyWithCidr() {
+
+ NovaSecurityGroupToSecurityGroup parser = createGroupParser();
+
+ org.jclouds.openstack.nova.v2_0.domain.SecurityGroup origGroup = securityGroupWithCidr();
+
+ SecurityGroup group = parser.apply(origGroup);
+
+ assertEquals(group.getId(), origGroup.getId());
+ assertEquals(group.getProviderId(), origGroup.getId());
+ assertEquals(group.getName(), origGroup.getName());
+ assertEquals(group.getOwnerId(), origGroup.getTenantId());
+ assertEquals(group.getIpPermissions(), ImmutableSet.copyOf(transform(origGroup.getRules(), ruleConverter)));
+ }
+
+ private NovaSecurityGroupToSecurityGroup createGroupParser() {
+ NovaSecurityGroupToSecurityGroup parser = new NovaSecurityGroupToSecurityGroup(ruleConverter);
+
+ return parser;
+ }
+
+}
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/functions/OrphanedGroupsByZoneIdTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneIdTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneIdTest.java
new file mode 100644
index 0000000..1f520dc
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneIdTest.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.functions;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LocationBuilder;
+import org.jclouds.domain.LocationScope;
+import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
+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.parse.ParseServerTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicates;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+
+/**
+ *
+ *
+ * @author Adrian Cole
+ */
+@Test(testName = "OrphanedGroupsByZoneIdTest")
+public class OrphanedGroupsByZoneIdTest {
+
+ Location provider = new LocationBuilder().scope(LocationScope.PROVIDER).id("openstack-nova").description(
+ "openstack-nova").build();
+ Location zone = new LocationBuilder().id("az-1.region-a.geo-1").description("az-1.region-a.geo-1").scope(
+ LocationScope.ZONE).parent(provider).build();
+ Supplier<Map<String, Location>> locationIndex = Suppliers.<Map<String, Location>> ofInstance(ImmutableMap
+ .<String, Location> of("az-1.region-a.geo-1", zone));
+
+ GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class);
+
+ @Test
+ public void testWhenComputeServiceSaysAllNodesAreDeadBothGroupsAreReturned() {
+
+ ServerInZone withoutHost = new ServerInZone(new ServerInZoneToNodeMetadataTest().expectedServer(), "az-1.region-a.geo-1");
+ ServerInZone withHost = new ServerInZone(new ParseServerTest().expected(), "az-1.region-a.geo-1");
+
+ ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
+ NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
+ .<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of()), Suppliers
+ .<Set<? extends Hardware>> ofInstance(ImmutableSet.<Hardware> of()), namingConvention);
+
+ Set<? extends NodeMetadata> set = ImmutableSet.of(converter.apply(withHost), converter.apply(withoutHost));
+
+ assertEquals(new OrphanedGroupsByZoneId(Predicates.<ZoneAndName> alwaysTrue()).apply(set), ImmutableMultimap
+ .<String, String> builder().putAll("az-1.region-a.geo-1", "sample", "test").build());
+ }
+
+ @Test
+ public void testWhenComputeServiceSaysAllNodesAreDeadNoGroupsAreReturned() {
+
+ ServerInZone withoutHost = new ServerInZone(new ServerInZoneToNodeMetadataTest().expectedServer(), "az-1.region-a.geo-1");
+ ServerInZone withHost = new ServerInZone(new ParseServerTest().expected(), "az-1.region-a.geo-1");
+
+ ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata(
+ NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, Suppliers
+ .<Set<? extends Image>> ofInstance(ImmutableSet.<Image> of()), Suppliers
+ .<Set<? extends Hardware>> ofInstance(ImmutableSet.<Hardware> of()), namingConvention);
+
+ Set<? extends NodeMetadata> set = ImmutableSet.of(converter.apply(withHost), converter.apply(withoutHost));
+
+ assertEquals(new OrphanedGroupsByZoneId(Predicates.<ZoneAndName> alwaysFalse()).apply(set), ImmutableMultimap
+ .<String, String> of());
+
+ }
+}
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/functions/SecurityGroupRuleToIpPermissionTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermissionTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermissionTest.java
new file mode 100644
index 0000000..59c59d0
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermissionTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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.functions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.net.domain.IpPermission;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+import org.jclouds.openstack.nova.v2_0.domain.TenantIdAndName;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+
+/**
+ * Tests for the function for transforming a nova specific SecurityGroupRule into a generic
+ * IpPermission object.
+ *
+ * @author Andrew Bayer
+ */
+public class SecurityGroupRuleToIpPermissionTest {
+
+ @Test
+ public void testApplyWithGroup() {
+
+ TenantIdAndName group = TenantIdAndName.builder().tenantId("tenant").name("some-group").build();
+
+ SecurityGroupRule ruleToConvert = SecurityGroupRule.builder()
+ .id("some-id")
+ .ipProtocol(IpProtocol.TCP)
+ .fromPort(10)
+ .toPort(20)
+ .group(group)
+ .parentGroupId("some-other-id")
+ .build();
+
+ IpPermission convertedPerm = NovaSecurityGroupToSecurityGroupTest.ruleConverter.apply(ruleToConvert);
+
+ assertEquals(convertedPerm.getIpProtocol(), ruleToConvert.getIpProtocol());
+ assertEquals(convertedPerm.getFromPort(), ruleToConvert.getFromPort());
+ assertEquals(convertedPerm.getToPort(), ruleToConvert.getToPort());
+ assertTrue(convertedPerm.getGroupIds().contains("az-1.region-a.geo-1/some-id"));
+ assertTrue(convertedPerm.getCidrBlocks().size() == 0);
+ }
+
+ @Test
+ public void testApplyWithCidr() {
+ SecurityGroupRule ruleToConvert = SecurityGroupRule.builder()
+ .id("some-id")
+ .ipProtocol(IpProtocol.TCP)
+ .fromPort(10)
+ .toPort(20)
+ .ipRange("0.0.0.0/0")
+ .parentGroupId("some-other-id")
+ .build();
+
+ IpPermission convertedPerm = NovaSecurityGroupToSecurityGroupTest.ruleConverter.apply(ruleToConvert);
+
+ assertEquals(convertedPerm.getIpProtocol(), ruleToConvert.getIpProtocol());
+ assertEquals(convertedPerm.getFromPort(), ruleToConvert.getFromPort());
+ assertEquals(convertedPerm.getToPort(), ruleToConvert.getToPort());
+ assertEquals(convertedPerm.getCidrBlocks(), ImmutableSet.of("0.0.0.0/0"));
+ assertTrue(convertedPerm.getTenantIdGroupNamePairs().size() == 0);
+ }
+}
[21/21] git commit: Merge branch 'master' of
https://git-wip-us.apache.org/repos/asf/incubator-stratos
Posted by ni...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/incubator-stratos
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/bf3a353b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/bf3a353b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/bf3a353b
Branch: refs/heads/master
Commit: bf3a353bceba2d520b41570b0cdd7e82263eea1c
Parents: d4243b7 5857efc
Author: Nirmal Fernando <ni...@apache.org>
Authored: Tue Mar 18 08:29:18 2014 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Tue Mar 18 08:29:18 2014 +0530
----------------------------------------------------------------------
----------------------------------------------------------------------
[08/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
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/extensions/FlavorExtraSpecsApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiLiveTest.java
new file mode 100644
index 0000000..d958324
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiLiveTest.java
@@ -0,0 +1,123 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Map;
+
+import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Maps;
+
+/**
+ * Tests behavior of FlavorExtraSpecsApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "live", testName = "FlavorExtraSpecsApiLiveTest", singleThreaded = true)
+public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest {
+ private FlavorApi flavorApi;
+ private Optional<? extends FlavorExtraSpecsApi> apiOption;
+ private String zone;
+
+ private Resource testFlavor;
+ private Map<String, String> testSpecs = ImmutableMap.of("jclouds-test", "some data", "jclouds-test2", "more data!");
+
+ @BeforeClass(groups = {"integration", "live"})
+ @Override
+ public void setup() {
+ super.setup();
+ zone = Iterables.getLast(api.getConfiguredZones(), "nova");
+ flavorApi = api.getFlavorApiForZone(zone);
+ apiOption = api.getFlavorExtraSpecsExtensionForZone(zone);
+ }
+
+ @AfterClass(groups = { "integration", "live" })
+ @Override
+ protected void tearDown() {
+ if (apiOption.isPresent() && testFlavor != null) {
+ for (String key : testSpecs.keySet()) {
+ assertTrue(apiOption.get().deleteMetadataKey(testFlavor.getId(), key));
+ }
+ }
+ super.tearDown();
+ }
+
+ public void testCreateExtraSpecs() {
+ if (apiOption.isPresent()) {
+ FlavorExtraSpecsApi api = apiOption.get();
+ testFlavor = Iterables.getLast(flavorApi.list().concat());
+ Map<String, String> before = api.getMetadata(testFlavor.getId());
+ assertNotNull(before);
+ Map<String, String> specs = Maps.newHashMap(before);
+ specs.putAll(testSpecs);
+ assertTrue(api.updateMetadata(testFlavor.getId(), specs));
+ assertEquals(api.getMetadata(testFlavor.getId()), specs);
+ for (Map.Entry<String, String> entry : specs.entrySet()) {
+ assertEquals(api.getMetadataKey(testFlavor.getId(), entry.getKey()), entry.getValue());
+ }
+ }
+ }
+
+ @Test(dependsOnMethods = "testCreateExtraSpecs")
+ public void testListExtraSpecs() {
+ if (apiOption.isPresent()) {
+ FlavorExtraSpecsApi api = apiOption.get();
+ for (String key : testSpecs.keySet()) {
+ assertTrue(api.getMetadata(testFlavor.getId()).containsKey(key));
+ }
+ for (Resource flavor : flavorApi.list().concat()) {
+ Map<String, String> specs = api.getMetadata(flavor.getId());
+ assertNotNull(specs);
+ for (Map.Entry<String, String> entry : specs.entrySet()) {
+ assertEquals(api.getMetadataKey(flavor.getId(), entry.getKey()), entry.getValue());
+ }
+ }
+ }
+ }
+
+ @Test(dependsOnMethods = "testCreateExtraSpecs")
+ public void testTwiddleIndividualSpecs() {
+ if (apiOption.isPresent()) {
+ FlavorExtraSpecsApi api = apiOption.get();
+ for (String key : testSpecs.keySet()) {
+ assertTrue(api.updateMetadataEntry(testFlavor.getId(), key, "new value"));
+ }
+ for (String key : testSpecs.keySet()) {
+ assertEquals(api.getMetadataKey(testFlavor.getId(), key), "new value");
+ }
+ for (Resource flavor : flavorApi.list().concat()) {
+ Map<String, String> specs = api.getMetadata(flavor.getId());
+ assertNotNull(specs);
+ for (Map.Entry<String, String> entry : specs.entrySet()) {
+ assertEquals(api.getMetadataKey(flavor.getId(), entry.getKey()), entry.getValue());
+ }
+ }
+ }
+ }
+}
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/extensions/FloatingIPApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiExpectTest.java
new file mode 100644
index 0000000..65cf1d4
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiExpectTest.java
@@ -0,0 +1,191 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseFloatingIPListTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseFloatingIPTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests annotation parsing of {@code FloatingIPAsyncApi}
+ *
+ * @author Michael Arnold
+ */
+@Test(groups = "unit", testName = "FloatingIPApiExpectTest")
+public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest {
+ public void testWhenNamespaceInExtensionsListFloatingIpPresent() throws Exception {
+
+ NovaApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse);
+
+ assertEquals(apiWhenExtensionNotInList.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
+
+ assertTrue(apiWhenExtensionNotInList.getFloatingIPExtensionForZone("az-1.region-a.geo-1").isPresent());
+
+ }
+
+ public void testWhenNamespaceNotInExtensionsListFloatingIpNotPresent() throws Exception {
+
+ NovaApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, unmatchedExtensionsOfNovaResponse);
+
+ assertEquals(apiWhenExtensionNotInList.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
+
+ assertFalse(apiWhenExtensionNotInList.getFloatingIPExtensionForZone("az-1.region-a.geo-1").isPresent());
+
+ }
+
+ public void testListFloatingIPsWhenResponseIs2xx() throws Exception {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/floatingip_list.json")).build();
+
+ NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
+
+ assertEquals(apiWhenFloatingIPsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
+
+ assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().list()
+ .toString(), new ParseFloatingIPListTest().expected().toString());
+ }
+
+ public void testListFloatingIPsWhenResponseIs404() throws Exception {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
+
+ assertTrue(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().list().isEmpty());
+ }
+
+ public void testGetFloatingIPWhenResponseIs2xx() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips/1")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse getResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/floatingip_details.json")).build();
+
+ NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse);
+
+ assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().get("1")
+ .toString(), new ParseFloatingIPTest().expected().toString());
+ }
+
+ public void testGetFloatingIPWhenResponseIs404() throws Exception {
+ HttpRequest get = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips/1")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse getResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse);
+
+ assertNull(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().get("1"));
+ }
+
+ public void testAllocateWhenResponseIs2xx() throws Exception {
+ HttpRequest createFloatingIP = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{}", "application/json")).build();
+
+ HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/floatingip_details.json")).build();
+
+ NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
+ createFloatingIPResponse);
+
+ assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create().toString(),
+ new ParseFloatingIPTest().expected().toString());
+
+ }
+
+ public void testAllocateWhenResponseIs404() throws Exception {
+ HttpRequest createFloatingIP = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{}", "application/json")).build();
+
+ HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
+ createFloatingIPResponse);
+
+ assertNull(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create());
+ }
+
+ public void testAllocateWithPoolNameWhenResponseIs2xx() throws Exception {
+ HttpRequest createFloatingIP = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"pool\":\"myPool\"}", "application/json")).build();
+
+ HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/floatingip_details.json")).build();
+
+ NovaApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
+ createFloatingIPResponse);
+
+ assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().allocateFromPool("myPool").toString(),
+ new ParseFloatingIPTest().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/extensions/FloatingIPApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java
new file mode 100644
index 0000000..d85604c
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java
@@ -0,0 +1,171 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.openstack.nova.v2_0.domain.Address;
+import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.features.ServerApi;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.Multimap;
+
+/**
+ * Tests behavior of {@code ServerApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", testName = "FloatingIPApiLiveTest")
+public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
+
+ private static final int INCONSISTENCY_WINDOW = 5000;
+
+ @Test
+ public void testListFloatingIPs() throws Exception {
+ for (String zoneId : api.getConfiguredZones()) {
+ Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId);
+ if (!apiOption.isPresent())
+ continue;
+ FloatingIPApi api = apiOption.get();
+ Set<? extends FloatingIP> response = api.list().toSet();
+ assert null != response;
+ assertTrue(response.size() >= 0);
+ for (FloatingIP ip : response) {
+ FloatingIP newDetails = api.get(ip.getId());
+
+ assertEquals(newDetails.getId(), ip.getId());
+ assertEquals(newDetails.getIp(), ip.getIp());
+ assertEquals(newDetails.getFixedIp(), ip.getFixedIp());
+ assertEquals(newDetails.getInstanceId(), ip.getInstanceId());
+
+ }
+ }
+ }
+
+ @Test
+ public void testAllocateAndDecreateFloatingIPs() throws Exception {
+ for (String zoneId : api.getConfiguredZones()) {
+ Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId);
+ if (!apiOption.isPresent())
+ continue;
+ FloatingIPApi api = apiOption.get();
+ FloatingIP floatingIP = api.create();
+ assertNotNull(floatingIP);
+
+ Set<? extends FloatingIP> response = api.list().toSet();
+ boolean ipInSet = false;
+ for (FloatingIP ip : response) {
+ if (ip.getId().equals(floatingIP.getId()))
+ ipInSet = true;
+ }
+ assertTrue(ipInSet);
+
+ api.delete(floatingIP.getId());
+
+ response = api.list().toSet();
+ ipInSet = false;
+ for (FloatingIP ip : response) {
+ if (ip.getId().equals(floatingIP.getId())) {
+ ipInSet = true;
+ }
+ }
+ assertFalse(ipInSet);
+ }
+ }
+
+ @Test
+ public void testAddAndRemoveFloatingIp() throws Exception {
+ for (String zoneId : api.getConfiguredZones()) {
+ Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId);
+ if (!apiOption.isPresent())
+ continue;
+ FloatingIPApi api = apiOption.get();
+ ServerApi serverApi = this.api.getServerApiForZone(zoneId);
+ Server server = createServerInZone(zoneId);
+ FloatingIP floatingIP = api.create();
+ assertNotNull(floatingIP);
+ try {
+ api.addToServer(floatingIP.getIp(), server.getId());
+ assertEventually(new ServerHasFloatingIP(serverApi, server.getId(), floatingIP.getIp()));
+ } finally {
+ api.removeFromServer(floatingIP.getIp(), server.getId());
+ serverApi.delete(server.getId());
+ }
+ }
+ }
+
+ protected static void assertEventually(Runnable assertion) {
+ long start = System.currentTimeMillis();
+ AssertionError error = null;
+ for (int i = 0; i < 30; i++) {
+ try {
+ assertion.run();
+ if (i > 0)
+ System.err.printf("%d attempts and %dms asserting %s%n", i + 1, System.currentTimeMillis() - start,
+ assertion.getClass().getSimpleName());
+ return;
+ } catch (AssertionError e) {
+ error = e;
+ }
+ try {
+ Thread.sleep(INCONSISTENCY_WINDOW / 30);
+ } catch (InterruptedException e) {
+ }
+ }
+ if (error != null)
+ throw error;
+
+ }
+
+ public static final class ServerHasFloatingIP implements Runnable {
+ private final ServerApi api;
+ private final String serverId;
+ private final String floatingIP;
+
+ public ServerHasFloatingIP(ServerApi serverApi, String serverId, String floatingIP) {
+ this.api = serverApi;
+ this.serverId = serverId;
+ this.floatingIP = floatingIP;
+ }
+
+ public void run() {
+ try {
+ Server server = api.get(serverId);
+ boolean ipInServerAddresses = false;
+ Multimap<String, Address> addresses = server.getAddresses();
+ for (Address address : addresses.values()) {
+ if (address.getAddr().equals(floatingIP)) {
+ ipInServerAddresses = true;
+ }
+ }
+ assertTrue(ipInServerAddresses);
+ } catch (Exception e) {
+ throw new AssertionError(e);
+ }
+ }
+ }
+
+}
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/extensions/HostAdministrationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiExpectTest.java
new file mode 100644
index 0000000..97861e3
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiExpectTest.java
@@ -0,0 +1,241 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.domain.Host;
+import org.jclouds.openstack.nova.v2_0.domain.HostResourceUsage;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests HostAdministrationApi guice wiring and parsing (including the Response parsers in FieldValueResponseParsers)
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "HostAdministrationApiExpectTest")
+public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest {
+
+
+ public void testList() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts");
+ HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("GET")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/hosts_list.json")).build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
+
+ Host expected = Host.builder().name("ubuntu").service("compute").build();
+
+ Set<? extends Host> result = api.list().toSet();
+ Host host = Iterables.getOnlyElement(result);
+ assertEquals(host.getName(), "ubuntu");
+ assertEquals(host.getService(), "compute");
+
+ assertEquals(host, expected);
+ }
+
+ public void testGet() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/xyz");
+ HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("GET")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host.json")).build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
+
+ Set<HostResourceUsage> expected = ImmutableSet.of(
+ HostResourceUsage.builder().memoryMb(16083).project("(total)").cpu(4).diskGb(181).host("ubuntu").build(),
+ HostResourceUsage.builder().memoryMb(3396).project("(used_now)").cpu(3).diskGb(5).host("ubuntu").build(),
+ HostResourceUsage.builder().memoryMb(6144).project("(used_max)").cpu(3).diskGb(80).host("ubuntu").build(),
+ HostResourceUsage.builder().memoryMb(6144).project("f8535069c3fb404cb61c873b1a0b4921").cpu(3).diskGb(80).host("ubuntu").build()
+ );
+
+ assertEquals(api.listResourceUsage("xyz").toSet(), expected);
+ }
+
+ public void testEnableHost() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu");
+ HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("PUT")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"status\":\"enable\"}", MediaType.APPLICATION_JSON))
+ .endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"status\":\"enabled\"}", MediaType.APPLICATION_JSON))
+ .build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
+ assertTrue(api.enable("ubuntu"));
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testEnableHostFailNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu");
+ HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("PUT")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"status\":\"enable\"}", MediaType.APPLICATION_JSON))
+ .endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404)
+ .build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
+ api.enable("ubuntu");
+ }
+
+ public void testEnableHostFailNotEnabled() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu");
+ HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("PUT")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"status\":\"enable\"}", MediaType.APPLICATION_JSON))
+ .endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"status\":\"disabled\"}", MediaType.APPLICATION_JSON))
+ .build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
+ assertFalse(api.enable("ubuntu"));
+ }
+
+ public void testDisableHost() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu");
+ HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("PUT")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"status\":\"disable\"}", MediaType.APPLICATION_JSON))
+ .endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"status\":\"disabled\"}", MediaType.APPLICATION_JSON))
+ .build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
+ assertTrue(api.disable("ubuntu"));
+ }
+
+ public void testStartMaintenance() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu");
+ HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("PUT")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"maintenance_mode\":\"enable\"}", MediaType.APPLICATION_JSON))
+ .endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"maintenance_mode\":\"on_maintenance\"}", MediaType.APPLICATION_JSON))
+ .build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
+ assertTrue(api.startMaintenance("ubuntu"));
+ }
+
+ public void testStopMaintenance() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu");
+ HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("PUT")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"maintenance_mode\":\"disable\"}", MediaType.APPLICATION_JSON))
+ .endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"maintenance_mode\":\"off_maintenance\"}", MediaType.APPLICATION_JSON))
+ .build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
+ assertTrue(api.stopMaintenance("ubuntu"));
+ }
+
+ public void testStartupHost() {
+ HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu/startup")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build(),
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"power_action\":\"startup\"}", MediaType.APPLICATION_JSON))
+ .build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
+ assertTrue(api.startup("ubuntu"));
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testStartupHostFailNotFound() {
+ HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu/startup")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build(),
+ HttpResponse.builder().statusCode(404).build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
+ assertTrue(api.startup("ubuntu"));
+ }
+
+ public void testStartupHostFailWrongActionInProgress() {
+ HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu/startup")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build(),
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"power_action\":\"shutdown\"}", MediaType.APPLICATION_JSON))
+ .build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
+ assertFalse(api.startup("ubuntu"));
+ }
+
+ public void testShutdownHost() {
+ HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu/shutdown")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build(),
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"power_action\":\"shutdown\"}", MediaType.APPLICATION_JSON))
+ .build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
+ assertTrue(api.shutdown("ubuntu"));
+ }
+
+ public void testRebootHost() {
+ HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu/reboot")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build(),
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType("{\"host\":\"ubuntu\",\"power_action\":\"reboot\"}", MediaType.APPLICATION_JSON))
+ .build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get();
+ assertTrue(api.reboot("ubuntu"));
+ }
+}
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/extensions/HostAdministrationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiLiveTest.java
new file mode 100644
index 0000000..814cd7d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiLiveTest.java
@@ -0,0 +1,116 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.openstack.nova.v2_0.domain.Host;
+import org.jclouds.openstack.nova.v2_0.domain.HostResourceUsage;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.testng.annotations.BeforeGroups;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests behavior of HostAdministrationApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "live", testName = "HostAdministrationApiLiveTest", singleThreaded = true)
+public class HostAdministrationApiLiveTest extends BaseNovaApiLiveTest {
+ private Optional<? extends HostAdministrationApi> optApi = Optional.absent();
+
+ Predicate<Host> isComputeHost = new Predicate<Host>() {
+ @Override
+ public boolean apply(Host input) {
+ return Objects.equal("compute", input.getService());
+ }
+ };
+
+ @BeforeGroups(groups = {"integration", "live"})
+ @Override
+ public void setup() {
+ super.setup();
+
+ if (identity.endsWith(":admin")) {
+ String zone = Iterables.getLast(api.getConfiguredZones(), "nova");
+ optApi = api.getHostAdministrationExtensionForZone(zone);
+ }
+ }
+
+ public void testListAndGet() throws Exception {
+ if (optApi.isPresent()) {
+ HostAdministrationApi api = optApi.get();
+ Set<? extends Host> hosts = api.list().toSet();
+ assertNotNull(hosts);
+ for (Host host : hosts) {
+ for (HostResourceUsage usage : api.listResourceUsage(host.getName())) {
+ assertEquals(usage.getHost(), host.getName());
+ assertNotNull(usage);
+ }
+ }
+ }
+ }
+
+ @Test(enabled = false)
+ public void testEnableDisable() throws Exception {
+ if (optApi.isPresent()) {
+ HostAdministrationApi api = optApi.get();
+ Host host = Iterables.find(api.list(), isComputeHost);
+
+ assertTrue(api.disable(host.getName()));
+ assertTrue(api.enable(host.getName()));
+ }
+ }
+
+ @Test(enabled = false)
+ public void testMaintenanceMode() throws Exception {
+ if (optApi.isPresent()) {
+ HostAdministrationApi api = optApi.get();
+ Host host = Iterables.find(api.list(), isComputeHost);
+ assertTrue(api.startMaintenance(host.getName()));
+ assertTrue(api.stopMaintenance(host.getName()));
+ }
+ }
+
+ @Test(enabled = false)
+ public void testReboot() throws Exception {
+ if (optApi.isPresent()) {
+ HostAdministrationApi api = optApi.get();
+ Host host = Iterables.find(api.list(), isComputeHost);
+ assertTrue(api.reboot(host.getName()));
+ }
+ }
+
+ @Test(enabled = false)
+ public void testShutdownAndStartup() throws Exception {
+ if (optApi.isPresent()) {
+ HostAdministrationApi api = optApi.get();
+ Host host = Iterables.find(api.list(), isComputeHost);
+ assertTrue(api.shutdown(host.getName()));
+ assertTrue(api.startup(host.getName()));
+ }
+ }
+}
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/extensions/HostAggregateApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiExpectTest.java
new file mode 100644
index 0000000..4f0ac08
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiExpectTest.java
@@ -0,0 +1,179 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.DateService;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.domain.HostAggregate;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests HostAggregateApi guice wiring and parsing
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "HostAggregateApiExpectTest")
+public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest {
+ private DateService dateService = new SimpleDateFormatDateService();
+
+ public void testList() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates");
+ HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_list.json")).build())
+ .getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
+
+ HostAggregate result = Iterables.getOnlyElement(api.list());
+ assertEquals(result, exampleHostAggregate());
+ }
+
+ public void testGet() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1");
+ HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_with_host_details.json")).build())
+ .getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertEquals(api.get("1"), exampleHostAggregateWithHost());
+ }
+
+ public void testGetFailNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1");
+ HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertNull(api.get("1"));
+ }
+
+ public void testCreateAggregate() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates");
+ HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("POST")
+ .payload(payloadFromStringWithContentType("{\"aggregate\":{\"name\":\"ubuntu1\",\"availability_zone\":\"nova\"}}", MediaType.APPLICATION_JSON))
+ .endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build())
+ .getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertEquals(api.createInAvailabilityZone("ubuntu1", "nova"), exampleHostAggregate());
+ }
+
+ public void testDeleteAggregate() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1");
+ HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(200).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.delete("1"));
+ }
+
+ public void testDeleteAggregateFailNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1");
+ HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(404).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.delete("1"));
+ }
+
+ public void testUpdateName() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1");
+ HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("POST")
+ .payload(payloadFromStringWithContentType("{\"aggregate\":{\"name\":\"newaggregatename\"}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertEquals(api.updateName("1", "newaggregatename"), exampleHostAggregate());
+ }
+
+ public void testUpdateAvailabilityZone() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1");
+ HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("POST")
+ .payload(payloadFromStringWithContentType("{\"aggregate\":{\"availability_zone\":\"zone1\"}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertEquals(api.updateAvailabilityZone("1", "zone1"), exampleHostAggregate());
+ }
+
+ public void testAddHost() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1/action");
+ HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("POST")
+ .payload(payloadFromStringWithContentType("{\"add_host\":{\"host\":\"ubuntu\"}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertEquals(api.addHost("1", "ubuntu"), exampleHostAggregate());
+ }
+
+ public void testRemoveHost() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1/action");
+ HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("POST")
+ .payload(payloadFromStringWithContentType("{\"remove_host\":{\"host\":\"ubuntu\"}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertEquals(api.removeHost("1", "ubuntu"), exampleHostAggregate());
+ }
+
+
+ public void testSetMetadata() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1/action");
+ HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("POST")
+ .payload(payloadFromStringWithContentType("{\"set_metadata\":{\"metadata\":{\"mykey\":\"some value or other\"}}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/host_aggregate_details.json")).build()).getHostAggregateExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertEquals(api.setMetadata("1", ImmutableMap.of("mykey", "some value or other")), exampleHostAggregate());
+ }
+
+ public HostAggregate exampleHostAggregate() {
+ return HostAggregate.builder().name("jclouds-test-a").availabilityZone("nova")
+ .created(dateService.iso8601SecondsDateParse("2012-05-11 11:40:17"))
+ .updated(dateService.iso8601SecondsDateParse("2012-05-11 11:46:44"))
+ .state("created").id("1").metadata(ImmutableMap.of("somekey", "somevalue", "anotherkey", "another val")).build();
+ }
+
+ public HostAggregate exampleHostAggregateWithHost() {
+ return exampleHostAggregate().toBuilder().hosts("ubuntu").build();
+ }
+}
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/extensions/HostAggregateApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiLiveTest.java
new file mode 100644
index 0000000..5a237db
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiLiveTest.java
@@ -0,0 +1,148 @@
+/*
+ * 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.extensions;
+
+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.Set;
+
+import org.jclouds.openstack.nova.v2_0.domain.Host;
+import org.jclouds.openstack.nova.v2_0.domain.HostAggregate;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests behavior of AggregateApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "live", testName = "AggregateApiLiveTest", singleThreaded = true)
+public class HostAggregateApiLiveTest extends BaseNovaApiLiveTest {
+ private Optional<? extends HostAggregateApi> apiOption;
+ private Optional<? extends HostAdministrationApi> hostAdminOption;
+
+ private HostAggregate testAggregate;
+
+ @BeforeClass(groups = {"integration", "live"})
+ @Override
+ public void setup() {
+ super.setup();
+ String zone = Iterables.getLast(api.getConfiguredZones(), "nova");
+ apiOption = api.getHostAggregateExtensionForZone(zone);
+ hostAdminOption = api.getHostAdministrationExtensionForZone(zone);
+ }
+
+ @AfterClass(groups = { "integration", "live" })
+ @Override
+ protected void tearDown() {
+ if (testAggregate != null) {
+ assertTrue(apiOption.get().delete(testAggregate.getId()));
+ }
+ super.tearDown();
+ }
+
+ public void testCreateAggregate() {
+ if (apiOption.isPresent()) {
+ // TODO assuming "nova" availability zone is present
+ testAggregate = apiOption.get().createInAvailabilityZone("jclouds-test-a", "nova");
+ }
+ }
+
+ @Test(dependsOnMethods = "testCreateAggregate")
+ public void testListAndGetAggregate() {
+ if (apiOption.isPresent()) {
+ HostAggregateApi api = apiOption.get();
+ Set<? extends HostAggregate> aggregates = api.list().toSet();
+ for (HostAggregate aggregate : aggregates) {
+ assertNotNull(aggregate.getId());
+ assertNotNull(aggregate.getName());
+ assertNotNull(aggregate.getAvailabilityZone());
+
+ HostAggregate details = api.get(aggregate.getId());
+ assertEquals(details.getId(), aggregate.getId());
+ assertEquals(details.getName(), aggregate.getName());
+ assertEquals(details.getAvailabilityZone(), aggregate.getAvailabilityZone());
+ assertEquals(details.getHosts(), aggregate.getHosts());
+ }
+ }
+ }
+
+ @Test(dependsOnMethods = "testCreateAggregate")
+ public void testModifyMetadata() {
+ if (apiOption.isPresent()) {
+ HostAggregateApi api = apiOption.get();
+ for (Map<String, String> theMetaData : ImmutableSet.of(
+ ImmutableMap.of("somekey", "somevalue"),
+ ImmutableMap.of("somekey", "some other value", "anotherkey", "another val")
+ )) {
+ // Apply changes
+ HostAggregate details = api.setMetadata(testAggregate.getId(), theMetaData);
+
+ // bug in openstack - metadata values are never removed, so we just checking what we've set
+ for (Map.Entry<String, String> entry : theMetaData.entrySet()) {
+ assertEquals(details.getMetadata().get(entry.getKey()), entry.getValue());
+ }
+
+ // Re-fetch to double-check
+ details = api.get(testAggregate.getId());
+ for (Map.Entry<String, String> entry : theMetaData.entrySet()) {
+ assertEquals(details.getMetadata().get(entry.getKey()), entry.getValue());
+ }
+ }
+ }
+ }
+
+ // Note the host will be added, but cannot remove it til
+ @Test(enabled = false, dependsOnMethods = "testCreateAggregate")
+ public void testModifyHosts() {
+ if (apiOption.isPresent() && hostAdminOption.isPresent()) {
+ HostAggregateApi api = apiOption.get();
+ Host host = Iterables.getFirst(hostAdminOption.get().list(), null);
+ assertNotNull(host);
+
+ String host_id = host.getName();
+ assertNotNull(host_id);
+ HostAggregate details;
+
+ try {
+ details = api.addHost(testAggregate.getId(), host_id);
+
+ assertEquals(details.getHosts(), ImmutableSet.of(host_id));
+
+ // re-fetch to double-check
+ details = api.get(testAggregate.getId());
+ assertEquals(details.getHosts(), ImmutableSet.of(host_id));
+
+ // TODO wait until status of aggregate isn't CHANGING (hostAdministration.shutdown?)
+ } finally {
+ details = api.removeHost(testAggregate.getId(), host_id);
+ }
+
+ assertEquals(details.getHosts(), ImmutableSet.of());
+ }
+ }
+}
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/extensions/KeyPairApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiExpectTest.java
new file mode 100644
index 0000000..55f0d58
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiExpectTest.java
@@ -0,0 +1,142 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseKeyPairListTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseKeyPairTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests annotation parsing of {@code KeyPairAsyncApi}
+ *
+ * @author Michael Arnold
+ */
+@Test(groups = "unit", testName = "KeyPairApiExpectTest")
+public class KeyPairApiExpectTest extends BaseNovaApiExpectTest {
+
+ public void testListKeyPairsWhenResponseIs2xx() throws Exception {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-keypairs")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/keypair_list.json")).build();
+
+ NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
+
+ assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
+
+ // NOTE this required a change to the KeyPair domain object toString method
+ assertEquals(apiWhenServersExist.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().list().toString(),
+ new ParseKeyPairListTest().expected().toString());
+ }
+
+ public void testListKeyPairsWhenResponseIs404() throws Exception {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-keypairs")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
+
+ assertTrue(apiWhenNoServersExist.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().list().isEmpty());
+
+ }
+
+ public void testCreateKeyPair() throws Exception {
+ HttpRequest create = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-keypairs")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"keypair\":{\"name\":\"testkeypair\"}}", "application/json"))
+ .build();
+
+ HttpResponse createResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/keypair_created.json")).build();
+
+ NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, create, createResponse);
+
+ assertEquals(apiWhenServersExist.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().create("testkeypair")
+ .toString(), new ParseKeyPairTest().expected().toString());
+
+ }
+
+ public void testCreateKeyPairWithPublicKey() throws Exception {
+ HttpRequest create = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-keypairs")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(
+ payloadFromStringWithContentType(
+ "{\"keypair\":{\"name\":\"testkeypair\",\"public_key\":\"ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001\n\"}}",
+ "application/json")).build();
+
+ HttpResponse createResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/keypair_created.json")).build();
+
+ NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, create, createResponse);
+
+ assertEquals(
+ apiWhenServersExist
+ .getKeyPairExtensionForZone("az-1.region-a.geo-1")
+ .get()
+ .createWithPublicKey(
+ "testkeypair",
+ "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001\n")
+ .toString(), new ParseKeyPairTest().expected().toString());
+ }
+
+ public void testDeleteKeyPair() throws Exception {
+ HttpRequest delete = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-keypairs/testkeypair")
+ .addHeader("Accept", "*/*")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(202).build();
+
+ NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, delete, deleteResponse);
+
+ assertTrue(apiWhenServersExist.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().delete("testkeypair"));
+ }
+}
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/extensions/KeyPairApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiLiveTest.java
new file mode 100644
index 0000000..da2e1e4
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiLiveTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertNotNull;
+
+import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.FluentIterable;
+
+/**
+ * Tests behavior of {@code KeyPairApi}
+ *
+ * @author Michael Arnold
+ */
+@Test(groups = "live", testName = "KeyPairApiLiveTest")
+public class KeyPairApiLiveTest extends BaseNovaApiLiveTest {
+
+ public void testListKeyPairs() throws Exception {
+ for (String zoneId : api.getConfiguredZones()) {
+ KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get();
+ FluentIterable<? extends KeyPair> keyPairsList = keyPairApi.list();
+ assertNotNull(keyPairsList);
+ }
+ }
+
+ public void testCreateAndDeleteKeyPair() throws Exception {
+ final String KEYPAIR_NAME = "testkp";
+ for (String zoneId : api.getConfiguredZones()) {
+ KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get();
+ KeyPair keyPair = null;
+ try {
+ keyPair = keyPairApi.create(KEYPAIR_NAME);
+ assertNotNull(keyPair);
+ } finally {
+ if (keyPair != null) {
+ keyPairApi.delete(KEYPAIR_NAME);
+ }
+ }
+ }
+ }
+
+ public void testCreateAndDeleteKeyPairWithPublicKey() throws Exception {
+ final String KEYPAIR_NAME = "testkp";
+ final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrrBREFxz3002l1HuXz0+UOdJQ/mOYD5DiJwwB/TOybwIKQJPOxJWA9gBoo4k9dthTKBTaEYbzrll7iZcp59E80S6mNiAr3mUgi+x5Y8uyXeJ2Ws+h6peVyFVUu9epkwpcTd1GVfdcVWsTajwDz9+lxCDhl0RZKDFoT0scTxbj/w== nova@nv-aw2az2-api0002";
+
+ for (String zoneId : api.getConfiguredZones()) {
+ KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get();
+ KeyPair keyPair = null;
+ try {
+ keyPair = keyPairApi.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY);
+ assertNotNull(keyPair);
+ } finally {
+ if (keyPair != null) {
+ keyPairApi.delete(KEYPAIR_NAME);
+ }
+ }
+ }
+ }
+}
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/extensions/QuotaApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiExpectTest.java
new file mode 100644
index 0000000..79e6747
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiExpectTest.java
@@ -0,0 +1,125 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.domain.Quota;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+/**
+ * Tests HostAdministrationApi guice wiring and parsing
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "QuotaApiExpectTest")
+public class QuotaApiExpectTest extends BaseNovaApiExpectTest {
+
+ public void testGetQuotas() throws Exception {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo");
+ QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/quotas.json")).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertEquals(api.getByTenant("demo"), getTestQuotas());
+ }
+
+ public void testGetQuotasFailsTenantNotFound() throws Exception {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo");
+ QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get();
+ assertNull(api.getByTenant("demo"));
+ }
+
+ public void testGetDefaultQuotas() throws Exception {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo/defaults");
+ QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/quotas.json")).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertEquals(api.getDefaultsForTenant("demo"), getTestQuotas());
+ }
+
+ public void testGetDefaultQuotasFailsTenantNotFound() throws Exception {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo/defaults");
+ QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get();
+ assertNull(api.getDefaultsForTenant("demo"));
+ }
+
+
+ public void testUpdateQuotas() throws Exception {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo");
+ QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().endpoint(endpoint).method("PUT")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromResourceWithContentType("/quotas.json", MediaType.APPLICATION_JSON))
+ .build(),
+ HttpResponse.builder().statusCode(200).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.updateQuotaOfTenant(getTestQuotas(), "demo"));
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testUpdateQuotasFailsNotFound() throws Exception {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo");
+ QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().endpoint(endpoint).method("PUT")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromResourceWithContentType("/quotas.json", MediaType.APPLICATION_JSON))
+ .build(),
+ HttpResponse.builder().statusCode(404).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get();
+
+ api.updateQuotaOfTenant(getTestQuotas(), "demo");
+ }
+
+ public static Quota getTestQuotas() {
+ return Quota.builder()
+ .metadataItems(128)
+ .injectedFileContentBytes(10240)
+ .injectedFiles(5)
+ .gigabytes(1000)
+ .ram(51200)
+ .floatingIps(10)
+ .securityGroups(10)
+ .securityGroupRules(20)
+ .instances(10)
+ .keyPairs(100)
+ .volumes(10)
+ .cores(20)
+ .id("demo").build();
+ }
+
+}
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/extensions/QuotaApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiLiveTest.java
new file mode 100644
index 0000000..1408223
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiLiveTest.java
@@ -0,0 +1,100 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.openstack.nova.v2_0.domain.Quota;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests behavior of QuotaApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "live", testName = "QuotaApiLiveTest", singleThreaded = true)
+public class QuotaApiLiveTest extends BaseNovaApiLiveTest {
+ private Optional<? extends QuotaApi> apiOption;
+ private String tenant;
+
+ @BeforeClass(groups = {"integration", "live"})
+ @Override
+ public void setup() {
+ super.setup();
+ tenant = identity.split(":")[0];
+ String zone = Iterables.getLast(api.getConfiguredZones(), "nova");
+ apiOption = api.getQuotaExtensionForZone(zone);
+ }
+
+ public void testGetQuotasForCurrentTenant() {
+ if (apiOption.isPresent()) {
+ Quota quota = apiOption.get().getByTenant(tenant);
+ assertQuotasIsValid(quota);
+ }
+ }
+
+ public void testGetDefaultQuotasForCurrentTenant() {
+ if (apiOption.isPresent()) {
+ Quota quota = apiOption.get().getDefaultsForTenant(tenant);
+ assertQuotasIsValid(quota);
+ }
+ }
+
+ public void testUpdateQuotasOfCurrentTenantThenReset() {
+ if (apiOption.isPresent()) {
+ QuotaApi api = apiOption.get();
+ Quota before = api.getByTenant(tenant);
+ assertQuotasIsValid(before);
+
+ Quota modified = before.toBuilder()
+ .cores(before.getCores() - 1)
+ .instances(before.getInstances() - 1)
+ .metadataItems(before.getMetadatas() - 1)
+ .ram(before.getRam() - 1)
+ .volumes(before.getVolumes() - 1)
+ .build();
+
+ assertTrue(api.updateQuotaOfTenant(modified, tenant));
+
+ assertEquals(api.getByTenant(tenant), modified);
+
+ assertTrue(api.updateQuotaOfTenant(before, tenant));
+
+ assertEquals(api.getByTenant(tenant), before);
+ }
+ }
+
+ protected void assertQuotasIsValid(Quota quota) {
+ assertTrue(quota.getCores() > 0);
+ assertTrue(quota.getFloatingIps() >= 0);
+ assertTrue(quota.getGigabytes() > 0);
+ assertTrue(quota.getInjectedFileContentBytes() >= 0);
+ assertTrue(quota.getInjectedFiles() >= 0);
+ assertTrue(quota.getInstances() > 0);
+ assertTrue(quota.getKeyPairs() > 0);
+ assertTrue(quota.getRam() > 0);
+ assertTrue(quota.getSecurityGroups() > 0);
+ assertTrue(quota.getSecurityGroupRules() > 0);
+ assertTrue(quota.getVolumes() > 0);
+ }
+}
[16/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java
new file mode 100644
index 0000000..a7b316a
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java
@@ -0,0 +1,476 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.util.Date;
+import java.util.Map;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.Multimap;
+
+/**
+ * A server is a virtual machine instance in the compute system. Flavor and image are requisite
+ * elements when creating a server.
+ *
+ * @author Adrian Cole
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-compute/1.1/content/Get_Server_Details-d1e2623.html"
+ * />
+ */
+public class Server extends Resource {
+ public static final String DISK_CONFIG_MANUAL = "MANUAL";
+ public static final String DISK_CONFIG_AUTO = "AUTO";
+
+ /**
+ * Servers contain a status attribute that can be used as an indication of the current server
+ * state. Servers with an ACTIVE status are available for use.
+ * <p/>
+ * Other possible values for the status attribute include: BUILD, REBUILD, SUSPENDED, RESIZE,
+ * VERIFY_RESIZE, REVERT_RESIZE, PASSWORD, REBOOT, HARD_REBOOT, DELETED, UNKNOWN, and ERROR.
+ *
+ * @author Adrian Cole
+ */
+ public static enum Status {
+
+ ACTIVE, BUILD, REBUILD, SUSPENDED, PAUSED, RESIZE, VERIFY_RESIZE, REVERT_RESIZE, PASSWORD, REBOOT, HARD_REBOOT, DELETED, UNKNOWN, ERROR, STOPPED, UNRECOGNIZED;
+
+ public String value() {
+ return name();
+ }
+
+ public static Status fromValue(String v) {
+ try {
+ return valueOf(v.replaceAll("\\(.*", ""));
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+ }
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromServer(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> extends Resource.Builder<T> {
+ protected String uuid;
+ protected String tenantId;
+ protected String userId;
+ protected Date updated;
+ protected Date created;
+ protected String hostId;
+ protected String accessIPv4;
+ protected String accessIPv6;
+ protected Server.Status status;
+ protected Resource image;
+ protected Resource flavor;
+ protected String keyName;
+ protected String configDrive;
+ protected Multimap<String, Address> addresses = ImmutableMultimap.of();
+ protected Map<String, String> metadata = ImmutableMap.of();
+ protected ServerExtendedStatus extendedStatus;
+ protected ServerExtendedAttributes extendedAttributes;
+ protected String diskConfig;
+
+ /**
+ * @see Server#getUuid()
+ */
+ public T uuid(String uuid) {
+ this.uuid = uuid;
+ return self();
+ }
+
+ /**
+ * @see Server#getTenantId()
+ */
+ public T tenantId(String tenantId) {
+ this.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * @see Server#getUserId()
+ */
+ public T userId(String userId) {
+ this.userId = userId;
+ return self();
+ }
+
+ /**
+ * @see Server#getUpdated()
+ */
+ public T updated(Date updated) {
+ this.updated = updated;
+ return self();
+ }
+
+ /**
+ * @see Server#getCreated()
+ */
+ public T created(Date created) {
+ this.created = created;
+ return self();
+ }
+
+ /**
+ * @see Server#getHostId()
+ */
+ public T hostId(String hostId) {
+ this.hostId = hostId;
+ return self();
+ }
+
+ /**
+ * @see Server#getAccessIPv4()
+ */
+ public T accessIPv4(String accessIPv4) {
+ this.accessIPv4 = accessIPv4;
+ return self();
+ }
+
+ /**
+ * @see Server#getAccessIPv6()
+ */
+ public T accessIPv6(String accessIPv6) {
+ this.accessIPv6 = accessIPv6;
+ return self();
+ }
+
+ /**
+ * @see Server#getStatus()
+ */
+ public T status(Server.Status status) {
+ this.status = status;
+ return self();
+ }
+
+ /**
+ * @see Server#getImage()
+ */
+ public T image(Resource image) {
+ this.image = image;
+ return self();
+ }
+
+ /**
+ * @see Server#getFlavor()
+ */
+ public T flavor(Resource flavor) {
+ this.flavor = flavor;
+ return self();
+ }
+
+ /**
+ * @see Server#getKeyName()
+ */
+ public T keyName(String keyName) {
+ this.keyName = keyName;
+ return self();
+ }
+
+ /**
+ * @see Server#getConfigDrive()
+ */
+ public T configDrive(String configDrive) {
+ this.configDrive = configDrive;
+ return self();
+ }
+
+ /**
+ * @see Server#getAddresses()
+ */
+ public T addresses(Multimap<String, Address> addresses) {
+ this.addresses = addresses;
+ return self();
+ }
+
+ /**
+ * @see Server#getMetadata()
+ */
+ public T metadata(Map<String, String> metadata) {
+ this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
+ return self();
+ }
+
+ /**
+ * @see Server#getExtendedStatus()
+ */
+ public T extendedStatus(ServerExtendedStatus extendedStatus) {
+ this.extendedStatus = extendedStatus;
+ return self();
+ }
+
+ /**
+ * @see Server#getExtendedAttributes()
+ */
+ public T extendedAttributes(ServerExtendedAttributes extendedAttributes) {
+ this.extendedAttributes = extendedAttributes;
+ return self();
+ }
+
+ /**
+ * @see Server#getDiskConfig()
+ */
+ public T diskConfig(String diskConfig) {
+ this.diskConfig = diskConfig;
+ return self();
+ }
+
+ public Server build() {
+ return new Server(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6,
+ status, image, flavor, keyName, configDrive, addresses, metadata, extendedStatus,
+ extendedAttributes, diskConfig);
+ }
+
+ public T fromServer(Server in) {
+ return super.fromResource(in)
+ .uuid(in.getUuid())
+ .tenantId(in.getTenantId())
+ .userId(in.getUserId())
+ .updated(in.getUpdated())
+ .created(in.getCreated())
+ .hostId(in.getHostId())
+ .accessIPv4(in.getAccessIPv4())
+ .accessIPv6(in.getAccessIPv6())
+ .status(in.getStatus())
+ .image(in.getImage())
+ .flavor(in.getFlavor())
+ .keyName(in.getKeyName())
+ .configDrive(in.getConfigDrive())
+ .addresses(in.getAddresses())
+ .metadata(in.getMetadata())
+ .extendedStatus(in.getExtendedStatus().orNull())
+ .extendedAttributes(in.getExtendedAttributes().orNull())
+ .diskConfig(in.getDiskConfig().orNull());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String uuid;
+ @Named("tenant_id")
+ private final String tenantId;
+ @Named("user_id")
+ private final String userId;
+ private final Date updated;
+ private final Date created;
+ private final String hostId;
+ private final String accessIPv4;
+ private final String accessIPv6;
+ private final Server.Status status;
+ private final Resource image;
+ private final Resource flavor;
+ @Named("key_name")
+ private final String keyName;
+ @Named("config_drive")
+ private final String configDrive;
+ private final Multimap<String, Address> addresses;
+ private final Map<String, String> metadata;
+ private final Optional<ServerExtendedStatus> extendedStatus;
+ private final Optional<ServerExtendedAttributes> extendedAttributes;
+ @Named("OS-DCF:diskConfig")
+ private final Optional<String> diskConfig;
+
+ @ConstructorProperties({
+ "id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "image", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig"
+ })
+ protected Server(String id, @Nullable String name, java.util.Set<Link> links, @Nullable String uuid, String tenantId,
+ String userId, @Nullable Date updated, Date created, @Nullable String hostId, @Nullable String accessIPv4,
+ @Nullable String accessIPv6, Server.Status status, Resource image, Resource flavor, @Nullable String keyName,
+ @Nullable String configDrive, Multimap<String, Address> addresses, Map<String, String> metadata,
+ @Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes,
+ @Nullable String diskConfig) {
+ super(id, name, links);
+ this.uuid = uuid;
+ this.tenantId = checkNotNull(tenantId, "tenantId");
+ this.userId = checkNotNull(userId, "userId");
+ this.updated = updated;
+ this.created = checkNotNull(created, "created");
+ this.hostId = Strings.emptyToNull(hostId);
+ this.accessIPv4 = Strings.emptyToNull(accessIPv4);
+ this.accessIPv6 = Strings.emptyToNull(accessIPv6);
+ this.status = checkNotNull(status, "status");
+ this.image = checkNotNull(image, "image");
+ this.flavor = checkNotNull(flavor, "flavor");
+ this.keyName = Strings.emptyToNull(keyName);
+ this.configDrive = Strings.emptyToNull(configDrive);
+ this.addresses = ImmutableMultimap.copyOf(checkNotNull(addresses, "addresses"));
+ this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
+ this.extendedStatus = Optional.fromNullable(extendedStatus);
+ this.extendedAttributes = Optional.fromNullable(extendedAttributes);
+ this.diskConfig = Optional.fromNullable(diskConfig);
+ }
+
+ /**
+ * only present until the id is in uuid form
+ *
+ * @return uuid, if id is an integer val
+ */
+ @Nullable
+ public String getUuid() {
+ return this.uuid;
+ }
+
+ public String getTenantId() {
+ return this.tenantId;
+ }
+
+ public String getUserId() {
+ return this.userId;
+ }
+
+ @Nullable
+ public Date getUpdated() {
+ return this.updated;
+ }
+
+ public Date getCreated() {
+ return this.created;
+ }
+
+ /**
+ * @return host identifier, or null if in {@link Status#BUILD}
+ */
+ @Nullable
+ public String getHostId() {
+ return this.hostId;
+ }
+
+ @Nullable
+ public String getAccessIPv4() {
+ return this.accessIPv4;
+ }
+
+ @Nullable
+ public String getAccessIPv6() {
+ return this.accessIPv6;
+ }
+
+ public Status getStatus() {
+ return this.status;
+ }
+
+ @Nullable
+ public String getConfigDrive() {
+ return this.configDrive;
+ }
+
+ public Resource getImage() {
+ return this.image;
+ }
+
+ public Resource getFlavor() {
+ return this.flavor;
+ }
+
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ /**
+ * @return the ip addresses assigned to the server
+ */
+ public Multimap<String, Address> getAddresses() {
+ return addresses;
+ }
+
+ /**
+ * @return keyName if extension is present and there is a value for this server
+ * @see KeyPairApi
+ */
+ @Nullable
+ public String getKeyName() {
+ return keyName;
+ }
+
+ /**
+ * Retrieves the extended server status fields (alias "OS-EXT-STS")
+ * <p/>
+ * NOTE: This field is only present if the Extended Status extension is installed.
+ *
+ * @see org.jclouds.openstack.nova.v2_0.features.ExtensionApi#getExtensionByAlias
+ * @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#EXTENDED_STATUS
+ */
+ public Optional<ServerExtendedStatus> getExtendedStatus() {
+ return this.extendedStatus;
+ }
+
+ /**
+ * Retrieves the extended server attributes fields (alias "OS-EXT-SRV-ATTR")
+ * <p/>
+ * NOTE: This field is only present if the The Extended Server Attributes API extension is installed.
+ *
+ * @see org.jclouds.openstack.nova.v2_0.features.ExtensionApi#getExtensionByAlias
+ * @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#EXTENDED_STATUS
+ */
+ public Optional<ServerExtendedAttributes> getExtendedAttributes() {
+ return this.extendedAttributes;
+ }
+
+ /**
+ * Disk config attribute from the Disk Config Extension (alias "OS-DCF").
+ * One of {@link Server#DISK_CONFIG_AUTO} or {@link Server#DISK_CONFIG_MANUAL}.
+ * This field is only present if the Disk Config extension is installed.
+ * <p/>
+ * NOTE: Typically a field like this would be implemented as an enum but this field was
+ * originally implmented as a String and {@link Server#DISK_CONFIG_AUTO} and
+ * {@link Server#DISK_CONFIG_MANUAL} were added later as Strings to preserve backwards
+ * compatibility.
+ *
+ * @see org.jclouds.openstack.nova.v2_0.features.ExtensionApi#getExtensionByAlias
+ * @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#DISK_CONFIG
+ * @see CreateServerOptions#getDiskConfig()
+ */
+ public Optional<String> getDiskConfig() {
+ return this.diskConfig;
+ }
+
+
+ // hashCode/equals from super is ok
+
+ @Override
+ protected ToStringHelper string() {
+ return super.string()
+ .add("uuid", uuid).add("tenantId", tenantId).add("userId", userId).add("updated", updated).add("created", created)
+ .add("hostId", hostId).add("accessIPv4", accessIPv4).add("accessIPv6", accessIPv6).add("status", status).add("image", image)
+ .add("flavor", flavor).add("keyName", keyName).add("configDrive", configDrive).add("addresses", addresses)
+ .add("metadata", metadata).add("extendedStatus", extendedStatus).add("extendedAttributes", extendedAttributes)
+ .add("diskConfig", diskConfig);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerCreated.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerCreated.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerCreated.java
new file mode 100644
index 0000000..dcaf6fc
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerCreated.java
@@ -0,0 +1,127 @@
+/*
+ * 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.domain;
+
+import java.beans.ConstructorProperties;
+import java.util.Set;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+
+/**
+ * Server Resource with administrative password returned by ServerApi#CreateServer calls
+ *
+ * @author Adam Lowe
+ * @see <a href=
+ "http://docs.openstack.org/api/openstack-compute/1.1/content/Get_Server_Details-d1e2623.html"
+ />
+*/
+public class ServerCreated extends Resource {
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromServerCreated(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+ protected String adminPass;
+ protected String diskConfig;
+
+ /**
+ * @see ServerCreated#getAdminPass()
+ */
+ public Builder adminPass(String adminPass) {
+ this.adminPass = adminPass;
+ return self();
+ }
+
+ /**
+ * @see ServerCreated#getDiskConfig()
+ */
+ public Builder diskConfig(String diskConfig) {
+ this.diskConfig = diskConfig;
+ return self();
+ }
+
+ public ServerCreated build() {
+ return new ServerCreated(id, name, links, adminPass, diskConfig);
+ }
+
+ public Builder fromServerCreated(ServerCreated in) {
+ return super.fromResource(in).adminPass(in.getAdminPass().orNull()).diskConfig(in.getDiskConfig().orNull());
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+ }
+
+ private final Optional<String> adminPass;
+ private final Optional<String> diskConfig;
+
+ @ConstructorProperties({
+ "id", "name", "links", "adminPass", "OS-DCF:diskConfig"
+ })
+ protected ServerCreated(String id, @Nullable String name, Set<Link> links, @Nullable String adminPass,
+ @Nullable String diskConfig) {
+ super(id, name, links);
+ this.adminPass = Optional.fromNullable(adminPass);
+ this.diskConfig = Optional.fromNullable(diskConfig);
+ }
+
+ /**
+ * present unless the nova install was configured with the option {@code enable_instance_password=false}
+ */
+ public Optional<String> getAdminPass() {
+ return this.adminPass;
+ }
+
+ /**
+ * @see CreateServerOptions#getDiskConfig()
+ */
+ public Optional<String> getDiskConfig() {
+ return this.diskConfig;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(adminPass, diskConfig);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ ServerCreated that = ServerCreated.class.cast(obj);
+ return super.equals(that) && Objects.equal(this.adminPass, that.adminPass)
+ && Objects.equal(this.diskConfig, that.diskConfig);
+ }
+
+ @Override
+ protected ToStringHelper string() {
+ return super.string().add("adminPass", adminPass.orNull()).add("diskConfig", diskConfig.orNull());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedAttributes.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedAttributes.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedAttributes.java
new file mode 100644
index 0000000..1390660
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedAttributes.java
@@ -0,0 +1,156 @@
+/*
+ * 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.domain;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * Additional attributes delivered by Extended Server Attributes extension (alias "OS-EXT-SRV-ATTR")
+ *
+ * @author Adam Lowe
+ * @see <a href=
+ "http://nova.openstack.org/api/nova.api.openstack.compute.contrib.extended_server_attributes.html"
+ />
+ * @see org.jclouds.openstack.nova.v2_0.features.ExtensionApi#getExtensionByAlias
+ * @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#EXTENDED_STATUS
+*/
+public class ServerExtendedAttributes {
+
+ public static String PREFIX;
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromServerExtendedAttributes(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String instanceName;
+ protected String hostName;
+ protected String hypervisorHostName;
+
+ /**
+ * @see ServerExtendedAttributes#getInstanceName()
+ */
+ public T instanceName(String instanceName) {
+ this.instanceName = instanceName;
+ return self();
+ }
+
+ /**
+ * @see ServerExtendedAttributes#getHostName()
+ */
+ public T hostName(String hostName) {
+ this.hostName = hostName;
+ return self();
+ }
+
+ /**
+ * @see ServerExtendedAttributes#getHypervisorHostName()
+ */
+ public T hypervisorHostName(String hypervisorHostName) {
+ this.hypervisorHostName = hypervisorHostName;
+ return self();
+ }
+
+ public ServerExtendedAttributes build() {
+ return new ServerExtendedAttributes(instanceName, hostName, hypervisorHostName);
+ }
+
+ public T fromServerExtendedAttributes(ServerExtendedAttributes in) {
+ return this
+ .instanceName(in.getInstanceName())
+ .hostName(in.getHostName())
+ .hypervisorHostName(in.getHypervisorHostName());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ @Named("OS-EXT-SRV-ATTR:instance_name")
+ private final String instanceName;
+ @Named("OS-EXT-SRV-ATTR:host")
+ private final String hostName;
+ @Named("OS-EXT-SRV-ATTR:hypervisor_hostname")
+ private final String hypervisorHostName;
+
+ @ConstructorProperties({
+ "OS-EXT-SRV-ATTR:instance_name", "OS-EXT-SRV-ATTR:host", "OS-EXT-SRV-ATTR:hypervisor_hostname"
+ })
+ protected ServerExtendedAttributes(@Nullable String instanceName, @Nullable String hostName, @Nullable String hypervisorHostName) {
+ this.instanceName = instanceName;
+ this.hostName = hostName;
+ this.hypervisorHostName = hypervisorHostName;
+ }
+
+ @Nullable
+ public String getInstanceName() {
+ return this.instanceName;
+ }
+
+ @Nullable
+ public String getHostName() {
+ return this.hostName;
+ }
+
+ @Nullable
+ public String getHypervisorHostName() {
+ return this.hypervisorHostName;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(instanceName, hostName, hypervisorHostName);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ ServerExtendedAttributes that = ServerExtendedAttributes.class.cast(obj);
+ return Objects.equal(this.instanceName, that.instanceName)
+ && Objects.equal(this.hostName, that.hostName)
+ && Objects.equal(this.hypervisorHostName, that.hypervisorHostName);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("instanceName", instanceName).add("hostName", hostName).add("hypervisorHostName", hypervisorHostName);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedStatus.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedStatus.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedStatus.java
new file mode 100644
index 0000000..33dcb75
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedStatus.java
@@ -0,0 +1,155 @@
+/*
+ * 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.domain;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * Additional attributes delivered by Extended Server Status extension (alias "OS-EXT-STS")
+ *
+ * @author Adam Lowe
+ * @see <a href=
+ "http://nova.openstack.org/api/nova.api.openstack.compute.contrib.extended_status.html"
+ />
+ * @see org.jclouds.openstack.nova.v2_0.features.ExtensionApi#getExtensionByAlias
+ * @see org.jclouds.openstack.nova.v1_1.extensions.ExtensionNamespaces#EXTENDED_STATUS (extended status?)
+*/
+public class ServerExtendedStatus {
+
+ public static String PREFIX;
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromServerExtendedStatus(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String taskState;
+ protected String vmState;
+ protected int powerState;
+
+ /**
+ * @see ServerExtendedStatus#getTaskState()
+ */
+ public T taskState(String taskState) {
+ this.taskState = taskState;
+ return self();
+ }
+
+ /**
+ * @see ServerExtendedStatus#getVmState()
+ */
+ public T vmState(String vmState) {
+ this.vmState = vmState;
+ return self();
+ }
+
+ /**
+ * @see ServerExtendedStatus#getPowerState()
+ */
+ public T powerState(int powerState) {
+ this.powerState = powerState;
+ return self();
+ }
+
+ public ServerExtendedStatus build() {
+ return new ServerExtendedStatus(taskState, vmState, powerState);
+ }
+
+ public T fromServerExtendedStatus(ServerExtendedStatus in) {
+ return this
+ .taskState(in.getTaskState())
+ .vmState(in.getVmState())
+ .powerState(in.getPowerState());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ @Named("OS-EXT-STS:task_state")
+ private final String taskState;
+ @Named("OS-EXT-STS:vm_state")
+ private final String vmState;
+ @Named("OS-EXT-STS:power_state")
+ private final int powerState;
+
+ @ConstructorProperties({
+ "OS-EXT-STS:task_state", "OS-EXT-STS:vm_state", "OS-EXT-STS:power_state"
+ })
+ protected ServerExtendedStatus(@Nullable String taskState, @Nullable String vmState, int powerState) {
+ this.taskState = taskState;
+ this.vmState = vmState;
+ this.powerState = powerState;
+ }
+
+ @Nullable
+ public String getTaskState() {
+ return this.taskState;
+ }
+
+ @Nullable
+ public String getVmState() {
+ return this.vmState;
+ }
+
+ public int getPowerState() {
+ return this.powerState;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(taskState, vmState, powerState);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ ServerExtendedStatus that = ServerExtendedStatus.class.cast(obj);
+ return Objects.equal(this.taskState, that.taskState)
+ && Objects.equal(this.vmState, that.vmState)
+ && Objects.equal(this.powerState, that.powerState);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("taskState", taskState).add("vmState", vmState).add("powerState", powerState);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerWithSecurityGroups.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerWithSecurityGroups.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerWithSecurityGroups.java
new file mode 100644
index 0000000..3d7a9b9
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerWithSecurityGroups.java
@@ -0,0 +1,128 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Multimap;
+
+/**
+ * Extended server returned by ServerWithSecurityGroupsApi
+ *
+ * @author Adam Lowe
+ * @see <a href=
+"http://docs.openstack.org/api/openstack-compute/1.1/content/Get_Server_Details-d1e2623.html"
+/>
+*/
+public class ServerWithSecurityGroups extends Server {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromServerWithSecurityGroups(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> extends Server.Builder<T> {
+ protected Set<String> securityGroupNames = ImmutableSet.of();
+
+ /**
+ * @see ServerWithSecurityGroups#getSecurityGroupNames()
+ */
+ public T securityGroupNames(Set<String> securityGroupNames) {
+ this.securityGroupNames = ImmutableSet.copyOf(checkNotNull(securityGroupNames, "securityGroupNames"));
+ return self();
+ }
+
+ public T securityGroupNames(String... in) {
+ return securityGroupNames(ImmutableSet.copyOf(in));
+ }
+
+ public ServerWithSecurityGroups build() {
+ return new ServerWithSecurityGroups(id, name, links, uuid, tenantId, userId, updated, created, hostId,
+ accessIPv4, accessIPv6, status, image, flavor, keyName, configDrive, addresses,
+ metadata, extendedStatus, extendedAttributes, diskConfig, securityGroupNames);
+ }
+
+ public T fromServerWithSecurityGroups(ServerWithSecurityGroups in) {
+ return super.fromServer(in)
+ .securityGroupNames(in.getSecurityGroupNames());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ @Named("security_groups")
+ private final Set<String> securityGroupNames;
+
+ @ConstructorProperties({
+ "id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "image", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig", "security_groups"
+ })
+ protected ServerWithSecurityGroups(String id, @Nullable String name, Set<Link> links, @Nullable String uuid,
+ String tenantId, String userId, Date updated, Date created, @Nullable String hostId,
+ @Nullable String accessIPv4, @Nullable String accessIPv6, Server.Status status, Resource image,
+ Resource flavor, @Nullable String keyName, @Nullable String configDrive,
+ Multimap<String, Address> addresses, Map<String, String> metadata,
+ @Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes,
+ @Nullable String diskConfig, Set<String> securityGroupNames) {
+ super(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6, status, image, flavor, keyName, configDrive, addresses, metadata, extendedStatus, extendedAttributes, diskConfig);
+ this.securityGroupNames = ImmutableSet.copyOf(checkNotNull(securityGroupNames, "securityGroupNames"));
+ }
+
+ public Set<String> getSecurityGroupNames() {
+ return this.securityGroupNames;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(securityGroupNames);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ ServerWithSecurityGroups that = ServerWithSecurityGroups.class.cast(obj);
+ return super.equals(that) && Objects.equal(this.securityGroupNames, that.securityGroupNames);
+ }
+
+ protected ToStringHelper string() {
+ return super.string()
+ .add("securityGroupNames", securityGroupNames);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleServerUsage.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleServerUsage.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleServerUsage.java
new file mode 100644
index 0000000..eba8531
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleServerUsage.java
@@ -0,0 +1,312 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.util.Date;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * Information the SimpleTenantUsage extension return data about each Server
+ *
+ * @author Adam Lowe
+*/
+public class SimpleServerUsage {
+
+ /**
+ */
+ public static enum Status {
+
+ UNRECOGNIZED, ACTIVE;
+
+ public String value() {
+ return name();
+ }
+
+ public static Status fromValue(String v) {
+ try {
+ return valueOf(v.toUpperCase());
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+
+ }
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromSimpleServerUsage(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String instanceName;
+ protected double hours;
+ protected double flavorMemoryMb;
+ protected double flavorLocalGb;
+ protected double flavorVcpus;
+ protected String tenantId;
+ protected String flavorName;
+ protected Date instanceCreated;
+ protected Date instanceTerminated;
+ protected SimpleServerUsage.Status instanceStatus;
+ protected long uptime;
+
+ /**
+ * @see SimpleServerUsage#getInstanceName()
+ */
+ public T instanceName(String instanceName) {
+ this.instanceName = instanceName;
+ return self();
+ }
+
+ /**
+ * @see SimpleServerUsage#getHours()
+ */
+ public T hours(double hours) {
+ this.hours = hours;
+ return self();
+ }
+
+ /**
+ * @see SimpleServerUsage#getFlavorMemoryMb()
+ */
+ public T flavorMemoryMb(double flavorMemoryMb) {
+ this.flavorMemoryMb = flavorMemoryMb;
+ return self();
+ }
+
+ /**
+ * @see SimpleServerUsage#getFlavorLocalGb()
+ */
+ public T flavorLocalGb(double flavorLocalGb) {
+ this.flavorLocalGb = flavorLocalGb;
+ return self();
+ }
+
+ /**
+ * @see SimpleServerUsage#getFlavorVcpus()
+ */
+ public T flavorVcpus(double flavorVcpus) {
+ this.flavorVcpus = flavorVcpus;
+ return self();
+ }
+
+ /**
+ * @see SimpleServerUsage#getTenantId()
+ */
+ public T tenantId(String tenantId) {
+ this.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * @see SimpleServerUsage#getFlavorName()
+ */
+ public T flavorName(String flavorName) {
+ this.flavorName = flavorName;
+ return self();
+ }
+
+ /**
+ * @see SimpleServerUsage#getInstanceCreated()
+ */
+ public T instanceCreated(Date instanceCreated) {
+ this.instanceCreated = instanceCreated;
+ return self();
+ }
+
+ /**
+ * @see SimpleServerUsage#getInstanceTerminated()
+ */
+ public T instanceTerminated(Date instanceTerminated) {
+ this.instanceTerminated = instanceTerminated;
+ return self();
+ }
+
+ /**
+ * @see SimpleServerUsage#getInstanceStatus()
+ */
+ public T instanceStatus(SimpleServerUsage.Status instanceStatus) {
+ this.instanceStatus = instanceStatus;
+ return self();
+ }
+
+ /**
+ * @see SimpleServerUsage#getUptime()
+ */
+ public T uptime(long uptime) {
+ this.uptime = uptime;
+ return self();
+ }
+
+ public SimpleServerUsage build() {
+ return new SimpleServerUsage(instanceName, hours, flavorMemoryMb, flavorLocalGb, flavorVcpus, tenantId, flavorName, instanceCreated, instanceTerminated, instanceStatus, uptime);
+ }
+
+ public T fromSimpleServerUsage(SimpleServerUsage in) {
+ return this
+ .instanceName(in.getInstanceName())
+ .hours(in.getHours())
+ .flavorMemoryMb(in.getFlavorMemoryMb())
+ .flavorLocalGb(in.getFlavorLocalGb())
+ .flavorVcpus(in.getFlavorVcpus())
+ .tenantId(in.getTenantId())
+ .flavorName(in.getFlavorName())
+ .instanceCreated(in.getInstanceCreated())
+ .instanceTerminated(in.getInstanceTerminated())
+ .instanceStatus(in.getInstanceStatus())
+ .uptime(in.getUptime());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ @Named("name")
+ private final String instanceName;
+ private final double hours;
+ @Named("memory_mb")
+ private final double flavorMemoryMb;
+ @Named("local_gb")
+ private final double flavorLocalGb;
+ @Named("vcpus")
+ private final double flavorVcpus;
+ @Named("tenant_id")
+ private final String tenantId;
+ @Named("flavor")
+ private final String flavorName;
+ @Named("started_at")
+ private final Date instanceCreated;
+ @Named("ended_at")
+ private final Date instanceTerminated;
+ @Named("state")
+ private final SimpleServerUsage.Status instanceStatus;
+ private final long uptime;
+
+ @ConstructorProperties({
+ "name", "hours", "memory_mb", "local_gb", "vcpus", "tenant_id", "flavor", "started_at", "ended_at", "state", "uptime"
+ })
+ protected SimpleServerUsage(String instanceName, double hours, double flavorMemoryMb, double flavorLocalGb, double flavorVcpus, String tenantId, String flavorName, Date instanceCreated, @Nullable Date instanceTerminated, SimpleServerUsage.Status instanceStatus, long uptime) {
+ this.instanceName = checkNotNull(instanceName, "instanceName");
+ this.hours = hours;
+ this.flavorMemoryMb = flavorMemoryMb;
+ this.flavorLocalGb = flavorLocalGb;
+ this.flavorVcpus = flavorVcpus;
+ this.tenantId = checkNotNull(tenantId, "tenantId");
+ this.flavorName = checkNotNull(flavorName, "flavorName");
+ this.instanceCreated = checkNotNull(instanceCreated, "instanceCreated");
+ this.instanceTerminated = instanceTerminated;
+ this.instanceStatus = checkNotNull(instanceStatus, "instanceStatus");
+ this.uptime = uptime;
+ }
+
+ public String getInstanceName() {
+ return this.instanceName;
+ }
+
+ public double getHours() {
+ return this.hours;
+ }
+
+ public double getFlavorMemoryMb() {
+ return this.flavorMemoryMb;
+ }
+
+ public double getFlavorLocalGb() {
+ return this.flavorLocalGb;
+ }
+
+ public double getFlavorVcpus() {
+ return this.flavorVcpus;
+ }
+
+ public String getTenantId() {
+ return this.tenantId;
+ }
+
+ public String getFlavorName() {
+ return this.flavorName;
+ }
+
+ public Date getInstanceCreated() {
+ return this.instanceCreated;
+ }
+
+ @Nullable
+ public Date getInstanceTerminated() {
+ return this.instanceTerminated;
+ }
+
+ public SimpleServerUsage.Status getInstanceStatus() {
+ return this.instanceStatus;
+ }
+
+ public long getUptime() {
+ return this.uptime;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(instanceName, hours, flavorMemoryMb, flavorLocalGb, flavorVcpus, tenantId, flavorName, instanceCreated, instanceTerminated, instanceStatus, uptime);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ SimpleServerUsage that = SimpleServerUsage.class.cast(obj);
+ return Objects.equal(this.instanceName, that.instanceName)
+ && Objects.equal(this.hours, that.hours)
+ && Objects.equal(this.flavorMemoryMb, that.flavorMemoryMb)
+ && Objects.equal(this.flavorLocalGb, that.flavorLocalGb)
+ && Objects.equal(this.flavorVcpus, that.flavorVcpus)
+ && Objects.equal(this.tenantId, that.tenantId)
+ && Objects.equal(this.flavorName, that.flavorName)
+ && Objects.equal(this.instanceCreated, that.instanceCreated)
+ && Objects.equal(this.instanceTerminated, that.instanceTerminated)
+ && Objects.equal(this.instanceStatus, that.instanceStatus)
+ && Objects.equal(this.uptime, that.uptime);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("instanceName", instanceName).add("hours", hours).add("flavorMemoryMb", flavorMemoryMb).add("flavorLocalGb", flavorLocalGb).add("flavorVcpus", flavorVcpus).add("tenantId", tenantId).add("flavorName", flavorName).add("instanceCreated", instanceCreated).add("instanceTerminated", instanceTerminated).add("instanceStatus", instanceStatus).add("uptime", uptime);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleTenantUsage.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleTenantUsage.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleTenantUsage.java
new file mode 100644
index 0000000..61cec18
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleTenantUsage.java
@@ -0,0 +1,245 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.util.Date;
+import java.util.Set;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Information the SimpleTenantUsage extension returns data about each tenant
+ *
+ * @author Adam Lowe
+*/
+public class SimpleTenantUsage {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromSimpleTenantUsage(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String tenantId;
+ protected double totalLocalGbUsage;
+ protected double totalVcpusUsage;
+ protected double totalMemoryMbUsage;
+ protected double totalHours;
+ protected Date start;
+ protected Date stop;
+ protected Set<SimpleServerUsage> serverUsages = ImmutableSet.of();
+
+ /**
+ * @see SimpleTenantUsage#getTenantId()
+ */
+ public T tenantId(String tenantId) {
+ this.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * @see SimpleTenantUsage#getTotalLocalGbUsage()
+ */
+ public T totalLocalGbUsage(double totalLocalGbUsage) {
+ this.totalLocalGbUsage = totalLocalGbUsage;
+ return self();
+ }
+
+ /**
+ * @see SimpleTenantUsage#getTotalVcpusUsage()
+ */
+ public T totalVcpusUsage(double totalVcpusUsage) {
+ this.totalVcpusUsage = totalVcpusUsage;
+ return self();
+ }
+
+ /**
+ * @see SimpleTenantUsage#getTotalMemoryMbUsage()
+ */
+ public T totalMemoryMbUsage(double totalMemoryMbUsage) {
+ this.totalMemoryMbUsage = totalMemoryMbUsage;
+ return self();
+ }
+
+ /**
+ * @see SimpleTenantUsage#getTotalHours()
+ */
+ public T totalHours(double totalHours) {
+ this.totalHours = totalHours;
+ return self();
+ }
+
+ /**
+ * @see SimpleTenantUsage#getStart()
+ */
+ public T start(Date start) {
+ this.start = start;
+ return self();
+ }
+
+ /**
+ * @see SimpleTenantUsage#getStop()
+ */
+ public T stop(Date stop) {
+ this.stop = stop;
+ return self();
+ }
+
+ /**
+ * @see SimpleTenantUsage#getServerUsages()
+ */
+ public T serverUsages(Set<SimpleServerUsage> serverUsages) {
+ this.serverUsages = ImmutableSet.copyOf(checkNotNull(serverUsages, "serverUsages"));
+ return self();
+ }
+
+ public T serverUsages(SimpleServerUsage... in) {
+ return serverUsages(ImmutableSet.copyOf(in));
+ }
+
+ public SimpleTenantUsage build() {
+ return new SimpleTenantUsage(tenantId, totalLocalGbUsage, totalVcpusUsage, totalMemoryMbUsage, totalHours, start, stop, serverUsages);
+ }
+
+ public T fromSimpleTenantUsage(SimpleTenantUsage in) {
+ return this
+ .tenantId(in.getTenantId())
+ .totalLocalGbUsage(in.getTotalLocalGbUsage())
+ .totalVcpusUsage(in.getTotalVcpusUsage())
+ .totalMemoryMbUsage(in.getTotalMemoryMbUsage())
+ .totalHours(in.getTotalHours())
+ .start(in.getStart())
+ .stop(in.getStop())
+ .serverUsages(in.getServerUsages());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ @Named("tenant_id")
+ private final String tenantId;
+ @Named("total_local_gb_usage")
+ private final double totalLocalGbUsage;
+ @Named("total_vcpus_usage")
+ private final double totalVcpusUsage;
+ @Named("total_memory_mb_usage")
+ private final double totalMemoryMbUsage;
+ @Named("total_hours")
+ private final double totalHours;
+ private final Date start;
+ private final Date stop;
+ @Named("server_usages")
+ private final Set<SimpleServerUsage> serverUsages;
+
+ @ConstructorProperties({
+ "tenant_id", "total_local_gb_usage", "total_vcpus_usage", "total_memory_mb_usage", "total_hours", "start", "stop", "server_usages"
+ })
+ protected SimpleTenantUsage(String tenantId, double totalLocalGbUsage, double totalVcpusUsage, double totalMemoryMbUsage, double totalHours, @Nullable Date start, @Nullable Date stop, @Nullable Set<SimpleServerUsage> serverUsages) {
+ this.tenantId = checkNotNull(tenantId, "tenantId");
+ this.totalLocalGbUsage = totalLocalGbUsage;
+ this.totalVcpusUsage = totalVcpusUsage;
+ this.totalMemoryMbUsage = totalMemoryMbUsage;
+ this.totalHours = totalHours;
+ this.start = start;
+ this.stop = stop;
+ this.serverUsages = serverUsages == null ? ImmutableSet.<SimpleServerUsage>of() : ImmutableSet.copyOf(serverUsages);
+ }
+
+ public String getTenantId() {
+ return this.tenantId;
+ }
+
+ public double getTotalLocalGbUsage() {
+ return this.totalLocalGbUsage;
+ }
+
+ public double getTotalVcpusUsage() {
+ return this.totalVcpusUsage;
+ }
+
+ public double getTotalMemoryMbUsage() {
+ return this.totalMemoryMbUsage;
+ }
+
+ public double getTotalHours() {
+ return this.totalHours;
+ }
+
+ @Nullable
+ public Date getStart() {
+ return this.start;
+ }
+
+ @Nullable
+ public Date getStop() {
+ return this.stop;
+ }
+
+ public Set<SimpleServerUsage> getServerUsages() {
+ return this.serverUsages;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(tenantId, totalLocalGbUsage, totalVcpusUsage, totalMemoryMbUsage, totalHours, start, stop, serverUsages);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ SimpleTenantUsage that = SimpleTenantUsage.class.cast(obj);
+ return Objects.equal(this.tenantId, that.tenantId)
+ && Objects.equal(this.totalLocalGbUsage, that.totalLocalGbUsage)
+ && Objects.equal(this.totalVcpusUsage, that.totalVcpusUsage)
+ && Objects.equal(this.totalMemoryMbUsage, that.totalMemoryMbUsage)
+ && Objects.equal(this.totalHours, that.totalHours)
+ && Objects.equal(this.start, that.start)
+ && Objects.equal(this.stop, that.stop)
+ && Objects.equal(this.serverUsages, that.serverUsages);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("tenantId", tenantId).add("totalLocalGbUsage", totalLocalGbUsage).add("totalVcpusUsage", totalVcpusUsage).add("totalMemoryMbUsage", totalMemoryMbUsage).add("totalHours", totalHours).add("start", start).add("stop", stop).add("serverUsages", serverUsages);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/TenantIdAndName.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/TenantIdAndName.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/TenantIdAndName.java
new file mode 100644
index 0000000..c90f40e
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/TenantIdAndName.java
@@ -0,0 +1,127 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * Class TenantIdAndName
+ *
+ * @author Adrian Cole
+*/
+public class TenantIdAndName {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromTenantIdAndName(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String tenantId;
+ protected String name;
+
+ /**
+ * @see TenantIdAndName#getTenantId()
+ */
+ public T tenantId(String tenantId) {
+ this.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * @see TenantIdAndName#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ public TenantIdAndName build() {
+ return new TenantIdAndName(tenantId, name);
+ }
+
+ public T fromTenantIdAndName(TenantIdAndName in) {
+ return this
+ .tenantId(in.getTenantId())
+ .name(in.getName());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ @Named("tenant_id")
+ private final String tenantId;
+ private final String name;
+
+ @ConstructorProperties({
+ "tenant_id", "name"
+ })
+ protected TenantIdAndName(String tenantId, String name) {
+ this.tenantId = checkNotNull(tenantId, "tenantId");
+ this.name = checkNotNull(name, "name");
+ }
+
+ public String getTenantId() {
+ return this.tenantId;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(tenantId, name);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ TenantIdAndName that = TenantIdAndName.class.cast(obj);
+ return Objects.equal(this.tenantId, that.tenantId)
+ && Objects.equal(this.name, that.name);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("tenantId", tenantId).add("name", name);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VirtualInterface.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VirtualInterface.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VirtualInterface.java
new file mode 100644
index 0000000..b77f242
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VirtualInterface.java
@@ -0,0 +1,128 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * Represents a Virtual Interface (VIF)
+ *
+ * @author Adam Lowe
+ * @see org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceApi
+*/
+public class VirtualInterface {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromVirtualInterface(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String id;
+ protected String macAddress;
+
+ /**
+ * @see VirtualInterface#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see VirtualInterface#getMacAddress()
+ */
+ public T macAddress(String macAddress) {
+ this.macAddress = macAddress;
+ return self();
+ }
+
+ public VirtualInterface build() {
+ return new VirtualInterface(id, macAddress);
+ }
+
+ public T fromVirtualInterface(VirtualInterface in) {
+ return this
+ .id(in.getId())
+ .macAddress(in.getMacAddress());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String id;
+ @Named("mac_address")
+ private final String macAddress;
+
+ @ConstructorProperties({
+ "id", "mac_address"
+ })
+ protected VirtualInterface(String id, String macAddress) {
+ this.id = checkNotNull(id, "id");
+ this.macAddress = checkNotNull(macAddress, "macAddress");
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public String getMacAddress() {
+ return this.macAddress;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, macAddress);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ VirtualInterface that = VirtualInterface.class.cast(obj);
+ return Objects.equal(this.id, that.id)
+ && Objects.equal(this.macAddress, that.macAddress);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("id", id).add("macAddress", macAddress);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Volume.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Volume.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Volume.java
new file mode 100644
index 0000000..7fecfb2
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Volume.java
@@ -0,0 +1,346 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.CaseFormat;
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * An OpenStack Nova Volume
+*/
+public class Volume {
+
+ /**
+ */
+ public static enum Status {
+ CREATING, AVAILABLE, IN_USE, DELETING, ERROR, UNRECOGNIZED;
+ public String value() {
+ return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static Status fromValue(String status) {
+ try {
+ return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status")));
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+ }
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromVolume(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String id;
+ protected Volume.Status status;
+ protected int size;
+ protected String zone;
+ protected Date created;
+ protected Set<VolumeAttachment> attachments = ImmutableSet.of();
+ protected String volumeType;
+ protected String snapshotId;
+ protected String name;
+ protected String description;
+ protected Map<String, String> metadata = ImmutableMap.of();
+
+ /**
+ * @see Volume#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see Volume#getStatus()
+ */
+ public T status(Volume.Status status) {
+ this.status = status;
+ return self();
+ }
+
+ /**
+ * @see Volume#getSize()
+ */
+ public T size(int size) {
+ this.size = size;
+ return self();
+ }
+
+ /**
+ * @see Volume#getZone()
+ */
+ public T zone(String zone) {
+ this.zone = zone;
+ return self();
+ }
+
+ /**
+ * @see Volume#getCreated()
+ */
+ public T created(Date created) {
+ this.created = created;
+ return self();
+ }
+
+ /**
+ * @see Volume#getAttachments()
+ */
+ public T attachments(Set<VolumeAttachment> attachments) {
+ this.attachments = ImmutableSet.copyOf(checkNotNull(attachments, "attachments"));
+ return self();
+ }
+
+ public T attachments(VolumeAttachment... in) {
+ return attachments(ImmutableSet.copyOf(in));
+ }
+
+ /**
+ * @see Volume#getVolumeType()
+ */
+ public T volumeType(String volumeType) {
+ this.volumeType = volumeType;
+ return self();
+ }
+
+ /**
+ * @see Volume#getSnapshotId()
+ */
+ public T snapshotId(String snapshotId) {
+ this.snapshotId = snapshotId;
+ return self();
+ }
+
+ /**
+ * @see Volume#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see Volume#getDescription()
+ */
+ public T description(String description) {
+ this.description = description;
+ return self();
+ }
+
+ /**
+ * @see Volume#getMetadata()
+ */
+ public T metadata(Map<String, String> metadata) {
+ this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
+ return self();
+ }
+
+ public Volume build() {
+ return new Volume(id, status, size, zone, created, attachments, volumeType, snapshotId, name, description, metadata);
+ }
+
+ public T fromVolume(Volume in) {
+ return this
+ .id(in.getId())
+ .status(in.getStatus())
+ .size(in.getSize())
+ .zone(in.getZone())
+ .created(in.getCreated())
+ .attachments(in.getAttachments())
+ .volumeType(in.getVolumeType())
+ .snapshotId(in.getSnapshotId())
+ .name(in.getName())
+ .description(in.getDescription())
+ .metadata(in.getMetadata());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String id;
+ private final Volume.Status status;
+ private final int size;
+ @Named("availabilityZone")
+ private final String zone;
+ @Named("createdAt")
+ private final Date created;
+ private final Set<VolumeAttachment> attachments;
+ private final String volumeType;
+ private final String snapshotId;
+ @Named("displayName")
+ private final String name;
+ @Named("displayDescription")
+ private final String description;
+ private final Map<String, String> metadata;
+
+ @ConstructorProperties({
+ "id", "status", "size", "availabilityZone", "createdAt", "attachments", "volumeType", "snapshotId", "displayName", "displayDescription", "metadata"
+ })
+ protected Volume(String id, Volume.Status status, int size, String zone, Date created, @Nullable Set<VolumeAttachment> attachments, @Nullable String volumeType, @Nullable String snapshotId, @Nullable String name, @Nullable String description, @Nullable Map<String, String> metadata) {
+ this.id = checkNotNull(id, "id");
+ this.status = checkNotNull(status, "status");
+ this.size = size;
+ this.zone = checkNotNull(zone, "zone");
+ this.created = checkNotNull(created, "created");
+ this.attachments = attachments == null ? ImmutableSet.<VolumeAttachment>of() : ImmutableSet.copyOf(attachments);
+ this.volumeType = volumeType;
+ this.snapshotId = snapshotId;
+ this.name = name;
+ this.description = description;
+ this.metadata = metadata == null ? ImmutableMap.<String, String>of() : ImmutableMap.copyOf(metadata);
+ }
+
+ /**
+ * @return the id of this volume
+ */
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * @return the status of this volume
+ */
+ public Volume.Status getStatus() {
+ return this.status;
+ }
+
+ /**
+ * @return the size in GB of this volume
+ */
+ public int getSize() {
+ return this.size;
+ }
+
+ /**
+ * @return the availabilityZone containing this volume
+ */
+ public String getZone() {
+ return this.zone;
+ }
+
+ /**
+ * @return the time this volume was created
+ */
+ public Date getCreated() {
+ return this.created;
+ }
+
+ /**
+ * @return the set of attachments (to Servers)
+ */
+ public Set<VolumeAttachment> getAttachments() {
+ return this.attachments;
+ }
+
+ /**
+ * @return the type of this volume
+ */
+ @Nullable
+ public String getVolumeType() {
+ return this.volumeType;
+ }
+
+ @Nullable
+ public String getSnapshotId() {
+ return this.snapshotId;
+ }
+
+ /**
+ * @return the name of this volume - as displayed in the openstack console
+ */
+ @Nullable
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * @return the description of this volume - as displayed in the openstack console
+ */
+ @Nullable
+ public String getDescription() {
+ return this.description;
+ }
+
+ public Map<String, String> getMetadata() {
+ return this.metadata;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, status, size, zone, created, attachments, volumeType, snapshotId, name, description, metadata);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Volume that = Volume.class.cast(obj);
+ return Objects.equal(this.id, that.id)
+ && Objects.equal(this.status, that.status)
+ && Objects.equal(this.size, that.size)
+ && Objects.equal(this.zone, that.zone)
+ && Objects.equal(this.created, that.created)
+ && Objects.equal(this.attachments, that.attachments)
+ && Objects.equal(this.volumeType, that.volumeType)
+ && Objects.equal(this.snapshotId, that.snapshotId)
+ && Objects.equal(this.name, that.name)
+ && Objects.equal(this.description, that.description)
+ && Objects.equal(this.metadata, that.metadata);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("id", id).add("status", status).add("size", size).add("zone", zone).add("created", created).add("attachments", attachments).add("volumeType", volumeType).add("snapshotId", snapshotId).add("name", name).add("description", description).add("metadata", metadata);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeAttachment.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeAttachment.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeAttachment.java
new file mode 100644
index 0000000..894f85b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeAttachment.java
@@ -0,0 +1,172 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * An OpenStack Nova Volume Attachment (describes how Volumes are attached to Servers)
+*/
+public class VolumeAttachment {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromVolumeAttachment(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String id;
+ protected String volumeId;
+ protected String serverId;
+ protected String device;
+
+ /**
+ * @see VolumeAttachment#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see VolumeAttachment#getVolumeId()
+ */
+ public T volumeId(String volumeId) {
+ this.volumeId = volumeId;
+ return self();
+ }
+
+ /**
+ * @see VolumeAttachment#getServerId()
+ */
+ public T serverId(String serverId) {
+ this.serverId = serverId;
+ return self();
+ }
+
+ /**
+ * @see VolumeAttachment#getDevice()
+ */
+ public T device(String device) {
+ this.device = device;
+ return self();
+ }
+
+ public VolumeAttachment build() {
+ return new VolumeAttachment(id, volumeId, serverId, device);
+ }
+
+ public T fromVolumeAttachment(VolumeAttachment in) {
+ return this
+ .id(in.getId())
+ .volumeId(in.getVolumeId())
+ .serverId(in.getServerId())
+ .device(in.getDevice());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String id;
+ private final String volumeId;
+ private final String serverId;
+ private final String device;
+
+ @ConstructorProperties({
+ "id", "volumeId", "serverId", "device"
+ })
+ protected VolumeAttachment(String id, String volumeId, @Nullable String serverId, @Nullable String device) {
+ this.id = checkNotNull(id, "id");
+ this.volumeId = checkNotNull(volumeId, "volumeId");
+ this.serverId = serverId;
+ this.device = device;
+ }
+
+ /**
+ * @return the attachment id (typically the same as #getVolumeId())
+ */
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * @return the id of the volume attached
+ */
+ public String getVolumeId() {
+ return this.volumeId;
+ }
+
+ /**
+ * @return the id of the server the volume is attached to
+ */
+ @Nullable
+ public String getServerId() {
+ return this.serverId;
+ }
+
+ /**
+ * @return the device name (e.g. "/dev/vdc")
+ */
+ @Nullable
+ public String getDevice() {
+ return this.device;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, volumeId, serverId, device);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ VolumeAttachment that = VolumeAttachment.class.cast(obj);
+ return Objects.equal(this.id, that.id)
+ && Objects.equal(this.volumeId, that.volumeId)
+ && Objects.equal(this.serverId, that.serverId)
+ && Objects.equal(this.device, that.device);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("id", id).add("volumeId", volumeId).add("serverId", serverId).add("device", device);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
[17/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java
new file mode 100644
index 0000000..c353ab0
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java
@@ -0,0 +1,211 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+
+/**
+ * A flavor is an available hardware configuration for a server. Each flavor has
+ * a unique combination of disk space and memory capacity.
+ *
+ * @author Jeremy Daggett, Ilja Bobkevic
+ * @see <a href=
+ "http://docs.openstack.org/api/openstack-compute/2/content/List_Flavors-d1e4188.html"
+ />
+*/
+public class Flavor extends Resource {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromFlavor(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> extends Resource.Builder<T> {
+ protected int ram;
+ protected int disk;
+ protected int vcpus;
+ protected String swap;
+ protected Double rxtxFactor;
+ protected Integer ephemeral;
+
+ /**
+ * @see Flavor#getRam()
+ */
+ public T ram(int ram) {
+ this.ram = ram;
+ return self();
+ }
+
+ /**
+ * @see Flavor#getDisk()
+ */
+ public T disk(int disk) {
+ this.disk = disk;
+ return self();
+ }
+
+ /**
+ * @see Flavor#getVcpus()
+ */
+ public T vcpus(int vcpus) {
+ this.vcpus = vcpus;
+ return self();
+ }
+
+ /**
+ * @see Flavor#getSwap()
+ */
+ public T swap(String swap) {
+ this.swap = swap;
+ return self();
+ }
+
+ /**
+ * @see Flavor#getRxtxFactor()
+ */
+ public T rxtxFactor(Double rxtxFactor) {
+ this.rxtxFactor = rxtxFactor;
+ return self();
+ }
+
+ /**
+ * @see Flavor#getEphemeral()
+ */
+ public T ephemeral(Integer ephemeral) {
+ this.ephemeral = ephemeral;
+ return self();
+ }
+
+ public Flavor build() {
+ return new Flavor(id, name, links, ram, disk, vcpus, swap, rxtxFactor, ephemeral);
+ }
+
+ public T fromFlavor(Flavor in) {
+ return super.fromResource(in)
+ .ram(in.getRam())
+ .disk(in.getDisk())
+ .vcpus(in.getVcpus())
+ .swap(in.getSwap().orNull())
+ .rxtxFactor(in.getRxtxFactor().orNull())
+ .ephemeral(in.getEphemeral().orNull());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final int ram;
+ private final int disk;
+ private final int vcpus;
+ private final Optional<String> swap;
+ @Named("rxtx_factor")
+ private final Optional<Double> rxtxFactor;
+ @Named("OS-FLV-EXT-DATA:ephemeral")
+ private final Optional<Integer> ephemeral;
+
+ @ConstructorProperties({
+ "id", "name", "links", "ram", "disk", "vcpus", "swap", "rxtx_factor", "OS-FLV-EXT-DATA:ephemeral"
+ })
+ protected Flavor(String id, String name, java.util.Set<Link> links, int ram, int disk, int vcpus,
+ @Nullable String swap, @Nullable Double rxtxFactor, @Nullable Integer ephemeral) {
+ super(id, checkNotNull(name, "name"), links);
+ checkArgument(ram > 0, "Value of ram has to greater than 0");
+ checkArgument(vcpus > 0, "Value of vcpus has to greater than 0");
+ this.ram = ram;
+ this.disk = disk;
+ this.vcpus = vcpus;
+ this.swap = Optional.fromNullable(swap);
+ this.rxtxFactor = Optional.fromNullable(rxtxFactor);
+ this.ephemeral = Optional.fromNullable(ephemeral);
+ }
+
+ public int getRam() {
+ return this.ram;
+ }
+
+ public int getDisk() {
+ return this.disk;
+ }
+
+ public int getVcpus() {
+ return this.vcpus;
+ }
+
+ public Optional<String> getSwap() {
+ return this.swap;
+ }
+
+ public Optional<Double> getRxtxFactor() {
+ return this.rxtxFactor;
+ }
+
+ /**
+ * Retrieves ephemeral disk space in GB
+ * <p/>
+ * NOTE: This field is only present if the Flavor Extra Data extension is installed (alias "OS-FLV-EXT-DATA").
+ *
+ * @see org.jclouds.openstack.nova.v2_0.features.ExtensionApi#getExtensionByAlias
+ * @see org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces#FLAVOR_EXTRA_DATA
+ */
+ public Optional<Integer> getEphemeral() {
+ return this.ephemeral;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(ram, disk, vcpus, swap, rxtxFactor, ephemeral);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Flavor that = Flavor.class.cast(obj);
+ return super.equals(that) && Objects.equal(this.ram, that.ram)
+ && Objects.equal(this.disk, that.disk)
+ && Objects.equal(this.vcpus, that.vcpus)
+ && Objects.equal(this.swap, that.swap)
+ && Objects.equal(this.rxtxFactor, that.rxtxFactor)
+ && Objects.equal(this.ephemeral, that.ephemeral);
+ }
+
+ protected ToStringHelper string() {
+ return super.string()
+ .add("ram", ram).add("disk", disk).add("vcpus", vcpus).add("swap", swap).add("rxtxFactor", rxtxFactor).add("ephemeral", ephemeral);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java
new file mode 100644
index 0000000..203b2da
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java
@@ -0,0 +1,173 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * A Floating IP is an IP address that can be created and associated with a
+ * Server instance. Floating IPs can also be disassociated and deleted from a
+ * Server instance.
+ *
+ * @author Jeremy Daggett
+ * @author chamerling
+*/
+public class FloatingIP implements Comparable<FloatingIP> {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromFloatingIP(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String id;
+ protected String ip;
+ protected String fixedIp;
+ protected String instanceId;
+
+ /**
+ * @see FloatingIP#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see FloatingIP#getIp()
+ */
+ public T ip(String ip) {
+ this.ip = ip;
+ return self();
+ }
+
+ /**
+ * @see FloatingIP#getFixedIp()
+ */
+ public T fixedIp(String fixedIp) {
+ this.fixedIp = fixedIp;
+ return self();
+ }
+
+ /**
+ * @see FloatingIP#getInstanceId()
+ */
+ public T instanceId(String instanceId) {
+ this.instanceId = instanceId;
+ return self();
+ }
+
+ public FloatingIP build() {
+ return new FloatingIP(id, ip, fixedIp, instanceId);
+ }
+
+ public T fromFloatingIP(FloatingIP in) {
+ return this
+ .id(in.getId())
+ .ip(in.getIp())
+ .fixedIp(in.getFixedIp())
+ .instanceId(in.getInstanceId());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String id;
+ private final String ip;
+ @Named("fixed_ip")
+ private final String fixedIp;
+ @Named("instance_id")
+ private final String instanceId;
+
+ @ConstructorProperties({
+ "id", "ip", "fixed_ip", "instance_id"
+ })
+ protected FloatingIP(String id, String ip, @Nullable String fixedIp, @Nullable String instanceId) {
+ this.id = checkNotNull(id, "id");
+ this.ip = checkNotNull(ip, "ip");
+ this.fixedIp = fixedIp;
+ this.instanceId = instanceId;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public String getIp() {
+ return this.ip;
+ }
+
+ @Nullable
+ public String getFixedIp() {
+ return this.fixedIp;
+ }
+
+ @Nullable
+ public String getInstanceId() {
+ return this.instanceId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, ip, fixedIp, instanceId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ FloatingIP that = FloatingIP.class.cast(obj);
+ return Objects.equal(this.id, that.id)
+ && Objects.equal(this.ip, that.ip)
+ && Objects.equal(this.fixedIp, that.fixedIp)
+ && Objects.equal(this.instanceId, that.instanceId);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("id", id).add("ip", ip).add("fixedIp", fixedIp).add("instanceId", instanceId);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ @Override
+ public int compareTo(FloatingIP o) {
+ return this.id.compareTo(o.getId());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java
new file mode 100644
index 0000000..72df77d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java
@@ -0,0 +1,127 @@
+/*
+ * 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.domain;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * Class Host
+*/
+public class Host {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromHost(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String name;
+ protected String service;
+
+ /**
+ * @see Host#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see Host#getService()
+ */
+ public T service(String service) {
+ this.service = service;
+ return self();
+ }
+
+ public Host build() {
+ return new Host(name, service);
+ }
+
+ public T fromHost(Host in) {
+ return this
+ .name(in.getName())
+ .service(in.getService());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ @Named("host_name")
+ private final String name;
+ private final String service;
+
+ @ConstructorProperties({
+ "host_name", "service"
+ })
+ protected Host(@Nullable String name, @Nullable String service) {
+ this.name = name;
+ this.service = service;
+ }
+
+ @Nullable
+ public String getName() {
+ return this.name;
+ }
+
+ @Nullable
+ public String getService() {
+ return this.service;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, service);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Host that = Host.class.cast(obj);
+ return Objects.equal(this.name, that.name)
+ && Objects.equal(this.service, that.service);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("name", name).add("service", service);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostAggregate.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostAggregate.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostAggregate.java
new file mode 100644
index 0000000..fc6744c
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostAggregate.java
@@ -0,0 +1,250 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Aggregates can be manipulated using the Aggregate Extension to Nova (alias "OS-AGGREGATES")
+ *
+ * @see org.jclouds.openstack.nova.v2_0.extensions.HostAggregateApi
+*/
+public class HostAggregate {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromHostAggregate(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String id;
+ protected String name;
+ protected String availabilityZone;
+ protected Set<String> hosts = ImmutableSet.of();
+ protected String state;
+ protected Date created;
+ protected Date updated;
+ protected Map<String, String> metadata = ImmutableMap.of();
+
+ /**
+ * @see HostAggregate#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see HostAggregate#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see HostAggregate#getAvailabilityZone()
+ */
+ public T availabilityZone(String availabilityZone) {
+ this.availabilityZone = availabilityZone;
+ return self();
+ }
+
+ /**
+ * @see HostAggregate#getHosts()
+ */
+ public T hosts(Set<String> hosts) {
+ this.hosts = ImmutableSet.copyOf(checkNotNull(hosts, "hosts"));
+ return self();
+ }
+
+ public T hosts(String... in) {
+ return hosts(ImmutableSet.copyOf(in));
+ }
+
+ /**
+ * @see HostAggregate#getState()
+ */
+ public T state(String state) {
+ this.state = state;
+ return self();
+ }
+
+ /**
+ * @see HostAggregate#getCreated()
+ */
+ public T created(Date created) {
+ this.created = created;
+ return self();
+ }
+
+ /**
+ * @see HostAggregate#getUpdated()
+ */
+ public T updated(Date updated) {
+ this.updated = updated;
+ return self();
+ }
+
+ /**
+ * @see HostAggregate#getMetadata()
+ */
+ public T metadata(Map<String, String> metadata) {
+ this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
+ return self();
+ }
+
+ public HostAggregate build() {
+ return new HostAggregate(id, name, availabilityZone, hosts, state, created, updated, metadata);
+ }
+
+ public T fromHostAggregate(HostAggregate in) {
+ return this
+ .id(in.getId())
+ .name(in.getName())
+ .availabilityZone(in.getAvailabilityZone())
+ .hosts(in.getHosts())
+ .state(in.getState())
+ .created(in.getCreated())
+ .updated(in.getUpdated().get())
+ .metadata(in.getMetadata());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String id;
+ private final String name;
+ @Named("availability_zone")
+ private final String availabilityZone;
+ private final Set<String> hosts;
+ @Named("operational_state")
+ private final String state;
+ @Named("created_at")
+ private final Date created;
+ @Named("updated_at")
+ private final Optional<Date> updated;
+ private final Map<String, String> metadata;
+
+ @ConstructorProperties({
+ "id", "name", "availability_zone", "hosts", "operational_state", "created_at", "updated_at", "metadata"
+ })
+ protected HostAggregate(String id, String name, String availabilityZone, @Nullable Set<String> hosts, String state, Date created,
+ @Nullable Date updated, @Nullable Map<String, String> metadata) {
+ this.id = checkNotNull(id, "id");
+ this.name = checkNotNull(name, "name");
+ this.availabilityZone = checkNotNull(availabilityZone, "availabilityZone");
+ this.hosts = hosts == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(hosts);
+ this.state = checkNotNull(state, "state");
+ this.created = checkNotNull(created, "created");
+ this.updated = Optional.fromNullable(updated);
+ this.metadata = metadata == null ? ImmutableMap.<String,String>of() : ImmutableMap.copyOf(metadata);
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * note: an "Availability Zone" is different from a Nova "Zone"
+ *
+ * @return the availability zone this aggregate is in
+ */
+ public String getAvailabilityZone() {
+ return this.availabilityZone;
+ }
+
+ public Set<String> getHosts() {
+ return this.hosts;
+ }
+
+ public String getState() {
+ return this.state;
+ }
+
+ public Date getCreated() {
+ return this.created;
+ }
+
+ public Optional<Date> getUpdated() {
+ return this.updated;
+ }
+
+ public Map<String, String> getMetadata() {
+ return this.metadata;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, name, availabilityZone, hosts, state, created, updated, metadata);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ HostAggregate that = HostAggregate.class.cast(obj);
+ return Objects.equal(this.id, that.id)
+ && Objects.equal(this.name, that.name)
+ && Objects.equal(this.availabilityZone, that.availabilityZone)
+ && Objects.equal(this.hosts, that.hosts)
+ && Objects.equal(this.state, that.state)
+ && Objects.equal(this.created, that.created)
+ && Objects.equal(this.updated, that.updated)
+ && Objects.equal(this.metadata, that.metadata);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("id", id).add("name", name).add("availabilityZone", availabilityZone).add("hosts", hosts).add("state", state).add("created", created).add("updated", updated).add("metadata", metadata);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostResourceUsage.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostResourceUsage.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostResourceUsage.java
new file mode 100644
index 0000000..186fb33
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostResourceUsage.java
@@ -0,0 +1,180 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * Class HostResourceUsage
+*/
+public class HostResourceUsage {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromHostResourceUsage(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String host;
+ protected String project;
+ protected int memoryMb;
+ protected int cpu;
+ protected int diskGb;
+
+ /**
+ * @see HostResourceUsage#getHost()
+ */
+ public T host(String host) {
+ this.host = host;
+ return self();
+ }
+
+ /**
+ * @see HostResourceUsage#getProject()
+ */
+ public T project(String project) {
+ this.project = project;
+ return self();
+ }
+
+ /**
+ * @see HostResourceUsage#getMemoryMb()
+ */
+ public T memoryMb(int memoryMb) {
+ this.memoryMb = memoryMb;
+ return self();
+ }
+
+ /**
+ * @see HostResourceUsage#getCpu()
+ */
+ public T cpu(int cpu) {
+ this.cpu = cpu;
+ return self();
+ }
+
+ /**
+ * @see HostResourceUsage#getDiskGb()
+ */
+ public T diskGb(int diskGb) {
+ this.diskGb = diskGb;
+ return self();
+ }
+
+ public HostResourceUsage build() {
+ return new HostResourceUsage(host, project, memoryMb, cpu, diskGb);
+ }
+
+ public T fromHostResourceUsage(HostResourceUsage in) {
+ return this
+ .host(in.getHost())
+ .project(in.getProject())
+ .memoryMb(in.getMemoryMb())
+ .cpu(in.getCpu())
+ .diskGb(in.getDiskGb());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String host;
+ private final String project;
+ @Named("memory_mb")
+ private final int memoryMb;
+ private final int cpu;
+ @Named("disk_gb")
+ private final int diskGb;
+
+ @ConstructorProperties({
+ "host", "project", "memory_mb", "cpu", "disk_gb"
+ })
+ protected HostResourceUsage(String host, @Nullable String project, int memoryMb, int cpu, int diskGb) {
+ this.host = checkNotNull(host, "host");
+ this.project = project;
+ this.memoryMb = memoryMb;
+ this.cpu = cpu;
+ this.diskGb = diskGb;
+ }
+
+ public String getHost() {
+ return this.host;
+ }
+
+ @Nullable
+ public String getProject() {
+ return this.project;
+ }
+
+ public int getMemoryMb() {
+ return this.memoryMb;
+ }
+
+ public int getCpu() {
+ return this.cpu;
+ }
+
+ public int getDiskGb() {
+ return this.diskGb;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(host, project, memoryMb, cpu, diskGb);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ HostResourceUsage that = HostResourceUsage.class.cast(obj);
+ return Objects.equal(this.host, that.host)
+ && Objects.equal(this.project, that.project)
+ && Objects.equal(this.memoryMb, that.memoryMb)
+ && Objects.equal(this.cpu, that.cpu)
+ && Objects.equal(this.diskGb, that.diskGb);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("host", host).add("project", project).add("memoryMb", memoryMb).add("cpu", cpu).add("diskGb", diskGb);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Image.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Image.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Image.java
new file mode 100644
index 0000000..65cc81d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Image.java
@@ -0,0 +1,303 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.util.Date;
+import java.util.Map;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * An image is a collection of files you use to create or rebuild a server. Operators provide
+ * pre-built OS images by default. You may also create custom images.
+ *
+ * @author Jeremy Daggett
+ * @see <a href= "http://docs.openstack.org/api/openstack-compute/1.1/content/Images-d1e4427.html"
+ />
+*/
+public class Image extends Resource {
+
+ /**
+ * In-flight images will have the status attribute set to SAVING and the conditional progress
+ * element (0-100% completion) will also be returned. Other possible values for the status
+ * attribute include: UNKNOWN, ACTIVE, SAVING, ERROR, and DELETED. Images with an ACTIVE status
+ * are available for install. The optional minDisk and minRam attributes set the minimum disk and
+ * RAM requirements needed to create a server with the image.
+ *
+ * @author Adrian Cole
+ */
+ public static enum Status {
+
+ UNRECOGNIZED, UNKNOWN, ACTIVE, SAVING, ERROR, DELETED;
+
+ public String value() {
+ return name();
+ }
+
+ public static Status fromValue(String v) {
+ try {
+ return valueOf(v);
+ } catch (IllegalArgumentException e) {
+ return UNRECOGNIZED;
+ }
+ }
+
+ }
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromImage(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> extends Resource.Builder<T> {
+ protected Date updated;
+ protected Date created;
+ protected String tenantId;
+ protected String userId;
+ protected Image.Status status;
+ protected int progress;
+ protected int minDisk;
+ protected int minRam;
+ protected Resource server;
+ protected Map<String, String> metadata = ImmutableMap.of();
+
+ /**
+ * @see Image#getUpdated()
+ */
+ public T updated(Date updated) {
+ this.updated = updated;
+ return self();
+ }
+
+ /**
+ * @see Image#getCreated()
+ */
+ public T created(Date created) {
+ this.created = created;
+ return self();
+ }
+
+ /**
+ * @see Image#getTenantId()
+ */
+ public T tenantId(String tenantId) {
+ this.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * @see Image#getUserId()
+ */
+ public T userId(String userId) {
+ this.userId = userId;
+ return self();
+ }
+
+ /**
+ * @see Image#getStatus()
+ */
+ public T status(Image.Status status) {
+ this.status = status;
+ return self();
+ }
+
+ /**
+ * @see Image#getProgress()
+ */
+ public T progress(int progress) {
+ this.progress = progress;
+ return self();
+ }
+
+ /**
+ * @see Image#getMinDisk()
+ */
+ public T minDisk(int minDisk) {
+ this.minDisk = minDisk;
+ return self();
+ }
+
+ /**
+ * @see Image#getMinRam()
+ */
+ public T minRam(int minRam) {
+ this.minRam = minRam;
+ return self();
+ }
+
+ /**
+ * @see Image#getServer()
+ */
+ public T server(Resource server) {
+ this.server = server;
+ return self();
+ }
+
+ /**
+ * @see Image#getMetadata()
+ */
+ public T metadata(Map<String, String> metadata) {
+ this.metadata = ImmutableMap.copyOf(checkNotNull(metadata, "metadata"));
+ return self();
+ }
+
+ public Image build() {
+ return new Image(id, name, links, updated, created, tenantId, userId, status, progress, minDisk, minRam, server, metadata);
+ }
+
+ public T fromImage(Image in) {
+ return super.fromResource(in)
+ .updated(in.getUpdated())
+ .created(in.getCreated())
+ .tenantId(in.getTenantId())
+ .userId(in.getUserId())
+ .status(in.getStatus())
+ .progress(in.getProgress())
+ .minDisk(in.getMinDisk())
+ .minRam(in.getMinRam())
+ .server(in.getServer())
+ .metadata(in.getMetadata());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final Date updated;
+ private final Date created;
+ @Named("tenant_id")
+ private final String tenantId;
+ @Named("user_id")
+ private final String userId;
+ private final Image.Status status;
+ private final int progress;
+ private final int minDisk;
+ private final int minRam;
+ private final Resource server;
+ private final Map<String, String> metadata;
+
+ @ConstructorProperties({
+ "id", "name", "links", "updated", "created", "tenant_id", "user_id", "status", "progress", "minDisk", "minRam", "server", "metadata"
+ })
+ protected Image(String id, @Nullable String name, java.util.Set<Link> links, @Nullable Date updated, @Nullable Date created,
+ String tenantId, @Nullable String userId, @Nullable Status status, int progress, int minDisk, int minRam,
+ @Nullable Resource server, @Nullable Map<String, String> metadata) {
+ super(id, name, links);
+ this.updated = updated;
+ this.created = created;
+ this.tenantId = tenantId;
+ this.userId = userId;
+ this.status = status;
+ this.progress = progress;
+ this.minDisk = minDisk;
+ this.minRam = minRam;
+ this.server = server;
+ this.metadata = metadata == null ? ImmutableMap.<String, String>of() : ImmutableMap.copyOf(metadata);
+ }
+
+ @Nullable
+ public Date getUpdated() {
+ return this.updated;
+ }
+
+ @Nullable
+ public Date getCreated() {
+ return this.created;
+ }
+
+ @Nullable
+ public String getTenantId() {
+ return this.tenantId;
+ }
+
+ @Nullable
+ public String getUserId() {
+ return this.userId;
+ }
+
+ @Nullable
+ public Status getStatus() {
+ return this.status;
+ }
+
+ public int getProgress() {
+ return this.progress;
+ }
+
+ public int getMinDisk() {
+ return this.minDisk;
+ }
+
+ public int getMinRam() {
+ return this.minRam;
+ }
+
+ @Nullable
+ public Resource getServer() {
+ return this.server;
+ }
+
+ public Map<String, String> getMetadata() {
+ return this.metadata;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(updated, created, tenantId, userId, status, progress, minDisk, minRam, server, metadata);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Image that = Image.class.cast(obj);
+ return super.equals(that) && Objects.equal(this.updated, that.updated)
+ && Objects.equal(this.created, that.created)
+ && Objects.equal(this.tenantId, that.tenantId)
+ && Objects.equal(this.userId, that.userId)
+ && Objects.equal(this.status, that.status)
+ && Objects.equal(this.progress, that.progress)
+ && Objects.equal(this.minDisk, that.minDisk)
+ && Objects.equal(this.minRam, that.minRam)
+ && Objects.equal(this.server, that.server)
+ && Objects.equal(this.metadata, that.metadata);
+ }
+
+ protected ToStringHelper string() {
+ return super.string()
+ .add("updated", updated).add("created", created).add("tenantId", tenantId).add("userId", userId).add("status", status).add("progress", progress).add("minDisk", minDisk).add("minRam", minRam).add("server", server).add("metadata", metadata);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Ingress.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Ingress.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Ingress.java
new file mode 100644
index 0000000..3a9322d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Ingress.java
@@ -0,0 +1,160 @@
+/*
+ * 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.domain;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.net.domain.IpProtocol;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * Ingress access to a destination protocol on particular ports
+ *
+ * @author Adrian Cole
+*/
+@Beta
+public class Ingress {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromIngress(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected IpProtocol ipProtocol;
+ protected int fromPort;
+ protected int toPort;
+
+ /**
+ * @see Ingress#getIpProtocol()
+ */
+ public T ipProtocol(IpProtocol ipProtocol) {
+ this.ipProtocol = ipProtocol;
+ return self();
+ }
+
+ /**
+ * @see Ingress#getFromPort()
+ */
+ public T fromPort(int fromPort) {
+ this.fromPort = fromPort;
+ return self();
+ }
+
+ /**
+ * @see Ingress#getToPort()
+ */
+ public T toPort(int toPort) {
+ this.toPort = toPort;
+ return self();
+ }
+
+ public Ingress build() {
+ return new Ingress(ipProtocol, fromPort, toPort);
+ }
+
+ public T fromIngress(Ingress in) {
+ return this
+ .ipProtocol(in.getIpProtocol())
+ .fromPort(in.getFromPort())
+ .toPort(in.getToPort());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ @Named("ip_protocol")
+ private final IpProtocol ipProtocol;
+ @Named("from_port")
+ private final int fromPort;
+ @Named("to_port")
+ private final int toPort;
+
+ @ConstructorProperties({
+ "ip_protocol", "from_port", "to_port"
+ })
+ protected Ingress(@Nullable IpProtocol ipProtocol, int fromPort, int toPort) {
+ this.ipProtocol = ipProtocol == null ? IpProtocol.UNRECOGNIZED : ipProtocol;
+ this.fromPort = fromPort;
+ this.toPort = toPort;
+ }
+
+ /**
+ * destination IP protocol
+ */
+ public IpProtocol getIpProtocol() {
+ return this.ipProtocol;
+ }
+
+ /**
+ * Start of destination port range for the TCP and UDP protocols, or an ICMP type number. An ICMP
+ * type number of -1 indicates a wildcard (i.e., any ICMP type number).
+ */
+ public int getFromPort() {
+ return this.fromPort;
+ }
+
+ /**
+ * End of destination port range for the TCP and UDP protocols, or an ICMP code. An ICMP code of
+ * -1 indicates a wildcard (i.e., any ICMP code).
+ */
+ public int getToPort() {
+ return this.toPort;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(ipProtocol, fromPort, toPort);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Ingress that = Ingress.class.cast(obj);
+ return Objects.equal(this.ipProtocol, that.ipProtocol)
+ && Objects.equal(this.fromPort, that.fromPort)
+ && Objects.equal(this.toPort, that.toPort);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("ipProtocol", ipProtocol).add("fromPort", fromPort).add("toPort", toPort);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/KeyPair.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/KeyPair.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/KeyPair.java
new file mode 100644
index 0000000..aded550
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/KeyPair.java
@@ -0,0 +1,189 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * Class KeyPair
+*/
+public class KeyPair {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromKeyPair(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String publicKey;
+ protected String privateKey;
+ protected String userId;
+ protected String name;
+ protected String fingerprint;
+
+ /**
+ * @see KeyPair#getPublicKey()
+ */
+ public T publicKey(String publicKey) {
+ this.publicKey = publicKey;
+ return self();
+ }
+
+ /**
+ * @see KeyPair#getPrivateKey()
+ */
+ public T privateKey(String privateKey) {
+ this.privateKey = privateKey;
+ return self();
+ }
+
+ /**
+ * @see KeyPair#getUserId()
+ */
+ public T userId(String userId) {
+ this.userId = userId;
+ return self();
+ }
+
+ /**
+ * @see KeyPair#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see KeyPair#getFingerprint()
+ */
+ public T fingerprint(String fingerprint) {
+ this.fingerprint = fingerprint;
+ return self();
+ }
+
+ public KeyPair build() {
+ return new KeyPair(publicKey, privateKey, userId, name, fingerprint);
+ }
+
+ public T fromKeyPair(KeyPair in) {
+ return this
+ .publicKey(in.getPublicKey())
+ .privateKey(in.getPrivateKey())
+ .userId(in.getUserId())
+ .name(in.getName())
+ .fingerprint(in.getFingerprint());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ @Named("public_key")
+ private final String publicKey;
+ @Named("private_key")
+ private final String privateKey;
+ @Named("user_id")
+ private final String userId;
+ private final String name;
+ private final String fingerprint;
+
+ @ConstructorProperties({
+ "public_key", "private_key", "user_id", "name", "fingerprint"
+ })
+ protected KeyPair(@Nullable String publicKey, @Nullable String privateKey, @Nullable String userId, String name, @Nullable String fingerprint) {
+ this.publicKey = publicKey;
+ this.privateKey = privateKey;
+ this.userId = userId;
+ this.name = checkNotNull(name, "name");
+ this.fingerprint = fingerprint;
+ }
+
+ @Nullable
+ public String getPublicKey() {
+ return this.publicKey;
+ }
+
+ @Nullable
+ public String getPrivateKey() {
+ return this.privateKey;
+ }
+
+ @Nullable
+ public String getUserId() {
+ return this.userId;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ @Nullable
+ public String getFingerprint() {
+ return this.fingerprint;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(publicKey, privateKey, userId, name, fingerprint);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ KeyPair that = KeyPair.class.cast(obj);
+ return Objects.equal(this.publicKey, that.publicKey)
+ && Objects.equal(this.privateKey, that.privateKey)
+ && Objects.equal(this.userId, that.userId)
+ && Objects.equal(this.name, that.name)
+ && Objects.equal(this.fingerprint, that.fingerprint);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper("")
+ .omitNullValues()
+ .add("public_key", publicKey)
+ .add("private_key", privateKey)
+ .add("user_id", userId)
+ .add("name", name)
+ .add("fingerprint", fingerprint);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Network.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Network.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Network.java
new file mode 100644
index 0000000..516f6e1
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Network.java
@@ -0,0 +1,173 @@
+/*
+ * 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.domain;
+
+import java.beans.ConstructorProperties;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+/**
+ * Nova (or Neutron) network definition
+ * Used to provide support for network, port, and fixed_ip when booting Nova servers.
+ * OpenStack will support either a Nova Network or Neutron, but not both at the same time.
+ * Specifying a port is only possible with Neutron.
+ * @author Zack Shoylev
+ */
+public class Network implements Comparable<Network> {
+ private final String networkUuid;
+ private final String portUuid;
+ private final String fixedIp;
+
+ @ConstructorProperties({
+ "networkUuid", "portUuid", "fixedIp"
+ })
+ protected Network(String networkUuid, String portUuid, String fixedIp) {
+ checkArgument(networkUuid != null || portUuid != null, "At least one of networkUuid or portUuid should be specified");
+ this.networkUuid = networkUuid;
+ this.portUuid = portUuid;
+ this.fixedIp = fixedIp;
+ }
+
+ /**
+ * @return the network uuid - Neutron or Nova
+ */
+ public String getNetworkUuid() {
+ return this.networkUuid;
+ }
+
+ /**
+ * @return the port uuid - Neutron only
+ */
+ public String getPortUuid() {
+ return this.portUuid;
+ }
+
+ /**
+ * @return the fixed IP address - Neutron or Nova
+ */
+ public String getFixedIp() {
+ return this.fixedIp;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(networkUuid, portUuid, fixedIp);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Network that = Network.class.cast(obj);
+ return Objects.equal(this.networkUuid, that.networkUuid) &&
+ Objects.equal(this.portUuid, that.portUuid) &&
+ Objects.equal(this.fixedIp, that.fixedIp);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("networkUuid", networkUuid)
+ .add("portUuid", portUuid)
+ .add("fixedIp", fixedIp);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ /**
+ * @return A new builder object
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * @return A new Builder object from another Network
+ */
+ public Builder toBuilder() {
+ return new Builder().fromNetwork(this);
+ }
+
+ /**
+ * Implements the Builder pattern for this class
+ */
+ public static class Builder {
+ protected String networkUuid;
+ protected String portUuid;
+ protected String fixedIp;
+
+ /**
+ * @param networkUuid The UUID for the Nova network or Neutron subnet to be attached.
+ * @return The builder object.
+ * @see Network#getNetworkUuid()
+ */
+ public Builder networkUuid(String networkUuid) {
+ this.networkUuid = networkUuid;
+ return this;
+ }
+
+ /**
+ * @param portUuid The port UUID for this Neutron Network.
+ * @return The builder object.
+ * @see Network#getPortUuid()
+ */
+ public Builder portUuid(String portUuid) {
+ this.portUuid = portUuid;
+ return this;
+ }
+
+ /**
+ * @param fixedIp The fixed IP address for this Network (if any).
+ * Service automatically assigns IP address if this is not provided.
+ * Fixed IP is compatible with both Nova Network and Neutron.
+ * @return The builder object.
+ * @see Network#getFixedIp()
+ */
+ public Builder fixedIp(String fixedIp) {
+ this.fixedIp = fixedIp;
+ return this;
+ }
+
+ /**
+ * @return A new Network object.
+ */
+ public Network build() {
+ return new Network(networkUuid, portUuid, fixedIp);
+ }
+
+ /**
+ * @param in The target Network
+ * @return A Builder from the provided Network
+ */
+ public Builder fromNetwork(Network in) {
+ return this
+ .networkUuid(in.getNetworkUuid())
+ .portUuid(in.getPortUuid())
+ .fixedIp(in.getFixedIp());
+ }
+ }
+
+ @Override
+ public int compareTo(Network that) {
+ return this.toString().compareTo(that.toString());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Quota.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Quota.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Quota.java
new file mode 100644
index 0000000..c16693e
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Quota.java
@@ -0,0 +1,356 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * Represents the set of limits (quotas) returned by the Quota Extension
+ *
+ * @see org.jclouds.openstack.nova.v2_0.extensions.QuotaApi
+*/
+public class Quota {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromQuotas(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String id;
+ protected int metadataItems;
+ protected int injectedFileContentBytes;
+ protected int volumes;
+ protected int gigabytes;
+ protected int ram;
+ protected int floatingIps;
+ protected int instances;
+ protected int injectedFiles;
+ protected int cores;
+ protected int securityGroups;
+ protected int securityGroupRules;
+ protected int keyPairs;
+
+ /**
+ * @see Quota#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see Quota#getMetadatas()
+ */
+ public T metadataItems(int metadataItems) {
+ this.metadataItems = metadataItems;
+ return self();
+ }
+
+ /**
+ * @see Quota#getInjectedFileContentBytes()
+ */
+ public T injectedFileContentBytes(int injectedFileContentBytes) {
+ this.injectedFileContentBytes = injectedFileContentBytes;
+ return self();
+ }
+
+ /**
+ * @see Quota#getVolumes()
+ */
+ public T volumes(int volumes) {
+ this.volumes = volumes;
+ return self();
+ }
+
+ /**
+ * @see Quota#getGigabytes()
+ */
+ public T gigabytes(int gigabytes) {
+ this.gigabytes = gigabytes;
+ return self();
+ }
+
+ /**
+ * @see Quota#getRam()
+ */
+ public T ram(int ram) {
+ this.ram = ram;
+ return self();
+ }
+
+ /**
+ * @see Quota#getFloatingIps()
+ */
+ public T floatingIps(int floatingIps) {
+ this.floatingIps = floatingIps;
+ return self();
+ }
+
+ /**
+ * @see Quota#getInstances()
+ */
+ public T instances(int instances) {
+ this.instances = instances;
+ return self();
+ }
+
+ /**
+ * @see Quota#getInjectedFiles()
+ */
+ public T injectedFiles(int injectedFiles) {
+ this.injectedFiles = injectedFiles;
+ return self();
+ }
+
+ /**
+ * @see Quota#getCores()
+ */
+ public T cores(int cores) {
+ this.cores = cores;
+ return self();
+ }
+
+ /**
+ * @see Quota#getSecurityGroups()
+ */
+ public T securityGroups(int securityGroups) {
+ this.securityGroups = securityGroups;
+ return self();
+ }
+
+ /**
+ * @see Quota#getSecurityGroupRules()
+ */
+ public T securityGroupRules(int securityGroupRules) {
+ this.securityGroupRules = securityGroupRules;
+ return self();
+ }
+
+ /**
+ * @see Quota#getKeyPairs()
+ */
+ public T keyPairs(int keyPairs) {
+ this.keyPairs = keyPairs;
+ return self();
+ }
+
+ public Quota build() {
+ return new Quota(id, metadataItems, injectedFileContentBytes, volumes, gigabytes, ram, floatingIps, instances, injectedFiles, cores, securityGroups, securityGroupRules, keyPairs);
+ }
+
+ public T fromQuotas(Quota in) {
+ return this
+ .id(in.getId())
+ .metadataItems(in.getMetadatas())
+ .injectedFileContentBytes(in.getInjectedFileContentBytes())
+ .volumes(in.getVolumes())
+ .gigabytes(in.getGigabytes())
+ .ram(in.getRam())
+ .floatingIps(in.getFloatingIps())
+ .instances(in.getInstances())
+ .injectedFiles(in.getInjectedFiles())
+ .cores(in.getCores())
+ .securityGroups(in.getSecurityGroups())
+ .securityGroupRules(in.getSecurityGroupRules())
+ .keyPairs(in.getKeyPairs());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String id;
+ @Named("metadata_items")
+ private final int metadataItems;
+ @Named("injected_file_content_bytes")
+ private final int injectedFileContentBytes;
+ private final int volumes;
+ private final int gigabytes;
+ private final int ram;
+ @Named("floating_ips")
+ private final int floatingIps;
+ private final int instances;
+ @Named("injected_files")
+ private final int injectedFiles;
+ private final int cores;
+ @Named("security_groups")
+ private final int securityGroups;
+ @Named("security_group_rules")
+ private final int securityGroupRules;
+ @Named("key_pairs")
+ private final int keyPairs;
+
+ @ConstructorProperties({
+ "id", "metadata_items", "injected_file_content_bytes", "volumes", "gigabytes", "ram", "floating_ips", "instances", "injected_files", "cores", "security_groups", "security_group_rules", "key_pairs"
+ })
+ protected Quota(String id, int metadataItems, int injectedFileContentBytes, int volumes, int gigabytes, int ram, int floatingIps, int instances, int injectedFiles, int cores, int securityGroups, int securityGroupRules, int keyPairs) {
+ this.id = checkNotNull(id, "id");
+ this.metadataItems = metadataItems;
+ this.injectedFileContentBytes = injectedFileContentBytes;
+ this.volumes = volumes;
+ this.gigabytes = gigabytes;
+ this.ram = ram;
+ this.floatingIps = floatingIps;
+ this.instances = instances;
+ this.injectedFiles = injectedFiles;
+ this.cores = cores;
+ this.securityGroups = securityGroups;
+ this.securityGroupRules = securityGroupRules;
+ this.keyPairs = keyPairs;
+ }
+
+ /**
+ * The id of the tenant this set of limits applies to
+ */
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * The limit of the number of metadata items for the tenant
+ */
+ public int getMetadatas() {
+ return this.metadataItems;
+ }
+
+ public int getInjectedFileContentBytes() {
+ return this.injectedFileContentBytes;
+ }
+
+ /**
+ * The limit of the number of volumes that can be created for the tenant
+ */
+ public int getVolumes() {
+ return this.volumes;
+ }
+
+ /**
+ * The limit of the total size of all volumes for the tenant
+ */
+ public int getGigabytes() {
+ return this.gigabytes;
+ }
+
+ /**
+ * The limit of total ram available to the tenant
+ */
+ public int getRam() {
+ return this.ram;
+ }
+
+ /**
+ * The limit of the number of floating ips for the tenant
+ */
+ public int getFloatingIps() {
+ return this.floatingIps;
+ }
+
+ /**
+ * The limit of the number of instances that can be created for the tenant
+ */
+ public int getInstances() {
+ return this.instances;
+ }
+
+ public int getInjectedFiles() {
+ return this.injectedFiles;
+ }
+
+ /**
+ * The limit of the number of cores that can be used by the tenant
+ */
+ public int getCores() {
+ return this.cores;
+ }
+
+ /**
+ * @return the limit of the number of security groups that can be created for the tenant
+ * @see org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi
+ */
+ public int getSecurityGroups() {
+ return this.securityGroups;
+ }
+
+ /**
+ * @return the limit of the number of security group rules that can be created for the tenant
+ * @see org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi
+ */
+ public int getSecurityGroupRules() {
+ return this.securityGroupRules;
+ }
+
+ /**
+ * @return the limit of the number of key pairs that can be created for the tenant
+ * @see org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi
+ */
+ public int getKeyPairs() {
+ return this.keyPairs;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, metadataItems, injectedFileContentBytes, volumes, gigabytes, ram, floatingIps, instances, injectedFiles, cores, securityGroups, securityGroupRules, keyPairs);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Quota that = Quota.class.cast(obj);
+ return Objects.equal(this.id, that.id)
+ && Objects.equal(this.metadataItems, that.metadataItems)
+ && Objects.equal(this.injectedFileContentBytes, that.injectedFileContentBytes)
+ && Objects.equal(this.volumes, that.volumes)
+ && Objects.equal(this.gigabytes, that.gigabytes)
+ && Objects.equal(this.ram, that.ram)
+ && Objects.equal(this.floatingIps, that.floatingIps)
+ && Objects.equal(this.instances, that.instances)
+ && Objects.equal(this.injectedFiles, that.injectedFiles)
+ && Objects.equal(this.cores, that.cores)
+ && Objects.equal(this.securityGroups, that.securityGroups)
+ && Objects.equal(this.securityGroupRules, that.securityGroupRules)
+ && Objects.equal(this.keyPairs, that.keyPairs);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("id", id).add("metadataItems", metadataItems).add("injectedFileContentBytes", injectedFileContentBytes).add("volumes", volumes).add("gigabytes", gigabytes).add("ram", ram).add("floatingIps", floatingIps).add("instances", instances).add("injectedFiles", injectedFiles).add("cores", cores).add("securityGroups", securityGroups).add("securityGroupRules", securityGroupRules).add("keyPairs", keyPairs);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/QuotaClass.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/QuotaClass.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/QuotaClass.java
new file mode 100644
index 0000000..27199ef
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/QuotaClass.java
@@ -0,0 +1,62 @@
+/*
+ * 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.domain;
+
+import java.beans.ConstructorProperties;
+
+/**
+ * Represents the set of limits (quota class) returned by the Quota Class Extension
+ *
+ * @see org.jclouds.openstack.nova.v2_0.extensions.QuotaClassApi
+*/
+public class QuotaClass extends Quota {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromQuotaClass(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> extends Quota.Builder<T> {
+
+ public QuotaClass build() {
+ return new QuotaClass(id, metadataItems, injectedFileContentBytes, volumes, gigabytes, ram, floatingIps, instances, injectedFiles, cores, securityGroups, securityGroupRules, keyPairs);
+ }
+
+ public T fromQuotaClass(QuotaClass in) {
+ return super.fromQuotas(in);
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+
+ @ConstructorProperties({
+ "id", "metadata_items", "injected_file_content_bytes", "volumes", "gigabytes", "ram", "floating_ips", "instances", "injected_files", "cores", "security_groups", "security_group_rules", "key_pairs"
+ })
+ protected QuotaClass(String id, int metadataItems, int injectedFileContentBytes, int volumes, int gigabytes, int ram, int floatingIps, int instances, int injectedFiles, int cores, int securityGroups, int securityGroupRules, int keyPairs) {
+ super(id, metadataItems, injectedFileContentBytes, volumes, gigabytes, ram, floatingIps, instances, injectedFiles, cores, securityGroups, securityGroupRules, keyPairs);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/RebootType.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/RebootType.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/RebootType.java
new file mode 100644
index 0000000..453dd77
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/RebootType.java
@@ -0,0 +1,35 @@
+/*
+ * 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.domain;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+public enum RebootType {
+
+ HARD, SOFT;
+
+ public String value() {
+ return name();
+ }
+
+ public static RebootType fromValue(String v) {
+ return valueOf(v);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroup.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroup.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroup.java
new file mode 100644
index 0000000..a0e2085
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroup.java
@@ -0,0 +1,188 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+import java.util.Set;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Defines a security group
+*/
+public class SecurityGroup {
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromSecurityGroup(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+ protected abstract T self();
+
+ protected String id;
+ protected String tenantId;
+ protected String name;
+ protected String description;
+ protected Set<SecurityGroupRule> rules = ImmutableSet.of();
+
+ /**
+ * @see SecurityGroup#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see SecurityGroup#getTenantId()
+ */
+ public T tenantId(String tenantId) {
+ this.tenantId = tenantId;
+ return self();
+ }
+
+ /**
+ * @see SecurityGroup#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see SecurityGroup#getDescription()
+ */
+ public T description(String description) {
+ this.description = description;
+ return self();
+ }
+
+ /**
+ * @see SecurityGroup#getRules()
+ */
+ public T rules(Set<SecurityGroupRule> rules) {
+ this.rules = ImmutableSet.copyOf(checkNotNull(rules, "rules"));
+ return self();
+ }
+
+ public T rules(SecurityGroupRule... in) {
+ return rules(ImmutableSet.copyOf(in));
+ }
+
+ public SecurityGroup build() {
+ return new SecurityGroup(id, tenantId, name, description, rules);
+ }
+
+ public T fromSecurityGroup(SecurityGroup in) {
+ return this
+ .id(in.getId())
+ .tenantId(in.getTenantId())
+ .name(in.getName())
+ .description(in.getDescription())
+ .rules(in.getRules());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String id;
+ @Named("tenant_id")
+ private final String tenantId;
+ private final String name;
+ private final String description;
+ private final Set<SecurityGroupRule> rules;
+
+ @ConstructorProperties({
+ "id", "tenant_id", "name", "description", "rules"
+ })
+ protected SecurityGroup(String id, @Nullable String tenantId, @Nullable String name, @Nullable String description, Set<SecurityGroupRule> rules) {
+ this.id = checkNotNull(id, "id");
+ this.tenantId = tenantId;
+ this.name = name;
+ this.description = description;
+ // if empty, leave null so this doesn't serialize to json
+ this.rules = checkNotNull(rules, "rules").size() == 0 ? null : ImmutableSet.copyOf(rules);
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ @Nullable
+ public String getTenantId() {
+ return this.tenantId;
+ }
+
+ @Nullable
+ public String getName() {
+ return this.name;
+ }
+
+ @Nullable
+ public String getDescription() {
+ return this.description;
+ }
+
+ public Set<SecurityGroupRule> getRules() {
+ return this.rules;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, tenantId, name, description, rules);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ SecurityGroup that = SecurityGroup.class.cast(obj);
+ return Objects.equal(this.id, that.id)
+ && Objects.equal(this.tenantId, that.tenantId)
+ && Objects.equal(this.name, that.name)
+ && Objects.equal(this.description, that.description)
+ && Objects.equal(this.rules, that.rules);
+ }
+
+ protected ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .add("id", id).add("tenantId", tenantId).add("name", name).add("description", description).add("rules", rules);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroupRule.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroupRule.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroupRule.java
new file mode 100644
index 0000000..92d58f7
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroupRule.java
@@ -0,0 +1,174 @@
+/*
+ * 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.domain;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Named;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.net.domain.IpProtocol;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ForwardingObject;
+
+/**
+ * Defines a security group rule
+ */
+public class SecurityGroupRule extends Ingress {
+
+ public static class Cidr extends ForwardingObject {
+ private String cidr;
+
+ @ConstructorProperties("cidr")
+ protected Cidr(String cidr) {
+ this.cidr = checkNotNull(cidr);
+ }
+
+ @Override
+ protected Object delegate() {
+ return cidr;
+ }
+ }
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromSecurityGroupRule(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> extends Ingress.Builder<T> {
+ protected String id;
+ protected TenantIdAndName group;
+ protected String parentGroupId;
+ protected String ipRange;
+
+ /**
+ * @see SecurityGroupRule#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see SecurityGroupRule#getGroup()
+ */
+ public T group(TenantIdAndName group) {
+ this.group = group;
+ return self();
+ }
+
+ /**
+ * @see SecurityGroupRule#getParentGroupId()
+ */
+ public T parentGroupId(String parentGroupId) {
+ this.parentGroupId = parentGroupId;
+ return self();
+ }
+
+ /**
+ * @see SecurityGroupRule#getIpRange()
+ */
+ public T ipRange(String ipRange) {
+ this.ipRange = ipRange;
+ return self();
+ }
+
+ public SecurityGroupRule build() {
+ return new SecurityGroupRule(ipProtocol, fromPort, toPort, id, group, parentGroupId, ipRange == null ? null : new Cidr(ipRange));
+ }
+
+ public T fromSecurityGroupRule(SecurityGroupRule in) {
+ return super.fromIngress(in)
+ .id(in.getId())
+ .group(in.getGroup())
+ .parentGroupId(in.getParentGroupId())
+ .ipRange(in.getIpRange());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+
+ private final String id;
+ private final TenantIdAndName group;
+ @Named("parent_group_id")
+ private final String parentGroupId;
+ @Named("ip_range")
+ private final SecurityGroupRule.Cidr ipRange;
+
+ @ConstructorProperties({
+ "ip_protocol", "from_port", "to_port", "id", "group", "parent_group_id", "ip_range"
+ })
+ protected SecurityGroupRule(IpProtocol ipProtocol, int fromPort, int toPort, String id, @Nullable TenantIdAndName group, String parentGroupId, @Nullable Cidr ipRange) {
+ super(ipProtocol, fromPort, toPort);
+ this.id = checkNotNull(id, "id");
+ this.group = group;
+ this.parentGroupId = checkNotNull(parentGroupId, "parentGroupId");
+ this.ipRange = ipRange;
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ @Nullable
+ public TenantIdAndName getGroup() {
+ return this.group;
+ }
+
+ public String getParentGroupId() {
+ return this.parentGroupId;
+ }
+
+ @Nullable
+ public String getIpRange() {
+ return ipRange == null ? null : ipRange.cidr;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(id, group, parentGroupId, ipRange);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ SecurityGroupRule that = SecurityGroupRule.class.cast(obj);
+ return super.equals(that) && Objects.equal(this.id, that.id)
+ && Objects.equal(this.group, that.group)
+ && Objects.equal(this.parentGroupId, that.parentGroupId)
+ && Objects.equal(this.ipRange, that.ipRange);
+ }
+
+ protected ToStringHelper string() {
+ return super.string()
+ .add("id", id).add("group", group).add("parentGroupId", parentGroupId).add("ipRange", ipRange);
+ }
+
+}
[14/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java
new file mode 100644
index 0000000..6b4af7b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java
@@ -0,0 +1,65 @@
+/*
+ * 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.extensions;
+
+import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+
+/**
+ * Provides synchronous access to Security Groups.
+ * <p/>
+ *
+ * @see KeyPairAsyncApi
+ * @author Jeremy Daggett
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.KEYPAIRS)
+public interface KeyPairApi {
+
+ /**
+ * List all Key Pairs.
+ *
+ * @return all Key Pairs
+ */
+ FluentIterable<? extends KeyPair> list();
+
+ /**
+ * Create a Key Pair.
+ *
+ * @return a Key Pair
+ */
+ KeyPair create(String name);
+
+ /**
+ * Create a Key Pair with a public key.
+ *
+ * @return a Key Pair with a public key.
+ */
+ KeyPair createWithPublicKey(String name, String publicKey);
+
+ /**
+ * Delete a Key Pairs.
+ *
+ * @return
+ */
+ boolean delete(String name);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairAsyncApi.java
new file mode 100644
index 0000000..246aec8
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairAsyncApi.java
@@ -0,0 +1,101 @@
+/*
+ * 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.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.binders.BindKeyPairToJsonPayload;
+import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseKeyPairs;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.Payload;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to Key Pairs via the REST API.
+ * <p/>
+ *
+ * @see KeyPairApi
+ * @author Jeremy Daggett
+ * @see ExtensionAsyncApi
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
+ * />
+ * @see <a href="http://nova.openstack.org/api_ext" />
+ * @see <a href="http://nova.openstack.org/api_ext/ext_keypairs.html" />
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.KEYPAIRS)
+@RequestFilters(AuthenticateRequest.class)
+public interface KeyPairAsyncApi {
+
+ @Named("keypair:list")
+ @GET
+ @Path("/os-keypairs")
+ @ResponseParser(ParseKeyPairs.class)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends KeyPair>> list();
+
+ @Named("keypair:create")
+ @POST
+ @Path("/os-keypairs")
+ @SelectJson("keypair")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"keypair\":%7B\"name\":\"{name}\"%7D%7D")
+ ListenableFuture<? extends KeyPair> create(@PayloadParam("name") String name);
+
+ @Named("keypair:create")
+ @POST
+ @Path("/os-keypairs")
+ @SelectJson("keypair")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @MapBinder(BindKeyPairToJsonPayload.class)
+ ListenableFuture<? extends KeyPair> createWithPublicKey(@PayloadParam("name") String name,
+ @PayloadParam("public_key") String publicKey);
+
+ @Named("keypair:delete")
+ @DELETE
+ @Path("/os-keypairs/{name}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ @Consumes
+ ListenableFuture<Boolean> delete(@PathParam("name") String name);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java
new file mode 100644
index 0000000..ea59d0f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java
@@ -0,0 +1,57 @@
+/*
+ * 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.extensions;
+
+import org.jclouds.openstack.nova.v2_0.domain.Quota;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * The quotas extension enables limiters placed on the resources used per tenant (project) for virtual instances. It is
+ * used with the OpenStack Compute API 1.1 for administrators who need to control the amount of volumes, memory, floating
+ * IP addresses, instances, or cores allowed within a defined tenant or project.
+ * <p/>
+ * To use this extension, you need to have administrative rights to the tenants upon which you are placing quotas.
+ *
+ * @author Adam Lowe
+ * @see QuotaAsyncApi
+ * @see <a href="http://nova.openstack.org/api_ext/ext_quotas.html"/>
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.QUOTAS)
+public interface QuotaApi {
+
+ /**
+ * @return the quota settings for the tenant
+ */
+ Quota getByTenant(String tenantId);
+
+ /**
+ * Update the quotas for a given tenant
+ *
+ * @return true if successful
+ */
+ boolean updateQuotaOfTenant(Quota quota, String tenantId);
+
+ /**
+ * @return the set of default quotas for the tenant
+ */
+ Quota getDefaultsForTenant(String tenantId);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaAsyncApi.java
new file mode 100644
index 0000000..b364fcb
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaAsyncApi.java
@@ -0,0 +1,89 @@
+/*
+ * 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.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.domain.Quota;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.annotations.Beta;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provide access to Quota information for Nova tenants.
+ *
+ * @author Adam Lowe
+ * @see QuotaApi
+ * @see <a href="http://nova.openstack.org/api_ext/ext_quotas.html"/>
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.QUOTAS)
+@RequestFilters(AuthenticateRequest.class)
+@Path("/os-quota-sets")
+public interface QuotaAsyncApi {
+
+ /**
+ * @see QuotaApi#getDefaultsForTenant(String)
+ */
+ @Named("quota:get")
+ @GET
+ @SelectJson("quota_set")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{tenant_id}")
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends Quota> getByTenant(@PathParam("tenant_id") String tenantId);
+
+ /**
+ * @see QuotaApi#updateQuotaOfTenant
+ */
+ @Named("quota:update")
+ @PUT
+ @Path("/{tenant_id}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @MapBinder(BindToJsonPayload.class)
+ ListenableFuture<Boolean> updateQuotaOfTenant(@PayloadParam("quota_set") Quota quota,
+ @PathParam("tenant_id") String tenantId);
+
+ /**
+ * @see QuotaApi#getDefaultsForTenant(String)
+ */
+ @Named("quota:get")
+ @GET
+ @SelectJson("quota_set")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{tenant_id}/defaults")
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends Quota> getDefaultsForTenant(@PathParam("tenant_id") String tenantId);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApi.java
new file mode 100644
index 0000000..4a6c010
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApi.java
@@ -0,0 +1,51 @@
+/*
+ * 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.extensions;
+
+import org.jclouds.openstack.nova.v2_0.domain.QuotaClass;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Provides synchronous access to Quota Classes via the REST API.
+ * <p/>
+ * To use this extension, you need to have administrative rights to the tenants upon which you are placing quotas.
+ *
+ * @author Adam Lowe
+ * @see QuotaClassAsyncApi
+ * @see <a href="http://nova.openstack.org/api/nova.api.openstack.compute.contrib.quota_classes.html"/>
+ * @see <a href="http://wiki.openstack.org/QuotaClass"/>
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.QUOTA_CLASSES)
+public interface QuotaClassApi {
+
+ /**
+ * @return the quota settings for the tenant
+ */
+ QuotaClass get(String id);
+
+ /**
+ * Update the quotas for a given tenant
+ *
+ * @return true if successful
+ */
+ boolean update(String id, QuotaClass quotas);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassAsyncApi.java
new file mode 100644
index 0000000..f07148f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassAsyncApi.java
@@ -0,0 +1,78 @@
+/*
+ * 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.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.domain.QuotaClass;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.annotations.Beta;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to Quota Classes via the REST API.
+ *
+ * @author Adam Lowe
+ * @see QuotaClassApi
+ * @see <a href="http://nova.openstack.org/api/nova.api.openstack.compute.contrib.quota_classes.html"/>
+ * @see <a href="http://wiki.openstack.org/QuotaClass"/>
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.QUOTA_CLASSES)
+@RequestFilters(AuthenticateRequest.class)
+@Path("/os-quota-class-sets")
+public interface QuotaClassAsyncApi {
+
+ /**
+ * @see QuotaClassApi#get
+ */
+ @Named("quotaclass:get")
+ @GET
+ @SelectJson("quota_class_set")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/{id}")
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends QuotaClass> get(@PathParam("id") String id);
+
+ /**
+ * @see QuotaClassApi#update
+ */
+ @Named("quotaclass:update")
+ @PUT
+ @Path("/{id}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @MapBinder(BindToJsonPayload.class)
+ ListenableFuture<Boolean> update(@PathParam("id") String id, @PayloadParam("quota_class_set") QuotaClass quotas);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java
new file mode 100644
index 0000000..867ccd3
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java
@@ -0,0 +1,89 @@
+/*
+ * 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.extensions;
+
+import org.jclouds.openstack.nova.v2_0.domain.Ingress;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+
+/**
+ * Provides synchronous access to Security Groups.
+ * <p/>
+ *
+ * @see SecurityGroupAsyncApi
+ * @author Jeremy Daggett
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.SECURITY_GROUPS)
+public interface SecurityGroupApi {
+
+ /**
+ * List all Security Groups.
+ *
+ * @return all Security Groups
+ */
+ FluentIterable<? extends SecurityGroup> list();
+
+ /**
+ * Get a specific Security Group
+ *
+ * @return a specific Security Group
+ */
+ SecurityGroup get(String id);
+
+ /**
+ * Create a Security Group
+ *
+ * @return a new Security Group
+ */
+ SecurityGroup createWithDescription(String name, String description);
+
+ /**
+ * Delete a Security Group.
+ *
+ * @return
+ */
+ boolean delete(String id);
+
+ /**
+ * Create a Security Group Rule.
+ *
+ * @return a new Security Group Rule
+ */
+ SecurityGroupRule createRuleAllowingCidrBlock(String parentGroup, Ingress ingress, String sourceCidr);
+
+ /**
+ * Create a Security Group Rule.
+ *
+ * @return a new Security Group Rule
+ */
+ SecurityGroupRule createRuleAllowingSecurityGroupId(String parentGroup, Ingress ingress,
+ String groupId);
+
+ /**
+ * Delete a Security Group Rule.
+ *
+ * @return
+ */
+ Boolean deleteRule(String id);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupAsyncApi.java
new file mode 100644
index 0000000..5e5a2de
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupAsyncApi.java
@@ -0,0 +1,152 @@
+/*
+ * 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.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.binders.BindSecurityGroupRuleToJsonPayload;
+import org.jclouds.openstack.nova.v2_0.domain.Ingress;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.Payload;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to Security Groups via the REST API.
+ * <p/>
+ *
+ * @see SecurityGroupApi
+ * @author Jeremy Daggett
+ * @see <a href= "http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html"
+ * />
+ * @see <a href="http://nova.openstack.org/api_ext" />
+ * @see <a href="http://wiki.openstack.org/os-security-groups" />
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.SECURITY_GROUPS)
+@RequestFilters(AuthenticateRequest.class)
+public interface SecurityGroupAsyncApi {
+
+ /**
+ * @see SecurityGroupApi#list
+ */
+ @Named("securitygroup:list")
+ @GET
+ @SelectJson("security_groups")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/os-security-groups")
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends SecurityGroup>> list();
+
+ /**
+ * @see SecurityGroupApi#get
+ */
+ @Named("securitygroup:get")
+ @GET
+ @Path("/os-security-groups/{id}")
+ @SelectJson("security_group")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends SecurityGroup> get(@PathParam("id") String id);
+
+ /**
+ * @see SecurityGroupApi#createWithDescription
+ */
+ @Named("securitygroup:create")
+ @POST
+ @Path("/os-security-groups")
+ @SelectJson("security_group")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"security_group\":%7B\"name\":\"{name}\",\"description\":\"{description}\"%7D%7D")
+ ListenableFuture<? extends SecurityGroup> createWithDescription(@PayloadParam("name") String name,
+ @PayloadParam("description") String description);
+
+ /**
+ * @see SecurityGroupApi#delete
+ */
+ @Named("securitygroup:delete")
+ @DELETE
+ @Path("/os-security-groups/{id}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ @Consumes(MediaType.APPLICATION_JSON)
+ ListenableFuture<Boolean> delete(@PathParam("id") String id);
+
+ /**
+ * @see SecurityGroupApi#createRuleAllowingCidrBlock
+ */
+ @Named("securitygroup:create")
+ @POST
+ @Path("/os-security-group-rules")
+ @SelectJson("security_group_rule")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @MapBinder(BindSecurityGroupRuleToJsonPayload.class)
+ ListenableFuture<? extends SecurityGroupRule> createRuleAllowingCidrBlock(
+ @PayloadParam("parent_group_id") String parent_group_id, Ingress ip_protocol,
+ @PayloadParam("cidr") String cidr);
+
+ /**
+ * @see SecurityGroupApi#createRuleOnSecurityGroupToCidrBlock
+ */
+ @Named("securitygroup:create")
+ @POST
+ @Path("/os-security-group-rules")
+ @SelectJson("security_group_rule")
+ @Fallback(NullOnNotFoundOr404.class)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @MapBinder(BindSecurityGroupRuleToJsonPayload.class)
+ ListenableFuture<? extends SecurityGroupRule> createRuleAllowingSecurityGroupId(
+ @PayloadParam("parent_group_id") String parent_group_id, Ingress ip_protocol,
+ @PayloadParam("group_id") String group_id);
+
+ /**
+ * @see SecurityGroupApi#deleteRule
+ */
+ @Named("securitygroup:delete")
+ @DELETE
+ @Path("/os-security-group-rules/{security_group_rule_ID}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ @Consumes
+ ListenableFuture<Boolean> deleteRule(@PathParam("security_group_rule_ID") String security_group_rule_ID);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java
new file mode 100644
index 0000000..6ad70c2
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java
@@ -0,0 +1,120 @@
+/*
+ * 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.extensions;
+
+import org.jclouds.openstack.nova.v2_0.domain.BackupType;
+import org.jclouds.openstack.nova.v2_0.options.CreateBackupOfServerOptions;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Provide additional actions for servers:
+ * 'suspend', 'resume', 'migrate', 'lock', 'unlock', 'resetNetwork', 'createBackup', 'pause', 'migrateLive',
+ * 'injectNetworkInfo', 'unpause'
+ *
+ * @author Adam Lowe
+ * @see org.jclouds.openstack.nova.v2_0.extensions.ServerAdminAsyncApi
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.ADMIN_ACTIONS)
+public interface ServerAdminApi {
+
+ /**
+ * Suspend a server.
+ *
+ * @param id id of the server
+ */
+ Boolean suspend(String id);
+
+ /**
+ * Resume a server.
+ *
+ * @param id id of the server
+ */
+ Boolean resume(String id);
+
+ /**
+ * Migrate a server.
+ *
+ * @param id id of the server
+ */
+ Boolean migrate(String id);
+
+ /**
+ * Lock a server.
+ *
+ * @param id id of the server
+ */
+ Boolean lock(String id);
+
+ /**
+ * Unlock a server.
+ *
+ * @param id id of the server
+ */
+ Boolean unlock(String id);
+
+ /**
+ * Reset network of a server.
+ *
+ * @param id id of the server
+ */
+ Boolean resetNetwork(String id);
+
+ /**
+ * Create backup of a server.
+ *
+ * @param id id of the server
+ * @param imageName the name of the image to create
+ * @param backupType the type of backup
+ * @param rotation the number of images to retain (0 to simply overwrite)
+ * @param options optional rotation and/or metadata parameters
+ * @return the id of the newly created image
+ */
+ String createBackup(String id, String imageName, BackupType backupType, int rotation, CreateBackupOfServerOptions... options);
+
+ /**
+ * Pause a server.
+ *
+ * @param id id of the server
+ */
+ Boolean pause(String id);
+
+ /**
+ * Unpause a server.
+ *
+ * @param id id of the server
+ */
+ Boolean unpause(String id);
+
+
+ /**
+ * Live migrate a server.
+ *
+ * @param id id of the server
+ */
+ Boolean liveMigrate(String id, String host, boolean blockMigration, boolean diskOverCommit);
+
+ /**
+ * Inject network info into a server.
+ *
+ * @param id id of the server
+ */
+ Boolean injectNetworkInfo(String id);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminAsyncApi.java
new file mode 100644
index 0000000..1797a9d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminAsyncApi.java
@@ -0,0 +1,175 @@
+/*
+ * 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.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
+import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.domain.BackupType;
+import org.jclouds.openstack.nova.v2_0.functions.ParseImageIdFromLocationHeader;
+import org.jclouds.openstack.nova.v2_0.options.CreateBackupOfServerOptions;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.Payload;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.WrapWith;
+
+import com.google.common.annotations.Beta;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provide access to Admin Server Actions via REST API
+ *
+ * @author Adam Lowe
+ * @see org.jclouds.openstack.nova.v2_0.extensions.ServerAdminApi
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.ADMIN_ACTIONS)
+@RequestFilters(AuthenticateRequest.class)
+@Path("/servers/{id}/action")
+public interface ServerAdminAsyncApi {
+
+ /**
+ * @see ServerAdminApi#suspend(String)
+ */
+ @Named("serveradmin:suspend")
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"suspend\":null}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> suspend(@PathParam("id") String id);
+
+ /**
+ * @see ServerAdminApi#resume(String)
+ */
+ @Named("serveradmin:resume")
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"resume\":null}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> resume(@PathParam("id") String id);
+
+ /**
+ * @see ServerAdminApi#migrate(String)
+ */
+ @Named("serveradmin:migrate")
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"migrate\":null}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> migrate(@PathParam("id") String id);
+
+ /**
+ * @see ServerAdminApi#lock(String)
+ */
+ @Named("serveradmin:lock")
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"lock\":null}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> lock(@PathParam("id") String id);
+
+ /**
+ * @see ServerAdminApi#unlock(String)
+ */
+ @Named("serveradmin:unlock")
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"unlock\":null}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> unlock(@PathParam("id") String id);
+
+ /**
+ * @see ServerAdminApi#resetNetwork(String)
+ */
+ @Named("serveradmin:resetnetwork")
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"resetNetwork\":null}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> resetNetwork(@PathParam("id") String id);
+
+ /**
+ * @see ServerAdminApi#createBackup
+ */
+ @Named("serveradmin:createbackup")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @WrapWith("createBackup")
+ @Fallback(MapHttp4xxCodesToExceptions.class)
+ @ResponseParser(ParseImageIdFromLocationHeader.class)
+ ListenableFuture<String> createBackup(@PathParam("id") String id,
+ @PayloadParam("name") String imageName,
+ @PayloadParam("backup_type") BackupType backupType,
+ @PayloadParam("rotation") int rotation,
+ CreateBackupOfServerOptions... options);
+
+ /**
+ * @see ServerAdminApi#pause(String)
+ */
+ @Named("serveradmin:pause")
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"pause\":null}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> pause(@PathParam("id") String id);
+
+ /**
+ * @see ServerAdminApi#unpause(String)
+ */
+ @Named("serveradmin:unpause")
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"unpause\":null}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> unpause(@PathParam("id") String id);
+
+ /**
+ * @see ServerAdminApi#injectNetworkInfo(String)
+ */
+ @Named("serveradmin:injectnetwork")
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"injectNetworkInfo\":null}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> injectNetworkInfo(@PathParam("id") String id);
+
+ /**
+ * @see ServerAdminApi#liveMigrate(String)
+ */
+ @Named("serveradmin:livemigrate")
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(FalseOnNotFoundOr404.class)
+ @WrapWith("os-migrateLive")
+ ListenableFuture<Boolean> liveMigrate(@PathParam("id") String id,
+ @PayloadParam("host") String host,
+ @PayloadParam("block_migration") boolean blockMigration,
+ @PayloadParam("disk_over_commit") boolean diskOverCommit);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java
new file mode 100644
index 0000000..f9c91ae
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java
@@ -0,0 +1,49 @@
+/*
+ * 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.extensions;
+
+import org.jclouds.openstack.nova.v2_0.domain.ServerWithSecurityGroups;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Provides synchronous access to Server details including security group, referred to as the CREATESERVEREXT extension
+ * in the nova documentation
+ * <p/>
+ * NOTE: the equivalent to listServersInDetail() isn't available at the other end, so not extending ServerApi at this
+ * time.
+ *
+ * @author Adam Lowe
+ * @see org.jclouds.openstack.nova.v2_0.features.ServerApi
+ * @see ServerWithSecurityGroupsAsyncApi
+ * @see <a href="http://nova.openstack.org/api/nova.api.openstack.compute.contrib.createserverext.html"/>
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.CREATESERVEREXT)
+public interface ServerWithSecurityGroupsApi {
+
+ /**
+ * Retrieve details of the specified server, including security groups
+ *
+ * @param id id of the server
+ * @return server or null if not found
+ */
+ ServerWithSecurityGroups get(String id);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsAsyncApi.java
new file mode 100644
index 0000000..069d39b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsAsyncApi.java
@@ -0,0 +1,62 @@
+/*
+ * 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.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.domain.ServerWithSecurityGroups;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+
+import com.google.common.annotations.Beta;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides synchronous access to Servers with Security Groups.
+ *
+ * @author Adam Lowe
+ * @see org.jclouds.openstack.nova.v2_0.features.ServerAsyncApi
+ * @see ServerWithSecurityGroupsApi
+ * @see <a href="http://nova.openstack.org/api/nova.api.openstack.compute.contrib.createserverext.html"/>
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.CREATESERVEREXT)
+@RequestFilters(AuthenticateRequest.class)
+public interface ServerWithSecurityGroupsAsyncApi {
+
+ /**
+ * @see ServerWithSecurityGroupsApi#get(String)
+ */
+ @Named("server:get")
+ @GET
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/os-create-server-ext/{id}")
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends ServerWithSecurityGroups> get(@PathParam("id") String id);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java
new file mode 100644
index 0000000..08a1852
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java
@@ -0,0 +1,50 @@
+/*
+ * 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.extensions;
+
+import org.jclouds.openstack.nova.v2_0.domain.SimpleTenantUsage;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+
+/**
+ * Provides asynchronous access to Simple Tenant Usage via the REST API.
+ * <p/>
+ *
+ * @author Adam Lowe
+ * @see SimpleTenantUsageAsyncApi
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.SIMPLE_TENANT_USAGE)
+public interface SimpleTenantUsageApi {
+
+ /**
+ * Retrieve tenant_usage for all tenants
+ *
+ * @return the set of TenantUsage reports
+ */
+ FluentIterable<? extends SimpleTenantUsage> list();
+
+ /**
+ * Retrieve tenant_usage for a specified tenant
+ *
+ * @return the requested tenant usage
+ */
+ SimpleTenantUsage get(String tenantId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageAsyncApi.java
new file mode 100644
index 0000000..550d404
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageAsyncApi.java
@@ -0,0 +1,77 @@
+/*
+ * 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.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.domain.SimpleTenantUsage;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to Simple Tenant Usage via the REST API.
+ * <p/>
+ *
+ * @author Adam Lowe
+ * @see SimpleTenantUsageApi
+ * @see <a href= "http://docs.openstack.org/api/openstack-compute/2/content/Extensions-d1e1444.html" />
+ * @see <a href="http://nova.openstack.org/api_ext" />
+ * @see <a href="http://nova.openstack.org/api/nova.api.openstack.compute.contrib.simple_tenant_usage.html" />
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.SIMPLE_TENANT_USAGE)
+@RequestFilters(AuthenticateRequest.class)
+public interface SimpleTenantUsageAsyncApi {
+
+ /**
+ * @see SimpleTenantUsageApi#list()
+ */
+ @Named("tenantusage:list")
+ @GET
+ @Path("/os-simple-tenant-usage")
+ @SelectJson("tenant_usages")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends SimpleTenantUsage>> list();
+
+ /**
+ * @see SimpleTenantUsageApi#get(String)
+ */
+ @Named("tenantusage:get")
+ @GET
+ @Path("/os-simple-tenant-usage/{id}")
+ @SelectJson("tenant_usage")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends SimpleTenantUsage> get(@PathParam("id") String tenantId);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java
new file mode 100644
index 0000000..daf089f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.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.extensions;
+
+import org.jclouds.openstack.nova.v2_0.domain.VirtualInterface;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+
+/**
+ * Provides synchronous access to Virtual Interface features (VIFs).
+ *
+ * @see VirtualInterfaceAsyncApi
+ * @author Adam Lowe
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VIRTUAL_INTERFACES)
+public interface VirtualInterfaceApi {
+
+ /**
+ * Returns the list of Virtual Interfaces for a given instance.
+ *
+ * @return the list of snapshots
+ */
+ FluentIterable<? extends VirtualInterface> listOnServer(String serverId);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceAsyncApi.java
new file mode 100644
index 0000000..c23228c
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceAsyncApi.java
@@ -0,0 +1,59 @@
+/*
+ * 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.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.domain.VirtualInterface;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to Virtual Interface features (VIFs).
+ *
+ * @see VirtualInterfaceApi
+ * @author Adam Lowe
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VIRTUAL_INTERFACES)
+@RequestFilters(AuthenticateRequest.class)
+public interface VirtualInterfaceAsyncApi {
+ /**
+ * @see VirtualInterfaceApi#listOnServer(String)
+ */
+ @Named("virtualinterface:list")
+ @GET
+ @SelectJson("virtual_interfaces")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/servers/{server_id}/os-virtual-interfaces")
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends VirtualInterface>> listOnServer(@PathParam("server_id") String serverId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java
new file mode 100644
index 0000000..f9ab865
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java
@@ -0,0 +1,147 @@
+/*
+ * 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.extensions;
+
+import org.jclouds.openstack.nova.v2_0.domain.Volume;
+import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment;
+import org.jclouds.openstack.nova.v2_0.domain.VolumeSnapshot;
+import org.jclouds.openstack.nova.v2_0.options.CreateVolumeOptions;
+import org.jclouds.openstack.nova.v2_0.options.CreateVolumeSnapshotOptions;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+
+/**
+ * Provides synchronous access to Volumes.
+ * <p/>
+ *
+ * @see VolumeAsyncApi
+ * @see org.jclouds.openstack.nova.v2_0.extensions.VolumeAsyncApi
+ * @author Adam Lowe
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VOLUMES)
+public interface VolumeApi {
+ /**
+ * Returns a summary list of snapshots.
+ *
+ * @return the list of snapshots
+ */
+ FluentIterable<? extends Volume> list();
+
+ /**
+ * Returns a detailed list of volumes.
+ *
+ * @return the list of volumes.
+ */
+ FluentIterable<? extends Volume> listInDetail();
+
+ /**
+ * Return data about the given volume.
+ *
+ * @return details of a specific snapshot.
+ */
+ Volume get(String volumeId);
+
+ /**
+ * Creates a new Snapshot
+ *
+ * @return the new Snapshot
+ */
+ Volume create(int sizeGB, CreateVolumeOptions... options);
+
+ /**
+ * Delete a snapshot.
+ *
+ * @return true if successful
+ */
+ boolean delete(String volumeId);
+
+ /**
+ * List volume attachments for a given instance.
+ *
+ * @return all Floating IPs
+ * @deprecated To be removed in jclouds 1.7
+ * @see VolumeAttachmentApi#listAttachmentsOnServer(String)
+ */
+ @Deprecated FluentIterable<? extends VolumeAttachment> listAttachmentsOnServer(String serverId);
+
+ /**
+ * Get a specific attached volume.
+ *
+ * @return data about the given volume attachment.
+ * @deprecated To be removed in jclouds 1.7
+ * @see VolumeAttachmentApi#getAttachmentForVolumeOnServer(String, String)
+ */
+ @Deprecated VolumeAttachment getAttachmentForVolumeOnServer(String volumeId, String serverId);
+
+ /**
+ * Attach a volume to an instance
+ *
+ * @return data about the new volume attachment
+ * @deprecated To be removed in jclouds 1.7
+ * @see VolumeAttachmentApi#attachVolumeToServerAsDevice(String, String, String)
+ */
+ @Deprecated VolumeAttachment attachVolumeToServerAsDevice(String volumeId, String serverId, String device);
+
+ /**
+ * Detach a Volume from an instance.
+ *
+ * @return true if successful
+ * @deprecated To be removed in jclouds 1.7
+ * @see VolumeAttachmentApi#detachVolumeFromServer(String, String)
+ */
+ @Deprecated Boolean detachVolumeFromServer(String server_id, String volumeId);
+
+ /**
+ * Returns a summary list of snapshots.
+ *
+ * @return the list of snapshots
+ */
+ FluentIterable<? extends VolumeSnapshot> listSnapshots();
+
+ /**
+ * Returns a summary list of snapshots.
+ *
+ * @return the list of snapshots
+ */
+ FluentIterable<? extends VolumeSnapshot> listSnapshotsInDetail();
+
+ /**
+ * Return data about the given snapshot.
+ *
+ * @return details of a specific snapshot.
+ */
+ VolumeSnapshot getSnapshot(String snapshotId);
+
+ /**
+ * Creates a new Snapshot
+ *
+ * @return the new Snapshot
+ */
+ VolumeSnapshot createSnapshot(String volumeId, CreateVolumeSnapshotOptions... options);
+
+ /**
+ * Delete a snapshot.
+ *
+ * @return true if successful
+ */
+ boolean deleteSnapshot(String snapshotId);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAsyncApi.java
new file mode 100644
index 0000000..0e84604
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAsyncApi.java
@@ -0,0 +1,254 @@
+/*
+ * 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.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.domain.Volume;
+import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment;
+import org.jclouds.openstack.nova.v2_0.domain.VolumeSnapshot;
+import org.jclouds.openstack.nova.v2_0.options.CreateVolumeOptions;
+import org.jclouds.openstack.nova.v2_0.options.CreateVolumeSnapshotOptions;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.WrapWith;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides synchronous access to Volumes.
+ * <p/>
+ *
+ * @see org.jclouds.openstack.nova.v2_0.extensions.VolumeAsyncApi
+ * @author Adam Lowe
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VOLUMES)
+@RequestFilters(AuthenticateRequest.class)
+public interface VolumeAsyncApi {
+ /**
+ * Returns a summary list of volumes.
+ *
+ * @return the list of volumes
+ */
+ @Named("volume:list")
+ @GET
+ @Path("/os-volumes")
+ @SelectJson("volumes")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends Volume>> list();
+
+ /**
+ * Returns a detailed list of volumes.
+ *
+ * @return the list of volumes.
+ */
+ @Named("volume:list")
+ @GET
+ @Path("/os-volumes/detail")
+ @SelectJson("volumes")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends Volume>> listInDetail();
+
+ /**
+ * Return data about the given volume.
+ *
+ * @return details of a specific volume.
+ */
+ @Named("volume:get")
+ @GET
+ @Path("/os-volumes/{id}")
+ @SelectJson("volume")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends Volume> get(@PathParam("id") String volumeId);
+
+ /**
+ * Creates a new volume
+ *
+ * @return the new Snapshot
+ */
+ @Named("volume:create")
+ @POST
+ @Path("/os-volumes")
+ @SelectJson("volume")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @MapBinder(CreateVolumeOptions.class)
+ ListenableFuture<? extends Volume> create(@PayloadParam("size") int sizeGB, CreateVolumeOptions... options);
+
+ /**
+ * Delete a volume.
+ *
+ * @return true if successful
+ */
+ @Named("volume:delete")
+ @DELETE
+ @Path("/os-volumes/{id}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> delete(@PathParam("id") String volumeId);
+
+ /**
+ * List volume attachments for a given instance.
+ *
+ * @return all Floating IPs
+ * @deprecated To be removed in jclouds 1.7
+ * @see VolumeAttachmentApi#listAttachmentsOnServer(String)
+ */
+ @Named("volume:listattachments")
+ @GET
+ @Path("/servers/{server_id}/os-volume_attachments")
+ @SelectJson("volumeAttachments")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ @Deprecated ListenableFuture<? extends FluentIterable<? extends VolumeAttachment>> listAttachmentsOnServer(@PathParam("server_id") String serverId);
+
+ /**
+ * Get a specific attached volume.
+ *
+ * @return data about the given volume attachment.
+ * @deprecated To be removed in jclouds 1.7
+ * @see VolumeAttachmentApi#getAttachmentForVolumeOnServer(String, String)
+ */
+ @Named("volume:getattachments")
+ @GET
+ @Path("/servers/{server_id}/os-volume_attachments/{id}")
+ @SelectJson("volumeAttachment")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Deprecated ListenableFuture<? extends VolumeAttachment> getAttachmentForVolumeOnServer(@PathParam("id") String volumeId,
+ @PathParam("server_id") String serverId);
+
+ /**
+ * Attach a volume to an instance
+ *
+ * @return the new Attachment
+ * @deprecated To be removed in jclouds 1.7
+ * @see VolumeAttachmentApi#attachVolumeToServerAsDevice(String, String, String)
+ */
+ @Named("volume:attach")
+ @POST
+ @Path("/servers/{server_id}/os-volume_attachments")
+ @SelectJson("volumeAttachment")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @WrapWith("volumeAttachment")
+ @Deprecated ListenableFuture<? extends VolumeAttachment> attachVolumeToServerAsDevice(@PayloadParam("volumeId") String volumeId,
+ @PathParam("server_id") String serverId, @PayloadParam("device") String device);
+
+ /**
+ * Detach a Volume from an instance.
+ *
+ * @return true if successful
+ * @deprecated To be removed in jclouds 1.7
+ * @see VolumeAttachmentApi#detachVolumeFromServer(String, String)
+ */
+ @Named("volume:detach")
+ @DELETE
+ @Path("/servers/{server_id}/os-volume_attachments/{id}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(FalseOnNotFoundOr404.class)
+ @Deprecated ListenableFuture<Boolean> detachVolumeFromServer(@PathParam("id") String volumeId, @PathParam("server_id") String serverId);
+
+ /**
+ * Returns a summary list of snapshots.
+ *
+ * @return the list of snapshots
+ */
+ @Named("volume:listsnapshots")
+ @GET
+ @Path("/os-snapshots")
+ @SelectJson("snapshots")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends VolumeSnapshot>> listSnapshots();
+
+ /**
+ * Returns a summary list of snapshots.
+ *
+ * @return the list of snapshots
+ */
+ @Named("volume:listsnapshot")
+ @GET
+ @Path("/os-snapshots/detail")
+ @SelectJson("snapshots")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends VolumeSnapshot>> listSnapshotsInDetail();
+
+ /**
+ * Return data about the given snapshot.
+ *
+ * @return details of a specific snapshot.
+ */
+ @Named("volume:getsnapshot")
+ @GET
+ @Path("/os-snapshots/{id}")
+ @SelectJson("snapshot")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends VolumeSnapshot> getSnapshot(@PathParam("id") String snapshotId);
+
+ /**
+ * Creates a new Snapshot
+ *
+ * @return the new Snapshot
+ */
+ @Named("volume:createsnapshot")
+ @POST
+ @Path("/os-snapshots")
+ @SelectJson("snapshot")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @MapBinder(CreateVolumeSnapshotOptions.class)
+ ListenableFuture<? extends VolumeSnapshot> createSnapshot(@PayloadParam("volume_id") String volumeId, CreateVolumeSnapshotOptions... options);
+
+ /**
+ * Delete a snapshot.
+ *
+ * @return true if successful
+ */
+ @Named("volume:deletesnapshot")
+ @DELETE
+ @Path("/os-snapshots/{id}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> deleteSnapshot(@PathParam("id") String snapshotId);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java
new file mode 100644
index 0000000..273815e
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java
@@ -0,0 +1,87 @@
+/*
+ * 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.extensions;
+
+import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+
+/**
+ * Provides synchronous access to Volume Attachments.
+ *
+ * This API strictly handles attaching Volumes to Servers. To create and manage Volumes you need to use one of the
+ * following APIs:
+ *
+ * 1. The Cinder API
+ * If your OpenStack deployment is Folsom or later and it supports the Cinder block storage service, use this API.
+ * @see org.jclouds.openstack.cinder.v1.features.VolumeApi
+ *
+ * 2. The nova-volume API
+ * If your OpenStack deployment is Essex or earlier and it supports the nova-volume extension, use this API.
+ * @see org.jclouds.openstack.nova.v2_0.extensions.VolumeApi
+ *
+ * @see VolumeAttachmentAsyncApi
+ * @author Everett Toews
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VOLUMES)
+public interface VolumeAttachmentApi {
+ /**
+ * List Volume Attachments for a given Server.
+ *
+ * @param serverId The ID of the Server
+ * @return All VolumeAttachments for the Server
+ */
+ FluentIterable<? extends VolumeAttachment> listAttachmentsOnServer(String serverId);
+
+ /**
+ * Get a specific Volume Attachment for a Volume and Server.
+ *
+ * @param volumeId The ID of the Volume
+ * @param serverId The ID of the Server
+ * @return The Volume Attachment.
+ */
+ VolumeAttachment getAttachmentForVolumeOnServer(String volumeId, String serverId);
+
+ /**
+ * Attach a Volume to a Server.
+ *
+ * Note: If you are using KVM as your hypervisor then the actual device name in the Server will be different than
+ * the one specified. When the Server sees a new device, it picks the next available name (which in most cases is
+ * /dev/vdc) and the disk shows up there on the Server.
+ *
+ * @param serverId The ID of the Server
+ * @param volumeId The ID of the Volume
+ * @param device The name of the device this Volume will be identified as in the Server (e.g. /dev/vdc)
+ * @return The Volume Attachment.
+ */
+ VolumeAttachment attachVolumeToServerAsDevice(String volumeId, String serverId, String device);
+
+ /**
+ * Detach a Volume from a server.
+ *
+ * Note: Make sure you've unmounted the volume first. Failure to do so could result in failure or data loss.
+ *
+ * @param volumeId The ID of the Volume
+ * @param serverId The ID of the Server
+ * @return true if successful
+ */
+ boolean detachVolumeFromServer(String volumeId, String serverId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentAsyncApi.java
new file mode 100644
index 0000000..7aa5763
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentAsyncApi.java
@@ -0,0 +1,107 @@
+/*
+ * 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.extensions;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.WrapWith;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to Volume Attachments .
+ *
+ * @see VolumeAttachmentApi
+ * @author Everett Toews
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VOLUMES)
+@RequestFilters(AuthenticateRequest.class)
+public interface VolumeAttachmentAsyncApi {
+ /**
+ * @see VolumeAttachmentApi#listAttachmentsOnServer(String)
+ */
+ @Named("volumeattachment:list")
+ @GET
+ @Path("/servers/{server_id}/os-volume_attachments")
+ @SelectJson("volumeAttachments")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends VolumeAttachment>> listAttachmentsOnServer(
+ @PathParam("server_id") String serverId);
+
+ /**
+ * @see VolumeAttachmentApi#getAttachmentForVolumeOnServer(String, String)
+ */
+ @Named("volumeattachment:get")
+ @GET
+ @Path("/servers/{server_id}/os-volume_attachments/{id}")
+ @SelectJson("volumeAttachment")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends VolumeAttachment> getAttachmentForVolumeOnServer(
+ @PathParam("id") String volumeId,
+ @PathParam("server_id") String serverId);
+
+ /**
+ * @see VolumeAttachmentApi#attachVolumeToServerAsDevice(String, String, String)
+ */
+ @Named("volumeattachment:attach")
+ @POST
+ @Path("/servers/{server_id}/os-volume_attachments")
+ @SelectJson("volumeAttachment")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @WrapWith("volumeAttachment")
+ ListenableFuture<? extends VolumeAttachment> attachVolumeToServerAsDevice(
+ @PayloadParam("volumeId") String volumeId,
+ @PathParam("server_id") String serverId,
+ @PayloadParam("device") String device);
+
+ /**
+ * @see VolumeAttachmentApi#detachVolumeFromServer(String, String)
+ */
+ @Named("volumeattachment:detach")
+ @DELETE
+ @Path("/servers/{server_id}/os-volume_attachments/{id}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> detachVolumeFromServer(
+ @PathParam("id") String volumeId,
+ @PathParam("server_id") String serverId);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java
new file mode 100644
index 0000000..be0e5cc
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java
@@ -0,0 +1,101 @@
+/*
+ * 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.extensions;
+
+import java.util.Map;
+import org.jclouds.openstack.nova.v2_0.domain.VolumeType;
+import org.jclouds.openstack.nova.v2_0.options.CreateVolumeTypeOptions;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+
+/**
+ * Provides synchronous access to Volume Type features
+ *
+ * @author Adam Lowe
+ * @see VolumeApi
+ * @see VolumeTypeAsyncApi
+ * @see <a href="http://nova.openstack.org/api/nova.api.openstack.compute.contrib.volumetypes.html"/>
+ * @see <a href="https://blueprints.launchpad.net/nova/+spec/volume-type"/>
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VOLUME_TYPES)
+public interface VolumeTypeApi {
+
+ /**
+ * @return set of all volume types
+ */
+ FluentIterable<? extends VolumeType> list();
+
+ /**
+ * @param id the id of the volume type to retrieve
+ * @return the requested volume type
+ */
+ VolumeType get(String id);
+
+ /**
+ * Creates a new volume type
+ *
+ * @param name the name of the new volume type
+ * @param options optional settings for the new volume type
+ * @return the new volume type
+ */
+ VolumeType create(String name, CreateVolumeTypeOptions... options);
+
+ /**
+ * Deletes a volume type
+ */
+ boolean delete(String id);
+
+ /**
+ * @param id the id of the volume type
+ * @return the set of extra metadata for the flavor
+ */
+ Map<String, String> getExtraSpecs(String id);
+
+ /**
+ * Creates or updates the extra metadata for a given flavor
+ */
+ boolean updateExtraSpecs(String id, Map<String, String> specs);
+
+ /**
+ * Retrieve a single extra spec value
+ *
+ * @param id the id of the volume type
+ * @param key the key of the extra spec item to retrieve
+ */
+ String getExtraSpec(String id, String key);
+
+ /**
+ * Creates or updates a single extra spec value
+ *
+ * @param id the id of the volume type
+ * @param key the extra spec key (when creating ensure this does not include whitespace or other difficult characters)
+ * @param value the new value to store associate with the key
+ */
+ boolean updateExtraSpec(String id, String key, String value);
+
+ /**
+ * Deletes an existing extra spec
+ *
+ * @param id the id of the volume type
+ * @param key the key of the extra spec to delete
+ */
+ boolean deleteExtraSpec(String id, String key);
+}
[05/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
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/features/ImageApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiExpectTest.java
new file mode 100644
index 0000000..85407d1
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiExpectTest.java
@@ -0,0 +1,377 @@
+/*
+ * 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.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseImageListTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseImageTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseMetadataListTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseMetadataUpdateTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests annotation parsing of {@code ImageAsyncApi}
+ *
+ * @author Michael Arnold
+ */
+@Test(groups = "unit", testName = "ImageAsyncApiTest")
+public class ImageApiExpectTest extends BaseNovaApiExpectTest {
+ public void testListImagesWhenResponseIs2xx() throws Exception {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/image_list.json")).build();
+
+ NovaApi apiWhenImagesExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, list, listResponse);
+
+ assertEquals(apiWhenImagesExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
+
+ assertEquals(apiWhenImagesExist.getImageApiForZone("az-1.region-a.geo-1").list().concat().toString(),
+ new ParseImageListTest().expected().toString());
+ }
+
+ public void testListImagesWhenReponseIs404IsEmpty() throws Exception {
+ HttpRequest list = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, list, listResponse);
+
+ assertTrue(apiWhenNoServersExist.getImageApiForZone("az-1.region-a.geo-1").list().concat().isEmpty());
+ }
+
+ public void testGetImageWhenResponseIs2xx() throws Exception {
+
+ 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_details.json")).build();
+
+ NovaApi apiWhenImagesExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, getImage, getImageResponse);
+
+ assertEquals(
+ apiWhenImagesExist.getImageApiForZone("az-1.region-a.geo-1").get("52415800-8b69-11e0-9b19-734f5736d2a2")
+ .toString(), new ParseImageTest().expected().toString());
+ }
+
+ public void testGetImageWhenResponseIs404() throws Exception {
+ 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(404).build();
+
+ NovaApi apiWhenNoImagesExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, getImage, getImageResponse);
+
+ assertNull(apiWhenNoImagesExist.getImageApiForZone("az-1.region-a.geo-1").get(
+ "52415800-8b69-11e0-9b19-734f5736d2a2"));
+
+ }
+
+ public void testListMetadataWhenResponseIs2xx() throws Exception {
+ String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
+ HttpRequest getMetadata = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse getMetadataResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/metadata_list.json")).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, getMetadata, getMetadataResponse);
+
+ assertEquals(apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").getMetadata(imageId).toString(),
+ new ParseMetadataListTest().expected().toString());
+ }
+
+ public void testListMetadataWhenResponseIs404() throws Exception {
+ String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
+ HttpRequest getMetadata = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata")
+ .addHeader("Accept", "*/*")
+ .addHeader("X-Auth-Token", authToken)
+ .build();
+
+ HttpResponse getMetadataResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, getMetadata, getMetadataResponse);
+
+ try {
+ apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").getMetadata(imageId);
+ fail("Expected an exception.");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ public void testSetMetadataWhenResponseIs2xx() throws Exception {
+ String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
+ ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
+ .put("Server Label", "Web Head 1")
+ .put("Image Version", "2.1")
+ .build();
+
+ HttpRequest setMetadata = HttpRequest
+ .builder()
+ .method("PUT")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 1\",\"Image Version\":\"2.1\"}}","application/json"))
+ .build();
+
+ HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/metadata_list.json")).build();
+
+ NovaApi apiWhenImageExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, setMetadata, setMetadataResponse);
+
+ assertEquals(apiWhenImageExists.getImageApiForZone("az-1.region-a.geo-1").setMetadata(imageId, metadata).toString(),
+ new ParseMetadataListTest().expected().toString());
+ }
+
+ public void testSetMetadataWhenResponseIs404() throws Exception {
+ String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
+ ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
+ .put("Server Label", "Web Head 1")
+ .put("Image Version", "2.1")
+ .build();
+
+ HttpRequest setMetadata = HttpRequest
+ .builder()
+ .method("PUT")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" +imageId + "/metadata")
+ .addHeader("Accept", "*/*")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 1\",\"Image Version\":\"2.1\"}}","application/json"))
+ .build();
+
+ HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, setMetadata, setMetadataResponse);
+
+ try {
+ apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").setMetadata(imageId, metadata);
+ fail("Expected an exception.");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ public void testUpdateMetadataWhenResponseIs2xx() throws Exception {
+ String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
+ ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
+ .put("Server Label", "Web Head 2")
+ .put("Server Description", "Simple Server")
+ .build();
+
+ HttpRequest setMetadata = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}","application/json"))
+ .build();
+
+ HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/metadata_updated.json")).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, setMetadata, setMetadataResponse);
+
+ assertEquals(apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").updateMetadata(imageId, metadata).toString(),
+ new ParseMetadataUpdateTest().expected().toString());
+ }
+
+ public void testUpdateMetadataWhenResponseIs404() throws Exception {
+ String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
+ ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
+ .put("Server Label", "Web Head 2")
+ .put("Server Description", "Simple Server")
+ .build();
+
+ HttpRequest setMetadata = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + imageId + "/metadata")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}","application/json"))
+ .build();
+
+ HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404)
+ .payload(payloadFromResource("/metadata_updated.json")).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, setMetadata, setMetadataResponse);
+
+ try {
+ apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").setMetadata(imageId, metadata);
+ fail("Expected an exception.");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ public void testGetMetadataItemWhenResponseIs2xx() throws Exception {
+ String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
+ String key = "Image%20Version";
+
+ HttpRequest getMetadata = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata/" + key)
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .build();
+
+ HttpResponse getMetadataResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromString("{\"metadata\":{\"Image Version\":\"2.5\"}}")).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, getMetadata, getMetadataResponse);
+
+ assertEquals(apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").getMetadata(imageId, "Image Version").toString(),
+ "2.5");
+ }
+
+ public void testGetMetadataItemWhenResponseIs404() throws Exception {
+ String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
+ String key = "Image%20Version";
+
+ HttpRequest getMetadata = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata/" + key)
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .build();
+
+ HttpResponse getMetadataResponse = HttpResponse.builder().statusCode(404)
+ .payload(payloadFromStringWithContentType("{\"metadata\":{\"Image Version\":\"2.5\"}}", "application/json")).build();
+
+ NovaApi apiWhenImageExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, getMetadata, getMetadataResponse);
+
+ assertNull(apiWhenImageExists.getImageApiForZone("az-1.region-a.geo-1").getMetadata(imageId, key));
+ }
+
+ public void testSetMetadataItemWhenResponseIs2xx() throws Exception {
+ String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
+ String key = "Image Version";
+
+ HttpRequest updateMetadata = HttpRequest
+ .builder()
+ .method("PUT")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata/" + "Image%20Version")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"metadata\":{\"Image Version\":\"2.5\"}}", "application/json"))
+ .build();
+
+ HttpResponse updateMetadataResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromStringWithContentType("{\"metadata\":{\"Image Version\":\"2.5\"}}", "application/json")).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, updateMetadata, updateMetadataResponse);
+
+ assertEquals(apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").updateMetadata(imageId, key, "2.5").toString(),
+ "2.5");
+ }
+
+ public void testDeleteMetadataItemWhenResponseIs2xx() throws Exception {
+ String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
+ String key = "Image%20Version";
+
+ HttpRequest deleteMetadata = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata/" + key)
+ .addHeader("Accept", "*/*")
+ .addHeader("X-Auth-Token", authToken)
+ .build();
+
+ HttpResponse deleteMetadataResponse = HttpResponse.builder().statusCode(204).build();
+
+ NovaApi apiWhenImageExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, deleteMetadata, deleteMetadataResponse);
+
+ apiWhenImageExists.getImageApiForZone("az-1.region-a.geo-1").deleteMetadata(imageId, key);
+ }
+
+ public void testDeleteMetadataItemWhenResponseIs404() throws Exception {
+ String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2";
+ String key = "Image%20Version";
+
+ HttpRequest deleteMetadata = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata/" + key)
+ .addHeader("Accept", "*/*")
+ .addHeader("X-Auth-Token", authToken)
+ .build();
+
+ HttpResponse deleteMetadataResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenImageExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, deleteMetadata, deleteMetadataResponse);
+
+ apiWhenImageExists.getImageApiForZone("az-1.region-a.geo-1").deleteMetadata(imageId, key);
+
+ }
+}
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/features/ImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiLiveTest.java
new file mode 100644
index 0000000..83d0b62
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiLiveTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@link ImageApi}
+ *
+ * @author Michael Arnold
+ */
+@Test(groups = "live", testName = "ImageApiLiveTest")
+public class ImageApiLiveTest extends BaseNovaApiLiveTest {
+
+ @Test(description = "GET /v${apiVersion}/{tenantId}/images")
+ public void testListImages() throws Exception {
+ for (String zoneId : zones) {
+ ImageApi imageApi = api.getImageApiForZone(zoneId);
+ Set<? extends Resource> response = imageApi.list().concat().toSet();
+ assertNotNull(response);
+ assertFalse(response.isEmpty());
+ for (Resource image : response) {
+ assertNotNull(image.getId());
+ assertNotNull(image.getName());
+ assertNotNull(image.getLinks());
+ }
+ }
+ }
+
+ @Test(description = "GET /v${apiVersion}/{tenantId}/images/detail")
+ public void testListImagesInDetail() throws Exception {
+ for (String zoneId : api.getConfiguredZones()) {
+ ImageApi imageApi = api.getImageApiForZone(zoneId);
+ Set<? extends Image> response = imageApi.listInDetail().concat().toSet();
+ assertNotNull(response);
+ assertFalse(response.isEmpty());
+ for (Image image : response) {
+ assertNotNull(image.getId());
+ assertNotNull(image.getName());
+ assertNotNull(image.getLinks());
+ assertNotNull(image.getCreated());
+ // image.getMinDisk() can be zero
+ // image.getMinRam() can be zero
+ assertTrue(image.getProgress() >= 0 && image.getProgress() <= 100);
+ assertNotNull(image.getStatus());
+ // image.getServer() can be null
+ // image.getTenantId() can be null
+ // image.getUpdated() can be null
+ // image.getUserId() can be null
+ }
+ }
+ }
+
+ @Test(description = "GET /v${apiVersion}/{tenantId}/images/{id}", dependsOnMethods = { "testListImagesInDetail" })
+ public void testGetImageById() throws Exception {
+ for (String zoneId : api.getConfiguredZones()) {
+ ImageApi imageApi = api.getImageApiForZone(zoneId);
+ Set<? extends Image> response = imageApi.listInDetail().concat().toSet();
+ for (Image image : response) {
+ Image details = imageApi.get(image.getId());
+ assertNotNull(details);
+ assertEquals(details.getId(), image.getId());
+ assertEquals(details.getName(), image.getName());
+ assertEquals(details.getLinks(), image.getLinks());
+ assertEquals(details.getCreated(), image.getCreated());
+ assertEquals(details.getMinDisk(), image.getMinDisk());
+ assertEquals(details.getMinRam(), image.getMinRam());
+ assertEquals(details.getProgress(), image.getProgress());
+ assertEquals(details.getStatus(), image.getStatus());
+ assertEquals(details.getServer(), image.getServer());
+ assertEquals(details.getTenantId(), image.getTenantId());
+ assertEquals(details.getUpdated(), image.getUpdated());
+ assertEquals(details.getUserId(), image.getUserId());
+ }
+ }
+ }
+}
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/features/ServerApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiExpectTest.java
new file mode 100644
index 0000000..070dcf6
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiExpectTest.java
@@ -0,0 +1,746 @@
+/*
+ * 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.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions;
+import org.jclouds.openstack.nova.v2_0.options.RebuildServerOptions;
+import org.jclouds.openstack.nova.v2_0.parse.ParseCreatedServerTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseMetadataListTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseMetadataUpdateTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseServerListTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+import org.jclouds.openstack.nova.v2_0.parse.ParseServerDiagnostics;
+
+/**
+ * Tests annotation parsing of {@code ServerAsyncApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ServerAsyncApiTest")
+public class ServerApiExpectTest extends BaseNovaApiExpectTest {
+
+ 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());
+ }
+
+ 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")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse listServersResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, listServers, listServersResponse);
+
+ assertTrue(apiWhenNoServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().isEmpty());
+ }
+
+ public void testCreateServerWhenResponseIs202() 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.json","application/json; charset=UTF-8")).build();
+
+ NovaApi apiWithNewServer = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, createServer, createServerResponse);
+
+ assertEquals(apiWithNewServer.getServerApiForZone("az-1.region-a.geo-1").create("test-e92", "1241", "100").toString(),
+ new ParseCreatedServerTest().expected().toString());
+ }
+
+ public void testCreateServerInAvailabilityZoneWhenResponseIs202() 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\",\"availability_zone\":\"nova\"}}","application/json"))
+ .build();
+
+
+ HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
+ .payload(payloadFromResourceWithContentType("/new_server_in_zone.json","application/json; charset=UTF-8")).build();
+
+ NovaApi apiWithNewServer = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, createServer, createServerResponse);
+
+ CreateServerOptions options = new CreateServerOptions().availabilityZone("nova");
+
+ assertEquals(apiWithNewServer.getServerApiForZone("az-1.region-a.geo-1").create("test-e92", "1241", "100", options).toString(),
+ new ParseCreatedServerTest().expected().toString());
+ }
+
+ public void testCreateServerWithSecurityGroupsWhenResponseIs202() 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();
+
+
+ NovaApi apiWithNewServer = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, createServer, createServerResponse);
+
+ assertEquals(apiWithNewServer.getServerApiForZone("az-1.region-a.geo-1").create("test-e92", "1241",
+ "100", new CreateServerOptions().securityGroupNames("group1", "group2")).toString(),
+ new ParseCreatedServerTest().expected().toString());
+ }
+
+ public void testCreateServerWithNetworksWhenResponseIs202() 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\":\"b3856ac0-f481-11e2-b778-0800200c9a66\"},{\"uuid\":\"bf0f0f90-f481-11e2-b778-0800200c9a66\"}]}}","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();
+
+
+ NovaApi apiWithNewServer = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, createServer, createServerResponse);
+
+ assertEquals(apiWithNewServer.getServerApiForZone("az-1.region-a.geo-1").create("test-e92", "1241",
+ "100", new CreateServerOptions().networks("b3856ac0-f481-11e2-b778-0800200c9a66", "bf0f0f90-f481-11e2-b778-0800200c9a66")).toString(),
+ new ParseCreatedServerTest().expected().toString());
+ }
+
+ public void testCreateServerWithDiskConfigAuto() 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();
+
+
+ NovaApi apiWithNewServer = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ createServer, createServerResponse);
+
+ assertEquals(apiWithNewServer.getServerApiForZone("az-1.region-a.geo-1").create("test-e92", "1241",
+ "100", new CreateServerOptions().diskConfig(Server.DISK_CONFIG_AUTO)).toString(),
+ new ParseCreatedServerTest().expectedWithDiskConfig(Server.DISK_CONFIG_AUTO).toString());
+ }
+
+ public void testCreateServerWithDiskConfigManual() 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\":\"MANUAL\"}}","application/json"))
+ .build();
+
+
+ HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
+ .payload(payloadFromResourceWithContentType("/new_server_disk_config_manual.json","application/json; charset=UTF-8")).build();
+
+
+ NovaApi apiWithNewServer = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess,
+ createServer, createServerResponse);
+
+ assertEquals(apiWithNewServer.getServerApiForZone("az-1.region-a.geo-1").create("test-e92", "1241",
+ "100", new CreateServerOptions().diskConfig(Server.DISK_CONFIG_MANUAL)).toString(),
+ new ParseCreatedServerTest().expectedWithDiskConfig(Server.DISK_CONFIG_MANUAL).toString());
+ }
+
+ public void testRebuildServerWhenResponseIs202() throws Exception {
+ String serverId = "52415800-8b69-11e0-9b19-734f565bc83b";
+ HttpRequest rebuildServer = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId +"/action")
+ .addHeader("Accept", "*/*")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType(
+ "{\"rebuild\":{\"adminPass\":\"password\",\"imageRef\":\"1234\",\"name\":\"newName\",\"accessIPv4\":\"1.1.1.1\",\"accessIPv6\":\"fe80::100\"}}","application/json"))
+ .build();
+
+ HttpResponse rebuildServerResponse = HttpResponse.builder().statusCode(202).build();
+
+ NovaApi apiRebuildServer = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, rebuildServer, rebuildServerResponse);
+
+ RebuildServerOptions options = new RebuildServerOptions().withImage("1234").name("newName").adminPass("password").ipv4Address("1.1.1.1").ipv6Address("fe80::100");
+
+ apiRebuildServer.getServerApiForZone("az-1.region-a.geo-1").rebuild(serverId, options);
+ }
+
+ public void testCreateImageWhenResponseIs2xx() throws Exception {
+ String serverId = "123";
+ String imageId = "456";
+ String imageName = "foo";
+
+ HttpRequest createImage = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/action")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType(
+ "{\"createImage\":{\"name\":\"" + imageName + "\", \"metadata\": {}}}", "application/json"))
+ .build();
+
+ HttpResponse createImageResponse = HttpResponse.builder()
+ .statusCode(200)
+ .headers(
+ ImmutableMultimap.<String, String> builder()
+ .put("Location", "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId).build()).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, createImage, createImageResponse);
+
+ assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").createImageFromServer(imageName, serverId),
+ imageId);
+ }
+
+ public void testCreateImageWhenResponseIs404IsEmpty() throws Exception {
+ String serverId = "123";
+ String imageName = "foo";
+
+ HttpRequest createImage = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/action")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType(
+ "{\"createImage\":{\"name\":\"" + imageName + "\", \"metadata\": {}}}", "application/json"))
+ .build();
+
+ HttpResponse createImageResponse = HttpResponse.builder().statusCode(404).build();
+ NovaApi apiWhenServerDoesNotExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, createImage, createImageResponse);
+
+ try {
+ apiWhenServerDoesNotExist.getServerApiForZone("az-1.region-a.geo-1").createImageFromServer(imageName, serverId);
+ fail("Expected an exception.");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ public void testStopServerWhenResponseIs2xx() throws Exception {
+ String serverId = "123";
+ HttpRequest stopServer = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/action")
+ .addHeader("Accept", "*/*")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType(
+ "{\"os-stop\":null}", "application/json"))
+ .build();
+
+ HttpResponse stopServerResponse = HttpResponse.builder().statusCode(202).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, stopServer, stopServerResponse);
+
+ apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").stop(serverId);
+ }
+
+ public void testStopServerWhenResponseIs404() throws Exception {
+ String serverId = "123";
+ HttpRequest stopServer = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/action")
+ .addHeader("Accept", "*/*")
+ .addHeader("X-Auth-Token", authToken)
+
+ .payload(payloadFromStringWithContentType(
+ "{\"os-stop\":null}", "application/json"))
+ .build();
+
+ HttpResponse stopServerResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, stopServer, stopServerResponse);
+
+ try {
+ apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").stop(serverId);
+ fail("Expected an exception.");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ public void testStartServerWhenResponseIs2xx() throws Exception {
+ String serverId = "123";
+ HttpRequest startServer = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/action")
+ .addHeader("Accept", "*/*")
+ .addHeader("X-Auth-Token", authToken)
+
+ .payload(payloadFromStringWithContentType(
+ "{\"os-start\":null}", "application/json"))
+ .build();
+
+ HttpResponse startServerResponse = HttpResponse.builder().statusCode(202).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, startServer, startServerResponse);
+
+ apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").start(serverId);
+ }
+
+ public void testStartServerWhenResponseIs404() throws Exception {
+ String serverId = "123";
+ HttpRequest startServer = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/action")
+ .addHeader("Accept", "*/*")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType(
+ "{\"os-startp\":null}", "application/json"))
+ .build();
+
+ HttpResponse startServerResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, startServer, startServerResponse);
+
+ try {
+ apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").start(serverId);
+ fail("Expected an exception.");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ public void testListMetadataWhenResponseIs2xx() throws Exception {
+ String serverId = "123";
+
+ HttpRequest getMetadata = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse getMetadataResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/metadata_list.json")).build();
+
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, getMetadata, getMetadataResponse);
+
+ assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").getMetadata(serverId).toString(),
+ new ParseMetadataListTest().expected().toString());
+ }
+
+ public void testListMetadataWhenResponseIs404() throws Exception {
+ String serverId = "123";
+ HttpRequest getMetadata = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata")
+ .addHeader("Accept", "*/*")
+ .addHeader("X-Auth-Token", authToken)
+ .build();
+
+ HttpResponse getMetadataResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, getMetadata, getMetadataResponse);
+
+ try {
+ apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").getMetadata(serverId);
+ fail("Expected an exception.");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ public void testSetMetadataWhenResponseIs2xx() throws Exception {
+ String serverId = "123";
+ ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
+ .put("Server Label", "Web Head 1")
+ .put("Image Version", "2.1")
+ .build();
+
+ HttpRequest setMetadata = HttpRequest
+ .builder()
+ .method("PUT")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 1\",\"Image Version\":\"2.1\"}}","application/json"))
+ .build();
+
+ HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/metadata_list.json")).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, setMetadata, setMetadataResponse);
+
+ assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata).toString(),
+ new ParseMetadataListTest().expected().toString());
+ }
+
+ public void testSetMetadataWhenResponseIs404() throws Exception {
+ String serverId = "123";
+ ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
+ .put("Server Label", "Web Head 1")
+ .put("Image Version", "2.1")
+ .build();
+
+ HttpRequest setMetadata = HttpRequest
+ .builder()
+ .method("PUT")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata")
+ .addHeader("Accept", "*/*")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 1\",\"Image Version\":\"2.1\"}}","application/json"))
+ .build();
+
+ HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, setMetadata, setMetadataResponse);
+
+ try {
+ apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata);
+ fail("Expected an exception.");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ public void testUpdateMetadataWhenResponseIs2xx() throws Exception {
+ String serverId = "123";
+ ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
+ .put("Server Label", "Web Head 2")
+ .put("Server Description", "Simple Server")
+ .build();
+
+ HttpRequest setMetadata = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}","application/json"))
+ .build();
+
+ HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/metadata_updated.json")).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, setMetadata, setMetadataResponse);
+
+ assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").updateMetadata(serverId, metadata).toString(),
+ new ParseMetadataUpdateTest().expected().toString());
+ }
+
+ public void testUpdateMetadataWhenResponseIs404() throws Exception {
+ String serverId = "123";
+ ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
+ .put("Server Label", "Web Head 2")
+ .put("Server Description", "Simple Server")
+ .build();
+
+ HttpRequest setMetadata = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}","application/json"))
+ .build();
+
+ HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404)
+ .payload(payloadFromResource("/metadata_updated.json")).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, setMetadata, setMetadataResponse);
+
+ try {
+ apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata);
+ fail("Expected an exception.");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ public void testGetMetadataItemWhenResponseIs2xx() throws Exception {
+ String serverId = "123";
+ String key = "Server Label";
+
+ HttpRequest getMetadata = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata/" + "Server%20Label")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .build();
+
+ HttpResponse getMetadataResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/metadata_item.json")).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, getMetadata, getMetadataResponse);
+
+ assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").getMetadata(serverId, key).toString(),
+ "Web Head 1");
+ }
+
+ public void testGetMetadataItemWhenResponseIs404() throws Exception {
+ String serverId = "123";
+ ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
+ .put("Server Label", "Web Head 1")
+ .build();
+
+ HttpRequest setMetadata = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}","application/json"))
+ .build();
+
+ HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404)
+ .payload(payloadFromResource("/metadata_updated.json")).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, setMetadata, setMetadataResponse);
+
+ try {
+ apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata);
+ fail("Expected an exception.");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ public void testSetMetadataItemWhenResponseIs2xx() throws Exception {
+ String serverId = "123";
+ ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
+ .put("Server Label", "Web Head 2")
+ .put("Server Description", "Simple Server")
+ .build();
+
+ HttpRequest setMetadata = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}","application/json"))
+ .build();
+
+ HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/metadata_updated.json")).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, setMetadata, setMetadataResponse);
+
+ assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").updateMetadata(serverId, metadata).toString(),
+ new ParseMetadataUpdateTest().expected().toString());
+ }
+
+ public void testSetMetadataItemWhenResponseIs404() throws Exception {
+ String serverId = "123";
+ ImmutableMap<String, String> metadata = new ImmutableMap.Builder<String, String>()
+ .put("Server Label", "Web Head 2")
+ .put("Server Description", "Simple Server")
+ .build();
+
+ HttpRequest setMetadata = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}","application/json"))
+ .build();
+
+ HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404)
+ .payload(payloadFromResource("/metadata_updated.json")).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, setMetadata, setMetadataResponse);
+
+ try {
+ apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata);
+ fail("Expected an exception.");
+ } catch (Exception e) {
+ // expected
+ }
+ }
+
+ public void testDeleteMetadataItemWhenResponseIs2xx() throws Exception {
+ String serverId = "123";
+ String key = "Server%20Label";
+
+ HttpRequest updateMetadata = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata/" + key)
+ .addHeader("Accept", "*/*")
+ .addHeader("X-Auth-Token", authToken)
+ .build();
+
+ HttpResponse updateMetadataResponse = HttpResponse.builder().statusCode(204).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, updateMetadata, updateMetadataResponse);
+
+ apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").deleteMetadata(serverId, key);
+
+ }
+
+ public void testDeleteMetadataItemWhenResponseIs404() throws Exception {
+ String serverId = "123";
+ String key = "Server%20Label";
+
+ HttpRequest deleteMetadata = HttpRequest
+ .builder()
+ .method("DELETE")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata/" + key)
+ .addHeader("Accept", "*/*")
+ .addHeader("X-Auth-Token", authToken)
+ .build();
+
+ HttpResponse deleteMetadataResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, deleteMetadata, deleteMetadataResponse);
+
+ apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").deleteMetadata(serverId, key);
+
+ }
+
+ public void testGetDiagnosticsWhenResponseIs200() throws Exception {
+
+ String serverId = "123";
+ HttpRequest getDiagnostics = HttpRequest
+ .builder()
+ .method("GET")
+ .addHeader("Accept", "application/json")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/"+ serverId + "/diagnostics")
+ .addHeader("X-Auth-Token", authToken)
+ .build();
+
+
+ HttpResponse serverDiagnosticsResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted")
+ .payload(payloadFromResourceWithContentType("/server_diagnostics.json","application/json; charset=UTF-8")).build();
+
+ NovaApi apiWithNewServer = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, getDiagnostics, serverDiagnosticsResponse);
+ assertEquals(apiWithNewServer.getServerApiForZone("az-1.region-a.geo-1").getDiagnostics(serverId),
+ new ParseServerDiagnostics().expected());
+ }
+
+
+ public void testGetDiagnosticsWhenResponseIs403Or404Or500() throws Exception {
+
+ String serverId = "123";
+ HttpRequest getDiagnostics = HttpRequest
+ .builder()
+ .method("GET")
+ .addHeader("Accept", "application/json")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/"+ serverId + "/diagnostics")
+ .addHeader("X-Auth-Token", authToken)
+ .build();
+
+ for (int statusCode : ImmutableSet.of(403, 404, 500)) {
+ assertTrue(!requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, getDiagnostics,
+ HttpResponse.builder().statusCode(statusCode).build()).getServerApiForZone("az-1.region-a.geo-1").getDiagnostics(serverId).isPresent());
+ }
+ }
+
+
+
+}
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/features/ServerApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiLiveTest.java
new file mode 100644
index 0000000..3553d18
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiLiveTest.java
@@ -0,0 +1,206 @@
+/*
+ * 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.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+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.ServerCreated;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions;
+import org.jclouds.openstack.nova.v2_0.options.RebuildServerOptions;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.openstack.v2_0.predicates.LinkPredicates;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests behavior of {@link ServerApi}
+ *
+ * @author Adrian Cole
+ * @author Inbar Stolberg
+ */
+@Test(groups = "live", testName = "ServerApiLiveTest")
+public class ServerApiLiveTest extends BaseNovaApiLiveTest {
+
+ @Test(description = "GET /v${apiVersion}/{tenantId}/servers")
+ public void testListServers() throws Exception {
+ for (String zoneId : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ for (Resource server : serverApi.list().concat()) {
+ checkResource(server);
+ }
+ }
+ }
+
+ @Test(description = "GET /v${apiVersion}/{tenantId}/servers/detail")
+ public void testListServersInDetail() throws Exception {
+ for (String zoneId : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ for (Server server : serverApi.listInDetail().concat()) {
+ checkServer(server);
+ }
+ }
+ }
+
+ @Test(description = "GET /v${apiVersion}/{tenantId}/servers/{id}", dependsOnMethods = { "testListServersInDetail" })
+ public void testGetServerById() throws Exception {
+ for (String zoneId : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ for (Resource server : serverApi.list().concat()) {
+ Server details = serverApi.get(server.getId());
+ assertEquals(details.getId(), server.getId());
+ assertEquals(details.getName(), server.getName());
+ assertEquals(details.getLinks(), server.getLinks());
+ checkServer(details);
+ }
+ }
+ }
+
+ @Test
+ public void testCreateInAvailabilityZone() {
+ String serverId = null;
+ for (String zoneId : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ try {
+ serverId = createServer(zoneId, "nova", Server.Status.ACTIVE).getId();
+ Server server = serverApi.get(serverId);
+ assertEquals(server.getStatus(), Server.Status.ACTIVE);
+ } finally {
+ serverApi.delete(serverId);
+ }
+ }
+ }
+
+ /**
+ * This needs to be supported by the provider, and is usually not supported.
+ * However this can be tested on devstack:
+ * In apis/openstack-nova:
+ * mvn -Plive clean install "-Dtest.openstack-nova.endpoint=http://localhost:5000/v2.0" "-Dtest.openstack-nova.identity=demo:demo" "-Dtest.openstack-nova.credential=devstack" "-Dtest=org.jclouds.openstack.nova.v2_0.features.ServerApiLiveTest#testCreateWithNetworkOptions"
+ */
+ @Test(enabled = false)
+ public void testCreateWithNetworkOptions() {
+ String serverId = null;
+ for (String zoneId : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ try {
+ CreateServerOptions options = CreateServerOptions.Builder.novaNetworks(
+ // This network UUID must match an existing network.
+ ImmutableSet.of(Network.builder().networkUuid("bc4cfa2b-2b27-4671-8e8f-73009623def0").fixedIp("192.168.55.56").build())
+ );
+ ServerCreated server = serverApi.create(hostName, imageIdForZone(zoneId), "1", options);
+ serverId = server.getId();
+
+ blockUntilServerInState(server.getId(), serverApi, Server.Status.ACTIVE);
+ Server serverCheck = serverApi.get(serverId);
+ assertEquals(serverCheck.getStatus(), Server.Status.ACTIVE);
+ } finally {
+ if (serverId != null) {
+ serverApi.delete(serverId);
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testCreateInWrongAvailabilityZone() {
+ String serverId = null;
+ for (String zoneId : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ try {
+ serverId = createServer(zoneId, "err", Server.Status.ERROR).getId();
+ Server server = serverApi.get(serverId);
+ assertEquals(server.getStatus(), Server.Status.ERROR);
+ } finally {
+ serverApi.delete(serverId);
+ }
+ }
+ }
+
+ @Test
+ public void testRebuildServer() {
+
+ String serverId = null;
+
+ for (String zoneId : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ try {
+ serverId = createServer(zoneId, Server.Status.ACTIVE).getId();
+
+ Server server = serverApi.get(serverId);
+
+ assertEquals(server.getStatus(), Server.Status.ACTIVE);
+
+ RebuildServerOptions options = new RebuildServerOptions().
+ withImage(server.getImage().getId()).
+ name("newName").
+ adminPass("password").
+ ipv4Address("1.1.1.1").
+ ipv6Address("fe80::100");
+
+ serverApi.rebuild(serverId, options);
+
+ Server rebuiltServer = serverApi.get(serverId);
+
+ assertEquals("newName", rebuiltServer.getName());
+ assertEquals("1.1.1.1", rebuiltServer.getAccessIPv4());
+ assertEquals("fe80::100", rebuiltServer.getAccessIPv6());
+
+ } finally {
+ serverApi.delete(serverId);
+ }
+ }
+ }
+
+ private Server createServer(String regionId, Server.Status serverStatus) {
+ ServerApi serverApi = api.getServerApiForZone(regionId);
+ CreateServerOptions options = new CreateServerOptions();
+ ServerCreated server = serverApi.create(hostName, imageIdForZone(regionId), flavorRefForZone(regionId), options);
+
+ blockUntilServerInState(server.getId(), serverApi, serverStatus);
+
+ return serverApi.get(server.getId());
+ }
+
+ private Server createServer(String regionId, String availabilityZoneId, Server.Status serverStatus) {
+ ServerApi serverApi = api.getServerApiForZone(regionId);
+ CreateServerOptions options = new CreateServerOptions();
+ options = options.availabilityZone(availabilityZoneId);
+ ServerCreated server = serverApi.create(hostName, imageIdForZone(regionId), flavorRefForZone(regionId), options);
+ blockUntilServerInState(server.getId(), serverApi, serverStatus);
+ return serverApi.get(server.getId());
+ }
+
+ private void checkResource(Resource resource) {
+ assertNotNull(resource.getId());
+ assertNotNull(resource.getName());
+ assertNotNull(resource.getLinks());
+ assertTrue(Iterables.any(resource.getLinks(), LinkPredicates.relationEquals(Relation.SELF)));
+ }
+
+ private void checkServer(Server server) {
+ checkResource(server);
+ assertFalse(server.getAddresses().isEmpty());
+ }
+}
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/functions/CreateSecurityGroupIfNeededTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/CreateSecurityGroupIfNeededTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/CreateSecurityGroupIfNeededTest.java
new file mode 100644
index 0000000..ba4be4d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/CreateSecurityGroupIfNeededTest.java
@@ -0,0 +1,168 @@
+/*
+ * 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.functions;
+
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.compute.functions.CreateSecurityGroupIfNeeded;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseComputeServiceTypicalSecurityGroupTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "CreateSecurityGroupIfNeededTest")
+public class CreateSecurityGroupIfNeededTest extends BaseNovaApiExpectTest {
+ HttpRequest create = HttpRequest.builder().method("POST").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build())
+ .payload(
+ payloadFromStringWithContentType(
+ "{\"security_group\":{\"name\":\"jclouds_mygroup\",\"description\":\"jclouds_mygroup\"}}",
+ "application/json")).build();
+
+ public void testCreateNewGroup() throws Exception {
+
+ Builder<HttpRequest, HttpResponse> builder = ImmutableMap.builder();
+
+ builder.put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess);
+ builder.put(extensionsOfNovaRequest, extensionsOfNovaResponse);
+ int groupId = 2769;
+
+ HttpResponse createResponse = HttpResponse.builder().statusCode(200)
+ .payload(
+ payloadFromStringWithContentType(
+ String.format("{\"security_group\": {\"rules\": [], \"tenant_id\": \"37936628937291\", \"id\": %s, \"name\": \"jclouds_mygroup\", \"description\": \"jclouds_mygroup\"}}", groupId),
+ "application/json; charset=UTF-8")).build();
+
+ builder.put(create, createResponse);
+
+ int ruleId = 10331;
+
+ for (int port : ImmutableList.of(22,8080)) {
+
+ HttpRequest createCidrRule = HttpRequest.builder().method("POST").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build())
+ .payload(
+ payloadFromStringWithContentType(
+ String.format("{\"security_group_rule\":{\"parent_group_id\":\"%s\",\"cidr\":\"0.0.0.0/0\",\"ip_protocol\":\"tcp\",\"from_port\":\"%d\",\"to_port\":\"%d\"}}",
+ groupId, port, port), "application/json")).build();
+
+ HttpResponse createCidrRuleResponse = HttpResponse.builder().statusCode(200)
+ .payload(
+ payloadFromStringWithContentType(
+ String.format("{\"security_group_rule\": {\"from_port\": %d, \"group\": {}, \"ip_protocol\": \"tcp\", \"to_port\": %d, \"parent_group_id\": %d, \"ip_range\": {\"cidr\": \"0.0.0.0/0\"}, \"id\": %d}}",
+ port, port, groupId, ruleId++), "application/json; charset=UTF-8")).build();
+
+ builder.put(createCidrRule, createCidrRuleResponse);
+
+ HttpRequest createSelfRule = HttpRequest.builder().method("POST").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build())
+ .payload(
+ payloadFromStringWithContentType(
+ String.format("{\"security_group_rule\":{\"group_id\":\"%d\",\"parent_group_id\":\"%d\",\"ip_protocol\":\"tcp\",\"from_port\":\"%d\",\"to_port\":\"%d\"}}",
+ groupId, groupId, port, port), "application/json")).build();
+
+ // note server responds with group name in the rule!!
+ HttpResponse createSelfRuleResponse = HttpResponse.builder().statusCode(200)
+ .payload(
+ payloadFromStringWithContentType(
+ String.format("{\"security_group_rule\": {\"from_port\": %d, \"group\": {\"tenant_id\": \"37936628937291\", \"name\": \"jclouds_mygroup\"}, \"ip_protocol\": \"tcp\", \"to_port\": %d, \"parent_group_id\": %d, \"ip_range\": {}, \"id\": %d}}",
+ port, port, groupId, ruleId++), "application/json; charset=UTF-8")).build();
+
+ builder.put(createSelfRule, createSelfRuleResponse);
+ }
+
+ HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/" + groupId)).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_details_computeservice_typical.json")).build();
+
+ builder.put(getSecurityGroup, getSecurityGroupResponse);
+
+ NovaApi apiCanCreateSecurityGroup = requestsSendResponses(builder.build());
+
+ CreateSecurityGroupIfNeeded fn = new CreateSecurityGroupIfNeeded(apiCanCreateSecurityGroup);
+
+ // we can find it
+ assertEquals(fn.apply(
+ new ZoneSecurityGroupNameAndPorts("az-1.region-a.geo-1", "jclouds_mygroup", ImmutableSet.of(22, 8080)))
+ .toString(), new SecurityGroupInZone(new ParseComputeServiceTypicalSecurityGroupTest().expected(),
+ "az-1.region-a.geo-1").toString());
+
+ }
+
+ public void testReturnExistingGroupOnAlreadyExists() throws Exception {
+
+ Builder<HttpRequest, HttpResponse> builder = ImmutableMap.builder();
+
+ builder.put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess);
+ builder.put(extensionsOfNovaRequest, extensionsOfNovaResponse);
+
+ HttpResponse createResponse = HttpResponse.builder().statusCode(400)
+ .payload(
+ payloadFromStringWithContentType(
+ "{\"badRequest\": {\"message\": \"Security group test already exists\", \"code\": 400}}",
+ "application/json; charset=UTF-8")).build();
+
+ builder.put(create, createResponse);
+
+ HttpRequest list = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_list_details_computeservice_typical.json")).build();
+
+ builder.put(list, listResponse);
+
+ NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(builder.build());
+
+ CreateSecurityGroupIfNeeded fn = new CreateSecurityGroupIfNeeded(apiWhenSecurityGroupsExist);
+
+ // we can find it
+ assertEquals(fn.apply(
+ new ZoneSecurityGroupNameAndPorts("az-1.region-a.geo-1", "jclouds_mygroup", ImmutableSet.of(22, 8080)))
+ .toString(), new SecurityGroupInZone(new ParseComputeServiceTypicalSecurityGroupTest().expected(),
+ "az-1.region-a.geo-1").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/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java
new file mode 100644
index 0000000..c8e2639
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.functions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseSecurityGroupListTest;
+import org.jclouds.openstack.nova.v2_0.predicates.FindSecurityGroupWithNameAndReturnTrue;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.Iterables;
+import com.google.common.util.concurrent.Atomics;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "FindSecurityGroupWithNameAndReturnTrueExpectTest")
+public class FindSecurityGroupWithNameAndReturnTrueExpectTest extends BaseNovaApiExpectTest {
+
+ public void testUpdateReferenceWhenSecurityGroupListContainsGroupName() throws Exception {
+ HttpRequest list = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_list.json")).build();
+
+ NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list,
+ listResponse);
+
+ FindSecurityGroupWithNameAndReturnTrue predicate = new FindSecurityGroupWithNameAndReturnTrue(
+ apiWhenSecurityGroupsExist);
+
+ AtomicReference<ZoneAndName> securityGroupInZoneRef = Atomics.newReference(ZoneAndName
+ .fromZoneAndName("az-1.region-a.geo-1", "name1"));
+
+ // we can find it
+ assertTrue(predicate.apply(securityGroupInZoneRef));
+
+ // the reference is now up to date, and includes the actual group found.
+ assertEquals(securityGroupInZoneRef.get().toString(), new SecurityGroupInZone(Iterables
+ .getOnlyElement(new ParseSecurityGroupListTest().expected()), "az-1.region-a.geo-1").toString());
+
+ }
+
+ public void testDoesNotUpdateReferenceWhenSecurityGroupListMissingGroupName() throws Exception {
+ HttpRequest list = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_list.json")).build();
+
+ NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list,
+ listResponse);
+
+ FindSecurityGroupWithNameAndReturnTrue predicate = new FindSecurityGroupWithNameAndReturnTrue(
+ apiWhenSecurityGroupsExist);
+
+ ZoneAndName zoneAndGroup = ZoneAndName.fromZoneAndName("az-1.region-a.geo-1", "name2");
+
+ AtomicReference<ZoneAndName> securityGroupInZoneRef = Atomics.newReference(zoneAndGroup);
+
+ // we cannot find it
+ assertFalse(predicate.apply(securityGroupInZoneRef));
+
+ // the reference is the same
+ assertEquals(securityGroupInZoneRef.get(), zoneAndGroup);
+
+ }
+}
[13/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeAsyncApi.java
new file mode 100644
index 0000000..4312258
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeAsyncApi.java
@@ -0,0 +1,161 @@
+/*
+ * 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.extensions;
+
+import java.util.Map;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404;
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.domain.VolumeType;
+import org.jclouds.openstack.nova.v2_0.options.CreateVolumeTypeOptions;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.openstack.v2_0.services.Extension;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.Payload;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Unwrap;
+import org.jclouds.rest.annotations.WrapWith;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.FluentIterable;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to Volume Type features
+ *
+ * @author Adam Lowe
+ * @see VolumeTypeApi
+ */
+@Beta
+@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VOLUME_TYPES)
+@RequestFilters(AuthenticateRequest.class)
+@Path("/os-volume-types")
+@Consumes(MediaType.APPLICATION_JSON)
+public interface VolumeTypeAsyncApi {
+
+ /**
+ * @see VolumeTypeApi#list
+ */
+ @Named("volumetype:list")
+ @GET
+ @SelectJson("volume_types")
+ @Fallback(EmptyFluentIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends FluentIterable<? extends VolumeType>> list();
+
+
+ /**
+ * @see VolumeTypeApi#get
+ */
+ @Named("volumetype:get")
+ @GET
+ @Path("/{id}")
+ @SelectJson("volume_type")
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends VolumeType> get(@PathParam("id") String id);
+
+ /**
+ * @see VolumeTypeApi#create
+ */
+ @Named("volumetype:create")
+ @POST
+ @SelectJson("volume_type")
+ @Produces(MediaType.APPLICATION_JSON)
+ @WrapWith("volume_type")
+ ListenableFuture<? extends VolumeType> create(@PayloadParam("name") String name, CreateVolumeTypeOptions... options);
+
+ /**
+ * @see VolumeTypeApi#delete
+ */
+ @Named("volumetype:delete")
+ @DELETE
+ @Path("/{id}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> delete(@PathParam("id") String id);
+
+ /**
+ * @see VolumeTypeApi#getExtraSpecs(String)
+ */
+ @Named("volumetype:getextraspecs")
+ @GET
+ @SelectJson("extra_specs")
+ @Path("/{id}/extra_specs")
+ @Fallback(EmptyMapOnNotFoundOr404.class)
+ ListenableFuture<Map<String, String>> getExtraSpecs(@PathParam("id") String id);
+
+ /**
+ * @see VolumeTypeApi#updateExtraSpecs(String, java.util.Map)
+ */
+ @Named("volumetype:udpateextraspecs")
+ @POST
+ @Path("/{id}/extra_specs")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(FalseOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ ListenableFuture<Boolean> updateExtraSpecs(@PathParam("id") String id, @PayloadParam("extra_specs") Map<String, String> specs);
+
+ /**
+ * @see VolumeTypeApi#getExtraSpec(String, String)
+ */
+ @Named("volumetype:getextraspec")
+ @GET
+ @Path("/{id}/extra_specs/{key}")
+ @Unwrap
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<String> getExtraSpec(@PathParam("id") String id, @PathParam("key") String key);
+
+ /**
+ * @see VolumeTypeApi#updateExtraSpec(String, String, String)
+ */
+ @Named("volumetype:updateextraspec")
+ @PUT
+ @Path("/{id}/extra_specs/{key}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"{key}\":\"{value}\"%7D")
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> updateExtraSpec(@PathParam("id") String id,
+ @PathParam("key") @PayloadParam("key") String key,
+ @PayloadParam("value") String value);
+
+ /**
+ * @see VolumeTypeApi#deleteExtraSpec(String, String)
+ */
+ @Named("volumetype:deleteextraspec")
+ @DELETE
+ @Path("/{id}/extra_specs/{key}")
+ @Fallback(FalseOnNotFoundOr404.class)
+ ListenableFuture<Boolean> deleteExtraSpec(@PathParam("id") String id,
+ @PathParam("key") String key);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java
new file mode 100644
index 0000000..7924120
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java
@@ -0,0 +1,78 @@
+/*
+ * 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.features;
+
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * Provides asynchronous access to Flavors via their REST API.
+ * <p/>
+ *
+ * @see FlavorAsyncApi
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-compute/2/content/List_Flavors-d1e4188.html"
+ * />
+ * @author Jeremy Daggett, Ilja Bobkevic
+ */
+public interface FlavorApi {
+
+ /**
+ * List all flavors (IDs, names, links)
+ *
+ * @return all flavors (IDs, names, links)
+ */
+ PagedIterable<? extends Resource> list();
+
+ PaginatedCollection<? extends Resource> list(PaginationOptions options);
+
+ /**
+ * List all flavors (all details)
+ *
+ * @return all flavors (all details)
+ */
+ PagedIterable<? extends Flavor> listInDetail();
+
+ PaginatedCollection<? extends Flavor> listInDetail(PaginationOptions options);
+
+ /**
+ * List details of the specified flavor
+ *
+ * @param id
+ * id of the flavor
+ * @return flavor or null if not found
+ */
+ Flavor get(String id);
+
+ /**
+ * Create flavor according to the provided object
+ *
+ * @param flavor - flavor object
+ * @return newly created flavor
+ */
+ Flavor create(Flavor flavor);
+
+ /**
+ * Delete flavor with a given id
+ *
+ * @param id - flavor id
+ */
+ void delete(String id);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorAsyncApi.java
new file mode 100644
index 0000000..7c1552e
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorAsyncApi.java
@@ -0,0 +1,144 @@
+/*
+ * 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.features;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavorDetails;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavors;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.annotations.Unwrap;
+import org.jclouds.rest.annotations.WrapWith;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to Flavors via their REST API.
+ * <p/>
+ *
+ * @see FlavorApi
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-compute/2/content/List_Flavors-d1e4188.html"
+ * >docs</a>
+ * @author Jeremy Daggett TODO: Need a ListFlavorOptions class minDisk=minDiskInGB&
+ * minRam=minRamInMB& marker=markerID&limit=int
+ * @author Ilja Bobkevic
+ */
+@RequestFilters(AuthenticateRequest.class)
+public interface FlavorAsyncApi {
+
+ /**
+ * @see FlavorApi#list()
+ */
+ @Named("flavor:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/flavors")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseFlavors.class)
+ @Transform(ParseFlavors.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends PagedIterable<? extends Resource>> list();
+
+ /** @see FlavorApi#list(PaginationOptions) */
+ @Named("flavor:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/flavors")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseFlavors.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ ListenableFuture<? extends PaginatedCollection<? extends Resource>> list(PaginationOptions options);
+
+ /**
+ * @see FlavorApi#listInDetail()
+ */
+ @Named("flavor:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/flavors/detail")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseFlavorDetails.class)
+ @Transform(ParseFlavorDetails.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends PagedIterable<? extends Flavor>> listInDetail();
+
+ /** @see FlavorApi#listInDetail(PaginationOptions) */
+ @Named("flavor:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/flavors/detail")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseFlavorDetails.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ ListenableFuture<? extends PaginatedCollection<? extends Flavor>> listInDetail(PaginationOptions options);
+
+ /**
+ * @see FlavorApi#get
+ */
+ @Named("flavor:get")
+ @GET
+ @SelectJson("flavor")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/flavors/{id}")
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends Flavor> get(@PathParam("id") String id);
+
+
+ /**
+ * @see FlavorApi#create
+ */
+ @Named("flavor:create")
+ @POST
+ @Unwrap
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/flavors")
+ ListenableFuture<? extends Flavor> create(@WrapWith("flavor") Flavor flavor);
+
+ /**
+ * @see FlavorApi#delete
+ */
+ @Named("flavor:delete")
+ @DELETE
+ @Consumes
+ @Path("/flavors/{id}")
+ @Fallback(VoidOnNotFoundOr404.class)
+ ListenableFuture<Void> delete(@PathParam("id") String id);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java
new file mode 100644
index 0000000..cc7f468
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java
@@ -0,0 +1,142 @@
+/*
+ * 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.features;
+
+import java.util.Map;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * Provides synchronous access to Images.
+ * <p/>
+ *
+ * @see ImageAsyncApi
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-compute/1.1/content/Servers-d1e2073.html"
+ * />
+ * @author Adrian Cole
+ */
+public interface ImageApi {
+
+ /**
+ * List all images (IDs, names, links)
+ *
+ * @return all images (IDs, names, links)
+ */
+ PagedIterable<? extends Resource> list();
+
+ PaginatedCollection<? extends Resource> list(PaginationOptions options);
+
+ /**
+ * List all images (all details)
+ *
+ * @return all images (all details)
+ */
+ PagedIterable<? extends Image> listInDetail();
+
+ PaginatedCollection<? extends Image> listInDetail(PaginationOptions options);
+
+ /**
+ * List details of the specified image
+ *
+ * @param id
+ * id of the server
+ * @return server or null if not found
+ */
+ Image get(String id);
+
+ /**
+ * Delete the specified image
+ *
+ * @param id
+ * id of the image
+ * @return server or null if not found
+ */
+ void delete(String id);
+
+ /**
+ * List all metadata for an image.
+ *
+ * @param id
+ * id of the image
+ * @return the metadata as a Map<String, String>
+ */
+ Map<String, String> getMetadata(String id);
+
+ /**
+ * Sets the metadata for an image.
+ *
+ * @param id
+ * id of the image
+ * @param metadata
+ * a Map containing the metadata
+ * @return the metadata as a Map<String, String>
+ */
+ Map<String, String> setMetadata(String id, Map<String, String> metadata);
+
+ /**
+ * Update the metadata for a server.
+ *
+ * @param id
+ * id of the image
+ * @param metadata
+ * a Map containing the metadata
+ * @return the metadata as a Map<String, String>
+ */
+ Map<String, String> updateMetadata(String id, Map<String, String> metadata);
+
+ /**
+ * Update the metadata for an image.
+ *
+ * @param id
+ * id of the image
+ * @param metadata
+ * a Map containing the metadata
+ * @return the value or null if not present
+ */
+ @Nullable
+ String getMetadata(String id, String key);
+
+
+ /**
+ * Set a metadata item for an image.
+ *
+ * @param id
+ * id of the image
+ * @param key
+ * the name of the metadata item
+ * @param value
+ * the value of the metadata item
+ * @return the value you updated
+ */
+ String updateMetadata(String id, String key, String value);
+
+ /**
+ * Delete a metadata item from an image.
+ *
+ * @param id
+ * id of the image
+ * @param key
+ * the name of the metadata item
+ */
+ void deleteMetadata(String id, String key);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageAsyncApi.java
new file mode 100644
index 0000000..f45826c
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageAsyncApi.java
@@ -0,0 +1,206 @@
+/*
+ * 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.features;
+
+import java.util.Map;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.binders.BindMetadataToJsonPayload;
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+import org.jclouds.openstack.nova.v2_0.functions.internal.OnlyMetadataValueOrNull;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseImageDetails;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseImages;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to Images via the REST API.
+ * <p/>
+ *
+ * @see ImageApi
+ * @author Jeremy Daggett
+ */
+@RequestFilters(AuthenticateRequest.class)
+public interface ImageAsyncApi {
+
+ /**
+ * @see ImageApi#list()
+ */
+ @Named("image:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/images")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseImages.class)
+ @Transform(ParseImages.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends PagedIterable<? extends Resource>> list();
+
+ /** @see ImageApi#list(PaginationOptions) */
+ @Named("image:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/images")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseImages.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ ListenableFuture<? extends PaginatedCollection<? extends Resource>> list(PaginationOptions options);
+
+ /**
+ * @see ImageApi#listInDetail()
+ */
+ @Named("image:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/images/detail")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseImageDetails.class)
+ @Transform(ParseImageDetails.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends PagedIterable<? extends Image>> listInDetail();
+
+ /** @see ImageApi#listInDetail(PaginationOptions) */
+ @Named("image:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/images/detail")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseImageDetails.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ ListenableFuture<? extends PaginatedCollection<? extends Image>> listInDetail(PaginationOptions options);
+
+ /**
+ * @see ImageApi#get
+ */
+ @Named("image:get")
+ @GET
+ @SelectJson("image")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/images/{id}")
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends Image> get(@PathParam("id") String id);
+
+ /**
+ * @see ImageApi#delete
+ */
+ @Named("image:delete")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/images/{id}")
+ @Fallback(VoidOnNotFoundOr404.class)
+ ListenableFuture<Void> delete(@PathParam("id") String id);
+
+ /**
+ * @see ImageApi#getMetadata
+ */
+ @Named("image:getmetadata")
+ @GET
+ @SelectJson("metadata")
+ @Path("/images/{id}/metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyMapOnNotFoundOr404.class)
+ ListenableFuture<Map<String, String>> getMetadata(@PathParam("id") String id);
+
+ /**
+ * @see ImageApi#setMetadata
+ */
+ @Named("image:setmetadata")
+ @PUT
+ @SelectJson("metadata")
+ @Path("/images/{id}/metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyMapOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ ListenableFuture<Map<String, String>> setMetadata(@PathParam("id") String id, @PayloadParam("metadata") Map<String, String> metadata);
+
+ /**
+ * @see ImageApi#updateMetadata
+ */
+ @Named("image:updatemetadata")
+ @POST
+ @SelectJson("metadata")
+ @Path("/images/{id}/metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyMapOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ ListenableFuture<? extends Map<String, String>> updateMetadata(@PathParam("id") String id, @PayloadParam("metadata") Map<String, String> metadata);
+
+ /**
+ * @see ImageApi#getMetadata
+ */
+ @Named("image:getmetadata")
+ @GET
+ @Path("/images/{id}/metadata/{key}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(OnlyMetadataValueOrNull.class)
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<String> getMetadata(@PathParam("id") String id, @PathParam("key") String key);
+
+ /**
+ * @see ImageApi#updateMetadata
+ */
+ @Named("image:updatemetadata")
+ @PUT
+ @Path("/images/{id}/metadata/{key}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ResponseParser(OnlyMetadataValueOrNull.class)
+ @MapBinder(BindMetadataToJsonPayload.class)
+ ListenableFuture<String> updateMetadata(@PathParam("id") String id,
+ @PathParam("key") @PayloadParam("key") String key, @PathParam("value") @PayloadParam("value") String value);
+
+
+ /**
+ * @see ImageApi#deleteMetadata
+ */
+ @Named("image:deletemetadata")
+ @DELETE
+ @Consumes
+ @Path("/images/{id}/metadata/{key}")
+ @Fallback(VoidOnNotFoundOr404.class)
+ ListenableFuture<Void> deleteMetadata(@PathParam("id") String id, @PathParam("key") String key);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java
new file mode 100644
index 0000000..9354d9a
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java
@@ -0,0 +1,276 @@
+/*
+ * 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.features;
+
+import com.google.common.base.Optional;
+import java.util.Map;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.domain.RebootType;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
+import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions;
+import org.jclouds.openstack.nova.v2_0.options.RebuildServerOptions;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * Provides synchronous access to Server.
+ * <p/>
+ *
+ * @see ServerAsyncApi
+ * @see <a href=
+ * "http://docs.openstack.org/api/openstack-compute/1.1/content/Servers-d1e2073.html"
+ * />
+ * @author Adrian Cole
+ */
+public interface ServerApi {
+
+ /**
+ * List all servers (IDs, names, links)
+ *
+ * @return all servers (IDs, names, links)
+ */
+ PagedIterable<? extends Resource> list();
+
+ PaginatedCollection<? extends Resource> list(PaginationOptions options);
+
+ /**
+ * List all servers (all details)
+ *
+ * @return all servers (all details)
+ */
+ PagedIterable<? extends Server> listInDetail();
+
+ PaginatedCollection<? extends Server> listInDetail(PaginationOptions options);
+
+ /**
+ * List details of the specified server
+ *
+ * @param id
+ * id of the server
+ * @return server or null if not found
+ */
+ Server get(String id);
+
+ /**
+ * Create a new server
+ *
+ * @param name
+ * name of the server to create
+ * @param imageRef
+ * reference to the image for the server to use
+ * @param flavorRef
+ * reference to the flavor to use when creating the server
+ * @param options
+ * optional parameters to be passed into the server creation
+ * request
+ * @return the newly created server
+ */
+ ServerCreated create(String name, String imageRef, String flavorRef, CreateServerOptions... options);
+
+ /**
+ * Terminate and delete a server.
+ *
+ * @param id
+ * id of the server
+ * @return True if successful, False otherwise
+ */
+ boolean delete(String id);
+
+ /**
+ * Start a server
+ *
+ * @param id
+ * id of the server
+ */
+ void start(String id);
+
+ /**
+ * Stop a server
+ *
+ * @param id
+ * id of the server
+ */
+ void stop(String id);
+
+ /**
+ * Reboot a server.
+ *
+ * @param id
+ * id of the server
+ * @param rebootType
+ * The type of reboot to perform (Hard/Soft)
+ */
+ void reboot(String id, RebootType rebootType);
+
+ /**
+ * Resize a server to a new flavor size.
+ *
+ * @param id
+ * id of the server
+ * @param flavorId
+ * id of the new flavor to use
+ */
+ void resize(String id, String flavorId);
+
+ /**
+ * Confirm a resize operation.
+ *
+ * @param id
+ * id of the server
+ */
+ void confirmResize(String id);
+
+ /**
+ * Revert a resize operation.
+ *
+ * @param id
+ * id of the server
+ */
+ void revertResize(String id);
+
+ /**
+ * Rebuild a server.
+ *
+ * @param id
+ * id of the server
+ * @param options
+ * Optional parameters to the rebuilding operation.
+ */
+ void rebuild(String id, RebuildServerOptions... options);
+
+ /**
+ * Change the administrative password to a server.
+ *
+ * @param id
+ * id of the server
+ * @param adminPass
+ * The new administrative password to use
+ */
+ void changeAdminPass(String id, String adminPass);
+
+ /**
+ * Rename a server.
+ *
+ * @param id
+ * id of the server
+ * @param newName
+ * The new name for the server
+ */
+ void rename(String id, String newName);
+
+ /**
+ * Create an image from a server.
+ *
+ * @param name
+ * The name of the new image
+ * @param id
+ * id of the server
+ *
+ * @return ID of the new / updated image
+ */
+ String createImageFromServer(String name, String id);
+
+ /**
+ * List all metadata for a server.
+ *
+ * @param id
+ * id of the server
+ *
+ * @return the metadata as a Map<String, String>
+ */
+ Map<String, String> getMetadata(String id);
+
+ /**
+ * Set the metadata for a server.
+ *
+ * @param id
+ * id of the server
+ * @param metadata
+ * a Map containing the metadata
+ * @return the metadata as a Map<String, String>
+ */
+ Map<String, String> setMetadata(String id, Map<String, String> metadata);
+
+ /**
+ * Update the metadata for a server.
+ *
+ * @param id
+ * id of the server
+ * @param metadata
+ * a Map containing the metadata
+ * @return the metadata as a Map<String, String>
+ */
+ Map<String, String> updateMetadata(String id, Map<String, String> metadata);
+
+ /**
+ * Update the metadata for a server.
+ *
+ * @param id
+ * id of the image
+ * @param metadata
+ * a Map containing the metadata
+ * @return the value or null if not present
+ */
+ @Nullable
+ String getMetadata(String id, String key);
+
+ /**
+ * Set a metadata item for a server.
+ *
+ * @param id
+ * id of the image
+ * @param key
+ * the name of the metadata item
+ * @param value
+ * the value of the metadata item
+ * @return the value you updated
+ */
+ String updateMetadata(String id, String key, String value);
+
+ /**
+ * Delete a metadata item from a server.
+ *
+ * @param id
+ * id of the image
+ * @param key
+ * the name of the metadata item
+ */
+ void deleteMetadata(String id, String key);
+
+
+ /**
+ * Get usage information about the server such as CPU usage, Memory and IO.
+ * The information returned by this method is dependent on the hypervisor
+ * in use by the OpenStack installation and whether that hypervisor supports
+ * this method. More information can be found in the
+ * <a href="http://api.openstack.org/api-ref.html"> OpenStack API
+ * reference</a>. <br/>
+ * At the moment the returned response is a generic map. In future versions
+ * of OpenStack this might be subject to change.
+ *
+ * @param id
+ * id of the server
+ * @return A Map containing the collected values organized by key - value.
+ * @Beta
+ */
+ Optional<Map<String, String>> getDiagnostics(String id);
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncApi.java
new file mode 100644
index 0000000..2d63d65
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncApi.java
@@ -0,0 +1,356 @@
+/*
+ * 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.features;
+
+import java.util.Map;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.AbsentOn403Or404Or500;
+import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
+import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
+import org.jclouds.openstack.nova.v2_0.binders.BindMetadataToJsonPayload;
+import org.jclouds.openstack.nova.v2_0.domain.RebootType;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
+import org.jclouds.openstack.nova.v2_0.functions.ParseImageIdFromLocationHeader;
+import org.jclouds.openstack.nova.v2_0.functions.internal.OnlyMetadataValueOrNull;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseDiagnostics;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServerDetails;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServers;
+import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions;
+import org.jclouds.openstack.nova.v2_0.options.RebuildServerOptions;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.Payload;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SelectJson;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.annotations.Unwrap;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * Provides asynchronous access to Server via their REST API.
+ * <p/>
+ *
+ * @see ServerApi
+ * @see <a href= "http://docs.openstack.org/api/openstack-compute/1.1/content/Servers-d1e2073.html"
+ * />
+ * @author Adrian Cole
+ */
+@RequestFilters(AuthenticateRequest.class)
+public interface ServerAsyncApi {
+
+ /**
+ * @see ServerApi#list()
+ */
+ @Named("server:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/servers")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseServers.class)
+ @Transform(ParseServers.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends PagedIterable<? extends Resource>> list();
+
+ /** @see ServerApi#list(PaginationOptions) */
+ @Named("server:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/servers")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseServers.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ ListenableFuture<? extends PaginatedCollection<? extends Resource>> list(PaginationOptions options);
+
+ /**
+ * @see ServerApi#listInDetail()
+ */
+ @Named("server:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/servers/detail")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseServerDetails.class)
+ @Transform(ParseServerDetails.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ ListenableFuture<? extends PagedIterable<? extends Server>> listInDetail();
+
+ /** @see ServerApi#listInDetail(PaginationOptions) */
+ @Named("server:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/servers/detail")
+ @RequestFilters(AuthenticateRequest.class)
+ @ResponseParser(ParseServerDetails.class)
+ @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class)
+ ListenableFuture<? extends PaginatedCollection<? extends Server>> listInDetail(PaginationOptions options);
+
+ /**
+ * @see ServerApi#get
+ */
+ @Named("server:get")
+ @GET
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/servers/{id}")
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<? extends Server> get(@PathParam("id") String id);
+
+ /**
+ * @see ServerApi#delete
+ */
+ @Named("server:delete")
+ @DELETE
+ @Consumes
+ @Fallback(FalseOnNotFoundOr404.class)
+ @Path("/servers/{id}")
+ ListenableFuture<Boolean> delete(@PathParam("id") String id);
+
+ /**
+ * @see ServerApi#start
+ */
+ @Named("server:start")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"os-start\":null}")
+ ListenableFuture<Void> start(@PathParam("id") String id);
+
+ /**
+ * @see ServerApi#stop
+ */
+ @Named("server:stop")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"os-stop\":null}")
+ ListenableFuture<Void> stop(@PathParam("id") String id);
+
+ /**
+ * @see ServerApi#reboot
+ */
+ @Named("server:reboot")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"reboot\":%7B\"type\":\"{type}\"%7D%7D")
+ ListenableFuture<Void> reboot(@PathParam("id") String id, @PayloadParam("type") RebootType rebootType);
+
+ /**
+ * @see ServerApi#resize
+ */
+ @Named("server:resize")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"resize\":%7B\"flavorRef\":{flavorId}%7D%7D")
+ ListenableFuture<Void> resize(@PathParam("id") String id, @PayloadParam("flavorId") String flavorId);
+
+ /**
+ * @see ServerApi#confirmResize
+ */
+ @Named("server:resize")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"confirmResize\":null}")
+ ListenableFuture<Void> confirmResize(@PathParam("id") String id);
+
+ /**
+ * @see ServerApi#revertResize
+ */
+ @Named("server:resize")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("{\"revertResize\":null}")
+ ListenableFuture<Void> revertResize(@PathParam("id") String id);
+
+ /**
+ * @see ServerApi#create
+ */
+ @Named("server:create")
+ @POST
+ @Unwrap
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/servers")
+ @MapBinder(CreateServerOptions.class)
+ ListenableFuture<ServerCreated> create(@PayloadParam("name") String name, @PayloadParam("imageRef") String imageRef,
+ @PayloadParam("flavorRef") String flavorRef, CreateServerOptions... options);
+
+ /**
+ * @see ServerApi#rebuild
+ */
+ @Named("server:rebuild")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @MapBinder(RebuildServerOptions.class)
+ ListenableFuture<Void> rebuild(@PathParam("id") String id, RebuildServerOptions... options);
+
+ /**
+ * @see ServerApi#changeAdminPass
+ */
+ @Named("server:changeadminpass")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"changePassword\":%7B\"adminPass\":\"{adminPass}\"%7D%7D")
+ ListenableFuture<Void> changeAdminPass(@PathParam("id") String id, @PayloadParam("adminPass") String adminPass);
+
+ /**
+ * @see ServerApi#rename
+ */
+ @Named("server:rename")
+ @PUT
+ @Path("/servers/{id}")
+ @Consumes
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"server\":%7B\"name\":\"{name}\"%7D%7D")
+ ListenableFuture<Void> rename(@PathParam("id") String id, @PayloadParam("name") String newName);
+
+ /**
+ * @see ServerApi#createImageFromServer
+ */
+ @Named("server:create")
+ @POST
+ @Path("/servers/{id}/action")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Payload("%7B\"createImage\":%7B\"name\":\"{name}\", \"metadata\": %7B%7D%7D%7D")
+ @Fallback(MapHttp4xxCodesToExceptions.class)
+ @ResponseParser(ParseImageIdFromLocationHeader.class)
+ ListenableFuture<String> createImageFromServer(@PayloadParam("name") String name, @PathParam("id") String id);
+
+ /**
+ * @see ServerApi#getMetadata
+ */
+ @Named("server:getmetadata")
+ @GET
+ @SelectJson("metadata")
+ @Path("/servers/{id}/metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyMapOnNotFoundOr404.class)
+ ListenableFuture<? extends Map<String, String>> getMetadata(@PathParam("id") String id);
+
+ /**
+ * @see ServerApi#setMetadata
+ */
+ @Named("server:setmetadata")
+ @PUT
+ @SelectJson("metadata")
+ @Path("/servers/{id}/metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyMapOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ ListenableFuture<? extends Map<String, String>> setMetadata(@PathParam("id") String id,
+ @PayloadParam("metadata") Map<String, String> metadata);
+
+ /**
+ * @see ServerApi#updateMetadata
+ */
+ @Named("server:updatemetadata")
+ @POST
+ @SelectJson("metadata")
+ @Path("/servers/{id}/metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Fallback(EmptyMapOnNotFoundOr404.class)
+ @MapBinder(BindToJsonPayload.class)
+ ListenableFuture<? extends Map<String, String>> updateMetadata(@PathParam("id") String id,
+ @PayloadParam("metadata") Map<String, String> metadata);
+
+ /**
+ * @see ServerApi#getMetadata
+ */
+ @Named("server:getmetadata")
+ @GET
+ @Path("/servers/{id}/metadata/{key}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ResponseParser(OnlyMetadataValueOrNull.class)
+ @Fallback(NullOnNotFoundOr404.class)
+ ListenableFuture<String> getMetadata(@PathParam("id") String id, @PathParam("key") String key);
+
+ /**
+ * @see ServerApi#updateMetadata
+ */
+ @Named("server:updatemetadata")
+ @PUT
+ @Path("/servers/{id}/metadata/{key}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ResponseParser(OnlyMetadataValueOrNull.class)
+ @MapBinder(BindMetadataToJsonPayload.class)
+ ListenableFuture<String> updateMetadata(@PathParam("id") String id,
+ @PathParam("key") @PayloadParam("key") String key, @PathParam("value") @PayloadParam("value") String value);
+
+ /**
+ * @see ServerApi#deleteMetadata
+ */
+ @Named("server:deletemetadata")
+ @DELETE
+ @Consumes
+ @Path("/servers/{id}/metadata/{key}")
+ @Fallback(VoidOnNotFoundOr404.class)
+ ListenableFuture<Void> deleteMetadata(@PathParam("id") String id, @PathParam("key") String key);
+
+
+ /**
+ * @see ServerApi#getDiagnostics
+ */
+ @Named("server:getdiagnostics")
+ @GET
+ @Path("/servers/{id}/diagnostics")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Fallback(AbsentOn403Or404Or500.class)
+ @ResponseParser(ParseDiagnostics.class)
+ ListenableFuture<Optional<Map<String, String>>> getDiagnostics(@PathParam("id") String id);
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/FieldValueResponseParsers.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/FieldValueResponseParsers.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/FieldValueResponseParsers.java
new file mode 100644
index 0000000..f137c59
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/FieldValueResponseParsers.java
@@ -0,0 +1,105 @@
+/*
+ * 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.functions;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.functions.ParseFirstJsonValueNamed;
+import org.jclouds.json.internal.GsonWrapper;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+
+/**
+ * Parsers for extracting a single field value from a response and comparing it to an expected value
+ */
+public class FieldValueResponseParsers {
+ @Singleton
+ public static class StatusEnabledResponseParser extends FieldValueResponseParser<String> {
+ @Inject
+ public StatusEnabledResponseParser(GsonWrapper wrapper) {
+ super(wrapper, "status", "enabled");
+ }
+ }
+
+ @Singleton
+ public static class StatusDisabledResponseParser extends FieldValueResponseParser<String> {
+ @Inject
+ public StatusDisabledResponseParser(GsonWrapper wrapper) {
+ super(wrapper, "status", "disabled");
+ }
+ }
+
+ @Singleton
+ public static class MaintenanceModeEnabledResponseParser extends FieldValueResponseParser<String> {
+ @Inject
+ public MaintenanceModeEnabledResponseParser(GsonWrapper wrapper) {
+ super(wrapper, "maintenance_mode", "on_maintenance");
+ }
+ }
+
+ @Singleton
+ public static class MaintenanceModeDisabledResponseParser extends FieldValueResponseParser<String> {
+ @Inject
+ public MaintenanceModeDisabledResponseParser(GsonWrapper wrapper) {
+ super(wrapper, "maintenance_mode", "off_maintenance");
+ }
+ }
+
+ @Singleton
+ public static class PowerIsStartupResponseParser extends FieldValueResponseParser<String> {
+ @Inject
+ public PowerIsStartupResponseParser(GsonWrapper wrapper) {
+ super(wrapper, "power_action", "startup");
+ }
+ }
+
+ @Singleton
+ public static class PowerIsShutdownResponseParser extends FieldValueResponseParser<String> {
+ @Inject
+ public PowerIsShutdownResponseParser(GsonWrapper wrapper) {
+ super(wrapper, "power_action", "shutdown");
+ }
+ }
+
+ @Singleton
+ public static class PowerIsRebootResponseParser extends FieldValueResponseParser<String> {
+ @Inject
+ public PowerIsRebootResponseParser(GsonWrapper wrapper) {
+ super(wrapper, "power_action", "reboot");
+ }
+ }
+
+ public abstract static class FieldValueResponseParser<T> implements Function<HttpResponse, Boolean> {
+ private final T expectedValue;
+ private final ParseFirstJsonValueNamed<T> valueParser;
+
+ public FieldValueResponseParser(GsonWrapper wrapper, String fieldName, T expectedValue) {
+ valueParser = new ParseFirstJsonValueNamed<T>(wrapper, new TypeLiteral<T>() {
+ }, fieldName);
+ this.expectedValue = expectedValue;
+ }
+
+ @Override
+ public Boolean apply(HttpResponse response) {
+ return Objects.equal(expectedValue, valueParser.apply(response));
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.java
new file mode 100644
index 0000000..9627ece
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.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.functions;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+
+import org.jclouds.json.Json;
+import org.jclouds.logging.Logger;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ *
+ * The expected body contains the time as in this (real) response
+ *
+ * <pre>
+ * {
+ * "overLimit" : {
+ * "code" : 413,
+ * "message" : "OverLimit Retry...",
+ * "details" : "Error Details...",
+ * "retryAt" : "2012-11-14T21:51:28UTC"
+ * }
+ * }
+ * </pre>
+ *
+ * or
+ *
+ * <pre>
+ * {
+ * "overLimit": {
+ * "message": "This request was rate-limited.",
+ * "code": 413,
+ * "retryAfter": "54",
+ * "details": "Only 1 POST request(s) can be made to \"*\" every minute."
+ * }
+ * }
+ * </pre>
+ *
+ * @author Adrian Cole, Steve Loughran
+ *
+ */
+public class OverLimitParser implements Function<String, Map<String, String>> {
+
+ @Resource
+ private Logger logger = Logger.NULL;
+ private final Json json;
+
+ @Inject
+ public OverLimitParser(Json json) {
+ this.json = checkNotNull(json, "json");
+ }
+
+ private static class Holder {
+ Map<String, String> overLimit = ImmutableMap.of();
+ }
+
+ /**
+ * parses or returns an empty map.
+ */
+ @Override
+ public Map<String, String> apply(String in) {
+ try {
+ return json.fromJson(in, OverLimitParser.Holder.class).overLimit;
+ } catch (RuntimeException e) {
+ // an error was raised during parsing -which can include badly
+ // formatted fields.
+ logger.error("Failed to parse " + in + "", e);
+ return ImmutableMap.of();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java
new file mode 100644
index 0000000..1ca6f68
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java
@@ -0,0 +1,39 @@
+/*
+ * 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.functions;
+
+import javax.inject.Singleton;
+import javax.ws.rs.core.HttpHeaders;
+
+import org.jclouds.http.HttpResponse;
+
+import com.google.common.base.Function;
+
+/**
+ * This parses {@link Image} from the body of the link in the Location header of the HTTPResponse.
+ *
+ * @author Tim Miller
+ */
+@Singleton
+public class ParseImageIdFromLocationHeader implements Function<HttpResponse, String> {
+
+ public String apply(HttpResponse response) {
+ String location = response.getFirstHeaderOrNull(HttpHeaders.LOCATION);
+ String[] parts = location.split("/");
+ return parts[parts.length - 1];
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java
new file mode 100644
index 0000000..8183f84
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java
@@ -0,0 +1,63 @@
+/*
+ * 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.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.internal.GsonWrapper;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class OnlyMetadataValueOrNull implements Function<HttpResponse, String> {
+ private final ParseJson<Wrapper> parser;
+
+ private static class Wrapper implements Supplier<String> {
+ private Map<String, String> metadata;
+
+ @Override
+ public String get() {
+ return metadata == null ? null : Iterables.get(metadata.values(), 0, null);
+ }
+
+ }
+
+ @Inject
+ public OnlyMetadataValueOrNull(GsonWrapper gsonView) {
+ this.parser = new ParseJson<Wrapper>(checkNotNull(gsonView, "gsonView"), new TypeLiteral<Wrapper>() {
+ });
+ }
+
+ public String apply(HttpResponse response) {
+ checkNotNull(response, "response");
+ return parser.apply(response).get();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java
new file mode 100644
index 0000000..366aa4c
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java
@@ -0,0 +1,47 @@
+/*
+ * 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.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.functions.ParseJson;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.inject.Inject;
+import java.util.Map;
+
+/**
+ * @author Leander Beernaert
+ */
+public class ParseDiagnostics implements Function<HttpResponse, Optional <Map<String,String>>> {
+
+
+ private final ParseJson<Optional <Map<String,String>>> parser;
+
+ @Inject
+ public ParseDiagnostics(ParseJson<Optional <Map<String,String>>> parser) {
+ this.parser = parser;
+ }
+
+ @Override
+ public Optional <Map<String,String>> apply(HttpResponse response) {
+ checkNotNull(response, "response");
+ return parser.apply(response);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java
new file mode 100644
index 0000000..7e15016
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java
@@ -0,0 +1,94 @@
+/*
+ * 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.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavorDetails.Flavors;
+import org.jclouds.openstack.v2_0.domain.Link;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * boiler plate until we determine a better way
+ *
+ * @author Adrian Cole
+ */
+@Beta
+@Singleton
+public class ParseFlavorDetails extends ParseJson<Flavors> {
+ static class Flavors extends PaginatedCollection<Flavor> {
+
+ @ConstructorProperties({ "flavors", "flavors_links" })
+ protected Flavors(Iterable<Flavor> flavors, Iterable<Link> flavors_links) {
+ super(flavors, flavors_links);
+ }
+
+ }
+
+ @Inject
+ public ParseFlavorDetails(Json json) {
+ super(json, TypeLiteral.get(Flavors.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Flavor, ToPagedIterable> {
+
+ private final NovaApi api;
+
+ @Inject
+ protected ToPagedIterable(NovaApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Flavor>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.get().toString();
+ final FlavorApi flavorApi = api.getFlavorApiForZone(zone);
+ return new Function<Object, IterableWithMarker<Flavor>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Flavor> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(flavorApi.listInDetail(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listFlavorsInDetail()";
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java
new file mode 100644
index 0000000..5d183f4
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.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.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavors.Flavors;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * boiler plate until we determine a better way
+ *
+ * @author Adrian Cole
+ */
+@Beta
+@Singleton
+public class ParseFlavors extends ParseJson<Flavors> {
+ static class Flavors extends PaginatedCollection<Resource> {
+
+ @ConstructorProperties({ "flavors", "flavors_links" })
+ protected Flavors(Iterable<Resource> flavors, Iterable<Link> flavors_links) {
+ super(flavors, flavors_links);
+ }
+
+ }
+
+ @Inject
+ public ParseFlavors(Json json) {
+ super(json, TypeLiteral.get(Flavors.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Resource, ToPagedIterable> {
+
+ private final NovaApi api;
+
+ @Inject
+ protected ToPagedIterable(NovaApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.get().toString();
+ final FlavorApi flavorApi = api.getFlavorApiForZone(zone);
+ return new Function<Object, IterableWithMarker<Resource>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Resource> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(flavorApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listFlavors()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java
new file mode 100644
index 0000000..c69103a
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java
@@ -0,0 +1,95 @@
+/*
+ * 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.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+import org.jclouds.openstack.nova.v2_0.features.ImageApi;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseImageDetails.Images;
+import org.jclouds.openstack.v2_0.domain.Link;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * boiler plate until we determine a better way
+ *
+ * @author Adrian Cole
+ */
+@Beta
+@Singleton
+public class ParseImageDetails extends ParseJson<Images> {
+ static class Images extends PaginatedCollection<Image> {
+
+ @ConstructorProperties({ "images", "images_links" })
+ protected Images(Iterable<Image> images, Iterable<Link> images_links) {
+ super(images, images_links);
+ }
+
+ }
+
+ @Inject
+ public ParseImageDetails(Json json) {
+ super(json, TypeLiteral.get(Images.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Image, ToPagedIterable> {
+
+ private final NovaApi api;
+
+ @Inject
+ protected ToPagedIterable(NovaApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Image>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.get().toString();
+ final ImageApi imageApi = api.getImageApiForZone(zone);
+ return new Function<Object, IterableWithMarker<Image>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Image> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(imageApi.listInDetail(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listInDetail()";
+ }
+ };
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java
new file mode 100644
index 0000000..a939134
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.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.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.features.ImageApi;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseImages.Images;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * boiler plate until we determine a better way
+ *
+ * @author Adrian Cole
+ */
+@Beta
+@Singleton
+public class ParseImages extends ParseJson<Images> {
+ static class Images extends PaginatedCollection<Resource> {
+
+ @ConstructorProperties({ "images", "images_links" })
+ protected Images(Iterable<Resource> images, Iterable<Link> images_links) {
+ super(images, images_links);
+ }
+
+ }
+
+ @Inject
+ public ParseImages(Json json) {
+ super(json, TypeLiteral.get(Images.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Resource, ToPagedIterable> {
+
+ private final NovaApi api;
+
+ @Inject
+ protected ToPagedIterable(NovaApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.get().toString();
+ final ImageApi imageApi = api.getImageApiForZone(zone);
+ return new Function<Object, IterableWithMarker<Resource>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Resource> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(imageApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "list()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.java
new file mode 100644
index 0000000..96566ff
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.java
@@ -0,0 +1,64 @@
+/*
+ * 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.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.functions.ParseFirstJsonValueNamed;
+import org.jclouds.json.internal.GsonWrapper;
+import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
+import com.google.common.collect.FluentIterable;
+import com.google.inject.Inject;
+import com.google.inject.TypeLiteral;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class ParseKeyPairs implements Function<HttpResponse, FluentIterable<? extends KeyPair>> {
+ private final ParseFirstJsonValueNamed<FluentIterable<Wrapper>> parser;
+
+ private static class Wrapper implements Supplier<KeyPair> {
+ private KeyPair keypair;
+
+ @Override
+ public KeyPair get() {
+ return keypair;
+ }
+
+ }
+
+ @Inject
+ public ParseKeyPairs(GsonWrapper gsonView) {
+ this.parser = new ParseFirstJsonValueNamed<FluentIterable<Wrapper>>(checkNotNull(gsonView, "gsonView"),
+ new TypeLiteral<FluentIterable<Wrapper>>() {
+ }, "keypairs");
+ }
+
+ public FluentIterable<? extends KeyPair> apply(HttpResponse response) {
+ checkNotNull(response, "response");
+ return parser.apply(response).transform(Suppliers.<KeyPair> supplierFunction());
+ }
+}
[12/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java
new file mode 100644
index 0000000..4af2cea
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java
@@ -0,0 +1,94 @@
+/*
+ * 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.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.features.ServerApi;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServerDetails.Servers;
+import org.jclouds.openstack.v2_0.domain.Link;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * boiler plate until we determine a better way
+ *
+ * @author Adrian Cole
+ */
+@Beta
+@Singleton
+public class ParseServerDetails extends ParseJson<Servers> {
+ static class Servers extends PaginatedCollection<Server> {
+
+ @ConstructorProperties({ "servers", "servers_links" })
+ protected Servers(Iterable<Server> servers, Iterable<Link> servers_links) {
+ super(servers, servers_links);
+ }
+
+ }
+
+ @Inject
+ public ParseServerDetails(Json json) {
+ super(json, TypeLiteral.get(Servers.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Server, ToPagedIterable> {
+
+ private final NovaApi api;
+
+ @Inject
+ protected ToPagedIterable(NovaApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Server>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.get().toString();
+ final ServerApi serverApi = api.getServerApiForZone(zone);
+ return new Function<Object, IterableWithMarker<Server>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Server> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(serverApi.listInDetail(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "listInDetail()";
+ }
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java
new file mode 100644
index 0000000..2de8c76
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.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.functions.internal;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import com.google.common.base.Optional;
+import org.jclouds.collect.IterableWithMarker;
+import org.jclouds.collect.internal.Arg0ToPagedIterable;
+import org.jclouds.http.functions.ParseJson;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.v2_0.domain.PaginatedCollection;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.features.ServerApi;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServers.Servers;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Resource;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Function;
+import com.google.inject.TypeLiteral;
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * boiler plate until we determine a better way
+ *
+ * @author Adrian Cole
+ */
+@Beta
+@Singleton
+public class ParseServers extends ParseJson<Servers> {
+ static class Servers extends PaginatedCollection<Resource> {
+
+ @ConstructorProperties({ "servers", "servers_links" })
+ protected Servers(Iterable<Resource> servers, Iterable<Link> servers_links) {
+ super(servers, servers_links);
+ }
+
+ }
+
+ @Inject
+ public ParseServers(Json json) {
+ super(json, TypeLiteral.get(Servers.class));
+ }
+
+ public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Resource, ToPagedIterable> {
+
+ private final NovaApi api;
+
+ @Inject
+ protected ToPagedIterable(NovaApi api) {
+ this.api = checkNotNull(api, "api");
+ }
+
+ @Override
+ protected Function<Object, IterableWithMarker<Resource>> markerToNextForArg0(Optional<Object> arg0) {
+ String zone = arg0.get().toString();
+ final ServerApi serverApi = api.getServerApiForZone(zone);
+ return new Function<Object, IterableWithMarker<Resource>>() {
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public IterableWithMarker<Resource> apply(Object input) {
+ PaginationOptions paginationOptions = PaginationOptions.class.cast(input);
+ return IterableWithMarker.class.cast(serverApi.list(paginationOptions));
+ }
+
+ @Override
+ public String toString() {
+ return "list()";
+ }
+ };
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java
new file mode 100644
index 0000000..4bfb51b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java
@@ -0,0 +1,129 @@
+/*
+ * 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.handlers;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Predicates.in;
+import static com.google.common.base.Strings.emptyToNull;
+import static com.google.common.collect.Maps.filterKeys;
+import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream;
+
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.date.DateCodecFactory;
+import org.jclouds.fallbacks.HeaderToRetryAfterException;
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpErrorHandler;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.HttpResponseException;
+import org.jclouds.logging.Logger;
+import org.jclouds.openstack.nova.v2_0.functions.OverLimitParser;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.InsufficientResourcesException;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.jclouds.rest.RetryAfterException;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Ticker;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * This will parse and set an appropriate exception on the command object.
+ *
+ * @author Adrian Cole, Steve Loughran
+ *
+ */
+// TODO: is there error spec someplace? let's type errors, etc.
+@Singleton
+public class NovaErrorHandler implements HttpErrorHandler {
+
+ @Resource
+ protected Logger logger = Logger.NULL;
+ protected final HeaderToRetryAfterException retryAfterParser;
+ protected final OverLimitParser overLimitParser;
+
+ protected NovaErrorHandler(HeaderToRetryAfterException retryAfterParser, OverLimitParser overLimitParser) {
+ this.retryAfterParser = checkNotNull(retryAfterParser, "retryAfterParser");
+ this.overLimitParser = checkNotNull(overLimitParser, "overLimitParser");
+ }
+
+ /**
+ * in current format, retryAt has a value of {@code 2012-11-14T21:51:28UTC}, which is an ISO-8601 seconds (not milliseconds) format.
+ */
+ @Inject
+ public NovaErrorHandler(DateCodecFactory factory, OverLimitParser overLimitParser) {
+ this(HeaderToRetryAfterException.create(Ticker.systemTicker(), factory.iso8601Seconds()), overLimitParser);
+ }
+
+ public void handleError(HttpCommand command, HttpResponse response) {
+ // it is important to always read fully and close streams
+ byte[] data = closeClientButKeepContentStream(response);
+ String content = data != null ? emptyToNull(new String(data)) : null;
+
+ Exception exception = content != null ? new HttpResponseException(command, response, content)
+ : new HttpResponseException(command, response);
+ String requestLine = command.getCurrentRequest().getRequestLine();
+ String message = content != null ? content : String.format("%s -> %s", requestLine, response.getStatusLine());
+ switch (response.getStatusCode()) {
+ case 400:
+ if (message.indexOf("quota exceeded") != -1)
+ exception = new InsufficientResourcesException(message, exception);
+ else if (message.indexOf("has no fixed_ips") != -1)
+ exception = new IllegalStateException(message, exception);
+ else if (message.indexOf("already exists") != -1)
+ exception = new IllegalStateException(message, exception);
+ break;
+ case 401:
+ case 403:
+ exception = new AuthorizationException(message, exception);
+ break;
+ case 404:
+ if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
+ exception = new ResourceNotFoundException(message, exception);
+ }
+ break;
+ case 413:
+ if (content == null) {
+ exception = new InsufficientResourcesException(message, exception);
+ break;
+ }
+ exception = parseAndBuildRetryException(content, message, exception);
+ }
+ command.setException(exception);
+ }
+
+ /**
+ * Build an exception from the response. If it contains the JSON payload then
+ * that is parsed to create a {@link RetryAfterException}, otherwise a
+ * {@link InsufficientResourcesException} is returned
+ *
+ */
+ private Exception parseAndBuildRetryException(String json, String message, Exception exception) {
+ Set<String> retryFields = ImmutableSet.of("retryAfter", "retryAt");
+ for (String value : filterKeys(overLimitParser.apply(json), in(retryFields)).values()) {
+ Optional<RetryAfterException> retryException = retryAfterParser.tryCreateRetryAfterException(exception, value);
+ if (retryException.isPresent())
+ return retryException.get();
+ }
+ return new InsufficientResourcesException(message, exception);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java
new file mode 100644
index 0000000..e6002e5
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java
@@ -0,0 +1,105 @@
+/*
+ * 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.options;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+/**
+ * @author Adam Lowe
+ */
+public class CreateBackupOfServerOptions implements MapBinder {
+ public static final CreateBackupOfServerOptions NONE = new CreateBackupOfServerOptions();
+
+ @Inject
+ protected BindToJsonPayload jsonBinder;
+
+ private Map<String, String> metadata = ImmutableMap.of();
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ Map<String, Object> data = Maps.newHashMap();
+ data.putAll(postParams);
+ data.put("metadata", metadata);
+ return jsonBinder.bindToRequest(request, ImmutableMap.of("createBackup", data));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
+ throw new IllegalStateException("createBackup is a POST operation");
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (!(object instanceof CreateBackupOfServerOptions)) return false;
+ final CreateBackupOfServerOptions other = CreateBackupOfServerOptions.class.cast(object);
+ return equal(metadata, other.metadata);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(metadata);
+ }
+
+ protected ToStringHelper string() {
+ return toStringHelper("").add("metadata", metadata);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ /** @see #getMetadata() */
+ public CreateBackupOfServerOptions metadata(Map<String, String> metadata) {
+ this.metadata = metadata;
+ return this;
+ }
+
+ /**
+ * Extra image properties to include
+ */
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public static class Builder {
+ /**
+ * @see CreateBackupOfServerOptions#getMetadata()
+ */
+ public static CreateBackupOfServerOptions metadata(Map<String, String> metadata) {
+ return new CreateBackupOfServerOptions().metadata(metadata);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java
new file mode 100644
index 0000000..b135e19
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java
@@ -0,0 +1,557 @@
+/*
+ * 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.options;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Strings.emptyToNull;
+import static com.google.common.io.BaseEncoding.base64;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.Network;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+import com.google.common.collect.ForwardingObject;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+/**
+ * @author Adrian Cole
+ * @author Inbar Stolberg
+ * @author Zack Shoylev
+ */
+public class CreateServerOptions implements MapBinder {
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ static class File {
+ private final String path;
+ private final String contents;
+
+ public File(String path, byte[] contents) {
+ this.path = checkNotNull(path, "path");
+ this.contents = base64().encode(checkNotNull(contents, "contents"));
+ checkArgument(
+ path.getBytes().length < 255,
+ String.format("maximum length of path is 255 bytes. Path specified %s is %d bytes", path,
+ path.getBytes().length));
+ checkArgument(contents.length < 10 * 1024,
+ String.format("maximum size of the file is 10KB. Contents specified is %d bytes", contents.length));
+ }
+
+ public String getContents() {
+ return contents;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof File) {
+ final File other = File.class.cast(object);
+ return equal(path, other.path);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(path);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper("file").add("path", path).toString();
+ }
+
+ }
+
+ private String keyName;
+ private String adminPass;
+ private Set<String> securityGroupNames = ImmutableSet.of();
+ private Map<String, String> metadata = ImmutableMap.of();
+ private List<File> personality = Lists.newArrayList();
+ private byte[] userData;
+ private String diskConfig;
+ private Set<String> networks = ImmutableSet.of();
+ private Set<Network> novaNetworks = ImmutableSet.of();
+ private String availabilityZone;
+ private boolean configDrive;
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (object instanceof CreateServerOptions) {
+ final CreateServerOptions other = CreateServerOptions.class.cast(object);
+ return equal(keyName, other.keyName) && equal(securityGroupNames, other.securityGroupNames)
+ && equal(metadata, other.metadata) && equal(personality, other.personality)
+ && equal(adminPass, other.adminPass) && equal(diskConfig, other.diskConfig)
+ && equal(adminPass, other.adminPass) && equal(networks, other.networks)
+ && equal(availabilityZone, other.availabilityZone);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(keyName, securityGroupNames, metadata, personality, adminPass, networks, availabilityZone);
+ }
+
+ protected ToStringHelper string() {
+ ToStringHelper toString = Objects.toStringHelper("").omitNullValues();
+ toString.add("keyName", keyName);
+ if (securityGroupNames.size() > 0)
+ toString.add("securityGroupNames", securityGroupNames);
+ if (metadata.size() > 0)
+ toString.add("metadata", metadata);
+ if (personality.size() > 0)
+ toString.add("personality", personality);
+ if (adminPass != null)
+ toString.add("adminPassPresent", true);
+ if (diskConfig != null)
+ toString.add("diskConfig", diskConfig);
+ toString.add("userData", userData == null ? null : new String(userData));
+ if (!networks.isEmpty())
+ toString.add("networks", networks);
+ toString.add("availability_zone", availabilityZone == null ? null : availabilityZone);
+ return toString;
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ static class ServerRequest {
+ final String name;
+ final String imageRef;
+ final String flavorRef;
+ @Named("availability_zone")
+ String availabilityZone;
+ String adminPass;
+ Map<String, String> metadata;
+ List<File> personality;
+ String key_name;
+ @Named("security_groups")
+ Set<NamedThingy> securityGroupNames;
+ String user_data;
+ @Named("OS-DCF:diskConfig")
+ String diskConfig;
+ Set<Map<String, String>> networks;
+
+ private ServerRequest(String name, String imageRef, String flavorRef) {
+ this.name = name;
+ this.imageRef = imageRef;
+ this.flavorRef = flavorRef;
+ }
+
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ ServerRequest server = new ServerRequest(checkNotNull(postParams.get("name"), "name parameter not present").toString(),
+ checkNotNull(postParams.get("imageRef"), "imageRef parameter not present").toString(),
+ checkNotNull(postParams.get("flavorRef"), "flavorRef parameter not present").toString());
+ if (metadata.size() > 0)
+ server.metadata = metadata;
+ if (personality.size() > 0)
+ server.personality = personality;
+ if (keyName != null)
+ server.key_name = keyName;
+ if (availabilityZone != null)
+ server.availabilityZone = availabilityZone;
+ if (userData != null)
+ server.user_data = base64().encode(userData);
+ if (securityGroupNames.size() > 0) {
+ server.securityGroupNames = Sets.newLinkedHashSet();
+ for (String groupName : securityGroupNames) {
+ server.securityGroupNames.add(new NamedThingy(groupName));
+ }
+ }
+ if (adminPass != null) {
+ server.adminPass = adminPass;
+ }
+
+ if (diskConfig != null) {
+ server.diskConfig = diskConfig;
+ }
+
+ if (!networks.isEmpty() || !novaNetworks.isEmpty()) {
+ server.networks = Sets.newLinkedHashSet(); // ensures ordering is preserved - helps testing and more intuitive for users.
+ for (Network network : novaNetworks) {
+ // Avoid serializing null values, which are common here.
+ ImmutableMap.Builder<String, String> networkMap = new ImmutableMap.Builder<String, String>();
+ if(network.getNetworkUuid() != null) {
+ networkMap.put("uuid", network.getNetworkUuid());
+ }
+ if(network.getPortUuid() != null) {
+ networkMap.put("port", network.getPortUuid());
+ }
+ if(network.getFixedIp() != null) {
+ networkMap.put("fixed_ip", network.getFixedIp());
+ }
+ server.networks.add(networkMap.build());
+ }
+ for (String network : networks) {
+ server.networks.add(ImmutableMap.of("uuid", network));
+ }
+ }
+
+ return bindToRequest(request, ImmutableMap.of("server", server));
+ }
+
+ private static class NamedThingy extends ForwardingObject {
+ private String name;
+
+ private NamedThingy(String name) {
+ this.name = name;
+ }
+
+ @Override
+ protected Object delegate() {
+ return name;
+ }
+ }
+
+ /**
+ * You may further customize a cloud server by injecting data into the file
+ * system of the cloud server itself. This is useful, for example, for
+ * inserting ssh keys, setting configuration files, or storing data that you
+ * want to retrieve from within the instance itself. It is intended to
+ * provide a minimal amount of launch-time personalization. If significant
+ * customization is required, a custom image should be created. The max size
+ * of the file path data is 255 bytes while the max size of the file contents
+ * is 10KB. Note that the file contents should be encoded as a Base64 string
+ * and the 10KB limit refers to the number of bytes in the decoded data not
+ * the number of characters in the encoded data. The maximum number of file
+ * path/content pairs that can be supplied is 5. Any existing files that
+ * match the specified file will be renamed to include the extension bak
+ * followed by a time stamp. For example, the file /etc/passwd will be backed
+ * up as /etc/passwd.bak.1246036261.5785. All files will have root and the
+ * root group as owner and group owner, respectively and will allow user and
+ * group read access only (-r--r-----).
+ */
+ public CreateServerOptions writeFileToPath(byte[] contents, String path) {
+ checkState(personality.size() < 5, "maximum number of files allowed is 5");
+ personality.add(new File(path, contents));
+ return this;
+ }
+
+ public CreateServerOptions adminPass(String adminPass) {
+ checkNotNull(adminPass, "adminPass");
+ this.adminPass = adminPass;
+ return this;
+ }
+
+ /**
+ * Custom cloud server metadata can also be supplied at launch time. This
+ * metadata is stored in the API system where it is retrievable by querying
+ * the API for server status. The maximum size of the metadata key and value
+ * is each 255 bytes and the maximum number of key-value pairs that can be
+ * supplied per server is 5.
+ */
+ public CreateServerOptions metadata(Map<String, String> metadata) {
+ checkNotNull(metadata, "metadata");
+ checkArgument(metadata.size() <= 5,
+ "you cannot have more then 5 metadata values. You specified: " + metadata.size());
+ for (Entry<String, String> entry : metadata.entrySet()) {
+ checkArgument(
+ entry.getKey().getBytes().length < 255,
+ String.format("maximum length of metadata key is 255 bytes. Key specified %s is %d bytes",
+ entry.getKey(), entry.getKey().getBytes().length));
+ checkArgument(entry.getKey().getBytes().length < 255, String.format(
+ "maximum length of metadata value is 255 bytes. Value specified for %s (%s) is %d bytes",
+ entry.getKey(), entry.getValue(), entry.getValue().getBytes().length));
+ }
+ this.metadata = ImmutableMap.copyOf(metadata);
+ return this;
+ }
+
+ /**
+ * Custom user-data can be also be supplied at launch time.
+ * It is retrievable by the instance and is often used for launch-time configuration
+ * by instance scripts.
+ */
+ public CreateServerOptions userData(byte[] userData) {
+ this.userData = userData;
+ return this;
+ }
+
+ /**
+ * Set to true to use a config drive for metadata.
+ * This is a separate configuration drive that can be used separately from the metadata service.
+ * This needs to be set to "true" when trying to use user data for cloud-init.
+ * @see http://docs.openstack.org/grizzly/openstack-compute/admin/content/config-drive.html
+ */
+ public CreateServerOptions configDrive(boolean configDrive) {
+ this.configDrive = configDrive;
+ return this;
+ }
+
+ /**
+ * A keypair name can be defined when creating a server. This key will be
+ * linked to the server and used to SSH connect to the machine
+ */
+ public String getKeyPairName() {
+ return keyName;
+ }
+
+ public String getAvailabilityZone() {
+ return availabilityZone;
+ }
+
+ /**
+ * @see #getKeyPairName()
+ */
+ public CreateServerOptions keyPairName(String keyName) {
+ this.keyName = keyName;
+ return this;
+ }
+
+ /**
+ * @see #getAvailabilityZone()
+ */
+ public CreateServerOptions availabilityZone(String availabilityZone) {
+ this.availabilityZone = availabilityZone;
+ return this;
+ }
+
+ /**
+ * Security groups the user specified to run servers with.
+ * <p/>
+ * <h3>Note</h3>
+ * <p/>
+ * This requires that {@link NovaApi#getSecurityGroupExtensionForZone(String)} to return
+ * {@link Optional#isPresent present}
+ */
+ public Set<String> getSecurityGroupNames() {
+ return securityGroupNames;
+ }
+
+ /**
+ * Get custom networks specified for the server.
+ *
+ * @return A set of uuids defined by Neutron (previously Quantum)
+ * @see <a href="https://wiki.openstack.org/wiki/Neutron/APIv2-specification#Network">Neutron Networks<a/>
+ */
+ public Set<String> getNetworks() {
+ return networks;
+ }
+
+ /**
+ * Get custom networks specified for the server.
+ *
+ * @return A set of uuids defined by Neutron (previously Quantum)
+ * @see <a href="https://wiki.openstack.org/wiki/Neutron/APIv2-specification#Network">Neutron Networks<a/>
+ */
+ public Set<Network> getNovaNetworks() {
+ return novaNetworks;
+ }
+
+ /**
+ * @see #getSecurityGroupNames
+ */
+ public CreateServerOptions securityGroupNames(String... securityGroupNames) {
+ return securityGroupNames(ImmutableSet.copyOf(checkNotNull(securityGroupNames, "securityGroupNames")));
+ }
+
+ /**
+ * @see #getSecurityGroupNames
+ */
+ public CreateServerOptions securityGroupNames(Iterable<String> securityGroupNames) {
+ for (String groupName : checkNotNull(securityGroupNames, "securityGroupNames"))
+ checkNotNull(emptyToNull(groupName), "all security groups must be non-empty");
+ this.securityGroupNames = ImmutableSet.copyOf(securityGroupNames);
+ return this;
+ }
+
+ /**
+ * When you create a server from an image with the diskConfig value set to
+ * {@link Server#DISK_CONFIG_AUTO}, the server is built with a single partition that is expanded to
+ * the disk size of the flavor selected. When you set the diskConfig attribute to
+ * {@link Server#DISK_CONFIG_MANUAL}, the server is built by using the partition scheme and file
+ * system that is in the source image.
+ * <p/>
+ * If the target flavor disk is larger, remaining disk space is left unpartitioned. A server inherits the diskConfig
+ * attribute from the image from which it is created. However, you can override the diskConfig value when you create
+ * a server. This field is only present if the Disk Config extension is installed in your OpenStack deployment.
+ */
+ public String getDiskConfig() {
+ return diskConfig;
+ }
+
+ /**
+ * @see #getDiskConfig
+ */
+ public CreateServerOptions diskConfig(String diskConfig) {
+ this.diskConfig = diskConfig;
+ return this;
+ }
+
+ /**
+ * Determines if a configuration drive will be attached to the server or not.
+ * This can be used for cloud-init or other configuration purposes.
+ */
+ public boolean getConfigDrive() {
+ return configDrive;
+ }
+
+ /**
+ * @see #getNetworks
+ */
+ public CreateServerOptions networks(Iterable<String> networks) {
+ this.networks = ImmutableSet.copyOf(networks);
+ return this;
+ }
+
+ /**
+ * @see #getNetworks
+ * Overwrites networks supplied by {@link #networks(Iterable)}
+ */
+ public CreateServerOptions novaNetworks(Iterable<Network> networks) {
+ this.novaNetworks = ImmutableSet.copyOf(networks);
+ return this;
+ }
+
+ /**
+ * @see #getNetworks
+ */
+ public CreateServerOptions networks(String... networks) {
+ return networks(ImmutableSet.copyOf(networks));
+ }
+
+ public static class Builder {
+
+ /**
+ * @see CreateServerOptions#writeFileToPath
+ */
+ public static CreateServerOptions writeFileToPath(byte[] contents, String path) {
+ CreateServerOptions options = new CreateServerOptions();
+ return options.writeFileToPath(contents, path);
+ }
+
+ public static CreateServerOptions adminPass(String adminPass) {
+ CreateServerOptions options = new CreateServerOptions();
+ return options.adminPass(adminPass);
+ }
+
+ /**
+ * @see CreateServerOptions#metadata(Map<String, String>)
+ */
+ public static CreateServerOptions metadata(Map<String, String> metadata) {
+ CreateServerOptions options = new CreateServerOptions();
+ return options.metadata(metadata);
+ }
+
+ /**
+ * @see #getKeyPairName()
+ */
+ public static CreateServerOptions keyPairName(String keyName) {
+ CreateServerOptions options = new CreateServerOptions();
+ return options.keyPairName(keyName);
+ }
+
+ /**
+ * @see CreateServerOptions#getSecurityGroupNames
+ */
+ public static CreateServerOptions securityGroupNames(String... groupNames) {
+ CreateServerOptions options = new CreateServerOptions();
+ return CreateServerOptions.class.cast(options.securityGroupNames(groupNames));
+ }
+
+ /**
+ * @see CreateServerOptions#getSecurityGroupNames
+ */
+ public static CreateServerOptions securityGroupNames(Iterable<String> groupNames) {
+ CreateServerOptions options = new CreateServerOptions();
+ return CreateServerOptions.class.cast(options.securityGroupNames(groupNames));
+ }
+
+ /**
+ * @see CreateServerOptions#getDiskConfig
+ */
+ public static CreateServerOptions diskConfig(String diskConfig) {
+ CreateServerOptions options = new CreateServerOptions();
+ return CreateServerOptions.class.cast(options.diskConfig(diskConfig));
+ }
+
+ /**
+ * @see CreateServerOptions#getNetworks
+ */
+ public static CreateServerOptions networks(String... networks) {
+ CreateServerOptions options = new CreateServerOptions();
+ return CreateServerOptions.class.cast(options.networks(networks));
+ }
+
+ /**
+ * @see CreateServerOptions#getNetworks
+ */
+ public static CreateServerOptions networks(Iterable<String> networks) {
+ CreateServerOptions options = new CreateServerOptions();
+ return CreateServerOptions.class.cast(options.networks(networks));
+ }
+
+ /**
+ * @see CreateServerOptions#getNetworks
+ */
+ public static CreateServerOptions novaNetworks(Iterable<Network> networks) {
+ CreateServerOptions options = new CreateServerOptions();
+ return CreateServerOptions.class.cast(options.novaNetworks(networks));
+ }
+
+ /**
+ * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getAvailabilityZone()
+ */
+ public static CreateServerOptions availabilityZone(String availabilityZone) {
+ CreateServerOptions options = new CreateServerOptions();
+ return options.availabilityZone(availabilityZone);
+ }
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object input) {
+ return jsonBinder.bindToRequest(request, input);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeOptions.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeOptions.java
new file mode 100644
index 0000000..921a4c8
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeOptions.java
@@ -0,0 +1,220 @@
+/*
+ * 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.options;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+/**
+ * @author Adam Lowe
+ */
+public class CreateVolumeOptions implements MapBinder {
+ public static final CreateVolumeOptions NONE = new CreateVolumeOptions();
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ protected String name;
+ protected String description;
+ protected String volumeType;
+ protected String availabilityZone;
+ protected String snapshotId;
+ protected Map<String, String> metadata = ImmutableMap.of();
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ Map<String, Object> image = Maps.newHashMap();
+ image.putAll(postParams);
+ if (name != null)
+ image.put("display_name", name);
+ if (description != null)
+ image.put("display_description", description);
+ if (volumeType != null)
+ image.put("volume_type", volumeType);
+ if (availabilityZone != null)
+ image.put("availability_zone", availabilityZone);
+ if (snapshotId != null)
+ image.put("snapshot_id", snapshotId);
+ if (!metadata.isEmpty())
+ image.put("metadata", metadata);
+ return jsonBinder.bindToRequest(request, ImmutableMap.of("volume", image));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
+ throw new IllegalStateException("CreateVolume is a POST operation");
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (!(object instanceof CreateVolumeOptions)) return false;
+ final CreateVolumeOptions other = CreateVolumeOptions.class.cast(object);
+ return equal(volumeType, other.volumeType) && equal(availabilityZone, other.availabilityZone) && equal(snapshotId, other.snapshotId)
+ && equal(name, other.name) && equal(description, other.description) && equal(metadata, other.metadata);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(volumeType, availabilityZone, snapshotId, name, description, metadata);
+ }
+
+ protected ToStringHelper string() {
+ return toStringHelper("").add("volumeType", volumeType).add("availabilityZone", availabilityZone)
+ .add("snapshotId", snapshotId).add("name", name).add("description", description).add("metadata", metadata);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ /**
+ * Custom cloud server metadata can also be supplied at launch time. This
+ * metadata is stored in the API system where it is retrievable by querying
+ * the API for server status. The maximum size of the metadata key and value
+ * is each 255 bytes and the maximum number of key-value pairs that can be
+ * supplied per volume is 5.
+ */
+ public CreateVolumeOptions metadata(Map<String, String> metadata) {
+ checkNotNull(metadata, "metadata");
+ checkArgument(metadata.size() <= 5,
+ "you cannot have more then 5 metadata values. You specified: " + metadata.size());
+ for (Entry<String, String> entry : metadata.entrySet()) {
+ checkArgument(
+ entry.getKey().getBytes().length < 255,
+ String.format("maximum length of metadata key is 255 bytes. Key specified %s is %d bytes",
+ entry.getKey(), entry.getKey().getBytes().length));
+ checkArgument(entry.getKey().getBytes().length < 255, String.format(
+ "maximum length of metadata value is 255 bytes. Value specified for %s (%s) is %d bytes",
+ entry.getKey(), entry.getValue(), entry.getValue().getBytes().length));
+ }
+ this.metadata = ImmutableMap.copyOf(metadata);
+ return this;
+ }
+
+ public CreateVolumeOptions name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public CreateVolumeOptions description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public CreateVolumeOptions volumeType(String volumeType) {
+ this.volumeType = volumeType;
+ return this;
+ }
+
+ public CreateVolumeOptions availabilityZone(String availabilityZone) {
+ this.availabilityZone = availabilityZone;
+ return this;
+ }
+
+ public CreateVolumeOptions snapshotId(String snapshotId) {
+ this.snapshotId = snapshotId;
+ return this;
+ }
+
+ public String getVolumeType() {
+ return volumeType;
+ }
+
+ public String getAvailabilityZone() {
+ return availabilityZone;
+ }
+
+ public String getSnapshotId() {
+ return snapshotId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public Map<String, String> getMetadata() {
+ return metadata;
+ }
+
+ public static class Builder {
+ /**
+ * @see CreateVolumeOptions#getName()
+ */
+ public static CreateVolumeOptions name(String name) {
+ return new CreateVolumeOptions().name(name);
+ }
+ /**
+ * @see CreateVolumeOptions#getDescription()
+ */
+ public static CreateVolumeOptions description(String description) {
+ return new CreateVolumeOptions().description(description);
+ }
+
+ /**
+ * @see CreateVolumeOptions#getVolumeType()
+ */
+ public static CreateVolumeOptions volumeType(String volumeType) {
+ return new CreateVolumeOptions().volumeType(volumeType);
+ }
+
+ /**
+ * @see CreateVolumeOptions#getAvailabilityZone()
+ */
+ public static CreateVolumeOptions availabilityZone(String availabilityZone) {
+ return new CreateVolumeOptions().availabilityZone(availabilityZone);
+ }
+
+ /**
+ * @see CreateVolumeOptions#getSnapshotId()
+ */
+ public static CreateVolumeOptions snapshotId(String snapshotId) {
+ return new CreateVolumeOptions().snapshotId(snapshotId);
+ }
+
+ /**
+ * @see CreateVolumeOptions#getMetadata()
+ */
+ public static CreateVolumeOptions metadata(Map<String, String> metadata) {
+ return new CreateVolumeOptions().metadata(metadata);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeSnapshotOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeSnapshotOptions.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeSnapshotOptions.java
new file mode 100644
index 0000000..b159367
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeSnapshotOptions.java
@@ -0,0 +1,138 @@
+/*
+ * 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.options;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+/**
+ * @author Adam Lowe
+ */
+public class CreateVolumeSnapshotOptions implements MapBinder {
+ public static final CreateVolumeSnapshotOptions NONE = new CreateVolumeSnapshotOptions();
+
+ @Inject
+ private BindToJsonPayload jsonBinder;
+
+ private String name;
+ private String description;
+ private boolean force = false;
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ Map<String, Object> data = Maps.newHashMap(postParams);
+ if (name != null)
+ data.put("display_name", name);
+ if (description != null)
+ data.put("display_description", description);
+ if (force)
+ data.put("force", "true");
+ return jsonBinder.bindToRequest(request, ImmutableMap.of("snapshot", data));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
+ throw new IllegalStateException("CreateSnapshot is a POST operation");
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (!(object instanceof CreateVolumeSnapshotOptions)) return false;
+ final CreateVolumeSnapshotOptions other = CreateVolumeSnapshotOptions.class.cast(object);
+ return equal(name, other.name) && equal(description, other.description);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, description);
+ }
+
+ protected ToStringHelper string() {
+ return toStringHelper("").add("name", name).add("description", description);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public CreateVolumeSnapshotOptions name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public CreateVolumeSnapshotOptions description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ public CreateVolumeSnapshotOptions force() {
+ this.force = true;
+ return this;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public boolean isForce() {
+ return force;
+ }
+
+ public static class Builder {
+ /**
+ * @see CreateVolumeSnapshotOptions#getName()
+ */
+ public static CreateVolumeSnapshotOptions name(String name) {
+ return new CreateVolumeSnapshotOptions().name(name);
+ }
+ /**
+ * @see CreateVolumeSnapshotOptions#getDescription()
+ */
+ public static CreateVolumeSnapshotOptions description(String description) {
+ return new CreateVolumeSnapshotOptions().description(description);
+ }
+
+ /**
+ * @see CreateVolumeSnapshotOptions#isForce()
+ */
+ public static CreateVolumeSnapshotOptions force() {
+ return new CreateVolumeSnapshotOptions().force();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeTypeOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeTypeOptions.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeTypeOptions.java
new file mode 100644
index 0000000..7ab6460
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeTypeOptions.java
@@ -0,0 +1,101 @@
+/*
+ * 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.options;
+
+import static com.google.common.base.Objects.equal;
+import static com.google.common.base.Objects.toStringHelper;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+/**
+ * @author Adam Lowe
+ */
+public class CreateVolumeTypeOptions implements MapBinder {
+ public static final CreateVolumeTypeOptions NONE = new CreateVolumeTypeOptions();
+
+ @Inject
+ protected BindToJsonPayload jsonBinder;
+
+ protected Map<String, String> specs = ImmutableMap.of();
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ Map<String, Object> data = Maps.newHashMap();
+ data.putAll(postParams);
+ data.put("extra_specs", specs);
+ return jsonBinder.bindToRequest(request, ImmutableMap.of("volume_type", data));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
+ throw new IllegalStateException("CreateWithExtraSpecs are POST operations");
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (!(object instanceof CreateVolumeTypeOptions)) return false;
+ final CreateVolumeTypeOptions other = CreateVolumeTypeOptions.class.cast(object);
+ return equal(specs, other.specs);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(specs);
+ }
+
+ protected ToStringHelper string() {
+ return toStringHelper("").add("specs", specs);
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public CreateVolumeTypeOptions specs(Map<String, String> specs) {
+ this.specs = specs;
+ return this;
+ }
+
+ public Map<String, String> getSpecs() {
+ return specs;
+ }
+
+ public static class Builder {
+ /**
+ * @see CreateVolumeTypeOptions#getSpecs()
+ */
+ public static CreateVolumeTypeOptions specs(Map<String, String> specs) {
+ return new CreateVolumeTypeOptions().specs(specs);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/ListOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/ListOptions.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/ListOptions.java
new file mode 100644
index 0000000..23eb5f3
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/ListOptions.java
@@ -0,0 +1,107 @@
+/*
+ * 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.options;
+
+import java.util.Date;
+
+import org.jclouds.openstack.v2_0.options.PaginationOptions;
+
+/**
+ * Options used to control the amount of detail in the request.
+ *
+ * @see PaginationOptions
+ * @see <a href="http://wiki.openstack.org/OpenStackAPI_1-1" />
+ * @author Adrian Cole
+ */
+public class ListOptions extends PaginationOptions {
+
+ public static final ListOptions NONE = new ListOptions();
+
+ /**
+ * unless used, only the name and id will be returned per row.
+ *
+ * @return
+ */
+ public ListOptions withDetails() {
+ this.pathSuffix = "/detail";
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ListOptions changesSince(Date ifModifiedSince) {
+ super.changesSince(ifModifiedSince);
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ListOptions limit(int limit) {
+ super.limit(limit);
+ return this;
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ListOptions marker(String marker) {
+ super.marker(marker);
+ return this;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see ListOptions#withDetails()
+ */
+ public static ListOptions withDetails() {
+ ListOptions options = new ListOptions();
+ return options.withDetails();
+ }
+
+ /**
+ * @see PaginationOptions#marker(String)
+ */
+ public static ListOptions marker(String marker) {
+ ListOptions options = new ListOptions();
+ return options.marker(marker);
+ }
+
+ /**
+ * @see PaginationOptions#limit(long)
+ */
+ public static ListOptions maxResults(int maxKeys) {
+ ListOptions options = new ListOptions();
+ return options.limit(maxKeys);
+ }
+
+ /**
+ * @see PaginationOptions#changesSince(Date)
+ */
+ public static ListOptions changesSince(Date since) {
+ ListOptions options = new ListOptions();
+ return options.changesSince(since);
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/RebuildServerOptions.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/RebuildServerOptions.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/RebuildServerOptions.java
new file mode 100644
index 0000000..e1f0d08
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/RebuildServerOptions.java
@@ -0,0 +1,142 @@
+/*
+ * 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.options;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+
+/**
+ * @author Adrian Cole
+ * @author Inbar Stolberg
+ */
+public class RebuildServerOptions implements MapBinder {
+ @Inject
+ private BindToJsonPayload jsonBinder;
+ String imageRef;
+ String name;
+ String adminPass;
+ String accessIPv4;
+ String accessIPv6;
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ Map<String, String> image = Maps.newHashMap();
+ if (imageRef != null)
+ image.put("imageRef", imageRef);
+ if (name != null)
+ image.put("name", name);
+ if (adminPass != null)
+ image.put("adminPass", adminPass);
+ if (accessIPv4 != null)
+ image.put("accessIPv4", accessIPv4);
+ if (accessIPv6 != null)
+ image.put("accessIPv6", accessIPv6);
+
+
+ return jsonBinder.bindToRequest(request, ImmutableMap.of("rebuild", image));
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
+ throw new IllegalStateException("RebuildServer is a POST operation");
+ }
+
+ /**
+ * @param ref
+ * - reference of the image to rebuild the server with.
+ */
+ public RebuildServerOptions withImage(String ref) {
+ checkNotNull(ref, "image reference should not be null");
+ checkArgument(!ref.isEmpty(), "image reference should not be empty");
+ this.imageRef = ref;
+ return this;
+ }
+
+ public RebuildServerOptions name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ public RebuildServerOptions adminPass(String adminPass) {
+ this.adminPass = adminPass;
+ return this;
+ }
+
+ public RebuildServerOptions ipv4Address(String ipv4Address) {
+ this.accessIPv4 = ipv4Address;
+ return this;
+ }
+
+ public RebuildServerOptions ipv6Address(String iPv6Address) {
+ this.accessIPv6 = iPv6Address;
+ return this;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see RebuildServerOptions#withImage(String)
+ */
+ public static RebuildServerOptions withImage(String ref) {
+ RebuildServerOptions options = new RebuildServerOptions();
+ return options.withImage(ref);
+ }
+
+ /**
+ * @see RebuildServerOptions#name(String)
+ */
+ public static RebuildServerOptions name(String name) {
+ RebuildServerOptions options = new RebuildServerOptions();
+ return options.name(name);
+ }
+
+ /**
+ * @see RebuildServerOptions#adminPass(String)
+ */
+ public static RebuildServerOptions adminPass(String adminPass) {
+ RebuildServerOptions options = new RebuildServerOptions();
+ return options.adminPass(adminPass);
+ }
+
+ /**
+ * @see RebuildServerOptions#ipv4Address(String)
+ */
+ public static RebuildServerOptions ipv4Address(String ipv4Address) {
+ RebuildServerOptions options = new RebuildServerOptions();
+ return options.ipv4Address(ipv4Address);
+ }
+
+ /**
+ * @see RebuildServerOptions#ipv6Address(String)
+ */
+ public static RebuildServerOptions ipv6Address(String ipv6Address) {
+ RebuildServerOptions options = new RebuildServerOptions();
+ return options.ipv6Address(ipv6Address);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java
new file mode 100644
index 0000000..a44b502
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java
@@ -0,0 +1,84 @@
+/*
+ * 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.predicates;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.NoSuchElementException;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.annotation.Resource;
+import javax.inject.Singleton;
+
+import org.jclouds.logging.Logger;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
+import org.jclouds.rest.ResourceNotFoundException;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.inject.Inject;
+
+/**
+ * AtomicReference is so that we can return the securityGroup that matched.
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class FindSecurityGroupWithNameAndReturnTrue implements Predicate<AtomicReference<ZoneAndName>> {
+
+ private final NovaApi novaApi;
+
+ @Resource
+ protected Logger logger = Logger.NULL;
+
+ @Inject
+ public FindSecurityGroupWithNameAndReturnTrue(NovaApi novaApi) {
+ this.novaApi = checkNotNull(novaApi, "novaApi");
+ }
+
+ public boolean apply(AtomicReference<ZoneAndName> securityGroupInZoneRef) {
+ checkNotNull(securityGroupInZoneRef, "securityGroupRef");
+ final ZoneAndName securityGroupInZone = checkNotNull(securityGroupInZoneRef.get(), "securityGroupInZone");
+
+ Optional<? extends SecurityGroupApi> api = novaApi.getSecurityGroupExtensionForZone(securityGroupInZone.getZone());
+ checkArgument(api.isPresent(), "Security groups are required, but the extension is not available!");
+
+ logger.trace("looking for security group %s", securityGroupInZone.slashEncode());
+ try {
+ SecurityGroup returnVal = Iterables.find(api.get().list(), new Predicate<SecurityGroup>() {
+
+ @Override
+ public boolean apply(SecurityGroup input) {
+ return input.getName().equals(securityGroupInZone.getName());
+ }
+
+ });
+ securityGroupInZoneRef.set(new SecurityGroupInZone(returnVal, securityGroupInZone.getZone()));
+ return true;
+ } catch (ResourceNotFoundException e) {
+ return false;
+ } catch (NoSuchElementException e) {
+ return false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicates.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicates.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicates.java
new file mode 100644
index 0000000..aa8cad7
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicates.java
@@ -0,0 +1,55 @@
+/*
+ * 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.predicates;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+import org.jclouds.openstack.nova.v2_0.domain.Image.Status;
+
+import com.google.common.base.Predicate;
+
+/**
+ * Predicates handy when working with Images
+ *
+ * @author Adrian Cole
+ */
+
+public class ImagePredicates {
+
+ /**
+ * matches status of the given image
+ *
+ * @param status
+ * @return predicate that matches status
+ */
+ public static Predicate<Image> statusEquals(final Status status) {
+ checkNotNull(status, "status must be defined");
+
+ return new Predicate<Image>() {
+ @Override
+ public boolean apply(Image image) {
+ return status.equals(image.getStatus());
+ }
+
+ @Override
+ public String toString() {
+ return "statusEquals(" + status + ")";
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/KeyPairPredicates.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/KeyPairPredicates.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/KeyPairPredicates.java
new file mode 100644
index 0000000..ec511bb
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/KeyPairPredicates.java
@@ -0,0 +1,77 @@
+/*
+ * 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.predicates;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
+
+import com.google.common.base.Predicate;
+
+/**
+ * Predicates handy when working with KeyPairs
+ *
+ * @author Adam Lowe
+ */
+
+public class KeyPairPredicates {
+
+
+ /**
+ * matches name of the given key pair
+ *
+ * @param name
+ * @return predicate that matches name
+ */
+ public static Predicate<KeyPair> nameMatches(final Predicate<String> name) {
+ checkNotNull(name, "name must be defined");
+
+ return new Predicate<KeyPair>() {
+ @Override
+ public boolean apply(KeyPair ext) {
+ return name.apply(ext.getName());
+ }
+
+ @Override
+ public String toString() {
+ return "nameMatches(" + name + ")";
+ }
+ };
+ }
+
+ /**
+ * matches name of the given keypair starts with the specified prefix
+ *
+ * @param name the prefix you are looking for
+ * @return the predicate
+ */
+ public static Predicate<KeyPair> nameEquals(final String name) {
+ checkNotNull(name, "name must be defined");
+
+ return new Predicate<KeyPair>() {
+ @Override
+ public boolean apply(KeyPair ext) {
+ return ext.getName() != null && ext.getName().equals(name);
+ }
+
+ @Override
+ public String toString() {
+ return "nameEquals(" + name + ")";
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicates.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicates.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicates.java
new file mode 100644
index 0000000..412e37f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicates.java
@@ -0,0 +1,213 @@
+/*
+ * 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.predicates;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Set;
+
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
+/**
+ * Predicates handy when working with SecurityGroups
+ *
+ * @author Adrian Cole
+ */
+
+public class SecurityGroupPredicates {
+
+ /**
+ * matches name of the given security group
+ *
+ * @param name
+ * @return predicate that matches name
+ */
+ public static Predicate<SecurityGroup> nameEquals(final String name) {
+ checkNotNull(name, "name must be defined");
+
+ return new Predicate<SecurityGroup>() {
+ @Override
+ public boolean apply(SecurityGroup ext) {
+ return name.equals(ext.getName());
+ }
+
+ @Override
+ public String toString() {
+ return "nameEquals(" + name + ")";
+ }
+ };
+ }
+
+ /**
+ * matches name of the given security group against a list
+ *
+ * @param names
+ * @return predicate that matches one of the names
+ */
+ public static Predicate<SecurityGroup> nameIn(final Set<String> names) {
+ checkNotNull(names, "names must be defined");
+
+ return new Predicate<SecurityGroup>() {
+ @Override
+ public boolean apply(SecurityGroup ext) {
+ return Predicates.in(names).apply(ext.getName());
+ }
+
+ @Override
+ public String toString() {
+ return "nameIn(" + names + ")";
+ }
+ };
+ }
+
+ /**
+ * matches name of the given security group
+ *
+ * @param name
+ * @return predicate that matches name
+ */
+ public static Predicate<SecurityGroup> nameMatches(final Predicate<String> name) {
+ checkNotNull(name, "name must be defined");
+
+ return new Predicate<SecurityGroup>() {
+ @Override
+ public boolean apply(SecurityGroup ext) {
+ return name.apply(ext.getName());
+ }
+
+ @Override
+ public String toString() {
+ return "nameMatches(" + name + ")";
+ }
+ };
+ }
+
+ /**
+ * matches a security group rule by its cidr
+ *
+ * @param cidr
+ * @return predicate that matches cidr
+ */
+ public static Predicate<SecurityGroupRule> ruleCidr(final String cidr) {
+ checkNotNull(cidr, "cidr must be defined");
+
+ return new Predicate<SecurityGroupRule>() {
+ @Override
+ public boolean apply(SecurityGroupRule ext) {
+ return cidr.equals(ext.getIpRange());
+ }
+
+ @Override
+ public String toString() {
+ return "cidr(" + cidr + ")";
+ }
+ };
+ }
+
+ /**
+ * matches a security group rule by the security group it allows
+ *
+ * @param groupName
+ * @return predicate that matches group
+ */
+ public static Predicate<SecurityGroupRule> ruleGroup(final String groupName) {
+ checkNotNull(groupName, "groupName must be defined");
+
+ return new Predicate<SecurityGroupRule>() {
+ @Override
+ public boolean apply(SecurityGroupRule ext) {
+ return ext.getGroup() != null && groupName.equals(ext.getGroup().getName());
+ }
+
+ @Override
+ public String toString() {
+ return "ruleGroup(" + groupName + ")";
+ }
+ };
+ }
+
+ /**
+ * matches a security group rule by the protocol
+ *
+ * @param protocol
+ * @return predicate that matches protocol
+ */
+ public static Predicate<SecurityGroupRule> ruleProtocol(final IpProtocol protocol) {
+ checkNotNull(protocol, "protocol must be defined");
+
+ return new Predicate<SecurityGroupRule>() {
+ @Override
+ public boolean apply(SecurityGroupRule ext) {
+ return protocol.equals(ext.getIpProtocol());
+ }
+
+ @Override
+ public String toString() {
+ return "ruleProtocol(" + protocol + ")";
+ }
+ };
+ }
+
+ /**
+ * matches a security group rule by the start port
+ *
+ * @param startPort
+ * @return predicate that matches startPort
+ */
+ public static Predicate<SecurityGroupRule> ruleStartPort(final int startPort) {
+ checkNotNull(startPort, "startPort must be defined");
+
+ return new Predicate<SecurityGroupRule>() {
+ @Override
+ public boolean apply(SecurityGroupRule ext) {
+ return startPort == ext.getFromPort();
+ }
+
+ @Override
+ public String toString() {
+ return "ruleStartPort(" + startPort + ")";
+ }
+ };
+ }
+
+ /**
+ * matches a security group rule by the end port
+ *
+ * @param endPort
+ * @return predicate that matches endPort
+ */
+ public static Predicate<SecurityGroupRule> ruleEndPort(final int endPort) {
+ checkNotNull(endPort, "endPort must be defined");
+
+ return new Predicate<SecurityGroupRule>() {
+ @Override
+ public boolean apply(SecurityGroupRule ext) {
+ return endPort == ext.getToPort();
+ }
+
+ @Override
+ public String toString() {
+ return "ruleEndPort(" + endPort + ")";
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
new file mode 100644
index 0000000..67c3d34
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
@@ -0,0 +1 @@
+org.jclouds.openstack.nova.v2_0.NovaApiMetadata
\ No newline at end of file
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/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java
new file mode 100644
index 0000000..9e6c46b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.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 = "AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest")
+public class AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest extends BaseNovaApiExpectTest {
+ public AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest() {
+ identity = identityWithTenantId;
+ }
+
+ /**
+ * 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-id", KeystoneFixture.INSTANCE.getTenantId());
+ 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(keystoneAuthWithAccessKeyAndSecretKeyAndTenantId,
+ 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());
+ }
+
+}
+
[11/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
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();
+ }
+
+}
[20/21] git commit: fixing
https://issues.apache.org/jira/browse/STRATOS-520 - adding Openstack-nova
module to dependencies
Posted by ni...@apache.org.
fixing https://issues.apache.org/jira/browse/STRATOS-520 - adding Openstack-nova module to dependencies
Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/d4243b7e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/d4243b7e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/d4243b7e
Branch: refs/heads/master
Commit: d4243b7e960e7f8067c81c07e3ec71290ba259a2
Parents: 517901a
Author: Jeffrey Nguyen <je...@cisco.com>
Authored: Tue Mar 18 08:20:54 2014 +0530
Committer: Nirmal Fernando <ni...@apache.org>
Committed: Tue Mar 18 08:26:53 2014 +0530
----------------------------------------------------------------------
.../org.apache.stratos.cloud.controller/pom.xml | 4 +-
.../openstack-nova/1.7.1-stratos/README.txt | 3 +
.../openstack-nova/1.7.1-stratos/pom.xml | 143 ++++
.../jclouds/openstack/nova/v2_0/NovaApi.java | 208 ++++++
.../openstack/nova/v2_0/NovaApiMetadata.java | 125 ++++
.../openstack/nova/v2_0/NovaAsyncApi.java | 214 ++++++
.../v2_0/binders/BindKeyPairToJsonPayload.java | 47 ++
.../v2_0/binders/BindMetadataToJsonPayload.java | 47 ++
.../BindSecurityGroupRuleToJsonPayload.java | 71 ++
.../nova/v2_0/compute/NovaComputeService.java | 183 +++++
.../v2_0/compute/NovaComputeServiceAdapter.java | 286 +++++++
.../config/NovaComputeServiceContextModule.java | 286 +++++++
.../compute/extensions/NovaImageExtension.java | 140 ++++
.../extensions/NovaSecurityGroupExtension.java | 373 ++++++++++
.../AllocateAndAddFloatingIpToNode.java | 112 +++
.../functions/CreateSecurityGroupIfNeeded.java | 93 +++
.../functions/FlavorInZoneToHardware.java | 60 ++
.../compute/functions/ImageInZoneToImage.java | 70 ++
.../functions/ImageToOperatingSystem.java | 128 ++++
.../NovaSecurityGroupInZoneToSecurityGroup.java | 75 ++
.../NovaSecurityGroupToSecurityGroup.java | 69 ++
.../functions/OrphanedGroupsByZoneId.java | 77 ++
.../RemoveFloatingIpFromNodeAndDeallocate.java | 74 ++
.../SecurityGroupRuleToIpPermission.java | 99 +++
.../functions/ServerInZoneToNodeMetadata.java | 199 +++++
.../compute/loaders/CreateUniqueKeyPair.java | 79 ++
.../loaders/FindSecurityGroupOrCreate.java | 86 +++
.../loaders/LoadFloatingIpsForInstance.java | 63 ++
.../compute/options/NovaTemplateOptions.java | 620 +++++++++++++++
.../predicates/AllNodesInGroupTerminated.java | 56 ++
...desWithGroupEncodedIntoNameThenAddToSet.java | 165 ++++
.../nova/v2_0/config/NovaParserModule.java | 159 ++++
.../nova/v2_0/config/NovaProperties.java | 43 ++
.../nova/v2_0/config/NovaRestClientModule.java | 191 +++++
.../openstack/nova/v2_0/domain/Address.java | 138 ++++
.../openstack/nova/v2_0/domain/BackupType.java | 41 +
.../openstack/nova/v2_0/domain/Flavor.java | 211 ++++++
.../openstack/nova/v2_0/domain/FloatingIP.java | 173 +++++
.../openstack/nova/v2_0/domain/Host.java | 127 ++++
.../nova/v2_0/domain/HostAggregate.java | 250 +++++++
.../nova/v2_0/domain/HostResourceUsage.java | 180 +++++
.../openstack/nova/v2_0/domain/Image.java | 303 ++++++++
.../openstack/nova/v2_0/domain/Ingress.java | 160 ++++
.../openstack/nova/v2_0/domain/KeyPair.java | 189 +++++
.../openstack/nova/v2_0/domain/Network.java | 173 +++++
.../openstack/nova/v2_0/domain/Quota.java | 356 +++++++++
.../openstack/nova/v2_0/domain/QuotaClass.java | 62 ++
.../openstack/nova/v2_0/domain/RebootType.java | 35 +
.../nova/v2_0/domain/SecurityGroup.java | 188 +++++
.../nova/v2_0/domain/SecurityGroupRule.java | 174 +++++
.../openstack/nova/v2_0/domain/Server.java | 476 ++++++++++++
.../nova/v2_0/domain/ServerCreated.java | 127 ++++
.../v2_0/domain/ServerExtendedAttributes.java | 156 ++++
.../nova/v2_0/domain/ServerExtendedStatus.java | 155 ++++
.../v2_0/domain/ServerWithSecurityGroups.java | 128 ++++
.../nova/v2_0/domain/SimpleServerUsage.java | 312 ++++++++
.../nova/v2_0/domain/SimpleTenantUsage.java | 245 ++++++
.../nova/v2_0/domain/TenantIdAndName.java | 127 ++++
.../nova/v2_0/domain/VirtualInterface.java | 128 ++++
.../openstack/nova/v2_0/domain/Volume.java | 346 +++++++++
.../nova/v2_0/domain/VolumeAttachment.java | 172 +++++
.../nova/v2_0/domain/VolumeSnapshot.java | 239 ++++++
.../openstack/nova/v2_0/domain/VolumeType.java | 192 +++++
.../domain/zonescoped/AvailabilityZone.java | 73 ++
.../v2_0/domain/zonescoped/FlavorInZone.java | 46 ++
.../v2_0/domain/zonescoped/ImageInZone.java | 46 ++
.../domain/zonescoped/SecurityGroupInZone.java | 46 ++
.../v2_0/domain/zonescoped/ServerInZone.java | 46 ++
.../nova/v2_0/domain/zonescoped/ZoneAndId.java | 86 +++
.../v2_0/domain/zonescoped/ZoneAndName.java | 111 +++
.../ZoneSecurityGroupNameAndPorts.java | 62 ++
.../nova/v2_0/domain/zonescoped/ZoneState.java | 61 ++
.../v2_0/extensions/AvailabilityZoneAPI.java | 40 +
.../extensions/AvailabilityZoneAsyncApi.java | 58 ++
.../v2_0/extensions/ExtensionNamespaces.java | 110 +++
.../v2_0/extensions/FlavorExtraSpecsApi.java | 77 ++
.../extensions/FlavorExtraSpecsAsyncApi.java | 118 +++
.../nova/v2_0/extensions/FloatingIPApi.java | 98 +++
.../v2_0/extensions/FloatingIPAsyncApi.java | 145 ++++
.../v2_0/extensions/HostAdministrationApi.java | 103 +++
.../extensions/HostAdministrationAsyncApi.java | 157 ++++
.../nova/v2_0/extensions/HostAggregateApi.java | 87 +++
.../v2_0/extensions/HostAggregateAsyncApi.java | 161 ++++
.../nova/v2_0/extensions/KeyPairApi.java | 65 ++
.../nova/v2_0/extensions/KeyPairAsyncApi.java | 101 +++
.../nova/v2_0/extensions/QuotaApi.java | 57 ++
.../nova/v2_0/extensions/QuotaAsyncApi.java | 89 +++
.../nova/v2_0/extensions/QuotaClassApi.java | 51 ++
.../v2_0/extensions/QuotaClassAsyncApi.java | 78 ++
.../nova/v2_0/extensions/SecurityGroupApi.java | 89 +++
.../v2_0/extensions/SecurityGroupAsyncApi.java | 152 ++++
.../nova/v2_0/extensions/ServerAdminApi.java | 120 +++
.../v2_0/extensions/ServerAdminAsyncApi.java | 175 +++++
.../extensions/ServerWithSecurityGroupsApi.java | 49 ++
.../ServerWithSecurityGroupsAsyncApi.java | 62 ++
.../v2_0/extensions/SimpleTenantUsageApi.java | 50 ++
.../extensions/SimpleTenantUsageAsyncApi.java | 77 ++
.../v2_0/extensions/VirtualInterfaceApi.java | 43 ++
.../extensions/VirtualInterfaceAsyncApi.java | 59 ++
.../nova/v2_0/extensions/VolumeApi.java | 147 ++++
.../nova/v2_0/extensions/VolumeAsyncApi.java | 254 +++++++
.../v2_0/extensions/VolumeAttachmentApi.java | 87 +++
.../extensions/VolumeAttachmentAsyncApi.java | 107 +++
.../nova/v2_0/extensions/VolumeTypeApi.java | 101 +++
.../v2_0/extensions/VolumeTypeAsyncApi.java | 161 ++++
.../openstack/nova/v2_0/features/FlavorApi.java | 78 ++
.../nova/v2_0/features/FlavorAsyncApi.java | 144 ++++
.../openstack/nova/v2_0/features/ImageApi.java | 142 ++++
.../nova/v2_0/features/ImageAsyncApi.java | 206 +++++
.../openstack/nova/v2_0/features/ServerApi.java | 276 +++++++
.../nova/v2_0/features/ServerAsyncApi.java | 356 +++++++++
.../functions/FieldValueResponseParsers.java | 105 +++
.../nova/v2_0/functions/OverLimitParser.java | 92 +++
.../ParseImageIdFromLocationHeader.java | 39 +
.../internal/OnlyMetadataValueOrNull.java | 63 ++
.../functions/internal/ParseDiagnostics.java | 47 ++
.../functions/internal/ParseFlavorDetails.java | 94 +++
.../v2_0/functions/internal/ParseFlavors.java | 96 +++
.../functions/internal/ParseImageDetails.java | 95 +++
.../v2_0/functions/internal/ParseImages.java | 96 +++
.../v2_0/functions/internal/ParseKeyPairs.java | 64 ++
.../functions/internal/ParseServerDetails.java | 94 +++
.../v2_0/functions/internal/ParseServers.java | 96 +++
.../nova/v2_0/handlers/NovaErrorHandler.java | 129 ++++
.../options/CreateBackupOfServerOptions.java | 105 +++
.../nova/v2_0/options/CreateServerOptions.java | 557 ++++++++++++++
.../nova/v2_0/options/CreateVolumeOptions.java | 220 ++++++
.../options/CreateVolumeSnapshotOptions.java | 138 ++++
.../v2_0/options/CreateVolumeTypeOptions.java | 101 +++
.../nova/v2_0/options/ListOptions.java | 107 +++
.../nova/v2_0/options/RebuildServerOptions.java | 142 ++++
.../FindSecurityGroupWithNameAndReturnTrue.java | 84 +++
.../nova/v2_0/predicates/ImagePredicates.java | 55 ++
.../nova/v2_0/predicates/KeyPairPredicates.java | 77 ++
.../predicates/SecurityGroupPredicates.java | 213 ++++++
.../services/org.jclouds.apis.ApiMetadata | 1 +
...tKeyAndTenantIdAuthenticationExpectTest.java | 75 ++
...antNamePropertyAuthenticationExpectTest.java | 75 ++
...KeyAndSecretKeyAuthenticationExpectTest.java | 69 ++
.../nova/v2_0/EndpointIdIsRandomExpectTest.java | 72 ++
.../nova/v2_0/NovaApiMetadataTest.java | 32 +
.../v2_0/PasswordAuthenticationExpectTest.java | 60 ++
...dAuthenticationWithTenantNameExpectTest.java | 69 ++
.../NovaComputeServiceAdapterExpectTest.java | 321 ++++++++
.../compute/NovaComputeServiceExpectTest.java | 382 ++++++++++
.../compute/NovaComputeServiceLiveTest.java | 96 +++
.../NovaImageExtensionExpectTest.java | 92 +++
.../extensions/NovaImageExtensionLiveTest.java | 43 ++
.../NovaSecurityGroupExtensionExpectTest.java | 433 +++++++++++
.../NovaSecurityGroupExtensionLiveTest.java | 35 +
...llocateAndAddFloatingIpToNodeExpectTest.java | 133 ++++
.../functions/FlavorInZoneToHardwareTest.java | 90 +++
.../functions/ImageInZoneToImageTest.java | 95 +++
.../functions/ImageToOperatingSystemTest.java | 192 +++++
...aSecurityGroupInZoneToSecurityGroupTest.java | 94 +++
.../NovaSecurityGroupToSecurityGroupTest.java | 155 ++++
.../functions/OrphanedGroupsByZoneIdTest.java | 96 +++
.../SecurityGroupRuleToIpPermissionTest.java | 81 ++
.../ServerInZoneToNodeMetadataTest.java | 311 ++++++++
.../loaders/CreateUniqueKeyPairTest.java | 111 +++
.../loaders/FindSecurityGroupOrCreateTest.java | 144 ++++
.../loaders/LoadFloatingIpsForInstanceTest.java | 108 +++
.../options/NovaTemplateOptionsTest.java | 263 +++++++
.../extensions/AdminActionsApiExpectTest.java | 350 +++++++++
.../extensions/AdminActionsApiLiveTest.java | 195 +++++
.../AvailabilityZoneApiExpectTest.java | 64 ++
.../AvailabilityZonesApiLiveTest.java | 45 ++
.../FlavorExtraSpecsApiExpectTest.java | 142 ++++
.../extensions/FlavorExtraSpecsApiLiveTest.java | 123 +++
.../extensions/FloatingIPApiExpectTest.java | 191 +++++
.../v2_0/extensions/FloatingIPApiLiveTest.java | 171 +++++
.../HostAdministrationApiExpectTest.java | 241 ++++++
.../HostAdministrationApiLiveTest.java | 116 +++
.../extensions/HostAggregateApiExpectTest.java | 179 +++++
.../extensions/HostAggregateApiLiveTest.java | 148 ++++
.../v2_0/extensions/KeyPairApiExpectTest.java | 142 ++++
.../v2_0/extensions/KeyPairApiLiveTest.java | 76 ++
.../v2_0/extensions/QuotaApiExpectTest.java | 125 ++++
.../nova/v2_0/extensions/QuotaApiLiveTest.java | 100 +++
.../extensions/QuotaClassApiExpectTest.java | 105 +++
.../v2_0/extensions/QuotaClassApiLiveTest.java | 73 ++
.../extensions/SecurityGroupApiExpectTest.java | 235 ++++++
.../extensions/SecurityGroupApiLiveTest.java | 100 +++
.../ServerWithSecurityGroupsApiExpectTest.java | 63 ++
.../ServerWithSecurityGroupsApiLiveTest.java | 80 ++
.../SimpleTenantUsageApiExpectTest.java | 99 +++
.../SimpleTenantUsageApiLiveTest.java | 51 ++
.../VirtualInterfaceApiExpectTest.java | 64 ++
.../extensions/VirtualInterfaceApiLiveTest.java | 68 ++
.../v2_0/extensions/VolumeApiExpectTest.java | 460 ++++++++++++
.../nova/v2_0/extensions/VolumeApiLiveTest.java | 274 +++++++
.../VolumeAttachmentApiExpectTest.java | 168 +++++
.../extensions/VolumeAttachmentApiLiveTest.java | 156 ++++
.../extensions/VolumeTypeApiExpectTest.java | 259 +++++++
.../v2_0/extensions/VolumeTypeApiLiveTest.java | 126 ++++
.../v2_0/features/ExtensionApiExpectTest.java | 115 +++
.../v2_0/features/ExtensionApiLiveTest.java | 84 +++
.../nova/v2_0/features/FlavorApiExpectTest.java | 164 ++++
.../nova/v2_0/features/FlavorApiLiveTest.java | 105 +++
.../nova/v2_0/features/ImageApiExpectTest.java | 377 ++++++++++
.../nova/v2_0/features/ImageApiLiveTest.java | 101 +++
.../nova/v2_0/features/ServerApiExpectTest.java | 746 +++++++++++++++++++
.../nova/v2_0/features/ServerApiLiveTest.java | 206 +++++
.../CreateSecurityGroupIfNeededTest.java | 168 +++++
...ityGroupWithNameAndReturnTrueExpectTest.java | 102 +++
.../v2_0/functions/InternalURLLiveTest.java | 64 ++
.../v2_0/handlers/NovaErrorHandlerTest.java | 225 ++++++
.../v2_0/internal/BaseNovaApiExpectTest.java | 28 +
.../nova/v2_0/internal/BaseNovaApiLiveTest.java | 120 +++
...BaseNovaComputeServiceContextExpectTest.java | 87 +++
.../BaseNovaComputeServiceExpectTest.java | 35 +
.../nova/v2_0/internal/BaseNovaExpectTest.java | 84 +++
...eComputeServiceTypicalSecurityGroupTest.java | 76 ++
.../nova/v2_0/parse/ParseCreateFlavorTest.java | 58 ++
.../nova/v2_0/parse/ParseCreatedServerTest.java | 80 ++
.../parse/ParseExtensionListNormalTest.java | 76 ++
.../nova/v2_0/parse/ParseExtensionListTest.java | 88 +++
.../nova/v2_0/parse/ParseExtensionTest.java | 71 ++
.../nova/v2_0/parse/ParseFlavorListTest.java | 85 +++
.../nova/v2_0/parse/ParseFlavorTest.java | 70 ++
.../v2_0/parse/ParseFloatingIPListTest.java | 59 ++
.../nova/v2_0/parse/ParseFloatingIPTest.java | 53 ++
.../nova/v2_0/parse/ParseImageListTest.java | 85 +++
.../nova/v2_0/parse/ParseImageTest.java | 98 +++
.../nova/v2_0/parse/ParseKeyPairListTest.java | 68 ++
.../nova/v2_0/parse/ParseKeyPairTest.java | 61 ++
.../nova/v2_0/parse/ParseMetadataItemTest.java | 58 ++
.../nova/v2_0/parse/ParseMetadataListTest.java | 63 ++
.../v2_0/parse/ParseMetadataUpdateTest.java | 64 ++
.../v2_0/parse/ParseSecurityGroupListTest.java | 72 ++
.../nova/v2_0/parse/ParseSecurityGroupTest.java | 69 ++
.../v2_0/parse/ParseServerDetailsEssexTest.java | 170 +++++
.../nova/v2_0/parse/ParseServerDiagnostics.java | 57 ++
.../nova/v2_0/parse/ParseServerListTest.java | 85 +++
.../nova/v2_0/parse/ParseServerTest.java | 117 +++
.../parse/ParseServerWithAllExtensionsTest.java | 104 +++
.../ParseServerWithInternetAddressesTest.java | 99 +++
...ublicIpsInPrivateAddressBlockExpectTest.java | 99 +++
.../v2_0/predicates/ImagePredicatesTest.java | 44 ++
.../predicates/SecurityGroupPredicatesTest.java | 129 ++++
.../src/test/resources/attachment_details.json | 1 +
.../src/test/resources/attachment_list.json | 1 +
.../src/test/resources/extension_details.json | 21 +
.../src/test/resources/extension_list.json | 42 ++
.../src/test/resources/extension_list_full.json | 281 +++++++
.../test/resources/extension_list_normal.json | 31 +
.../resources/extension_list_openstack.json | 115 +++
.../src/test/resources/flavor_details.json | 19 +
.../src/test/resources/flavor_list.json | 32 +
.../src/test/resources/flavor_list_detail.json | 1 +
.../resources/flavor_list_detail_openstack.json | 83 +++
.../src/test/resources/flavor_new.json | 10 +
.../src/test/resources/floatingip_details.json | 9 +
.../src/test/resources/floatingip_list.json | 16 +
.../1.7.1-stratos/src/test/resources/host.json | 1 +
.../test/resources/host_aggregate_details.json | 1 +
.../src/test/resources/host_aggregate_list.json | 1 +
.../host_aggregate_with_host_details.json | 1 +
.../src/test/resources/hosts_list.json | 1 +
.../src/test/resources/image_active.json | 41 +
.../src/test/resources/image_details.json | 41 +
.../src/test/resources/image_list.json | 32 +
.../src/test/resources/image_list_detail.json | 1 +
.../image_list_detail_imageextension.json | 121 +++
.../resources/image_list_detail_openstack.json | 81 ++
.../src/test/resources/keypair_created.json | 9 +
.../keypair_created_computeservice.json | 9 +
.../src/test/resources/keypair_list.json | 18 +
.../test/resources/listAvailabilityZones.json | 11 +
.../src/test/resources/metadata_item.json | 5 +
.../src/test/resources/metadata_list.json | 6 +
.../src/test/resources/metadata_updated.json | 7 +
.../src/test/resources/new_server.json | 41 +
.../resources/new_server_disk_config_auto.json | 42 ++
.../new_server_disk_config_manual.json | 42 ++
.../src/test/resources/new_server_in_zone.json | 41 +
.../resources/new_server_networks_response.json | 42 ++
.../test/resources/new_server_no_adminpass.json | 40 +
.../resources/new_server_nova_networks.json | 41 +
.../src/test/resources/quota_class.json | 15 +
.../src/test/resources/quotas.json | 15 +
.../test/resources/securitygroup_created.json | 9 +
.../test/resources/securitygroup_details.json | 34 +
...itygroup_details_computeservice_typical.json | 51 ++
.../securitygroup_details_extension.json | 34 +
...securitygroup_details_extension_norules.json | 10 +
.../resources/securitygroup_details_port22.json | 19 +
.../src/test/resources/securitygroup_list.json | 51 ++
...oup_list_details_computeservice_typical.json | 53 ++
.../resources/securitygroup_list_extension.json | 51 ++
.../resources/securitygrouprule_created.json | 12 +
.../securitygrouprule_created_cidr.json | 13 +
.../securitygrouprule_created_group.json | 14 +
.../src/test/resources/server_details.json | 86 +++
.../test/resources/server_details_devstack.json | 44 ++
.../resources/server_details_openstack.json | 46 ++
.../src/test/resources/server_diagnostics.json | 17 +
.../src/test/resources/server_list.json | 32 +
.../src/test/resources/server_list_details.json | 79 ++
.../resources/server_list_details_essex.json | 152 ++++
.../resources/server_public_ip_in_private.json | 51 ++
.../resources/server_with_security_groups.json | 1 +
.../server_with_security_groups_extension.json | 1 +
.../src/test/resources/simple_tenant_usage.json | 1 +
.../test/resources/simple_tenant_usages.json | 1 +
.../src/test/resources/snapshot_details.json | 1 +
.../src/test/resources/snapshot_list.json | 1 +
.../test/resources/snapshot_list_detail.json | 1 +
.../test/resources/virtual_interfaces_list.json | 1 +
.../src/test/resources/volume_details.json | 1 +
.../src/test/resources/volume_list.json | 1 +
.../src/test/resources/volume_list_detail.json | 1 +
.../src/test/resources/volume_type.json | 9 +
.../test/resources/volume_type_extra_specs.json | 1 +
.../src/test/resources/volume_type_list.json | 1 +
dependencies/pom.xml | 1 +
.../pom.xml | 8 +-
pom.xml | 2 +-
318 files changed, 34065 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/components/org.apache.stratos.cloud.controller/pom.xml
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/pom.xml b/components/org.apache.stratos.cloud.controller/pom.xml
index 73b67b4..c998706 100644
--- a/components/org.apache.stratos.cloud.controller/pom.xml
+++ b/components/org.apache.stratos.cloud.controller/pom.xml
@@ -196,7 +196,7 @@
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>openstack-nova</artifactId>
- <version>${jclouds.version}</version>
+ <version>${jclouds.stratos.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jclouds.api</groupId>
@@ -211,7 +211,7 @@
<dependency>
<groupId>org.apache.jclouds.api</groupId>
<artifactId>vcloud</artifactId>
- <version>${jclouds.vcloud.version}</version>
+ <version>${jclouds.stratos.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/README.txt
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/README.txt b/dependencies/jclouds/openstack-nova/1.7.1-stratos/README.txt
new file mode 100755
index 0000000..7162c0f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/README.txt
@@ -0,0 +1,3 @@
+#
+# The jclouds API for OpenStack Nova
+#
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/pom.xml
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/pom.xml b/dependencies/jclouds/openstack-nova/1.7.1-stratos/pom.xml
new file mode 100644
index 0000000..e022595
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/pom.xml
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-project</artifactId>
+ <version>1.7.1</version>
+ </parent>
+ <groupId>org.apache.jclouds.api</groupId>
+ <artifactId>openstack-nova</artifactId>
+ <version>1.7.1-stratos</version>
+ <name>jclouds openstack-nova api</name>
+ <description>jclouds components to access an implementation of OpenStack Nova</description>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <jclouds.version>1.7.1</jclouds.version>
+ <!-- keystone endpoint -->
+ <test.openstack-nova.endpoint>http://localhost:5000/v2.0/</test.openstack-nova.endpoint>
+ <!-- keystone version -->
+ <test.openstack-nova.api-version>1.1</test.openstack-nova.api-version>
+ <test.openstack-nova.build-version />
+ <test.openstack-nova.identity>FIXME_IDENTITY</test.openstack-nova.identity>
+ <test.openstack-nova.credential>FIXME_CREDENTIALS</test.openstack-nova.credential>
+ <test.openstack-nova.template />
+ <test.jclouds.openstack-nova.auto-allocate-floating-ips>false</test.jclouds.openstack-nova.auto-allocate-floating-ips>
+ <test.jclouds.keystone.credential-type>passwordCredentials</test.jclouds.keystone.credential-type>
+
+ <jclouds.osgi.export>org.jclouds.openstack.nova.v2_0*;version="${project.version}"</jclouds.osgi.export>
+ <jclouds.osgi.import>
+ org.jclouds.compute.internal;version="${jclouds.version}",
+ org.jclouds.rest.internal;version="${jclouds.version}",
+ org.jclouds*;version="${jclouds.version}",
+ *
+ </jclouds.osgi.import>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.jclouds.api</groupId>
+ <artifactId>openstack-keystone</artifactId>
+ <version>${jclouds.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-compute</artifactId>
+ <version>${jclouds.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-core</artifactId>
+ <version>${jclouds.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds.api</groupId>
+ <artifactId>openstack-keystone</artifactId>
+ <version>${jclouds.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds</groupId>
+ <artifactId>jclouds-compute</artifactId>
+ <version>${jclouds.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds.driver</groupId>
+ <artifactId>jclouds-sshj</artifactId>
+ <version>${jclouds.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jclouds.driver</groupId>
+ <artifactId>jclouds-slf4j</artifactId>
+ <version>${jclouds.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>live</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>integration</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <systemPropertyVariables>
+ <test.openstack-nova.endpoint>${test.openstack-nova.endpoint}</test.openstack-nova.endpoint>
+ <test.openstack-nova.api-version>${test.openstack-nova.api-version}</test.openstack-nova.api-version>
+ <test.openstack-nova.build-version>${test.openstack-nova.build-version}</test.openstack-nova.build-version>
+ <test.openstack-nova.identity>${test.openstack-nova.identity}</test.openstack-nova.identity>
+ <test.openstack-nova.credential>${test.openstack-nova.credential}</test.openstack-nova.credential>
+ <test.openstack-nova.template>${test.openstack-nova.template}</test.openstack-nova.template>
+ <test.jclouds.openstack-nova.auto-allocate-floating-ips>${test.jclouds.openstack-nova.auto-allocate-floating-ips}</test.jclouds.openstack-nova.auto-allocate-floating-ips>
+ <test.jclouds.keystone.credential-type>${test.jclouds.keystone.credential-type}</test.jclouds.keystone.credential-type>
+ </systemPropertyVariables>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java
new file mode 100644
index 0000000..b03727e
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java
@@ -0,0 +1,208 @@
+/*
+ * 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 java.io.Closeable;
+import java.util.Set;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.Zone;
+import org.jclouds.location.functions.ZoneToEndpoint;
+import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneAPI;
+import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsApi;
+import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi;
+import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationApi;
+import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateApi;
+import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
+import org.jclouds.openstack.nova.v2_0.extensions.QuotaApi;
+import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassApi;
+import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ServerAdminApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsApi;
+import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeAttachmentApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeApi;
+import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
+import org.jclouds.openstack.nova.v2_0.features.ImageApi;
+import org.jclouds.openstack.nova.v2_0.features.ServerApi;
+import org.jclouds.openstack.v2_0.features.ExtensionApi;
+import org.jclouds.rest.annotations.Delegate;
+import org.jclouds.rest.annotations.EndpointParam;
+
+import com.google.common.base.Optional;
+import com.google.inject.Provides;
+
+/**
+ * Provides synchronous access to Nova.
+ * <p/>
+ *
+ * @see NovaAsyncApi
+ * @see <a href="http://docs.openstack.org/api/openstack-compute/1.1/content/"
+ * />
+ * @author Adrian Cole
+ */
+public interface NovaApi extends Closeable {
+ /**
+ *
+ * @return the Zone codes configured
+ */
+ @Provides
+ @Zone
+ Set<String> getConfiguredZones();
+
+ /**
+ * Provides synchronous access to availability zone features
+ */
+ @Delegate
+ AvailabilityZoneAPI getAvailabilityZoneApi(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Server features.
+ */
+ @Delegate
+ ServerApi getServerApiForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Flavor features.
+ */
+ @Delegate
+ FlavorApi getFlavorApiForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Extension features.
+ */
+ @Delegate
+ ExtensionApi getExtensionApiForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Image features.
+ */
+ @Delegate
+ ImageApi getImageApiForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Floating IP features.
+ */
+ @Delegate
+ Optional<? extends FloatingIPApi> getFloatingIPExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Security Group features.
+ */
+ @Delegate
+ Optional<? extends SecurityGroupApi> getSecurityGroupExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Key Pair features.
+ */
+ @Delegate
+ Optional<? extends KeyPairApi> getKeyPairExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Host Administration features.
+ */
+ @Delegate
+ Optional<? extends HostAdministrationApi> getHostAdministrationExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Simple Tenant Usage features.
+ */
+ @Delegate
+ Optional<? extends SimpleTenantUsageApi> getSimpleTenantUsageExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Virtual Interface features.
+ */
+ @Delegate
+ Optional<? extends VirtualInterfaceApi> getVirtualInterfaceExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Server Extra Data features.
+ */
+ @Delegate
+ Optional<? extends ServerWithSecurityGroupsApi> getServerWithSecurityGroupsExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Server Admin Actions features.
+ */
+ @Delegate
+ Optional<? extends ServerAdminApi> getServerAdminExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Aggregate features.
+ */
+ @Delegate
+ Optional<? extends HostAggregateApi> getHostAggregateExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Flavor extra specs features.
+ */
+ @Delegate
+ Optional<? extends FlavorExtraSpecsApi> getFlavorExtraSpecsExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Quota features.
+ */
+ @Delegate
+ Optional<? extends QuotaApi> getQuotaExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Quota Classes features.
+ */
+ @Delegate
+ Optional<? extends QuotaClassApi> getQuotaClassExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Volume features.
+ */
+ @Delegate
+ Optional<? extends VolumeApi> getVolumeExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Volume Attachment features.
+ */
+ @Delegate
+ Optional<? extends VolumeAttachmentApi> getVolumeAttachmentExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides synchronous access to Volume Type features.
+ */
+ @Delegate
+ Optional<? extends VolumeTypeApi> getVolumeTypeExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java
new file mode 100644
index 0000000..ff87858
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java
@@ -0,0 +1,125 @@
+/*
+ * 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_SESSION_INTERVAL;
+import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.CREDENTIAL_TYPE;
+import static org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties.SERVICE_TYPE;
+import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.AUTO_ALLOCATE_FLOATING_IPS;
+import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.AUTO_GENERATE_KEYPAIRS;
+import static org.jclouds.openstack.nova.v2_0.config.NovaProperties.TIMEOUT_SECURITYGROUP_PRESENT;
+import static org.jclouds.reflect.Reflection2.typeToken;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
+import org.jclouds.openstack.keystone.v2_0.config.MappedAuthenticationApiModule;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule;
+import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaRestClientModule;
+import org.jclouds.openstack.v2_0.ServiceType;
+import org.jclouds.rest.internal.BaseRestApiMetadata;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.reflect.TypeToken;
+import com.google.inject.Module;
+
+/**
+ * Implementation of {@link ApiMetadata} for Nova 2.0 API
+ *
+ * @author Adrian Cole
+ */
+public class NovaApiMetadata extends BaseRestApiMetadata {
+
+ /**
+ * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(NovaApi.class)} as
+ * {@link NovaAsyncApi} interface will be removed in jclouds 1.7.
+ */
+ @Deprecated
+ public static final TypeToken<org.jclouds.rest.RestContext<NovaApi, NovaAsyncApi>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<NovaApi, NovaAsyncApi>>() {
+ private static final long serialVersionUID = 1L;
+ };
+
+ @Override
+ public Builder toBuilder() {
+ return new Builder().fromApiMetadata(this);
+ }
+
+ public NovaApiMetadata() {
+ this(new Builder());
+ }
+
+ protected NovaApiMetadata(Builder builder) {
+ super(builder);
+ }
+
+ public static Properties defaultProperties() {
+ Properties properties = BaseRestApiMetadata.defaultProperties();
+ // auth fail can happen while cloud-init applies keypair updates
+ properties.setProperty("jclouds.ssh.max-retries", "7");
+ properties.setProperty("jclouds.ssh.retry-auth", "true");
+ properties.setProperty(SERVICE_TYPE, ServiceType.COMPUTE);
+ properties.setProperty(CREDENTIAL_TYPE, CredentialTypes.PASSWORD_CREDENTIALS);
+ properties.setProperty(AUTO_ALLOCATE_FLOATING_IPS, "false");
+ properties.setProperty(AUTO_GENERATE_KEYPAIRS, "false");
+ properties.setProperty(TIMEOUT_SECURITYGROUP_PRESENT, "500");
+ // Keystone 1.1 expires tokens after 24 hours and allows renewal 1 hour
+ // before expiry by default. We choose a value less than the latter
+ // since the former persists between jclouds invocations.
+ properties.setProperty(PROPERTY_SESSION_INTERVAL, 30 * 60 + "");
+ return properties;
+ }
+
+ public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
+
+ @SuppressWarnings("deprecation")
+ protected Builder() {
+ super(NovaApi.class, NovaAsyncApi.class);
+ id("openstack-nova")
+ .name("OpenStack Nova Diablo+ API")
+ .identityName("${tenantName}:${userName} or ${userName}, if your keystone supports a default tenant")
+ .credentialName("${password}")
+ .endpointName("KeyStone base url ending in /v2.0/")
+ .documentation(URI.create("http://api.openstack.org/"))
+ .version("1.1")
+ .defaultEndpoint("http://localhost:5000/v2.0/")
+ .defaultProperties(NovaApiMetadata.defaultProperties())
+ .view(typeToken(ComputeServiceContext.class))
+ .defaultModules(ImmutableSet.<Class<? extends Module>>builder()
+ .add(MappedAuthenticationApiModule.class)
+ .add(KeystoneAuthenticationModule.class)
+ .add(ZoneModule.class)
+ .add(NovaParserModule.class)
+ .add(NovaRestClientModule.class)
+ .add(NovaComputeServiceContextModule.class).build());
+ }
+
+ @Override
+ public NovaApiMetadata build() {
+ return new NovaApiMetadata(this);
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaAsyncApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaAsyncApi.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaAsyncApi.java
new file mode 100644
index 0000000..9abea53
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaAsyncApi.java
@@ -0,0 +1,214 @@
+/*
+ * 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 java.io.Closeable;
+import java.util.Set;
+
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.location.Zone;
+import org.jclouds.location.functions.ZoneToEndpoint;
+import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneAPI;
+import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.KeyPairAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.QuotaAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ServerAdminAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeAttachmentAsyncApi;
+import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeAsyncApi;
+import org.jclouds.openstack.nova.v2_0.features.FlavorAsyncApi;
+import org.jclouds.openstack.nova.v2_0.features.ImageAsyncApi;
+import org.jclouds.openstack.nova.v2_0.features.ServerAsyncApi;
+import org.jclouds.openstack.v2_0.features.ExtensionAsyncApi;
+import org.jclouds.rest.annotations.Delegate;
+import org.jclouds.rest.annotations.EndpointParam;
+
+import com.google.common.base.Optional;
+import com.google.inject.Provides;
+
+/**
+ * Provides asynchronous access to Nova via their REST API.
+ * <p/>
+ *
+ * @see NovaApi
+ * @see <a href="http://docs.openstack.org/api/openstack-compute/1.1/content/"
+ * />
+ * @author Adrian Cole
+ * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(NovaApi.class)} as
+ * {@link NovaAsyncApi} interface will be removed in jclouds 1.7.
+ */
+@Deprecated
+public interface NovaAsyncApi extends Closeable {
+
+ /**
+ *
+ * @return the Zone codes configured
+ */
+ @Provides
+ @Zone
+ Set<String> getConfiguredZones();
+
+ /**
+ * Provides asynchronous access to availability zone features
+ */
+ @Delegate
+ AvailabilityZoneAPI getAvailabilityZoneApi(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Server features.
+ */
+ @Delegate
+ ServerAsyncApi getServerApiForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Flavor features.
+ */
+ @Delegate
+ FlavorAsyncApi getFlavorApiForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Extension features.
+ */
+ @Delegate
+ ExtensionAsyncApi getExtensionApiForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Image features.
+ */
+ @Delegate
+ ImageAsyncApi getImageApiForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Floating IP features.
+ */
+ @Delegate
+ Optional<? extends FloatingIPAsyncApi> getFloatingIPExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Security Group features.
+ */
+ @Delegate
+ Optional<? extends SecurityGroupAsyncApi> getSecurityGroupExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Key Pair features.
+ */
+ @Delegate
+ Optional<? extends KeyPairAsyncApi> getKeyPairExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Host Administration features.
+ */
+ @Delegate
+ Optional<? extends HostAdministrationAsyncApi> getHostAdministrationExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Simple Tenant Usage features.
+ */
+ @Delegate
+ Optional<? extends SimpleTenantUsageAsyncApi> getSimpleTenantUsageExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Virtual Interface features.
+ */
+ @Delegate
+ Optional<? extends VirtualInterfaceAsyncApi> getVirtualInterfaceExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+
+ /**
+ * Provides asynchronous access to Server Extra Data features.
+ */
+ @Delegate
+ Optional<? extends ServerWithSecurityGroupsAsyncApi> getServerWithSecurityGroupsExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Server Admin Actions features.
+ */
+ @Delegate
+ Optional<? extends ServerAdminAsyncApi> getServerAdminExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to HostAggregate features.
+ */
+ @Delegate
+ Optional<? extends HostAggregateAsyncApi> getHostAggregateExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Flavor extra specs features.
+ */
+ @Delegate
+ Optional<? extends FlavorExtraSpecsAsyncApi> getFlavorExtraSpecsExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Quota features.
+ */
+ @Delegate
+ Optional<? extends QuotaAsyncApi> getQuotaExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Quota Classes features.
+ */
+ @Delegate
+ Optional<? extends QuotaClassAsyncApi> getQuotaClassExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Volume features.
+ */
+ @Delegate
+ Optional<? extends VolumeAsyncApi> getVolumeExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Volume features.
+ */
+ @Delegate
+ Optional<? extends VolumeAttachmentAsyncApi> getVolumeAttachmentExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+ /**
+ * Provides asynchronous access to Volume Type features.
+ */
+ @Delegate
+ Optional<? extends VolumeTypeAsyncApi> getVolumeTypeExtensionForZone(
+ @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java
new file mode 100644
index 0000000..882eac6
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java
@@ -0,0 +1,47 @@
+/*
+ * 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.binders;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.json.Json;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSortedMap;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class BindKeyPairToJsonPayload extends BindToJsonPayload {
+
+ @Inject
+ public BindKeyPairToJsonPayload(Json jsonBinder) {
+ super(jsonBinder);
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ return bindToRequest(request, (Object) ImmutableMap.of("keypair", ImmutableSortedMap.copyOf(postParams)));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java
new file mode 100644
index 0000000..3cf29d7
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java
@@ -0,0 +1,47 @@
+/*
+ * 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.binders;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.json.Json;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+import com.google.common.collect.ImmutableMap;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Singleton
+public class BindMetadataToJsonPayload extends BindToJsonPayload {
+
+ @Inject
+ public BindMetadataToJsonPayload(Json jsonBinder) {
+ super(jsonBinder);
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ return bindToRequest(request,
+ (Object) ImmutableMap.of("metadata", ImmutableMap.of(postParams.get("key"), postParams.get("value"))));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java
new file mode 100644
index 0000000..cdd3df5
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java
@@ -0,0 +1,71 @@
+/*
+ * 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.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Predicates.instanceOf;
+import static com.google.common.collect.Iterables.find;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.json.Json;
+import org.jclouds.openstack.nova.v2_0.domain.Ingress;
+import org.jclouds.rest.MapBinder;
+import org.jclouds.rest.binders.BindToJsonPayload;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+
+/**
+ *
+ * @author Adrian Cole
+ *
+ */
+@Singleton
+public class BindSecurityGroupRuleToJsonPayload extends BindToJsonPayload implements MapBinder {
+ @Inject
+ public BindSecurityGroupRuleToJsonPayload(Json jsonBinder) {
+ super(jsonBinder);
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Object toBind) {
+ throw new IllegalStateException("BindCredentialsToJsonPayload needs parameters");
+ }
+
+ @Override
+ public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
+ Builder<String, Object> payload = ImmutableMap.builder();
+ payload.putAll(postParams);
+ checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
+ "this binder is only valid for GeneratedHttpRequests!");
+ GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
+
+ Ingress ingress = Ingress.class.cast(find(gRequest.getInvocation().getArgs(), instanceOf(Ingress.class)));
+ payload.put("ip_protocol", ingress.getIpProtocol().toString());
+ payload.put("from_port", ingress.getFromPort() + "");
+ payload.put("to_port", ingress.getToPort() + "");
+
+ return super.bindToRequest(request, ImmutableMap.of("security_group_rule", payload.build()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java
new file mode 100644
index 0000000..7a10942
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java
@@ -0,0 +1,183 @@
+/*
+ * 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 com.google.common.base.Preconditions.checkNotNull;
+import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
+import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
+import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_TERMINATED;
+import static org.jclouds.openstack.nova.v2_0.predicates.KeyPairPredicates.nameMatches;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.jclouds.Constants;
+import org.jclouds.collect.Memoized;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.compute.callables.RunScriptOnNode;
+import org.jclouds.compute.domain.Hardware;
+import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.domain.TemplateBuilder;
+import org.jclouds.compute.extensions.ImageExtension;
+import org.jclouds.compute.extensions.SecurityGroupExtension;
+import org.jclouds.compute.functions.GroupNamingConvention;
+import org.jclouds.compute.internal.BaseComputeService;
+import org.jclouds.compute.internal.PersistNodeCredentials;
+import org.jclouds.compute.options.TemplateOptions;
+import org.jclouds.compute.reference.ComputeServiceConstants.Timeouts;
+import org.jclouds.compute.strategy.CreateNodesInGroupThenAddToSet;
+import org.jclouds.compute.strategy.DestroyNodeStrategy;
+import org.jclouds.compute.strategy.GetImageStrategy;
+import org.jclouds.compute.strategy.GetNodeMetadataStrategy;
+import org.jclouds.compute.strategy.InitializeRunScriptOnNodeOrPlaceInBadMap;
+import org.jclouds.compute.strategy.ListNodesStrategy;
+import org.jclouds.compute.strategy.RebootNodeStrategy;
+import org.jclouds.compute.strategy.ResumeNodeStrategy;
+import org.jclouds.compute.strategy.SuspendNodeStrategy;
+import org.jclouds.domain.Credentials;
+import org.jclouds.domain.Location;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+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.SecurityGroup;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi;
+import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi;
+import org.jclouds.openstack.nova.v2_0.predicates.SecurityGroupPredicates;
+import org.jclouds.scriptbuilder.functions.InitAdminAccess;
+
+import com.google.common.base.Function;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Multimap;
+import com.google.common.util.concurrent.ListeningExecutorService;
+
+/**
+ * @author Adrian Cole
+ */
+@Singleton
+public class NovaComputeService extends BaseComputeService {
+ protected final NovaApi novaApi;
+ protected final LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupMap;
+ protected final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
+ protected final Function<Set<? extends NodeMetadata>, Multimap<String, String>> orphanedGroupsByZoneId;
+ protected final GroupNamingConvention.Factory namingConvention;
+
+ @Inject
+ protected NovaComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
+ @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
+ @Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
+ GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy,
+ CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy,
+ DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy,
+ SuspendNodeStrategy stopNodeStrategy, Provider<TemplateBuilder> templateBuilderProvider,
+ @Named("DEFAULT") Provider<TemplateOptions> templateOptionsProvider,
+ @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
+ @Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
+ @Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
+ InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
+ RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
+ PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
+ @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor, NovaApi novaApi,
+ LoadingCache<ZoneAndName, SecurityGroupInZone> securityGroupMap,
+ LoadingCache<ZoneAndName, KeyPair> keyPairCache,
+ Function<Set<? extends NodeMetadata>, Multimap<String, String>> orphanedGroupsByZoneId,
+ GroupNamingConvention.Factory namingConvention, Optional<ImageExtension> imageExtension,
+ Optional<SecurityGroupExtension> securityGroupExtension) {
+ super(context, credentialStore, images, sizes, locations, listNodesStrategy, getImageStrategy,
+ getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
+ startNodeStrategy, stopNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning,
+ nodeTerminated, nodeSuspended, initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory,
+ persistNodeCredentials, timeouts, userExecutor, imageExtension, securityGroupExtension);
+ this.novaApi = checkNotNull(novaApi, "novaApi");
+ this.securityGroupMap = checkNotNull(securityGroupMap, "securityGroupMap");
+ this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
+ this.orphanedGroupsByZoneId = checkNotNull(orphanedGroupsByZoneId, "orphanedGroupsByZoneId");
+ this.namingConvention = checkNotNull(namingConvention, "namingConvention");
+ }
+
+ @Override
+ protected void cleanUpIncidentalResourcesOfDeadNodes(Set<? extends NodeMetadata> deadNodes) {
+ Multimap<String, String> zoneToZoneAndGroupNames = orphanedGroupsByZoneId.apply(deadNodes);
+ for (Map.Entry<String, Collection<String>> entry : zoneToZoneAndGroupNames.asMap().entrySet()) {
+ cleanOrphanedGroupsInZone(ImmutableSet.copyOf(entry.getValue()), entry.getKey());
+ }
+ }
+
+ protected void cleanOrphanedGroupsInZone(Set<String> groups, String zoneId) {
+ cleanupOrphanedSecurityGroupsInZone(groups, zoneId);
+ cleanupOrphanedKeyPairsInZone(groups, zoneId);
+ }
+
+ private void cleanupOrphanedSecurityGroupsInZone(Set<String> groups, String zoneId) {
+ Optional<? extends SecurityGroupApi> securityGroupApi = novaApi.getSecurityGroupExtensionForZone(zoneId);
+ if (securityGroupApi.isPresent()) {
+ for (String group : groups) {
+ for (SecurityGroup securityGroup : Iterables.filter(securityGroupApi.get().list(),
+ SecurityGroupPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
+ ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, securityGroup.getName());
+ logger.debug(">> deleting securityGroup(%s)", zoneAndName);
+ securityGroupApi.get().delete(securityGroup.getId());
+ // TODO: test this clear happens
+ securityGroupMap.invalidate(zoneAndName);
+ logger.debug("<< deleted securityGroup(%s)", zoneAndName);
+ }
+ }
+ }
+ }
+
+ private void cleanupOrphanedKeyPairsInZone(Set<String> groups, String zoneId) {
+ Optional<? extends KeyPairApi> keyPairApi = novaApi.getKeyPairExtensionForZone(zoneId);
+ if (keyPairApi.isPresent()) {
+ for (String group : groups) {
+ for (KeyPair pair : keyPairApi.get().list().filter(nameMatches(namingConvention.create().containsGroup(group)))) {
+ ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, pair.getName());
+ logger.debug(">> deleting keypair(%s)", zoneAndName);
+ keyPairApi.get().delete(pair.getName());
+ // TODO: test this clear happens
+ keyPairCache.invalidate(zoneAndName);
+ logger.debug("<< deleted keypair(%s)", zoneAndName);
+ }
+ keyPairCache.invalidate(ZoneAndName.fromZoneAndName(zoneId,
+ namingConvention.create().sharedNameForGroup(group)));
+ }
+ }
+ }
+
+ /**
+ * returns template options, except of type {@link NovaTemplateOptions}.
+ */
+ @Override
+ public NovaTemplateOptions templateOptions() {
+ return NovaTemplateOptions.class.cast(super.templateOptions());
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/d4243b7e/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java
new file mode 100644
index 0000000..e4ceade
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java
@@ -0,0 +1,286 @@
+/*
+ * 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 com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.collect.Iterables.contains;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.collect.Iterables.transform;
+import static org.jclouds.compute.util.ComputeServiceUtils.metadataAndTagsAsCommaDelimitedValue;
+
+import java.util.Set;
+
+import javax.annotation.Resource;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jclouds.compute.ComputeServiceAdapter;
+import org.jclouds.compute.domain.Template;
+import org.jclouds.compute.reference.ComputeServiceConstants;
+import org.jclouds.domain.Location;
+import org.jclouds.domain.LoginCredentials;
+import org.jclouds.location.Zone;
+import org.jclouds.logging.Logger;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.compute.functions.RemoveFloatingIpFromNodeAndDeallocate;
+import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions;
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
+import org.jclouds.openstack.nova.v2_0.domain.RebootType;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.FlavorInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ImageInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions;
+import org.jclouds.openstack.nova.v2_0.predicates.ImagePredicates;
+
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSet.Builder;
+
+/**
+ * The adapter used by the NovaComputeServiceContextModule to interface the nova-specific domain
+ * model to the computeService generic domain model.
+ *
+ * @author Matt Stephenson, Adrian Cole
+ */
+public class NovaComputeServiceAdapter implements
+ ComputeServiceAdapter<ServerInZone, FlavorInZone, ImageInZone, Location> {
+
+ @Resource
+ @Named(ComputeServiceConstants.COMPUTE_LOGGER)
+ protected Logger logger = Logger.NULL;
+
+ protected final NovaApi novaApi;
+ protected final Supplier<Set<String>> zoneIds;
+ protected final RemoveFloatingIpFromNodeAndDeallocate removeFloatingIpFromNodeAndDeallocate;
+ protected final LoadingCache<ZoneAndName, KeyPair> keyPairCache;
+
+ @Inject
+ public NovaComputeServiceAdapter(NovaApi novaApi, @Zone Supplier<Set<String>> zoneIds,
+ RemoveFloatingIpFromNodeAndDeallocate removeFloatingIpFromNodeAndDeallocate,
+ LoadingCache<ZoneAndName, KeyPair> keyPairCache) {
+ this.novaApi = checkNotNull(novaApi, "novaApi");
+ this.zoneIds = checkNotNull(zoneIds, "zoneIds");
+ this.removeFloatingIpFromNodeAndDeallocate = checkNotNull(removeFloatingIpFromNodeAndDeallocate,
+ "removeFloatingIpFromNodeAndDeallocate");
+ this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache");
+ }
+
+ /**
+ * Note that we do not validate extensions here, on basis that
+ * {@link ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet} has already
+ * done so.
+ */
+ @Override
+ public NodeAndInitialCredentials<ServerInZone> createNodeWithGroupEncodedIntoName(String group, String name,
+ Template template) {
+
+ LoginCredentials.Builder credentialsBuilder = LoginCredentials.builder();
+ NovaTemplateOptions templateOptions = template.getOptions().as(NovaTemplateOptions.class);
+
+ CreateServerOptions options = new CreateServerOptions();
+ options.metadata(metadataAndTagsAsCommaDelimitedValue(template.getOptions()));
+ if (templateOptions.getSecurityGroupNames().isPresent())
+ options.securityGroupNames(templateOptions.getSecurityGroupNames().get());
+ options.userData(templateOptions.getUserData());
+ options.diskConfig(templateOptions.getDiskConfig());
+ options.configDrive(templateOptions.getConfigDrive());
+ if (templateOptions.getNovaNetworks() != null) {
+ options.novaNetworks(templateOptions.getNovaNetworks());
+ }
+ if (templateOptions.getNetworks() != null) {
+ options.networks(templateOptions.getNetworks());
+ }
+
+ Optional<String> privateKey = Optional.absent();
+ if (templateOptions.getKeyPairName() != null) {
+ options.keyPairName(templateOptions.getKeyPairName());
+ KeyPair keyPair = keyPairCache.getIfPresent(ZoneAndName.fromZoneAndName(template.getLocation().getId(), templateOptions.getKeyPairName()));
+ if (keyPair != null && keyPair.getPrivateKey() != null) {
+ privateKey = Optional.of(keyPair.getPrivateKey());
+ credentialsBuilder.privateKey(privateKey.get());
+ }
+ }
+
+ String zoneId = template.getLocation().getId();
+ String imageId = template.getImage().getProviderId();
+ String flavorId = template.getHardware().getProviderId();
+
+ logger.debug(">> creating new server zone(%s) name(%s) image(%s) flavor(%s) options(%s)", zoneId, name, imageId, flavorId, options);
+ ServerCreated lightweightServer = novaApi.getServerApiForZone(zoneId).create(name, imageId, flavorId, options);
+ Server server = novaApi.getServerApiForZone(zoneId).get(lightweightServer.getId());
+
+ logger.trace("<< server(%s)", server.getId());
+
+ ServerInZone serverInZone = new ServerInZone(server, zoneId);
+ if (!privateKey.isPresent() && lightweightServer.getAdminPass().isPresent())
+ credentialsBuilder.password(lightweightServer.getAdminPass().get());
+ return new NodeAndInitialCredentials<ServerInZone>(serverInZone, serverInZone.slashEncode(), credentialsBuilder
+ .build());
+ }
+
+ @Override
+ public Iterable<FlavorInZone> listHardwareProfiles() {
+ Builder<FlavorInZone> builder = ImmutableSet.builder();
+ for (final String zoneId : zoneIds.get()) {
+ builder.addAll(transform(novaApi.getFlavorApiForZone(zoneId).listInDetail().concat(),
+ new Function<Flavor, FlavorInZone>() {
+
+ @Override
+ public FlavorInZone apply(Flavor arg0) {
+ return new FlavorInZone(arg0, zoneId);
+ }
+
+ }));
+ }
+ return builder.build();
+ }
+
+ @Override
+ public Iterable<ImageInZone> listImages() {
+ Builder<ImageInZone> builder = ImmutableSet.builder();
+ Set<String> zones = zoneIds.get();
+ checkState(zones.size() > 0, "no zones found in supplier %s", zoneIds);
+ for (final String zoneId : zones) {
+ Set<? extends Image> images = novaApi.getImageApiForZone(zoneId).listInDetail().concat().toSet();
+ if (images.size() == 0) {
+ logger.debug("no images found in zone %s", zoneId);
+ continue;
+ }
+ Iterable<? extends Image> active = filter(images, ImagePredicates.statusEquals(Image.Status.ACTIVE));
+ if (images.size() == 0) {
+ logger.debug("no images with status active in zone %s; non-active: %s", zoneId,
+ transform(active, new Function<Image, String>() {
+
+ @Override
+ public String apply(Image input) {
+ return Objects.toStringHelper("").add("id", input.getId()).add("status", input.getStatus())
+ .toString();
+ }
+
+ }));
+ continue;
+ }
+ builder.addAll(transform(active, new Function<Image, ImageInZone>() {
+
+ @Override
+ public ImageInZone apply(Image arg0) {
+ return new ImageInZone(arg0, zoneId);
+ }
+
+ }));
+ }
+ return builder.build();
+ }
+
+ @Override
+ public Iterable<ServerInZone> listNodes() {
+ Builder<ServerInZone> builder = ImmutableSet.builder();
+ for (final String zoneId : zoneIds.get()) {
+ builder.addAll(novaApi.getServerApiForZone(zoneId).listInDetail().concat()
+ .transform(new Function<Server, ServerInZone>() {
+
+ @Override
+ public ServerInZone apply(Server arg0) {
+ return new ServerInZone(arg0, zoneId);
+ }
+
+ }));
+ }
+ return builder.build();
+ }
+
+ @Override
+ public Iterable<ServerInZone> listNodesByIds(final Iterable<String> ids) {
+ return filter(listNodes(), new Predicate<ServerInZone>() {
+
+ @Override
+ public boolean apply(ServerInZone server) {
+ return contains(ids, server.slashEncode());
+ }
+ });
+ }
+
+ @Override
+ public Iterable<Location> listLocations() {
+ // locations provided by keystone
+ return ImmutableSet.of();
+ }
+
+ @Override
+ public ServerInZone getNode(String id) {
+ ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
+ Server server = novaApi.getServerApiForZone(zoneAndId.getZone()).get(zoneAndId.getId());
+ return server == null ? null : new ServerInZone(server, zoneAndId.getZone());
+ }
+
+ @Override
+ public ImageInZone getImage(String id) {
+ ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
+ Image image = novaApi.getImageApiForZone(zoneAndId.getZone()).get(zoneAndId.getId());
+ return image == null ? null : new ImageInZone(image, zoneAndId.getZone());
+ }
+
+ @Override
+ public void destroyNode(String id) {
+ ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
+ if (novaApi.getFloatingIPExtensionForZone(zoneAndId.getZone()).isPresent()) {
+ try {
+ removeFloatingIpFromNodeAndDeallocate.apply(zoneAndId);
+ } catch (RuntimeException e) {
+ logger.warn(e, "<< error removing and deallocating ip from node(%s): %s", id, e.getMessage());
+ }
+ }
+ novaApi.getServerApiForZone(zoneAndId.getZone()).delete(zoneAndId.getId());
+ }
+
+ @Override
+ public void rebootNode(String id) {
+ ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
+ novaApi.getServerApiForZone(zoneAndId.getZone()).reboot(zoneAndId.getId(), RebootType.HARD);
+ }
+
+ @Override
+ public void resumeNode(String id) {
+ ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
+ if (novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).isPresent()) {
+ novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).get().resume(zoneAndId.getId());
+ }
+ throw new UnsupportedOperationException("resume requires installation of the Admin Actions extension");
+ }
+
+ @Override
+ public void suspendNode(String id) {
+ ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id);
+ if (novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).isPresent()) {
+ novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).get().suspend(zoneAndId.getId());
+ }
+ throw new UnsupportedOperationException("suspend requires installation of the Admin Actions extension");
+ }
+
+}
[06/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
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/extensions/VolumeApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiLiveTest.java
new file mode 100644
index 0000000..a7f14ad
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiLiveTest.java
@@ -0,0 +1,274 @@
+/*
+ * 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.extensions;
+
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.openstack.nova.v2_0.domain.Volume;
+import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment;
+import org.jclouds.openstack.nova.v2_0.domain.VolumeSnapshot;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.jclouds.openstack.nova.v2_0.options.CreateVolumeOptions;
+import org.jclouds.openstack.nova.v2_0.options.CreateVolumeSnapshotOptions;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests behavior of VolumeApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "live", testName = "VolumeApiLiveTest", singleThreaded = true)
+public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
+
+ private Optional<? extends VolumeApi> volumeOption;
+ private String zone;
+
+ private Volume testVolume;
+ private VolumeSnapshot testSnapshot;
+
+ @BeforeClass(groups = {"integration", "live"})
+ @Override
+ public void setup() {
+ super.setup();
+ zone = Iterables.getLast(api.getConfiguredZones(), "nova");
+ volumeOption = api.getVolumeExtensionForZone(zone);
+ }
+
+ @AfterClass(groups = { "integration", "live" })
+ @Override
+ protected void tearDown() {
+ if (volumeOption.isPresent()) {
+ if (testSnapshot != null) {
+ final String snapshotId = testSnapshot.getId();
+ assertTrue(volumeOption.get().deleteSnapshot(snapshotId));
+ assertTrue(retry(new Predicate<VolumeApi>() {
+ public boolean apply(VolumeApi volumeApi) {
+ return volumeOption.get().getSnapshot(snapshotId) == null;
+ }
+ }, 30 * 1000L).apply(volumeOption.get()));
+ }
+ if (testVolume != null) {
+ final String volumeId = testVolume.getId();
+ assertTrue(volumeOption.get().delete(volumeId));
+ assertTrue(retry(new Predicate<VolumeApi>() {
+ public boolean apply(VolumeApi volumeApi) {
+ return volumeOption.get().get(volumeId) == null;
+ }
+ }, 180 * 1000L).apply(volumeOption.get()));
+ }
+ }
+ super.tearDown();
+ }
+
+ public void testCreateVolume() {
+ if (volumeOption.isPresent()) {
+ testVolume = volumeOption.get().create(
+ 1,
+ CreateVolumeOptions.Builder.name("jclouds-test-volume").description("description of test volume")
+ .availabilityZone(zone));
+ assertTrue(retry(new Predicate<VolumeApi>() {
+ public boolean apply(VolumeApi volumeApi) {
+ return volumeOption.get().get(testVolume.getId()).getStatus() == Volume.Status.AVAILABLE;
+ }
+ }, 180 * 1000L).apply(volumeOption.get()));
+ }
+ }
+
+ @Test(dependsOnMethods = "testCreateVolume")
+ public void testListVolumes() {
+ if (volumeOption.isPresent()) {
+ Set<? extends Volume> volumes = volumeOption.get().list().toSet();
+ assertNotNull(volumes);
+ boolean foundIt = false;
+ for (Volume vol : volumes) {
+ Volume details = volumeOption.get().get(vol.getId());
+ assertNotNull(details);
+ if (Objects.equal(details.getId(), testVolume.getId())) {
+ foundIt = true;
+ }
+ }
+ assertTrue(foundIt, "Failed to find the volume we created in list() response");
+ }
+ }
+
+ @Test(dependsOnMethods = "testCreateVolume")
+ public void testListVolumesInDetail() {
+ if (volumeOption.isPresent()) {
+ Set<? extends Volume> volumes = volumeOption.get().listInDetail().toSet();
+ assertNotNull(volumes);
+ boolean foundIt = false;
+ for (Volume vol : volumes) {
+ Volume details = volumeOption.get().get(vol.getId());
+ assertNotNull(details);
+ assertNotNull(details.getId());
+ assertNotNull(details.getCreated());
+ assertTrue(details.getSize() > -1);
+
+ assertEquals(details.getId(), vol.getId());
+ assertEquals(details.getSize(), vol.getSize());
+ assertEquals(details.getName(), vol.getName());
+ assertEquals(details.getDescription(), vol.getDescription());
+ assertEquals(details.getCreated(), vol.getCreated());
+ if (Objects.equal(details.getId(), testVolume.getId())) {
+ foundIt = true;
+ }
+ }
+ assertTrue(foundIt, "Failed to find the volume we previously created in listInDetail() response");
+ }
+ }
+
+ @Test(dependsOnMethods = "testCreateVolume")
+ public void testCreateSnapshot() {
+ if (volumeOption.isPresent()) {
+ testSnapshot = volumeOption.get().createSnapshot(
+ testVolume.getId(),
+ CreateVolumeSnapshotOptions.Builder.name("jclouds-live-test").description(
+ "jclouds live test snapshot").force());
+ assertNotNull(testSnapshot);
+ assertNotNull(testSnapshot.getId());
+ final String snapshotId = testSnapshot.getId();
+ assertNotNull(testSnapshot.getStatus());
+ assertTrue(testSnapshot.getSize() > -1);
+ assertNotNull(testSnapshot.getCreated());
+
+ assertTrue(retry(new Predicate<VolumeApi>() {
+ public boolean apply(VolumeApi volumeApi) {
+ return volumeOption.get().getSnapshot(snapshotId).getStatus() == Volume.Status.AVAILABLE;
+ }
+ }, 30 * 1000L).apply(volumeOption.get()));
+ }
+ }
+
+ @Test(dependsOnMethods = "testCreateSnapshot")
+ public void testListSnapshots() {
+ if (volumeOption.isPresent()) {
+ Set<? extends VolumeSnapshot> snapshots = volumeOption.get().listSnapshots().toSet();
+ assertNotNull(snapshots);
+ boolean foundIt = false;
+ for (VolumeSnapshot snap : snapshots) {
+ VolumeSnapshot details = volumeOption.get().getSnapshot(snap.getId());
+ if (Objects.equal(snap.getVolumeId(), testVolume.getId())) {
+ foundIt = true;
+ }
+ assertNotNull(details);
+ assertEquals(details.getId(), snap.getId());
+ assertEquals(details.getVolumeId(), snap.getVolumeId());
+ }
+ assertTrue(foundIt, "Failed to find the snapshot we previously created in listSnapshots() response");
+ }
+ }
+
+ @Test(dependsOnMethods = "testCreateSnapshot")
+ public void testListSnapshotsInDetail() {
+ if (volumeOption.isPresent()) {
+ Set<? extends VolumeSnapshot> snapshots = volumeOption.get().listSnapshotsInDetail().toSet();
+ assertNotNull(snapshots);
+ boolean foundIt = false;
+ for (VolumeSnapshot snap : snapshots) {
+ VolumeSnapshot details = volumeOption.get().getSnapshot(snap.getId());
+ if (Objects.equal(snap.getVolumeId(), testVolume.getId())) {
+ foundIt = true;
+ assertSame(details, testSnapshot);
+ }
+ assertSame(details, snap);
+ }
+
+ assertTrue(foundIt, "Failed to find the snapshot we created in listSnapshotsInDetail() response");
+ }
+ }
+
+ private void assertSame(VolumeSnapshot a, VolumeSnapshot b) {
+ assertNotNull(a);
+ assertNotNull(b);
+ assertEquals(a.getId(), b.getId());
+ assertEquals(a.getDescription(), b.getDescription());
+ assertEquals(a.getName(), b.getName());
+ assertEquals(a.getVolumeId(), b.getVolumeId());
+ }
+
+ @Test(dependsOnMethods = "testCreateVolume")
+ public void testAttachments() {
+ if (volumeOption.isPresent()) {
+ String server_id = null;
+ try {
+ final String serverId = server_id = createServerInZone(zone).getId();
+
+ Set<? extends VolumeAttachment> attachments = volumeOption.get().listAttachmentsOnServer(serverId).toSet();
+ assertNotNull(attachments);
+ final int before = attachments.size();
+
+ VolumeAttachment testAttachment = volumeOption.get().attachVolumeToServerAsDevice(testVolume.getId(),
+ serverId, "/dev/vdf");
+ assertNotNull(testAttachment.getId());
+ assertEquals(testAttachment.getVolumeId(), testVolume.getId());
+
+ assertTrue(retry(new Predicate<VolumeApi>() {
+ public boolean apply(VolumeApi volumeApi) {
+ return volumeOption.get().listAttachmentsOnServer(serverId).size() > before;
+ }
+ }, 60 * 1000L).apply(volumeOption.get()));
+
+ attachments = volumeOption.get().listAttachmentsOnServer(serverId).toSet();
+ assertNotNull(attachments);
+ assertEquals(attachments.size(), before + 1);
+
+ assertEquals(volumeOption.get().get(testVolume.getId()).getStatus(), Volume.Status.IN_USE);
+
+ boolean foundIt = false;
+ for (VolumeAttachment att : attachments) {
+ VolumeAttachment details = volumeOption.get()
+ .getAttachmentForVolumeOnServer(att.getVolumeId(), serverId);
+ assertNotNull(details);
+ assertNotNull(details.getId());
+ assertNotNull(details.getServerId());
+ assertNotNull(details.getVolumeId());
+ if (Objects.equal(details.getVolumeId(), testVolume.getId())) {
+ foundIt = true;
+ assertEquals(details.getDevice(), "/dev/vdf");
+ assertEquals(details.getServerId(), serverId);
+ }
+ }
+
+ assertTrue(foundIt, "Failed to find the attachment we created in listAttachments() response");
+
+ volumeOption.get().detachVolumeFromServer(testVolume.getId(), serverId);
+ assertTrue(retry(new Predicate<VolumeApi>() {
+ public boolean apply(VolumeApi volumeApi) {
+ return volumeOption.get().listAttachmentsOnServer(serverId).size() == before;
+ }
+ }, 60 * 1000L).apply(volumeOption.get()));
+
+ } finally {
+ if (server_id != null)
+ api.getServerApiForZone(zone).delete(server_id);
+ }
+
+ }
+ }
+}
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/extensions/VolumeAttachmentApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiExpectTest.java
new file mode 100644
index 0000000..1b4857d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiExpectTest.java
@@ -0,0 +1,168 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.DateService;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.domain.Volume;
+import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests VolumeAttachmentApi Guice wiring and parsing
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "VolumeAttachmentApiExpectTest")
+public class VolumeAttachmentApiExpectTest extends BaseNovaApiExpectTest {
+ private DateService dateService = new SimpleDateFormatDateService();
+
+ public void testListAttachments() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments");
+ VolumeAttachmentApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/attachment_list.json")).build()
+ ).getVolumeAttachmentExtensionForZone("az-1.region-a.geo-1").get();
+
+ Set<? extends VolumeAttachment> attachments = api.listAttachmentsOnServer("instance-1").toSet();
+ assertEquals(attachments, ImmutableSet.of(testAttachment()));
+ // double-check individual fields
+ VolumeAttachment attachment = Iterables.getOnlyElement(attachments);
+ assertEquals(attachment.getDevice(), "/dev/vdc");
+ assertEquals(attachment.getServerId(), "b4785058-cb80-491b-baa3-e4ee6546450e");
+ assertEquals(attachment.getId(), "1");
+ assertEquals(attachment.getVolumeId(), "1");
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testListAttachmentsFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-2/os-volume_attachments");
+ VolumeAttachmentApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(401).build()
+ ).getVolumeAttachmentExtensionForZone("az-1.region-a.geo-1").get();
+
+ api.listAttachmentsOnServer("instance-2");
+ }
+
+ public void testGetAttachment() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1");
+ VolumeAttachmentApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/attachment_details.json")).build()
+ ).getVolumeAttachmentExtensionForZone("az-1.region-a.geo-1").get();
+
+ VolumeAttachment attachment = api.getAttachmentForVolumeOnServer("1", "instance-1");
+ assertEquals(attachment, testAttachment());
+ }
+
+ public void testGetAttachmentFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1");
+ VolumeAttachmentApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeAttachmentExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertNull(api.getAttachmentForVolumeOnServer("1", "instance-1"));
+ }
+
+ public void testAttachVolume() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments");
+ VolumeAttachmentApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("POST")
+ .payload(payloadFromStringWithContentType("{\"volumeAttachment\":{\"volumeId\":\"1\",\"device\":\"/dev/vdc\"}}", MediaType.APPLICATION_JSON)).endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/attachment_details.json")).build()
+ ).getVolumeAttachmentExtensionForZone("az-1.region-a.geo-1").get();
+
+ VolumeAttachment result = api.attachVolumeToServerAsDevice("1", "instance-1", "/dev/vdc");
+ assertEquals(result, testAttachment());
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testAttachVolumeFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments");
+ VolumeAttachmentApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("POST")
+ .payload(payloadFromStringWithContentType("{\"volumeAttachment\":{\"volumeId\":\"1\",\"device\":\"/dev/vdc\"}}", MediaType.APPLICATION_JSON)).endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeAttachmentExtensionForZone("az-1.region-a.geo-1").get();
+
+ api.attachVolumeToServerAsDevice("1", "instance-1","/dev/vdc");
+ }
+
+ public void testDetachVolume() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1");
+ VolumeAttachmentApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/attachment_details.json")).build()
+ ).getVolumeAttachmentExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.detachVolumeFromServer("1", "instance-1"));
+ }
+
+ public void testDetachVolumeFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1");
+ VolumeAttachmentApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeAttachmentExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.detachVolumeFromServer("1", "instance-1"));
+ }
+
+ protected Volume testVolume() {
+ return Volume.builder().status(Volume.Status.IN_USE).description("This is a test volume").zone("nova").name("test")
+ .attachments(ImmutableSet.of(testAttachment())).size(1).id("1").created(dateService.iso8601SecondsDateParse("2012-04-23 12:16:45")).build();
+ }
+
+ protected VolumeAttachment testAttachment() {
+ return VolumeAttachment.builder().device("/dev/vdc").serverId("b4785058-cb80-491b-baa3-e4ee6546450e").id("1").volumeId("1").build();
+ }
+}
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/extensions/VolumeAttachmentApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiLiveTest.java
new file mode 100644
index 0000000..cc853d8
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiLiveTest.java
@@ -0,0 +1,156 @@
+/*
+ * 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.extensions;
+
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.openstack.nova.v2_0.domain.Volume;
+import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.jclouds.openstack.nova.v2_0.options.CreateVolumeOptions;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests behavior of Volume Attachment API
+ *
+ * @author Everett Toews
+ */
+@Test(groups = "live", testName = "VolumeAttachmentApiLiveTest", singleThreaded = true)
+public class VolumeAttachmentApiLiveTest extends BaseNovaApiLiveTest {
+
+ private Optional<? extends VolumeApi> volumeApi;
+ private Optional<? extends VolumeAttachmentApi> volumeAttachmentApi;
+
+ private String zone;
+ private Volume testVolume;
+
+ @BeforeClass(groups = {"integration", "live"})
+ @Override
+ public void setup() {
+ super.setup();
+ zone = Iterables.getLast(api.getConfiguredZones(), "nova");
+ volumeApi = api.getVolumeExtensionForZone(zone);
+ volumeAttachmentApi = api.getVolumeAttachmentExtensionForZone(zone);
+ }
+
+ @AfterClass(groups = { "integration", "live" })
+ @Override
+ protected void tearDown() {
+ if (volumeApi.isPresent()) {
+ if (testVolume != null) {
+ final String volumeId = testVolume.getId();
+ assertTrue(volumeApi.get().delete(volumeId));
+ assertTrue(retry(new Predicate<VolumeApi>() {
+ public boolean apply(VolumeApi volumeApi) {
+ return volumeApi.get(volumeId) == null;
+ }
+ }, 180 * 1000L).apply(volumeApi.get()));
+ }
+ }
+
+ super.tearDown();
+ }
+
+ public void testCreateVolume() {
+ if (volumeApi.isPresent()) {
+ CreateVolumeOptions options = CreateVolumeOptions.Builder
+ .name("jclouds-test-volume")
+ .description("description of test volume")
+ .availabilityZone(zone);
+
+ testVolume = volumeApi.get().create(1, options);
+ assertTrue(retry(new Predicate<VolumeApi>() {
+ public boolean apply(VolumeApi volumeApi) {
+ return volumeApi.get(testVolume.getId()).getStatus() == Volume.Status.AVAILABLE;
+ }
+ }, 180 * 1000L).apply(volumeApi.get()));
+ }
+ }
+
+ @Test(dependsOnMethods = "testCreateVolume")
+ public void testAttachments() {
+ if (volumeApi.isPresent()) {
+ String server_id = null;
+ try {
+ final String serverId = server_id = createServerInZone(zone).getId();
+
+ Set<? extends VolumeAttachment> attachments =
+ volumeAttachmentApi.get().listAttachmentsOnServer(serverId).toSet();
+ assertNotNull(attachments);
+ final int before = attachments.size();
+
+ VolumeAttachment testAttachment = volumeAttachmentApi.get().attachVolumeToServerAsDevice(
+ testVolume.getId(), serverId, "/dev/vdf");
+ assertNotNull(testAttachment.getId());
+ assertEquals(testAttachment.getVolumeId(), testVolume.getId());
+
+ assertTrue(retry(new Predicate<VolumeAttachmentApi>() {
+ public boolean apply(VolumeAttachmentApi volumeAttachmentApi) {
+ return volumeAttachmentApi.listAttachmentsOnServer(serverId).size() > before;
+ }
+ }, 60 * 1000L).apply(volumeAttachmentApi.get()));
+
+ attachments = volumeAttachmentApi.get().listAttachmentsOnServer(serverId).toSet();
+ assertNotNull(attachments);
+ assertEquals(attachments.size(), before + 1);
+
+ assertEquals(volumeApi.get().get(testVolume.getId()).getStatus(), Volume.Status.IN_USE);
+
+ boolean foundIt = false;
+ for (VolumeAttachment att : attachments) {
+ VolumeAttachment details = volumeAttachmentApi.get()
+ .getAttachmentForVolumeOnServer(att.getVolumeId(), serverId);
+ assertNotNull(details);
+ assertNotNull(details.getId());
+ assertNotNull(details.getServerId());
+ assertNotNull(details.getVolumeId());
+ if (Objects.equal(details.getVolumeId(), testVolume.getId())) {
+ foundIt = true;
+ assertEquals(details.getDevice(), "/dev/vdf");
+ assertEquals(details.getServerId(), serverId);
+ }
+ }
+
+ assertTrue(foundIt, "Failed to find the attachment we created in listAttachments() response");
+
+ volumeAttachmentApi.get().detachVolumeFromServer(testVolume.getId(), serverId);
+ assertTrue(retry(new Predicate<VolumeAttachmentApi>() {
+ public boolean apply(VolumeAttachmentApi volumeAttachmentApi) {
+ return volumeAttachmentApi.listAttachmentsOnServer(serverId).size() == before;
+ }
+ }, 60 * 1000L).apply(volumeAttachmentApi.get()));
+
+ } finally {
+ if (server_id != null)
+ api.getServerApiForZone(zone).delete(server_id);
+ }
+
+ }
+ }
+}
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/extensions/VolumeTypeApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiExpectTest.java
new file mode 100644
index 0000000..36d8d0f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiExpectTest.java
@@ -0,0 +1,259 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.DateService;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.domain.VolumeType;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.options.CreateVolumeTypeOptions;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests guice wiring and parsing of VolumeTypeApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "VolumeTypeApiExpectTest")
+public class VolumeTypeApiExpectTest extends BaseNovaApiExpectTest {
+ private DateService dateService = new SimpleDateFormatDateService();
+
+ public void testListVolumeTypes() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_type_list.json")).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ Set<? extends VolumeType> types = api.list().toSet();
+ assertEquals(types, ImmutableSet.of(testVolumeType()));
+ }
+
+ public void testGetVolumeType() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/8");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_type.json")).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ VolumeType type = api.get("8");
+ assertEquals(type, testVolumeType());
+ }
+
+ public void testGetVolumeTypeFailNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/8");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertNull(api.get("8"));
+ }
+
+ public void testCreateVolumeType() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("POST")
+ .payload(payloadFromStringWithContentType("{\"volume_type\":{\"name\":\"jclouds-test-1\"}}", MediaType.APPLICATION_JSON))
+ .build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_type.json")).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ VolumeType type = api.create("jclouds-test-1");
+ assertEquals(type, testVolumeType());
+ }
+
+ public void testCreateVolumeTypeWithOptsNONE() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("POST")
+ .payload(payloadFromStringWithContentType("{\"volume_type\":{\"name\":\"jclouds-test-1\",\"extra_specs\":{}}}", MediaType.APPLICATION_JSON))
+ .build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_type.json")).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ VolumeType type = api.create("jclouds-test-1", CreateVolumeTypeOptions.NONE);
+ assertEquals(type, testVolumeType());
+ }
+
+ public void testCreateVolumeTypeWithOptsSet() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("POST")
+ .payload(payloadFromStringWithContentType("{\"volume_type\":{\"name\":\"jclouds-test-1\",\"extra_specs\":{\"x\": \"y\"}}}", MediaType.APPLICATION_JSON))
+ .build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_type.json")).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ VolumeType type = api.create("jclouds-test-1", CreateVolumeTypeOptions.Builder.specs(ImmutableMap.of("x", "y")));
+ assertEquals(type, testVolumeType());
+ }
+
+ public void testDeleteVolumeType() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/8");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(200).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.delete("8"));
+ }
+
+ public void testDeleteVolumeTypeFailNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/8");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.delete("8"));
+ }
+
+ public void testGetAllExtraSpecs() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/9/extra_specs");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_type_extra_specs.json")).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertEquals(api.getExtraSpecs("9"), ImmutableMap.of("test", "value1"));
+ }
+
+ public void testGetAllExtraSpecsFailNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/9/extra_specs");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.getExtraSpecs("9").isEmpty());
+ }
+
+ public void testSetAllExtraSpecs() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/9/extra_specs");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint)
+ .method("POST")
+ .payload(payloadFromStringWithContentType("{\"extra_specs\":{\"test1\":\"somevalue\"}}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.updateExtraSpecs("9", ImmutableMap.of("test1", "somevalue")));
+ }
+
+ public void testSetExtraSpec() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/5/extra_specs/test1");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint)
+ .method("PUT")
+ .payload(payloadFromStringWithContentType("{\"test1\":\"somevalue\"}", MediaType.APPLICATION_JSON)).build(),
+ HttpResponse.builder().statusCode(200).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.updateExtraSpec("5", "test1", "somevalue"));
+ }
+
+ public void testGetExtraSpec() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/5/extra_specs/test1");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromStringWithContentType("{\"test1\":\"another value\"}", MediaType.APPLICATION_JSON)).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertEquals(api.getExtraSpec("5", "test1"), "another value");
+ }
+
+ public void testGetExtraSpecFailNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/5/extra_specs/test1");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertNull(api.getExtraSpec("5", "test1"));
+ }
+
+ public void testDeleteExtraSpec() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/5/extra_specs/test1");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(200).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.deleteExtraSpec("5", "test1"));
+ }
+
+ public void testDeleteExtraSpecFailNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/5/extra_specs/test1");
+ VolumeTypeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeTypeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.deleteExtraSpec("5", "test1"));
+ }
+
+ public VolumeType testVolumeType() {
+ return VolumeType.builder().id("8").name("jclouds-test-1").created(dateService.iso8601SecondsDateParse("2012-05-10 12:33:06")).extraSpecs(ImmutableMap.of("test", "value1", "test1", "wibble")).build();
+ }
+}
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/extensions/VolumeTypeApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiLiveTest.java
new file mode 100644
index 0000000..02b0f50
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiLiveTest.java
@@ -0,0 +1,126 @@
+/*
+ * 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.extensions;
+
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.openstack.nova.v2_0.domain.VolumeType;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.jclouds.openstack.nova.v2_0.options.CreateVolumeTypeOptions;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeGroups;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests behavior of VolumeTypeApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "live", testName = "VolumeTypeApiLiveTest", singleThreaded = true)
+public class VolumeTypeApiLiveTest extends BaseNovaApiLiveTest {
+
+ private Optional<? extends VolumeTypeApi> volumeTypeOption;
+ private String zone;
+
+ private VolumeType testVolumeType;
+
+ @BeforeGroups(groups = {"integration", "live"})
+ @Override
+ public void setup() {
+ super.setup();
+ zone = Iterables.getLast(api.getConfiguredZones(), "nova");
+ volumeTypeOption = api.getVolumeTypeExtensionForZone(zone);
+ }
+
+
+ @AfterClass(groups = { "integration", "live" })
+ @Override
+ protected void tearDown() {
+ if (volumeTypeOption.isPresent()) {
+ if (testVolumeType != null) {
+ final String id = testVolumeType.getId();
+ assertTrue(volumeTypeOption.get().delete(id));
+ assertTrue(retry(new Predicate<VolumeTypeApi>() {
+ public boolean apply(VolumeTypeApi volumeApi) {
+ return volumeApi.get(id) == null;
+ }
+ }, 5 * 1000L).apply(volumeTypeOption.get()));
+ }
+ }
+ super.tearDown();
+ }
+
+ public void testCreateVolumeType() {
+ if (volumeTypeOption.isPresent()) {
+ testVolumeType = volumeTypeOption.get().create(
+ "jclouds-test-1", CreateVolumeTypeOptions.Builder.specs(ImmutableMap.of("test", "value1")));
+ assertTrue(retry(new Predicate<VolumeTypeApi>() {
+ public boolean apply(VolumeTypeApi volumeTypeApi) {
+ return volumeTypeApi.get(testVolumeType.getId()) != null;
+ }
+ }, 180 * 1000L).apply(volumeTypeOption.get()));
+
+ assertEquals(volumeTypeOption.get().get(testVolumeType.getId()).getName(), "jclouds-test-1");
+ assertEquals(volumeTypeOption.get().get(testVolumeType.getId()).getExtraSpecs(), ImmutableMap.of("test", "value1"));
+ }
+ }
+
+ @Test(dependsOnMethods = "testCreateVolumeType")
+ public void testListVolumeTypes() {
+ if (volumeTypeOption.isPresent()) {
+ Set<? extends VolumeType> volumeTypes = volumeTypeOption.get().list().toSet();
+ assertNotNull(volumeTypes);
+ boolean foundIt = false;
+ for (VolumeType vt : volumeTypes) {
+ VolumeType details = volumeTypeOption.get().get(vt.getId());
+ assertNotNull(details);
+ if (Objects.equal(details.getId(), testVolumeType.getId())) {
+ foundIt = true;
+ }
+ }
+ assertTrue(foundIt, "Failed to find the volume type we created in list() response");
+ }
+ }
+
+ @Test(dependsOnMethods = "testCreateVolumeType")
+ public void testExtraSpecs() {
+ if (volumeTypeOption.isPresent()) {
+ assertEquals(volumeTypeOption.get().getExtraSpecs(testVolumeType.getId()), ImmutableMap.of("test", "value1"));
+ assertEquals(volumeTypeOption.get().getExtraSpec(testVolumeType.getId(), "test"), "value1");
+ assertTrue(volumeTypeOption.get().updateExtraSpecs(testVolumeType.getId(), ImmutableMap.of("test1", "wibble")));
+ }
+ }
+
+ @Test(dependsOnMethods = "testCreateVolumeType")
+ public void testUpdateIndividualSpec() {
+ if (volumeTypeOption.isPresent()) {
+ assertTrue(volumeTypeOption.get().updateExtraSpec(testVolumeType.getId(), "test1", "freddy"));
+ assertEquals(volumeTypeOption.get().getExtraSpec(testVolumeType.getId(), "test1"), "freddy");
+ }
+ }
+}
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/features/ExtensionApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiExpectTest.java
new file mode 100644
index 0000000..4c91ec2
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiExpectTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseExtensionListTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseExtensionTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests annotation parsing of {@code ExtensionAsyncApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ExtensionApiExpectTest")
+public class ExtensionApiExpectTest extends BaseNovaApiExpectTest {
+
+ public void testListExtensionsWhenResponseIs2xx() throws Exception {
+ HttpRequest listExtensions = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/extensions")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse listExtensionsResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/extension_list.json")).build();
+
+ NovaApi apiWhenExtensionsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, listExtensions, listExtensionsResponse);
+
+ assertEquals(apiWhenExtensionsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
+
+ assertEquals(apiWhenExtensionsExist.getExtensionApiForZone("az-1.region-a.geo-1").list().toString(),
+ new ParseExtensionListTest().expected().toString());
+ }
+
+ public void testListExtensionsWhenReponseIs404IsEmpty() throws Exception {
+ HttpRequest listExtensions = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/extensions")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse listExtensionsResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, listExtensions, listExtensionsResponse);
+
+ assertTrue(apiWhenNoServersExist.getExtensionApiForZone("az-1.region-a.geo-1").list().isEmpty());
+ }
+
+ // TODO: gson deserializer for Multimap
+ public void testGetExtensionByAliasWhenResponseIs2xx() throws Exception {
+
+ HttpRequest getExtension = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/extensions/RS-PIE")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse getExtensionResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/extension_details.json")).build();
+
+ NovaApi apiWhenExtensionsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, getExtension, getExtensionResponse);
+
+ assertEquals(apiWhenExtensionsExist.getExtensionApiForZone("az-1.region-a.geo-1").get("RS-PIE")
+ .toString(), new ParseExtensionTest().expected().toString());
+ }
+
+ public void testGetExtensionByAliasWhenResponseIs404() throws Exception {
+ HttpRequest getExtension = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/extensions/RS-PIE")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse getExtensionResponse = HttpResponse.builder().statusCode(404)
+ .payload(payloadFromResource("/extension_details.json")).build();
+
+ NovaApi apiWhenNoExtensionsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, getExtension, getExtensionResponse);
+
+ assertNull(apiWhenNoExtensionsExist.getExtensionApiForZone("az-1.region-a.geo-1").get("RS-PIE"));
+
+ }
+
+}
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/features/ExtensionApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiLiveTest.java
new file mode 100644
index 0000000..b81a761
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiLiveTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Set;
+
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.jclouds.openstack.v2_0.domain.Extension;
+import org.jclouds.openstack.v2_0.features.ExtensionApi;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@link ExtensionApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live", testName = "ExtensionApiLiveTest")
+public class ExtensionApiLiveTest extends BaseNovaApiLiveTest {
+
+ /**
+ * Tests the listing of Extensions.
+ *
+ * @throws Exception
+ */
+ @Test(description = "GET /v${apiVersion}/{tenantId}/extensions")
+ public void testListExtensions() throws Exception {
+ for (String zoneId : zones) {
+ ExtensionApi extensionApi = api.getExtensionApiForZone(zoneId);
+ Set<? extends Extension> response = extensionApi.list();
+ assertNotNull(response);
+ assertFalse(response.isEmpty());
+ for (Extension extension : response) {
+ assertNotNull(extension.getId());
+ assertNotNull(extension.getName());
+ assertNotNull(extension.getDescription());
+ assertNotNull(extension.getNamespace());
+ assertNotNull(extension.getUpdated());
+ assertNotNull(extension.getLinks());
+ }
+ }
+ }
+
+ /**
+ * Tests retrieval of Extensions using their alias.
+ *
+ * @throws Exception
+ */
+ @Test(description = "GET /v${apiVersion}/{tenantId}/extensions/{alias}", dependsOnMethods = { "testListExtensions" })
+ public void testGetExtensionByAlias() throws Exception {
+ for (String zoneId : zones) {
+ ExtensionApi extensionApi = api.getExtensionApiForZone(zoneId);
+ Set<? extends Extension> response = extensionApi.list();
+ for (Extension extension : response) {
+ Extension details = extensionApi.get(extension.getId());
+ assertNotNull(details);
+ assertEquals(details.getId(), extension.getId());
+ assertEquals(details.getName(), extension.getName());
+ assertEquals(details.getDescription(), extension.getDescription());
+ assertEquals(details.getNamespace(), extension.getNamespace());
+ assertEquals(details.getUpdated(), extension.getUpdated());
+ assertEquals(details.getLinks(), extension.getLinks());
+ }
+ }
+ }
+
+}
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/features/FlavorApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiExpectTest.java
new file mode 100644
index 0000000..22af220
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiExpectTest.java
@@ -0,0 +1,164 @@
+/*
+ * 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.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseCreateFlavorTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseFlavorListTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseFlavorTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests annotation parsing of {@code FlavorAsyncApi}
+ *
+ * @author Jeremy Daggett, Ilja Bobkevic
+ */
+@Test(groups = "unit", testName = "FlavorApiExpectTest")
+public class FlavorApiExpectTest extends BaseNovaApiExpectTest {
+
+ public void testListFlavorsWhenResponseIs2xx() throws Exception {
+ HttpRequest listFlavors = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse listFlavorsResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/flavor_list.json")).build();
+
+ NovaApi apiWhenFlavorsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, listFlavors, listFlavorsResponse);
+
+ assertEquals(apiWhenFlavorsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
+
+ assertEquals(apiWhenFlavorsExist.getFlavorApiForZone("az-1.region-a.geo-1").list().concat().toString(),
+ new ParseFlavorListTest().expected().toString());
+ }
+
+ public void testListFlavorsWhenReponseIs404IsEmpty() throws Exception {
+ HttpRequest listFlavors = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse listFlavorsResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, listFlavors, listFlavorsResponse);
+
+ assertTrue(apiWhenNoServersExist.getFlavorApiForZone("az-1.region-a.geo-1").list().concat().isEmpty());
+ }
+
+ // TODO: gson deserializer for Multimap
+ public void testGetFlavorWhenResponseIs2xx() throws Exception {
+
+ HttpRequest getFlavor = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/52415800-8b69-11e0-9b19-734f1195ff37")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse getFlavorResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/flavor_details.json")).build();
+
+ NovaApi apiWhenFlavorsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, getFlavor, getFlavorResponse);
+
+ assertEquals(
+ apiWhenFlavorsExist.getFlavorApiForZone("az-1.region-a.geo-1").get("52415800-8b69-11e0-9b19-734f1195ff37")
+ .toString(), new ParseFlavorTest().expected().toString());
+ }
+
+ public void testGetFlavorWhenResponseIs404() throws Exception {
+ HttpRequest getFlavor = HttpRequest
+ .builder()
+ .method("GET")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/123")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ HttpResponse getFlavorResponse = HttpResponse.builder().statusCode(404)
+ .payload(payloadFromResource("/flavor_details.json")).build();
+
+ NovaApi apiWhenNoFlavorsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, getFlavor, getFlavorResponse);
+
+ assertNull(apiWhenNoFlavorsExist.getFlavorApiForZone("az-1.region-a.geo-1").get("123"));
+
+ }
+
+ public void testCreateFlavor200() throws Exception {
+ ParseCreateFlavorTest parser = new ParseCreateFlavorTest();
+ HttpRequest listFlavors = HttpRequest
+ .builder()
+ .method(HttpMethod.POST)
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors")
+ .addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON)
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromResource(parser.resource())).build();
+
+ HttpResponse listFlavorsResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource(parser.resource())).build();
+
+ NovaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, listFlavors, listFlavorsResponse);
+
+ assertEquals(
+ api.getFlavorApiForZone("az-1.region-a.geo-1").create(Flavor.builder()
+ .id("1cb47a44-9b84-4da4-bf81-c1976e8414ab")
+ .name("128 MB Server").ram(128).vcpus(1)
+ .disk(10).build())
+ .toString(), parser.expected().toString());
+ }
+
+ public void testDeleteFlavor202() throws Exception {
+ String flavorId = "1cb47a44-9b84-4da4-bf81-c1976e8414ab";
+
+ HttpRequest updateMetadata = HttpRequest
+ .builder()
+ .method(HttpMethod.DELETE)
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/" + flavorId)
+ .addHeader(HttpHeaders.ACCEPT, MediaType.WILDCARD)
+ .addHeader("X-Auth-Token", authToken)
+ .build();
+
+ HttpResponse updateMetadataResponse = HttpResponse.builder().statusCode(204).build();
+
+ NovaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, updateMetadata, updateMetadataResponse);
+
+ api.getFlavorApiForZone("az-1.region-a.geo-1").delete(flavorId);
+ }
+}
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/features/FlavorApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiLiveTest.java
new file mode 100644
index 0000000..2af0d54
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiLiveTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of {@link FlavorApi}
+ *
+ * @author Jeremy Daggett
+ */
+@Test(groups = "live", testName = "FlavorApiLiveTest")
+public class FlavorApiLiveTest extends BaseNovaApiLiveTest {
+
+ /**
+ * Tests the listing of Flavors.
+ *
+ * @throws Exception
+ */
+ @Test(description = "GET /v${apiVersion}/{tenantId}/flavors")
+ public void testListFlavors() throws Exception {
+ for (String zoneId : zones) {
+ FlavorApi flavorApi = api.getFlavorApiForZone(zoneId);
+ Set<? extends Resource> response = flavorApi.list().concat().toSet();
+ assertNotNull(response);
+ assertFalse(response.isEmpty());
+ for (Resource flavor : response) {
+ assertNotNull(flavor.getId());
+ assertNotNull(flavor.getName());
+ assertNotNull(flavor.getLinks());
+ }
+ }
+ }
+
+ /**
+ * Tests the listing of Flavors in detail.
+ *
+ * @throws Exception
+ */
+ @Test(description = "GET /v${apiVersion}/{tenantId}/flavors/detail")
+ public void testListFlavorsInDetail() throws Exception {
+ for (String zoneId : zones) {
+ FlavorApi flavorApi = api.getFlavorApiForZone(zoneId);
+ Set<? extends Flavor> response = flavorApi.listInDetail().concat().toSet();
+ assertNotNull(response);
+ assertFalse(response.isEmpty());
+ for (Flavor flavor : response) {
+ assertNotNull(flavor.getId());
+ assertNotNull(flavor.getName());
+ assertNotNull(flavor.getLinks());
+ assertTrue(flavor.getRam() > 0);
+ assertTrue(flavor.getDisk() > 0);
+ assertTrue(flavor.getVcpus() > 0);
+ }
+ }
+ }
+
+ /**
+ * Tests getting Flavors by id.
+ *
+ * @throws Exception
+ */
+ @Test(description = "GET /v${apiVersion}/{tenantId}/flavors/{id}", dependsOnMethods = { "testListFlavorsInDetail" })
+ public void testGetFlavorById() throws Exception {
+ for (String zoneId : zones) {
+ FlavorApi flavorApi = api.getFlavorApiForZone(zoneId);
+ Set<? extends Flavor> response = flavorApi.listInDetail().concat().toSet();
+ for (Flavor flavor : response) {
+ Flavor details = flavorApi.get(flavor.getId());
+ assertNotNull(details);
+ assertEquals(details.getId(), flavor.getId());
+ assertEquals(details.getName(), flavor.getName());
+ assertEquals(details.getLinks(), flavor.getLinks());
+ assertEquals(details.getRam(), flavor.getRam());
+ assertEquals(details.getDisk(), flavor.getDisk());
+ assertEquals(details.getVcpus(), flavor.getVcpus());
+ }
+ }
+ }
+
+}
[07/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
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/extensions/QuotaClassApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApiExpectTest.java
new file mode 100644
index 0000000..4611ea9
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApiExpectTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.domain.QuotaClass;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+/**
+ * Tests HostAdministrationApi guice wiring and parsing
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "QuotaClassApiExpectTest")
+public class QuotaClassApiExpectTest extends BaseNovaApiExpectTest {
+
+ public void testGetQuotas() throws Exception {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-class-sets/jcloudstestquotas");
+ QuotaClassApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/quota_class.json")).build()).getQuotaClassExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertEquals(api.get("jcloudstestquotas"), getTestQuotas());
+ }
+
+ public void testGetQuotasFailsTenantNotFound() throws Exception {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-class-sets/jcloudstestquotas");
+ QuotaClassApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()).getQuotaClassExtensionForZone("az-1.region-a.geo-1").get();
+ assertNull(api.get("jcloudstestquotas"));
+ }
+
+ public void testUpdateQuotas() throws Exception {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-class-sets/myclass");
+ QuotaClassApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().endpoint(endpoint).method("PUT")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromResourceWithContentType("/quota_class.json", MediaType.APPLICATION_JSON))
+ .build(),
+ HttpResponse.builder().statusCode(200).build()).getQuotaClassExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.update("myclass", getTestQuotas()));
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testUpdateQuotasFailsNotFound() throws Exception {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-class-sets/jcloudstestquotas");
+ QuotaClassApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().endpoint(endpoint).method("PUT")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(payloadFromResourceWithContentType("/quota_class.json", MediaType.APPLICATION_JSON))
+ .build(),
+ HttpResponse.builder().statusCode(404).build()).getQuotaClassExtensionForZone("az-1.region-a.geo-1").get();
+
+ api.update("jcloudstestquotas", getTestQuotas());
+ }
+
+ public static QuotaClass getTestQuotas() {
+ return QuotaClass.builder()
+ .metadataItems(128)
+ .injectedFileContentBytes(10240)
+ .injectedFiles(5)
+ .gigabytes(1000)
+ .ram(4096)
+ .floatingIps(10)
+ .securityGroups(10)
+ .securityGroupRules(20)
+ .instances(5)
+ .keyPairs(100)
+ .volumes(5)
+ .cores(10)
+ .id("jcloudstestquotas").build();
+ }
+
+}
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/extensions/QuotaClassApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApiLiveTest.java
new file mode 100644
index 0000000..43fd342
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApiLiveTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.openstack.nova.v2_0.domain.QuotaClass;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests behavior of QuotaApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "live", testName = "QuotaClassApiLiveTest", singleThreaded = true)
+public class QuotaClassApiLiveTest extends BaseNovaApiLiveTest {
+ private Optional<? extends QuotaClassApi> apiOption;
+ private String zone;
+
+ @BeforeClass(groups = {"integration", "live"})
+ @Override
+ public void setup() {
+ super.setup();
+ zone = Iterables.getLast(api.getConfiguredZones(), "nova");
+ apiOption = api.getQuotaClassExtensionForZone(zone);
+ }
+
+ public void testUpdateAndGetQuotaClass() {
+ if (apiOption.isPresent()) {
+ QuotaClassApi api = apiOption.get();
+
+ QuotaClass firstVersion =
+ QuotaClassApiExpectTest.getTestQuotas().toBuilder()
+ .id("jcloudstestquotas")
+ .cores(10)
+ .instances(5)
+ .ram(4096)
+ .volumes(5)
+ .build();
+
+ assertTrue(api.update(firstVersion.getId(), firstVersion));
+
+ assertEquals(api.get(firstVersion.getId()), firstVersion);
+
+ // Change it again (since we may have run this test before and we can't delete the QuotaClass)
+ QuotaClass secondVersion = firstVersion.toBuilder().ram(8192).build();
+
+ assertTrue(api.update(secondVersion.getId(), secondVersion));
+
+ assertEquals(api.get(secondVersion.getId()), secondVersion);
+ }
+ }
+}
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/extensions/SecurityGroupApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiExpectTest.java
new file mode 100644
index 0000000..1fa8416
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiExpectTest.java
@@ -0,0 +1,235 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.Ingress;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseSecurityGroupListTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseSecurityGroupTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests annotation parsing of {@code SecurityGroupAsyncApi}
+ *
+ * @author Michael Arnold
+ */
+@Test(groups = "unit", testName = "SecurityGroupApiExpectTest")
+public class SecurityGroupApiExpectTest extends BaseNovaApiExpectTest {
+ public void testListSecurityGroupsWhenResponseIs2xx() throws Exception {
+ HttpRequest list = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_list.json")).build();
+
+ NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list,
+ listResponse);
+
+ assertEquals(apiWhenSecurityGroupsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
+
+ assertEquals(apiWhenSecurityGroupsExist.getSecurityGroupExtensionForZone("az-1.region-a.geo-1").get()
+ .list().toString(), new ParseSecurityGroupListTest().expected().toString());
+ }
+
+ public void testListSecurityGroupsWhenReponseIs404IsEmpty() throws Exception {
+ HttpRequest listListSecurityGroups = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse listListSecurityGroupsResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenNoSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, listListSecurityGroups,
+ listListSecurityGroupsResponse);
+
+ assertTrue(apiWhenNoSecurityGroupsExist.getSecurityGroupExtensionForZone("az-1.region-a.geo-1").get()
+ .list().isEmpty());
+ }
+
+ public void testGetSecurityGroupWhenResponseIs2xx() throws Exception {
+
+ HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/0")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_details.json")).build();
+
+ NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, getSecurityGroup,
+ getSecurityGroupResponse);
+
+ assertEquals(apiWhenSecurityGroupsExist.getSecurityGroupExtensionForZone("az-1.region-a.geo-1").get()
+ .get("0").toString(), new ParseSecurityGroupTest().expected().toString());
+ }
+
+ public void testGetSecurityGroupWhenResponseIs404() throws Exception {
+ HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/0")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(404).build();
+
+ NovaApi apiWhenNoSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, getSecurityGroup,
+ getSecurityGroupResponse);
+
+ assertNull(apiWhenNoSecurityGroupsExist.getSecurityGroupExtensionForZone("az-1.region-a.geo-1").get()
+ .get("0"));
+
+ }
+
+ public void testCreateSecurityGroupWhenResponseIs2xx() throws Exception {
+ HttpRequest create = HttpRequest.builder().method("POST").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build())
+ .payload(
+ payloadFromStringWithContentType(
+ "{\"security_group\":{\"name\":\"jclouds-test\",\"description\":\"jclouds-test\"}}",
+ "application/json")).build();
+
+ HttpResponse createResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_created.json")).build();
+
+ NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, create,
+ createResponse);
+
+ assertEquals(apiWhenSecurityGroupsExist.getSecurityGroupExtensionForZone("az-1.region-a.geo-1").get()
+ .createWithDescription("jclouds-test", "jclouds-test").toString(),
+ createExpected().toString());
+ }
+
+ public void testDeleteSecurityGroupWhenResponseIs2xx() throws Exception {
+ HttpRequest delete = HttpRequest.builder().method("DELETE").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160"))
+ .headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json")
+ .put("X-Auth-Token", authToken).build()).build();
+
+ HttpResponse deleteResponse = HttpResponse.builder().statusCode(202).build();
+
+ NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, delete,
+ deleteResponse);
+
+ assertTrue(apiWhenServersExist.getSecurityGroupExtensionForZone("az-1.region-a.geo-1").get()
+ .delete("160"));
+
+ }
+
+ public void testCreateSecurityGroupRuleForCidrBlockWhenResponseIs2xx() throws Exception {
+ HttpRequest createRule = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(
+ payloadFromStringWithContentType(
+ "{\"security_group_rule\":{\"parent_group_id\":\"161\",\"cidr\":\"0.0.0.0/0\",\"ip_protocol\":\"tcp\",\"from_port\":\"80\",\"to_port\":\"8080\"}}",
+ "application/json")).build();
+
+ HttpResponse createRuleResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygrouprule_created.json")).build();
+
+ NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createRule,
+ createRuleResponse);
+
+ assertEquals(apiWhenSecurityGroupsExist.getSecurityGroupExtensionForZone("az-1.region-a.geo-1").get()
+ .createRuleAllowingCidrBlock("161",
+ Ingress.builder().ipProtocol(IpProtocol.TCP).fromPort(80).toPort(8080).build(), "0.0.0.0/0")
+ .toString(), createRuleExpected().toString());
+ }
+
+ public void testCreateSecurityGroupRuleForSecurityGroupIdWhenResponseIs2xx() throws Exception {
+ HttpRequest createRule = HttpRequest
+ .builder()
+ .method("POST")
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .payload(
+ payloadFromStringWithContentType(
+ "{\"security_group_rule\":{\"group_id\":\"999\",\"parent_group_id\":\"161\",\"ip_protocol\":\"tcp\",\"from_port\":\"80\",\"to_port\":\"8080\"}}",
+ "application/json")).build();
+
+ HttpResponse createRuleResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygrouprule_created.json")).build();
+
+ NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createRule,
+ createRuleResponse);
+
+ assertEquals(apiWhenSecurityGroupsExist.getSecurityGroupExtensionForZone("az-1.region-a.geo-1").get()
+ .createRuleAllowingSecurityGroupId("161",
+ Ingress.builder().ipProtocol(IpProtocol.TCP).fromPort(80).toPort(8080).build(), "999")
+ .toString(), createRuleExpected().toString());
+ }
+
+ public void testDeleteSecurityGroupRuleWhenResponseIs2xx() throws Exception {
+ HttpRequest deleteRule = HttpRequest.builder().method("DELETE").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules/161"))
+ .headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "*/*")
+ .put("X-Auth-Token", authToken).build()).build();
+
+ HttpResponse deleteRuleResponse = HttpResponse.builder().statusCode(202).build();
+
+ NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, deleteRule,
+ deleteRuleResponse);
+
+ assertTrue(apiWhenSecurityGroupsExist.getSecurityGroupExtensionForZone("az-1.region-a.geo-1").get()
+ .deleteRule("161"));
+
+ }
+
+ private SecurityGroup createExpected() {
+ return SecurityGroup.builder().description("jclouds-test").id("160").name("jclouds-test").rules(
+ ImmutableSet.<SecurityGroupRule> of()).tenantId("dev_16767499955063").build();
+ }
+
+ private SecurityGroupRule createRuleExpected() {
+ return SecurityGroupRule.builder().fromPort(80).id("218").ipProtocol(
+ IpProtocol.TCP).ipRange("0.0.0.0/0").parentGroupId("161").toPort(8080).build();
+ }
+
+}
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/extensions/SecurityGroupApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiLiveTest.java
new file mode 100644
index 0000000..c0fb2df
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiLiveTest.java
@@ -0,0 +1,100 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Set;
+
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.openstack.nova.v2_0.domain.Ingress;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests behavior of {@code SecurityGroupApi}
+ *
+ * @author Michael Arnold
+ */
+@Test(groups = "live", testName = "SecurityGroupApiLiveTest", singleThreaded = true)
+public class SecurityGroupApiLiveTest extends BaseNovaApiLiveTest {
+
+ public static final String SECURITY_GROUP_NAME = "testsg";
+
+ public void list() throws Exception {
+ for (String zoneId : api.getConfiguredZones()) {
+ SecurityGroupApi securityGroupApi = api.getSecurityGroupExtensionForZone(zoneId).get();
+ Set<? extends SecurityGroup> securityGroupsList = securityGroupApi.list().toSet();
+ assertNotNull(securityGroupsList);
+ }
+ }
+
+ public void createGetAndDeleteSecurityGroup() throws Exception {
+ for (String zoneId : api.getConfiguredZones()) {
+ SecurityGroupApi securityGroupApi = api.getSecurityGroupExtensionForZone(zoneId).get();
+ SecurityGroup securityGroup = null;
+ String id;
+ try {
+ securityGroup = securityGroupApi
+ .createWithDescription(SECURITY_GROUP_NAME, "test security group");
+ assertNotNull(securityGroup);
+ id = securityGroup.getId();
+ SecurityGroup theGroup = securityGroupApi.get(id);
+ assertNotNull(theGroup);
+ } finally {
+ if (securityGroup != null) {
+ securityGroupApi.delete(securityGroup.getId());
+ }
+ }
+ }
+ }
+
+ public void createAndDeleteSecurityGroupRule() throws Exception {
+ for (String zoneId : api.getConfiguredZones()) {
+ SecurityGroupApi securityGroupApi = api.getSecurityGroupExtensionForZone(zoneId).get();
+ SecurityGroup securityGroup = null;
+
+ try {
+ securityGroup = securityGroupApi.createWithDescription(SECURITY_GROUP_NAME, "test security group");
+ assertNotNull(securityGroup);
+
+ for (int port : ImmutableSet.of(22, 8080)) {
+ SecurityGroupRule rule = securityGroupApi.createRuleAllowingCidrBlock(securityGroup.getId(), Ingress
+ .builder().ipProtocol(IpProtocol.TCP).fromPort(port).toPort(port).build(), "0.0.0.0/0");
+ assertNotNull(rule);
+
+ SecurityGroupRule rule2 = securityGroupApi.createRuleAllowingSecurityGroupId(securityGroup.getId(),
+ Ingress.builder().ipProtocol(IpProtocol.TCP).fromPort(port).toPort(port).build(), securityGroup
+ .getId());
+
+ assertNotNull(rule2);
+ }
+ securityGroup = securityGroupApi.get(securityGroup.getId());
+
+ } finally {
+ if (securityGroup != null) {
+ securityGroupApi.delete(securityGroup.getId());
+ }
+ }
+ }
+
+ }
+}
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/extensions/ServerWithSecurityGroupsApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiExpectTest.java
new file mode 100644
index 0000000..3eb9524
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiExpectTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+
+import java.net.URI;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.domain.ServerWithSecurityGroups;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Tests parsing and guice wiring of ServerWithSecurityGroupsApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "ServerWithSecurityGroupsApiExpectTest")
+public class ServerWithSecurityGroupsApiExpectTest extends BaseNovaApiExpectTest {
+
+ public void testGetServerWithSecurityGroups() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-create-server-ext/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb");
+ ServerWithSecurityGroupsApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/server_with_security_groups.json")).build()
+ ).getServerWithSecurityGroupsExtensionForZone("az-1.region-a.geo-1").get();
+
+ ServerWithSecurityGroups server = api.get("8d0a6ca5-8849-4b3d-b86e-f24c92490ebb");
+ assertEquals(server.getId(), "8d0a6ca5-8849-4b3d-b86e-f24c92490ebb");
+ assertEquals(server.getSecurityGroupNames(), ImmutableSet.of("default", "group1"));
+ }
+
+ public void testGetServerWithSecurityGroupsFailNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-create-server-ext/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb");
+ ServerWithSecurityGroupsApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getServerWithSecurityGroupsExtensionForZone("az-1.region-a.geo-1").get();
+ assertNull(api.get("8d0a6ca5-8849-4b3d-b86e-f24c92490ebb"));
+ }
+}
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/extensions/ServerWithSecurityGroupsApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiLiveTest.java
new file mode 100644
index 0000000..a448253
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiLiveTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.ServerWithSecurityGroups;
+import org.jclouds.openstack.nova.v2_0.features.ServerApi;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.testng.annotations.BeforeGroups;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests behavior of ServerWithSecurityGroupsApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "live", testName = "ServerWithSecurityGroupsApiLiveTest", singleThreaded = true)
+public class ServerWithSecurityGroupsApiLiveTest extends BaseNovaApiLiveTest {
+ private ServerApi serverApi;
+ private Optional<? extends ServerWithSecurityGroupsApi> apiOption;
+ private String zone;
+
+ @BeforeGroups(groups = {"integration", "live"})
+ @Override
+ public void setup() {
+ super.setup();
+ zone = Iterables.getLast(api.getConfiguredZones(), "nova");
+ serverApi = api.getServerApiForZone(zone);
+ apiOption = api.getServerWithSecurityGroupsExtensionForZone(zone);
+ }
+
+ public void testGetServer() {
+ if (apiOption.isPresent()) {
+
+ for (Resource server : serverApi.list().concat()) {
+ ServerWithSecurityGroups serverWithGroups = apiOption.get().get(server.getId());
+ assertEquals(serverWithGroups.getId(), server.getId());
+ assertEquals(serverWithGroups.getName(), server.getName());
+ assertNotNull(serverWithGroups.getSecurityGroupNames());
+ }
+
+ // Create a new server to verify the groups work as expected
+ Server testServer = null;
+ try {
+ testServer = createServerInZone(zone);
+
+ ServerWithSecurityGroups results = apiOption.get().get(testServer.getId());
+ assertEquals(results.getId(), testServer.getId());
+ assertEquals(results.getSecurityGroupNames(), ImmutableSet.of("default"));
+ } finally {
+ if (testServer != null) {
+ serverApi.delete(testServer.getId());
+ }
+ }
+ }
+ }
+
+}
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/extensions/SimpleTenantUsageApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiExpectTest.java
new file mode 100644
index 0000000..cfb2393
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiExpectTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.Set;
+
+import org.jclouds.date.DateService;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.domain.SimpleServerUsage;
+import org.jclouds.openstack.nova.v2_0.domain.SimpleTenantUsage;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests SimpleTenantUsageApi guice wiring and parsing
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "SimpleTenantUsageApiExpectTest")
+public class SimpleTenantUsageApiExpectTest extends BaseNovaApiExpectTest {
+ private DateService dateService = new SimpleDateFormatDateService();
+
+ public void testList() throws Exception {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-simple-tenant-usage");
+ SimpleTenantUsageApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("GET")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/simple_tenant_usages.json")).build())
+ .getSimpleTenantUsageExtensionForZone("az-1.region-a.geo-1").get();
+
+ Set<? extends SimpleTenantUsage> results = api.list().toSet();
+
+ SimpleTenantUsage usage = Iterables.getOnlyElement(results);
+ assertEquals(usage.getTenantId(), "f8535069c3fb404cb61c873b1a0b4921");
+ assertEquals(usage.getTotalHours(), 4.888888888888889e-07);
+ assertEquals(usage.getTotalLocalGbUsage(), 1.9555555555555557e-05);
+ assertEquals(usage.getTotalMemoryMbUsage(), 0.0015018666666666667);
+ assertEquals(usage.getTotalVcpusUsage(), 7.333333333333333e-07);
+ assertEquals(usage.getStart(), dateService.iso8601DateParse("2012-04-18 12:18:39.702411"));
+ assertEquals(usage.getStop(), dateService.iso8601DateParse("2012-04-18 12:18:39.702499"));
+ assertNotNull(usage.getServerUsages());
+ assertTrue(usage.getServerUsages().isEmpty());
+ }
+
+ public void testGet() throws Exception {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-simple-tenant-usage/test-1234");
+ SimpleTenantUsageApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ HttpRequest.builder().method("GET")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken)
+ .endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/simple_tenant_usage.json")).build())
+ .getSimpleTenantUsageExtensionForZone("az-1.region-a.geo-1").get();
+
+ SimpleTenantUsage usage = api.get("test-1234");
+ assertEquals(usage.getTenantId(), "f8535069c3fb404cb61c873b1a0b4921");
+
+ SimpleTenantUsage expected = SimpleTenantUsage.builder().tenantId("f8535069c3fb404cb61c873b1a0b4921").totalHours(4.833333333333333E-7).totalLocalGbUsage(1.933333333333333E-05)
+ .start(dateService.iso8601DateParse("2012-04-18 13:32:07.255743")).stop(dateService.iso8601DateParse("2012-04-18 13:32:07.255743"))
+ .totalMemoryMbUsage(0.0014847999999999999).totalVcpusUsage(7.249999999999999E-07).serverUsages(
+ ImmutableSet.of(
+ SimpleServerUsage.builder().hours(2.4166666666666665e-07).uptime(91149).flavorLocalGb(50).instanceName("test1").tenantId("f8535069c3fb404cb61c873b1a0b4921").flavorVcpus(2).flavorMemoryMb(4096).instanceStatus(SimpleServerUsage.Status.ACTIVE).flavorName("m1.medium").instanceCreated(this.dateService.iso8601SecondsDateParse("2012-04-17T12:12:58")).build(),
+ SimpleServerUsage.builder().hours(2.4166666666666665e-07).uptime(84710).flavorLocalGb(30).instanceName("mish_test").tenantId("f8535069c3fb404cb61c873b1a0b4921").flavorVcpus(1).flavorMemoryMb(2048).instanceStatus(SimpleServerUsage.Status.ACTIVE).flavorName("m1.small").instanceCreated(this.dateService.iso8601SecondsDateParse("2012-04-17T14:00:17")).build()
+ )).build();
+
+ assertEquals(usage, expected);
+ }
+
+}
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/extensions/SimpleTenantUsageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiLiveTest.java
new file mode 100644
index 0000000..f658d26
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiLiveTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Set;
+
+import org.jclouds.openstack.nova.v2_0.domain.SimpleTenantUsage;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+
+/**
+ * Tests behavior of SimpleTenantUsageApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "live", testName = "SimpleTenantUsageApiLiveTest")
+public class SimpleTenantUsageApiLiveTest extends BaseNovaApiLiveTest {
+
+ public void testList() throws Exception {
+ for (String zoneId : api.getConfiguredZones()) {
+ Optional<? extends SimpleTenantUsageApi> optApi = api.getSimpleTenantUsageExtensionForZone(zoneId);
+ if (optApi.isPresent() && identity.endsWith(":admin")) {
+ SimpleTenantUsageApi api = optApi.get();
+ Set<? extends SimpleTenantUsage> usages = api.list().toSet();
+ assertNotNull(usages);
+ for (SimpleTenantUsage usage : usages) {
+ SimpleTenantUsage details = api.get(usage.getTenantId());
+ assertNotNull(details);
+ }
+ }
+ }
+ }
+}
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/extensions/VirtualInterfaceApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiExpectTest.java
new file mode 100644
index 0000000..ab9be8d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiExpectTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.domain.VirtualInterface;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests parsing and guice wiring of VirtualInterfaceApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "live", testName = "VirtualInterfaceApiLiveTest")
+public class VirtualInterfaceApiExpectTest extends BaseNovaApiExpectTest {
+
+ public void testListVirtualInterfaces() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/os-virtual-interfaces");
+ VirtualInterfaceApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/virtual_interfaces_list.json")).build()
+ ).getVirtualInterfaceExtensionForZone("az-1.region-a.geo-1").get();
+
+ VirtualInterface vif = Iterables.getOnlyElement(api.listOnServer("1"));
+ assertEquals(vif.getId(), "02315827-b05c-4668-9c05-75c68838074a");
+ assertEquals(vif.getMacAddress(), "fa:16:3e:09:71:34");
+ }
+
+ public void testListVirtualInterfacesFailNotFound() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/os-virtual-interfaces");
+ VirtualInterfaceApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVirtualInterfaceExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.listOnServer("1").isEmpty());
+ }
+}
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/extensions/VirtualInterfaceApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiLiveTest.java
new file mode 100644
index 0000000..4f36035
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiLiveTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertNotNull;
+
+import java.util.Set;
+
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.VirtualInterface;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests behavior of VirtualInterfaceApi
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "live", testName = "VirtualInterfaceApiLiveTest", singleThreaded = true)
+public class VirtualInterfaceApiLiveTest extends BaseNovaApiLiveTest {
+ private Optional<? extends VirtualInterfaceApi> apiOption;
+ private String zone;
+
+
+ @BeforeClass(groups = {"integration", "live"})
+ @Override
+ public void setup() {
+ super.setup();
+ zone = Iterables.getLast(api.getConfiguredZones(), "nova");
+ apiOption = api.getVirtualInterfaceExtensionForZone(zone);
+ }
+
+ public void testListVirtualInterfaces() {
+ if (apiOption.isPresent()) {
+ Server testServer = null;
+ try {
+ testServer = createServerInZone(zone);
+ Set<? extends VirtualInterface> results = apiOption.get().listOnServer(testServer.getId()).toSet();
+ for (VirtualInterface vif : results) {
+ assertNotNull(vif.getId());
+ assertNotNull(vif.getMacAddress());
+ }
+ } finally {
+ if (testServer != null) {
+ api.getServerApiForZone(zone).delete(testServer.getId());
+ }
+ }
+ }
+}
+}
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/extensions/VolumeApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiExpectTest.java
new file mode 100644
index 0000000..c177ce2
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiExpectTest.java
@@ -0,0 +1,460 @@
+/*
+ * 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.extensions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.DateService;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.domain.Volume;
+import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment;
+import org.jclouds.openstack.nova.v2_0.domain.VolumeSnapshot;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.options.CreateVolumeOptions;
+import org.jclouds.openstack.nova.v2_0.options.CreateVolumeSnapshotOptions;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests VolumeApi guice wiring and parsing
+ *
+ * @author Adam Lowe
+ */
+@Test(groups = "unit", testName = "VolumeApiExpectTest")
+public class VolumeApiExpectTest extends BaseNovaApiExpectTest {
+ private DateService dateService = new SimpleDateFormatDateService();
+
+ public void testListVolumes() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_list.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ Set<? extends Volume> volumes = api.list().toSet();
+ assertEquals(volumes, ImmutableSet.of(testVolume()));
+ }
+
+ public void testListVolumesFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ Set<? extends Volume> volumes = api.list().toSet();
+ assertTrue(volumes.isEmpty());
+ }
+
+ public void testListVolumesInDetail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes/detail");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_list_detail.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ Set<? extends Volume> volumes = api.listInDetail().toSet();
+ assertEquals(volumes, ImmutableSet.of(testVolume()));
+ }
+
+ public void testListVolumesInDetailFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes/detail");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ Set<? extends Volume> volumes = api.listInDetail().toSet();
+ assertTrue(volumes.isEmpty());
+ }
+
+ public void testCreateVolume() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint)
+ .method("POST")
+ .payload(payloadFromStringWithContentType("{\"volume\":{\"display_name\":\"jclouds-test-volume\",\"display_description\":\"description of test volume\",\"size\":1}}", MediaType.APPLICATION_JSON))
+ .build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_details.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ Volume volume = api.create(1, CreateVolumeOptions.Builder.name("jclouds-test-volume").description("description of test volume"));
+ assertEquals(volume, testVolume());
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testCreateVolumeFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint)
+ .endpoint(endpoint)
+ .method("POST")
+ .payload(payloadFromStringWithContentType("{\"volume\":{\"display_name\":\"jclouds-test-volume\",\"display_description\":\"description of test volume\",\"size\":1}}", MediaType.APPLICATION_JSON))
+ .build(),
+ HttpResponse.builder().statusCode(404).payload(payloadFromResource("/volume_details.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ api.create(1, CreateVolumeOptions.Builder.name("jclouds-test-volume").description("description of test volume"));
+ }
+
+ public void testGetVolume() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes/1");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/volume_details.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ Volume volume = api.get("1");
+ assertEquals(volume, testVolume());
+ // double-check equals()
+ assertEquals(volume.getStatus(), Volume.Status.IN_USE);
+ assertEquals(volume.getDescription(), "This is a test volume");
+ assertEquals(volume.getZone(), "nova");
+ assertEquals(volume.getName(), "test");
+ assertEquals(volume.getStatus(), Volume.Status.IN_USE);
+ assertEquals(Iterables.getOnlyElement(volume.getAttachments()), testAttachment());
+ }
+
+ public void testGetVolumeFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes/1");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertNull(api.get("1"));
+ }
+
+ public void testDeleteVolume() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes/1");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/attachment_details.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.delete("1"));
+ }
+
+ public void testDeleteVolumeFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes/1");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.delete("1"));
+ }
+
+ public void testListAttachments() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/attachment_list.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ Set<? extends VolumeAttachment> attachments = api.listAttachmentsOnServer("instance-1").toSet();
+ assertEquals(attachments, ImmutableSet.of(testAttachment()));
+ // double-check individual fields
+ VolumeAttachment attachment = Iterables.getOnlyElement(attachments);
+ assertEquals(attachment.getDevice(), "/dev/vdc");
+ assertEquals(attachment.getServerId(), "b4785058-cb80-491b-baa3-e4ee6546450e");
+ assertEquals(attachment.getId(), "1");
+ assertEquals(attachment.getVolumeId(), "1");
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testListAttachmentsFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-2/os-volume_attachments");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(401).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ api.listAttachmentsOnServer("instance-2");
+ }
+
+ public void testGetAttachment() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/attachment_details.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ VolumeAttachment attachment = api.getAttachmentForVolumeOnServer("1", "instance-1");
+ assertEquals(attachment, testAttachment());
+ }
+
+ public void testGetAttachmentFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertNull(api.getAttachmentForVolumeOnServer("1", "instance-1"));
+ }
+
+ public void testAttachVolume() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("POST")
+ .payload(payloadFromStringWithContentType("{\"volumeAttachment\":{\"volumeId\":\"1\",\"device\":\"/dev/vdc\"}}", MediaType.APPLICATION_JSON)).endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/attachment_details.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ VolumeAttachment result = api.attachVolumeToServerAsDevice("1", "instance-1", "/dev/vdc");
+ assertEquals(result, testAttachment());
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testAttachVolumeFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("POST")
+ .payload(payloadFromStringWithContentType("{\"volumeAttachment\":{\"volumeId\":\"1\",\"device\":\"/dev/vdc\"}}", MediaType.APPLICATION_JSON)).endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ api.attachVolumeToServerAsDevice("1", "instance-1","/dev/vdc");
+ }
+
+ public void testDetachVolume() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/attachment_details.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.detachVolumeFromServer("1", "instance-1"));
+ }
+
+ public void testDetachVolumeFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertFalse(api.detachVolumeFromServer("1", "instance-1"));
+ }
+
+ public void testListSnapshots() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/snapshot_list.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ Set<? extends VolumeSnapshot> snapshots = api.listSnapshots().toSet();
+ assertEquals(snapshots, ImmutableSet.of(testSnapshot()));
+ }
+
+ public void testListSnapshotsFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ Set<? extends VolumeSnapshot> snapshots = api.listSnapshots().toSet();
+ assertTrue(snapshots.isEmpty());
+ }
+
+ public void testGetSnapshot() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots/1");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/snapshot_details.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ VolumeSnapshot snapshot = api.getSnapshot("1");
+ assertEquals(snapshot, testSnapshot());
+ }
+
+ public void testGetSnapshotFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots/1");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertNull(api.getSnapshot("1"));
+ }
+
+ public void testListSnapshotsInDetail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots/detail");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/snapshot_list_detail.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ Set<? extends VolumeSnapshot> snapshots = api.listSnapshotsInDetail().toSet();
+ assertEquals(snapshots, ImmutableSet.of(testSnapshot()));
+
+ // double-check individual fields
+ VolumeSnapshot snappy = Iterables.getOnlyElement(snapshots);
+ assertEquals(snappy.getId(), "7");
+ assertEquals(snappy.getVolumeId(), "9");
+ assertEquals(snappy.getStatus(), Volume.Status.AVAILABLE);
+ assertEquals(snappy.getDescription(), "jclouds live test snapshot");
+ assertEquals(snappy.getName(), "jclouds-live-test");
+ assertEquals(snappy.getSize(), 1);
+ }
+
+ public void testListSnapshotsInDetailFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots/detail");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).build(),
+ HttpResponse.builder().statusCode(404).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ Set<? extends VolumeSnapshot> snapshots = api.listSnapshotsInDetail().toSet();
+ assertTrue(snapshots.isEmpty());
+ }
+
+ public void testCreateSnapshot() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint)
+ .method("POST")
+ .payload(payloadFromStringWithContentType("{\"snapshot\":{\"display_name\":\"jclouds-live-test\",\"volume_id\":\"13\",\"display_description\":\"jclouds live test snapshot\",\"force\":\"true\"}}", MediaType.APPLICATION_JSON))
+ .build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/snapshot_details.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ VolumeSnapshot snapshot = api.createSnapshot("13", CreateVolumeSnapshotOptions.Builder.name("jclouds-live-test").description("jclouds live test snapshot").force());
+ assertEquals(snapshot, testSnapshot());
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testCreateSnapshotFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint)
+ .method("POST")
+ .payload(payloadFromStringWithContentType("{\"snapshot\":{\"display_name\":\"jclouds-live-test\",\"volume_id\":\"13\",\"display_description\":\"jclouds live test snapshot\",\"force\":\"true\"}}", MediaType.APPLICATION_JSON))
+ .build(),
+ HttpResponse.builder().statusCode(401).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ api.createSnapshot("13", CreateVolumeSnapshotOptions.Builder.name("jclouds-live-test").description("jclouds live test snapshot").force());
+ }
+
+ public void testDeleteSnapshot() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots/1");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(200).payload(payloadFromResource("/snapshot_details.json")).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ assertTrue(api.deleteSnapshot("1"));
+ }
+
+ @Test(expectedExceptions = AuthorizationException.class)
+ public void testDeleteSnapshotFail() {
+ URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots/1");
+ VolumeApi api = requestsSendResponses(
+ keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse,
+ authenticatedGET().endpoint(endpoint).method("DELETE").build(),
+ HttpResponse.builder().statusCode(401).build()
+ ).getVolumeExtensionForZone("az-1.region-a.geo-1").get();
+
+ api.deleteSnapshot("1");
+ }
+
+ protected Volume testVolume() {
+ return Volume.builder().status(Volume.Status.IN_USE).description("This is a test volume").zone("nova").name("test")
+ .attachments(ImmutableSet.of(testAttachment())).size(1).id("1").created(dateService.iso8601SecondsDateParse("2012-04-23 12:16:45")).build();
+ }
+
+ protected VolumeAttachment testAttachment() {
+ return VolumeAttachment.builder().device("/dev/vdc").serverId("b4785058-cb80-491b-baa3-e4ee6546450e").id("1").volumeId("1").build();
+ }
+
+ protected VolumeSnapshot testSnapshot() {
+ return VolumeSnapshot.builder().id("7").volumeId("9").description("jclouds live test snapshot").status(Volume.Status.AVAILABLE)
+ .name("jclouds-live-test").size(1).created(dateService.iso8601SecondsDateParse("2012-04-24 13:34:42")).build();
+ }
+}
[04/21] fixing https://issues.apache.org/jira/browse/STRATOS-520 -
adding Openstack-nova module to dependencies
Posted by ni...@apache.org.
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/functions/InternalURLLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java
new file mode 100644
index 0000000..d1656d7
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.functions;
+
+import static org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT;
+
+import java.util.Properties;
+
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.jclouds.openstack.v2_0.config.InternalUrlModule;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+
+/**
+ * Simple live test to check the correct loading of the internal endpoint
+ * services.
+ *
+ * @author Ignacio Mulas
+ *
+ */
+@Test(groups = "live", testName = "InternalURLLiveTest")
+public class InternalURLLiveTest extends BaseNovaApiLiveTest {
+
+ @Test(description = "InternalUrl service endpoints loader")
+ public void testGetInternalUrlServiceEndpoint() throws Exception {
+ String zone = api.getConfiguredZones().iterator().next();
+ // List current servers to ensure that can reach nova with internalUrl ip
+ try {
+ api.getServerApiForZone(zone).list().concat().toList();
+ } catch (Exception e) {
+ Assert.fail("Could not retrieve servers list using the internalUrl", e);
+ }
+ }
+
+ @Override
+ protected Properties setupProperties() {
+ Properties properties = super.setupProperties();
+ properties.setProperty(PROPERTY_CONNECTION_TIMEOUT, "5000");
+ return properties;
+ }
+
+ @Override
+ protected Iterable<Module> setupModules() {
+ return ImmutableSet.<Module> of(getLoggingModule(), new InternalUrlModule());
+ }
+
+}
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/handlers/NovaErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandlerTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandlerTest.java
new file mode 100644
index 0000000..fe302a7
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandlerTest.java
@@ -0,0 +1,225 @@
+/*
+ * 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.handlers;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.concurrent.TimeUnit;
+
+import org.jclouds.date.DateCodec;
+import org.jclouds.date.internal.DateServiceDateCodecFactory.DateServiceIso8601SecondsCodec;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.fallbacks.HeaderToRetryAfterException;
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.json.internal.GsonWrapper;
+import org.jclouds.openstack.nova.v2_0.functions.OverLimitParser;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.InsufficientResourcesException;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.jclouds.rest.RetryAfterException;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Ticker;
+import com.google.gson.Gson;
+
+/**
+ *
+ * @author Adrian Cole, Steve Loughran
+ */
+@Test(groups = "unit", testName = "NovaErrorHandlerTest", singleThreaded = true)
+public class NovaErrorHandlerTest {
+
+ private HttpCommand command;
+
+ @BeforeTest
+ void setupCommand() {
+ command = command();
+ }
+
+ @Test
+ public void test401MakesAuthorizationException() {
+ fn.handleError(command, HttpResponse.builder().statusCode(401).message("Unauthorized").build());
+
+ assertEquals(command.getException().getClass(), AuthorizationException.class);
+ assertEquals(command.getException().getMessage(),
+ "POST https://nova/v1.1/servers HTTP/1.1 -> HTTP/1.1 401 Unauthorized");
+ }
+
+ @Test
+ public void test404MakesResourceNotFoundException() {
+ fn.handleError(command, HttpResponse.builder().statusCode(404).message("Not Found").build());
+
+ assertEquals(command.getException().getClass(), ResourceNotFoundException.class);
+ assertEquals(command.getException().getMessage(),
+ "POST https://nova/v1.1/servers HTTP/1.1 -> HTTP/1.1 404 Not Found");
+ }
+
+ // should wait until ips are associated w/the server
+ HttpResponse noFixedIps = HttpResponse.builder().statusCode(400)
+ .message("HTTP/1.1 400 Bad Request")
+ .payload("{\"badRequest\": {\"message\": "+
+ "\"instance |71554| has no fixed_ips. unable to associate floating ip\", \"code\": 400}}")
+ .build();
+
+ @Test
+ public void test400MakesIllegalStateExceptionOnQuotaExceededOnNoFixedIps() {
+ fn.handleError(command, noFixedIps);
+
+ assertEquals(command.getException().getClass(), IllegalStateException.class);
+ assertEquals(command.getException().getMessage(), noFixedIps.getPayload().getRawContent());
+ }
+
+ HttpResponse alreadyExists = HttpResponse.builder().statusCode(400)
+ .message("HTTP/1.1 400 Bad Request")
+ .payload("{\"badRequest\": {\"message\": \"Server with the name 'test' already exists\", \"code\": 400}}")
+ .build();
+
+ @Test
+ public void test400MakesIllegalStateExceptionOnAlreadyExists() {
+ fn.handleError(command, alreadyExists);
+
+ assertEquals(command.getException().getClass(), IllegalStateException.class);
+ assertEquals(command.getException().getMessage(), alreadyExists.getPayload().getRawContent());
+ }
+
+ HttpResponse quotaExceeded = HttpResponse.builder().statusCode(400)
+ .message("HTTP/1.1 400 Bad Request")
+ .payload("{\"badRequest\": {\"message\": \"AddressLimitExceeded: Address quota exceeded. " +
+ "You cannot create any more addresses\", \"code\": 400}}")
+ .build();
+
+ @Test
+ public void test400MakesInsufficientResourcesExceptionOnQuotaExceeded() {
+ fn.handleError(command, quotaExceeded);
+
+ assertEquals(command.getException().getClass(), InsufficientResourcesException.class);
+ assertEquals(command.getException().getMessage(), quotaExceeded.getPayload().getRawContent());
+ }
+
+ HttpResponse tooLarge = HttpResponse.builder().statusCode(413)
+ .message("HTTP/1.1 413 Request Entity Too Large")
+ .payload("{\"badRequest\": {\"message\": \"Volume quota exceeded. You cannot create a volume of size 1G\", " +
+ "\"code\": 413, \"retryAfter\": 0}}")
+ .build();
+
+ @Test
+ public void test413MakesInsufficientResourcesException() {
+ fn.handleError(command, tooLarge);
+
+ assertEquals(command.getException().getClass(), InsufficientResourcesException.class);
+ assertEquals(command.getException().getMessage(), tooLarge.getPayload().getRawContent());
+ }
+
+ /**
+ * Reponse received from Rackspace UK on November 14, 2012.
+ */
+ HttpResponse retryAt = HttpResponse.builder().statusCode(413)
+ .message("HTTP/1.1 413 Request Entity Too Large")
+ .payload("{ 'overLimit' : { 'code' : 413,"
+ + " 'message' : 'OverLimit Retry...', "
+ + " 'details' : 'Error Details...',"
+ + " 'retryAt' : '2012-11-14T21:51:28UTC' }}")
+ .build();
+
+ @Test
+ public void test413WithRetryAtExceptionParsesDelta() {
+ fn.handleError(command, retryAt);
+
+ assertEquals(command.getException().getClass(), RetryAfterException.class);
+ assertEquals(command.getException().getMessage(), "retry in 3600 seconds");
+ }
+
+ /**
+ * Folsom response. This contains a delta in seconds to retry after, not a
+ * fixed time.
+ *
+ */
+ HttpResponse retryAfter = HttpResponse.builder().statusCode(413)
+ .message("HTTP/1.1 413 Request Entity Too Large")
+ .payload("{ 'overLimit': { 'message': 'This request was rate-limited.', "
+ + " 'retryAfter': '54', "
+ + " 'details': 'Only 1 POST request(s) can be made to \\'*\\' every minute.'" + " }}")
+ .build();
+
+ @Test
+ public void test413WithRetryAfterExceptionFolsom() {
+ fn.handleError(command, retryAfter);
+
+ assertEquals(command.getException().getClass(), RetryAfterException.class);
+ assertEquals(command.getException().getMessage(), "retry in 54 seconds");
+ }
+
+ /**
+ * Folsom response with a retryAt field inserted -at a different date. This
+ * can be used to verify that the retryAfter field is picked up first
+ */
+ HttpResponse retryAfterTrumps = HttpResponse.builder().statusCode(413)
+ .message("HTTP/1.1 413 Request Entity Too Large")
+ .payload("{ 'overLimit': {"
+ + " 'message': 'This request was rate-limited.', "
+ + " 'retryAfter': '54', "
+ + " 'retryAt' : '2012-11-14T21:51:28UTC',"
+ + " 'details': 'Only 1 POST request(s) can be made to \\'*\\' every minute.' }}")
+ .build();
+
+ @Test
+ public void test413WithRetryAfterTrumpsRetryAt() {
+ fn.handleError(command, retryAfterTrumps);
+
+ assertEquals(command.getException().getClass(), RetryAfterException.class);
+ assertEquals(command.getException().getMessage(), "retry in 54 seconds");
+ }
+
+ HttpResponse badRetryAt = HttpResponse.builder().statusCode(413)
+ .message("HTTP/1.1 413 Request Entity Too Large")
+ .payload("{ 'overLimit' : { 'code' : 413,"
+ + " 'message' : 'OverLimit Retry...', "
+ + " 'details' : 'Error Details...',"
+ + " 'retryAt' : '2012-11-~~~:51:28UTC' }}")
+ .build();
+
+ @Test
+ public void test413WithBadRetryAtFormatFallsBack() {
+ fn.handleError(command, badRetryAt);
+
+ assertEquals(command.getException().getClass(), InsufficientResourcesException.class);
+ assertEquals(command.getException().getMessage(), badRetryAt.getPayload().getRawContent());
+ }
+
+
+ DateCodec iso8601Seconds = new DateServiceIso8601SecondsCodec(new SimpleDateFormatDateService());
+
+ Ticker y2k = new Ticker() {
+
+ @Override
+ public long read() {
+ return TimeUnit.MILLISECONDS.toNanos(iso8601Seconds.toDate("2012-11-14T20:51:28UTC").getTime());
+ }
+
+ };
+
+ NovaErrorHandler fn = new NovaErrorHandler(HeaderToRetryAfterException.create(y2k, iso8601Seconds),
+ new OverLimitParser(new GsonWrapper(new Gson())));
+
+ private HttpCommand command() {
+ return new HttpCommand(HttpRequest.builder().method("POST").endpoint("https://nova/v1.1/servers").build());
+ }
+
+}
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/internal/BaseNovaApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiExpectTest.java
new file mode 100644
index 0000000..6c63da5
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiExpectTest.java
@@ -0,0 +1,28 @@
+/*
+ * 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.internal;
+
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+
+/**
+ * Base class for writing KeyStone Rest Api Expect tests
+ *
+ * @author Adrian Cole
+ */
+public class BaseNovaApiExpectTest extends BaseNovaExpectTest<NovaApi> {
+
+}
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/internal/BaseNovaApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java
new file mode 100644
index 0000000..da1847b
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java
@@ -0,0 +1,120 @@
+/*
+ * 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.internal;
+
+import java.util.Properties;
+import java.util.Set;
+
+import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.config.NovaProperties;
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
+import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
+import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
+import org.jclouds.openstack.nova.v2_0.features.ImageApi;
+import org.jclouds.openstack.nova.v2_0.features.ServerApi;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.ComparisonChain;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Ordering;
+
+/**
+ * Tests behavior of {@code NovaApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live")
+public class BaseNovaApiLiveTest extends BaseApiLiveTest<NovaApi> {
+ protected String hostName = System.getProperty("user.name").replace('.','-').toLowerCase();
+
+ public BaseNovaApiLiveTest() {
+ provider = "openstack-nova";
+ }
+
+ protected Set<String> zones;
+
+ @BeforeClass(groups = { "integration", "live" })
+ @Override
+ public void setup() {
+ super.setup();
+ zones = api.getConfiguredZones();
+ for (String zone : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zone);
+ for (Resource server : serverApi.list().concat()) {
+ if (server.getName().equals(hostName))
+ serverApi.delete(server.getId());
+ }
+ }
+ }
+
+ @Override
+ protected Properties setupProperties() {
+ Properties props = super.setupProperties();
+ setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
+ setIfTestSystemPropertyPresent(props, NovaProperties.AUTO_ALLOCATE_FLOATING_IPS);
+ return props;
+ }
+
+ protected Server createServerInZone(String zoneId) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ ServerCreated server = serverApi.create(hostName, imageIdForZone(zoneId), flavorRefForZone(zoneId));
+ blockUntilServerInState(server.getId(), serverApi, Status.ACTIVE);
+ return serverApi.get(server.getId());
+ }
+
+ /**
+ * Will block until the requested server is in the correct state, if Extended Server Status extension is loaded
+ * this will continue to block while any task is in progress.
+ */
+ protected void blockUntilServerInState(String serverId, ServerApi api, Status status) {
+ Server currentDetails = null;
+ for (currentDetails = api.get(serverId); currentDetails.getStatus() != status
+ || ((currentDetails.getExtendedStatus().isPresent() && currentDetails.getExtendedStatus().get()
+ .getTaskState() != null)); currentDetails = api.get(serverId)) {
+ System.out.printf("blocking on status %s%n%s%n", status, currentDetails);
+ try {
+ Thread.sleep(5 * 1000);
+ } catch (InterruptedException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+ }
+
+ protected String imageIdForZone(String zoneId) {
+ ImageApi imageApi = api.getImageApiForZone(zoneId);
+ return Iterables.getLast(imageApi.list().concat()).getId();
+ }
+
+ protected String flavorRefForZone(String zoneId) {
+ FlavorApi flavorApi = api.getFlavorApiForZone(zoneId);
+ return DEFAULT_FLAVOR_ORDERING.min(flavorApi.listInDetail().concat()).getId();
+ }
+
+ static final Ordering<Flavor> DEFAULT_FLAVOR_ORDERING = new Ordering<Flavor>() {
+ public int compare(Flavor left, Flavor right) {
+ return ComparisonChain.start().compare(left.getVcpus(), right.getVcpus()).compare(left.getRam(), right.getRam())
+ .compare(left.getDisk(), right.getDisk()).result();
+ }
+ };
+}
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/internal/BaseNovaComputeServiceContextExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceContextExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceContextExpectTest.java
new file mode 100644
index 0000000..bd3b731
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceContextExpectTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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.internal;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.NovaApiMetadata;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.inject.Module;
+
+/**
+ * Base class for writing KeyStone Expect tests with the ComputeService abstraction
+ *
+ * @author Matt Stephenson
+ */
+public abstract class BaseNovaComputeServiceContextExpectTest<T> extends BaseNovaExpectTest<T> implements
+ Function<ComputeServiceContext, T> {
+
+ protected final HttpRequest listDetail = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/detail")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ protected final HttpResponse listDetailResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/image_list_detail.json")).build();
+
+ protected final HttpRequest listFlavorsDetail = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/detail")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ protected final HttpResponse listFlavorsDetailResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/flavor_list_detail.json")).build();
+
+ protected final HttpRequest listServers = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/detail")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ protected final HttpResponse listServersResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/server_list_details.json")).build();
+
+ protected final HttpRequest listFloatingIps = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ protected final HttpResponse listFloatingIpsResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/floatingip_list.json")).build();
+
+ @Override
+ public T createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
+ return apply(createComputeServiceContext(fn, module, props));
+ }
+
+ private ComputeServiceContext createComputeServiceContext(Function<HttpRequest, HttpResponse> fn, Module module,
+ Properties props) {
+ return createInjector(fn, module, props).getInstance(ComputeServiceContext.class);
+ }
+
+ @Override
+ protected ApiMetadata createApiMetadata() {
+ return 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/internal/BaseNovaComputeServiceExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceExpectTest.java
new file mode 100644
index 0000000..2664e8d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceExpectTest.java
@@ -0,0 +1,35 @@
+/*
+ * 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.internal;
+
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.ComputeServiceContext;
+
+/**
+ * Base class for writing KeyStone Expect tests with the ComputeService
+ * abstraction
+ *
+ * @author Matt Stephenson
+ */
+public class BaseNovaComputeServiceExpectTest extends BaseNovaComputeServiceContextExpectTest<ComputeService> {
+
+ @Override
+ public ComputeService apply(ComputeServiceContext input) {
+ return input.getComputeService();
+ }
+
+}
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/internal/BaseNovaExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaExpectTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaExpectTest.java
new file mode 100644
index 0000000..714930c
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaExpectTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.internal;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.keystone.v2_0.internal.KeystoneFixture;
+import org.jclouds.rest.internal.BaseRestApiExpectTest;
+
+/**
+ * Base class for writing Nova Expect tests
+ *
+ * @author Adrian Cole
+ */
+public class BaseNovaExpectTest<T> extends BaseRestApiExpectTest<T> {
+ protected HttpRequest keystoneAuthWithUsernameAndPassword;
+ protected HttpRequest keystoneAuthWithUsernameAndPasswordAndTenantName;
+ protected HttpRequest keystoneAuthWithAccessKeyAndSecretKeyAndTenantName;
+ protected String authToken;
+ protected HttpResponse responseWithKeystoneAccess;
+ protected HttpRequest extensionsOfNovaRequest;
+ protected HttpResponse extensionsOfNovaResponse;
+ protected HttpResponse unmatchedExtensionsOfNovaResponse;
+ protected HttpRequest keystoneAuthWithAccessKeyAndSecretKeyAndTenantId;
+ protected String identityWithTenantId;
+
+ public BaseNovaExpectTest() {
+ provider = "openstack-nova";
+ keystoneAuthWithUsernameAndPassword = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPassword(identity,
+ credential);
+ keystoneAuthWithUsernameAndPasswordAndTenantName = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPasswordAndTenantName(identity,
+ credential);
+ keystoneAuthWithAccessKeyAndSecretKeyAndTenantName = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKeyAndTenantName(identity,
+ credential);
+ keystoneAuthWithAccessKeyAndSecretKeyAndTenantId = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKeyAndTenantId(identity,
+ credential);
+
+ authToken = KeystoneFixture.INSTANCE.getAuthToken();
+ responseWithKeystoneAccess = KeystoneFixture.INSTANCE.responseWithAccess();
+ // now, createContext arg will need tenant prefix
+ identityWithTenantId = KeystoneFixture.INSTANCE.getTenantId() + ":" + identity;
+ identity = KeystoneFixture.INSTANCE.getTenantName() + ":" + identity;
+
+ extensionsOfNovaRequest = HttpRequest.builder().method("GET")
+ // NOTE THIS IS NOVA, NOT KEYSTONE
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/extensions")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ extensionsOfNovaResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/extension_list_full.json")).build();
+
+ unmatchedExtensionsOfNovaResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/extension_list.json")).build();
+ }
+
+ @Override
+ protected HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) {
+ return HttpRequestComparisonType.JSON;
+ }
+
+ protected HttpRequest.Builder<?> authenticatedGET() {
+ return HttpRequest.builder()
+ .method("GET")
+ .addHeader("Accept", MediaType.APPLICATION_JSON)
+ .addHeader("X-Auth-Token", authToken);
+ }
+}
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/parse/ParseComputeServiceTypicalSecurityGroupTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseComputeServiceTypicalSecurityGroupTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseComputeServiceTypicalSecurityGroupTest.java
new file mode 100644
index 0000000..9b056b9
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseComputeServiceTypicalSecurityGroupTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.parse;
+
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+import org.jclouds.openstack.nova.v2_0.domain.TenantIdAndName;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseSecurityGroupTest")
+public class ParseComputeServiceTypicalSecurityGroupTest extends BaseItemParserTest<SecurityGroup> {
+
+ @Override
+ public String resource() {
+ return "/securitygroup_details_computeservice_typical.json";
+ }
+
+ @Override
+ @SelectJson("security_group")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public SecurityGroup expected() {
+
+ Set<SecurityGroupRule> securityGroupRules = ImmutableSet.of(
+ SecurityGroupRule.builder().fromPort(22)
+ .ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("2769")
+ .ipRange("0.0.0.0/0").id("10331").build(),
+ SecurityGroupRule.builder().fromPort(22).group(TenantIdAndName.builder().tenantId("37936628937291").name("jclouds_mygroup").build())
+ .ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("2769")
+ .id("10332").build(),
+ SecurityGroupRule.builder().fromPort(8080)
+ .ipProtocol(IpProtocol.TCP).toPort(8080).parentGroupId("2769")
+ .ipRange("0.0.0.0/0").id("10333").build(),
+ SecurityGroupRule.builder().fromPort(8080).group(TenantIdAndName.builder().tenantId("37936628937291").name("jclouds_mygroup").build())
+ .ipProtocol(IpProtocol.TCP).toPort(8080).parentGroupId("2769")
+ .id("10334").build()
+ );
+
+ return SecurityGroup.builder().description("jclouds_mygroup").id("2769").tenantId("37936628937291").rules(securityGroupRules)
+ .name("jclouds_mygroup").build();
+ }
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/parse/ParseCreateFlavorTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreateFlavorTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreateFlavorTest.java
new file mode 100644
index 0000000..a125f9f
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreateFlavorTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.parse;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @see FlavorApiExpectTest
+ * @author Ilja Bobkevic
+ */
+@Test(groups = "unit", testName = "ParseCreateFlavorTest")
+public class ParseCreateFlavorTest extends BaseItemParserTest<Flavor> {
+
+ @Override
+ public String resource() {
+ return "/flavor_new.json";
+ }
+
+ @Override
+ @SelectJson("flavor")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Flavor expected() {
+ return Flavor.builder()
+ .id("1cb47a44-9b84-4da4-bf81-c1976e8414ab")
+ .name("128 MB Server").ram(128).vcpus(1)
+ .disk(10).build();
+ }
+
+ @Override
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/parse/ParseCreatedServerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreatedServerTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreatedServerTest.java
new file mode 100644
index 0000000..3b2a774
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreatedServerTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseCreatedServerTest")
+public class ParseCreatedServerTest extends BaseItemParserTest<ServerCreated> {
+
+ @Override
+ public String resource() {
+ return "/new_server.json";
+ }
+
+ @Override
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ServerCreated expected() {
+ return ServerCreated
+ .builder()
+ .id("71752")
+ .name("test-e92")
+ .adminPass("ZWuHcmTMQ7eXoHeM")
+ .links(
+ Link.create(Relation.SELF, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752")),
+ Link.create(Relation.BOOKMARK, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752"))).build();
+
+ }
+
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ServerCreated expectedWithDiskConfig(String diskConfig) {
+ return ServerCreated
+ .builder()
+ .id("71752")
+ .name("test-e92")
+ .adminPass("ZWuHcmTMQ7eXoHeM")
+ .diskConfig(diskConfig)
+ .links(
+ Link.create(Relation.SELF, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752")),
+ Link.create(Relation.BOOKMARK, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752"))).build();
+
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/parse/ParseExtensionListNormalTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java
new file mode 100644
index 0000000..4fec5c0
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.json.BaseSetParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.v2_0.domain.Extension;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseExtensionListNormalTest")
+public class ParseExtensionListNormalTest extends BaseSetParserTest<Extension> {
+
+ @Override
+ public String resource() {
+ return "/extension_list_normal.json";
+ }
+
+ @Override
+ @SelectJson("extensions")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Set<Extension> expected() {
+ return ImmutableSet.of(
+ Extension.builder().alias("os-keypairs").name("Keypairs")
+ .namespace(URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-08-08T00:00:00+00:00"))
+ .description("Keypair Support").build(),
+ Extension.builder().alias("os-volumes").name("Volumes")
+ .namespace(URI.create("http://docs.openstack.org/ext/volumes/api/v1.1"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-03-25T00:00:00+00:00"))
+ .description("Volumes support").build(),
+ Extension.builder().alias("security_groups").name("SecurityGroups")
+ .namespace(URI.create("http://docs.openstack.org/ext/securitygroups/api/v1.1"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-07-21T00:00:00+00:00"))
+ .description("Security group support").build(),
+ Extension.builder().alias("os-floating-ips").name("Floating_ips")
+ .namespace(URI.create("http://docs.openstack.org/ext/floating_ips/api/v1.1"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-06-16T00:00:00+00:00"))
+ .description("Floating IPs support").build());
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+
+}
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/parse/ParseExtensionListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListTest.java
new file mode 100644
index 0000000..ba83a85
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.json.BaseSetParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.v2_0.domain.Extension;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseExtensionListTest")
+public class ParseExtensionListTest extends BaseSetParserTest<Extension> {
+
+ @Override
+ public String resource() {
+ return "/extension_list.json";
+ }
+
+ @Override
+ @SelectJson("extensions")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Set<Extension> expected() {
+ return ImmutableSet
+ .of(Extension
+ .builder()
+ .alias("RAX-PIE")
+ .name("Public Image Extension")
+ .namespace(URI.create("http://docs.rackspacecloud.com/servers/api/ext/pie/v1.0"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-01-22T13:25:27-06:00"))
+ .description("Adds the capability to share an image with other users.")
+ .links(
+ ImmutableSet.of(
+ Link.create(Relation.DESCRIBEDBY, "application/pdf",
+ URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie-20111111.pdf")),
+ Link.create(Relation.DESCRIBEDBY, "application/vnd.sun.wadl+xml",
+ URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie.wadl")))).build(),
+ Extension
+ .builder()
+ .alias("RAX-CBS")
+ .name("Cloud Block Storage")
+ .namespace(URI.create("http://docs.rackspacecloud.com/servers/api/ext/cbs/v1.0"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-01-12T11:22:33-06:00"))
+ .description("Allows mounting cloud block storage volumes.")
+ .links(
+ ImmutableSet.of(Link.create(Relation.DESCRIBEDBY, "application/pdf",
+ URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-cbs-20111201.pdf")),
+ Link.create(Relation.DESCRIBEDBY, "application/vnd.sun.wadl+xml",
+ URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-cbs.wadl"))))
+ .build());
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+
+}
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/parse/ParseExtensionTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionTest.java
new file mode 100644
index 0000000..6ba9645
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionTest.java
@@ -0,0 +1,71 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.v2_0.domain.Extension;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseExtensionTest")
+public class ParseExtensionTest extends BaseItemParserTest<Extension> {
+
+ @Override
+ public String resource() {
+ return "/extension_details.json";
+ }
+
+ @Override
+ @SelectJson("extension")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Extension expected() {
+ return Extension
+ .builder()
+ .alias("RS-PIE")
+ .name("Public Image Extension")
+ .namespace(URI.create("http://docs.rackspacecloud.com/servers/api/ext/pie/v1.0"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-01-22T13:25:27-06:00"))
+ .description("Adds the capability to share an image with other users.")
+ .links(
+ ImmutableSet.of(
+ Link.create(Relation.DESCRIBEDBY, "application/pdf",
+ URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie-20111111.pdf")),
+ Link.create(Relation.DESCRIBEDBY, "application/vnd.sun.wadl+xml",
+ URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie.wadl")))).build();
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/parse/ParseFlavorListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorListTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorListTest.java
new file mode 100644
index 0000000..27f5484
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorListTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseSetParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Jeremy Daggett
+ */
+@Test(groups = "unit", testName = "ParseFlavorListTest")
+public class ParseFlavorListTest extends BaseSetParserTest<Resource> {
+
+ @Override
+ public String resource() {
+ return "/flavor_list.json";
+ }
+
+ @Override
+ @SelectJson("flavors")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Set<Resource> expected() {
+ return ImmutableSet
+ .of(Resource
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f1195ff37")
+ .name("256 MB Server")
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37")))
+ .build(),
+ Resource
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f216543fd")
+ .name("512 MB Server")
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")))
+ .build());
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+
+}
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/parse/ParseFlavorTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorTest.java
new file mode 100644
index 0000000..9d2a011
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @author Jeremy Daggett
+ */
+@Test(groups = "unit", testName = "ParseFlavorTest")
+public class ParseFlavorTest extends BaseItemParserTest<Flavor> {
+
+ @Override
+ public String resource() {
+ return "/flavor_details.json";
+ }
+
+ @Override
+ @SelectJson("flavor")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Flavor expected() {
+ return Flavor
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f1195ff37")
+ .name("256 MB Server")
+ .links(
+ ImmutableSet.of(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37"))))
+ .ram(256).disk(10).vcpus(1).build();
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/parse/ParseFloatingIPListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPListTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPListTest.java
new file mode 100644
index 0000000..705b6e6
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPListTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.parse;
+
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseSetParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Michael Arnold
+ */
+@Test(groups = "unit", testName = "ParseFloatingIPListTest")
+public class ParseFloatingIPListTest extends BaseSetParserTest<FloatingIP> {
+
+ @Override
+ public String resource() {
+ return "/floatingip_list.json";
+ }
+
+ @Override
+ @SelectJson("floating_ips")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Set<FloatingIP> expected() {
+ return ImmutableSet.of(FloatingIP.builder().id("1").instanceId("12").ip("10.0.0.3").fixedIp("11.0.0.1").build(),
+ FloatingIP.builder().id("2").instanceId(null).ip("10.0.0.5").fixedIp(null).build());
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+
+}
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/parse/ParseFloatingIPTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPTest.java
new file mode 100644
index 0000000..a75167c
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.parse;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.FloatingIP;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @author Michael Arnold
+ */
+@Test(groups = "unit", testName = "ParseFloatingIPTest")
+public class ParseFloatingIPTest extends BaseItemParserTest<FloatingIP> {
+
+ @Override
+ public String resource() {
+ return "/floatingip_details.json";
+ }
+
+ @Override
+ @SelectJson("floating_ip")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public FloatingIP expected() {
+ return FloatingIP.builder().id("1").instanceId("123").fixedIp("10.0.0.2").ip("10.0.0.3").build();
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/parse/ParseImageListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageListTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageListTest.java
new file mode 100644
index 0000000..2dd19b3
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageListTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseSetParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Jeremy Daggett
+ */
+@Test(groups = "unit", testName = "ParseImageListTest")
+public class ParseImageListTest extends BaseSetParserTest<Resource> {
+
+ @Override
+ public String resource() {
+ return "/image_list.json";
+ }
+
+ @Override
+ @SelectJson("images")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Set<Resource> expected() {
+ return ImmutableSet
+ .of(Resource
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f6f006e54")
+ .name("CentOS 5.2")
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")))
+ .build(),
+ Resource
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f5736d2a2")
+ .name("My Server Backup")
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2")))
+ .build());
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+
+}
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/parse/ParseImageTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageTest.java
new file mode 100644
index 0000000..4d36a56
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.Image;
+import org.jclouds.openstack.nova.v2_0.domain.Image.Status;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @author Jeremy Daggett
+ */
+@Test(groups = "unit", testName = "ParseImageTest")
+public class ParseImageTest extends BaseItemParserTest<Image> {
+
+ @Override
+ public String resource() {
+ return "/image_details.json";
+ }
+
+ @Override
+ @SelectJson("image")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Image expected() {
+ return Image
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f5736d2a2")
+ .name("My Server Backup")
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-10-10T12:00:00Z"))
+ .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-08-10T12:00:00Z"))
+ .tenantId("12345")
+ .userId("joe")
+ .status(Status.SAVING)
+ .progress(80)
+ .minDisk(5)
+ .minRam(256)
+ .metadata(
+ new ImmutableMap.Builder<String, String>().put("ImageType", "Gold").put("ImageVersion", "1.5")
+ .build())
+ .server(
+ Resource
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f335aa7b3")
+ .name("null")
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3")))
+ .build())
+ .links(
+ ImmutableSet.of(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2"))))
+ .build();
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/parse/ParseKeyPairListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairListTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairListTest.java
new file mode 100644
index 0000000..9576b52
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairListTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.parse;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
+import org.jclouds.openstack.nova.v2_0.functions.internal.ParseKeyPairs;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Michael Arnold
+ */
+@Test(groups = "unit", testName = "ParseKeyPairListTest")
+public class ParseKeyPairListTest extends BaseItemParserTest<FluentIterable<? extends KeyPair>> {
+
+ @Override
+ public String resource() {
+ return "/keypair_list.json";
+ }
+
+ @Override
+ @ResponseParser(ParseKeyPairs.class)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public FluentIterable<? extends KeyPair> expected() {
+ return FluentIterable.from(ImmutableSet.of(
+ KeyPair
+ .builder()
+ .publicKey(
+ "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQCy9EC3O7Ff80vPEfAHDQob61PGwcpYc5KE7tEZnZhrB9n0NyHPRm0E0M+ls3fcTa04HDi+R0DzmRwoyhHQJyI658v8kWZZcuvFjKCcsgsSh/dzdX0xTreLIzSOzt5U7RnZYfshP5cmxtF99yrEY3M/swdin0L+fXsTSkR1B42STQ== nova@nv-aw2az1-api0001")
+ .name("default").fingerprint("ab:0c:f4:f3:54:c0:5d:3f:ed:62:ad:d3:94:7c:79:7c").build(),
+ KeyPair
+ .builder()
+ .publicKey(
+ "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001")
+ .name("testkeypair").fingerprint("d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4").build()));
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+
+}
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/parse/ParseKeyPairTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairTest.java
new file mode 100644
index 0000000..da1423d
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.parse;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.KeyPair;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Michael Arnold
+ */
+@Test(groups = "unit", testName = "ParseKeyPairTest")
+public class ParseKeyPairTest extends BaseItemParserTest<KeyPair> {
+
+ @Override
+ public String resource() {
+ return "/keypair_created.json";
+ }
+
+ @Override
+ @SelectJson("keypair")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public KeyPair expected() {
+ return KeyPair
+ .builder()
+ .publicKey(
+ "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001\n")
+ .privateKey(
+ "-----BEGIN RSA PRIVATE KEY-----\nMIICXQIAAAKBgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABAC\nE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumA\nDSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQIDAQAB\nAoGAW8Ww+KbpQK8smcgCTr/RqcmsSI8VeL2hXjJvDq0L5WbyYuFdkanDvCztUVZn\nsmyfDtwAqZXB4Ct/dN1tY7m8QpdyRaKRW4Q+hghGCAQpsG7rYDdvwdEyvMaW5RA4\ntucQyajMNyQ/tozU3wMx/v8A7RvGcE9tqoG0WK1C3kBu95UCQQDrOd+joYDkvccz\nFIVu5gNPMXEh3fGGzDxk225UlvESquYLzfz4TfmuUjH4Z1BL3wRiwfJsrrjFkm33\njIidDE8PAkEA1qHjxuaIS1yz/rfzErmcOVNlbFHMP4ihjGTTvh1ZctXlNeLwzENQ\nEDaQV3IpUY1KQR6rxcWb5AXgfF9D9PYFpwJBANucAqGAbRgh3lJgPFtXP4u2O0tF\nLPOOxmvbOdybt6KYD4LB5AXmts77SlACFMNhCXUyYaT6UuOSXDyb5gfJsB0CQQC3\nFaGXKU9Z+doQjhlq/6mjvN/nZl80Uvh7Kgb1RVPoAU1kihGeLE0/h0vZTCiyyDNv\nGRqtucMg32J+tUTi0HpBAkAwHiCZMHMeJWHUwIwlRQY/dnR86FWobRl98ViF2rCL\nDHkDVOeIser3Q6zSqU5/m99lX6an5g8pAh/R5LqnOQZC\n-----END RSA PRIVATE KEY-----\n")
+ .name("testkeypair").userId("65649731189278")
+ .fingerprint("d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4").build();
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
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/parse/ParseMetadataItemTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataItemTest.java b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataItemTest.java
new file mode 100644
index 0000000..a13d484
--- /dev/null
+++ b/dependencies/jclouds/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataItemTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.parse;
+
+import java.util.Map;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Jeremy Daggett
+ */
+@Test(groups = "unit", testName = "ParseMetadataItemTest")
+public class ParseMetadataItemTest extends BaseItemParserTest<Map<String, String>> {
+
+ @Override
+ public String resource() {
+ return "/metadata_item.json";
+ }
+
+ @Override
+ @SelectJson("metadata")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Map<String, String> expected() {
+ ImmutableMap<String, String> metadata = ImmutableMap.of("Server Label", "Web Head 1");
+ return metadata;
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+
+}