deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [6/11] git commit: CIMI: Adds Address and AddressTemplate methods to deltacloud mock driver + json mock data
Date Wed, 11 Apr 2012 15:33:08 GMT
CIMI: Adds Address and AddressTemplate methods to deltacloud mock driver + json mock data


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/1e76228c
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/1e76228c
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/1e76228c

Branch: refs/heads/master
Commit: 1e76228ce4f1879c84fedf4d6b0c9d3a0fc76d1a
Parents: 2bc31ee
Author: marios <marios@redhat.com>
Authored: Thu Apr 5 13:21:53 2012 +0300
Committer: marios <marios@redhat.com>
Committed: Wed Apr 11 18:32:07 2012 +0300

----------------------------------------------------------------------
 .../drivers/mock/data/cimi/address/address1.json   |   19 +++++++++++++
 .../drivers/mock/data/cimi/address/address2.json   |   19 +++++++++++++
 .../drivers/mock/data/cimi/address/address3.json   |   19 +++++++++++++
 .../data/cimi/address_template/addr_template1.json |   18 ++++++++++++
 .../data/cimi/address_template/addr_template2.json |   18 ++++++++++++
 .../drivers/mock/mock_driver_cimi_methods.rb       |   22 +++++++++++++++
 6 files changed, 115 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/1e76228c/server/lib/deltacloud/drivers/mock/data/cimi/address/address1.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/address/address1.json b/server/lib/deltacloud/drivers/mock/data/cimi/address/address1.json
new file mode 100644
index 0000000..ccf0695
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/address/address1.json
@@ -0,0 +1,19 @@
+{ "id": "http://cimi.example.org/addresses/address1",
+  "name": "address1",
+  "description": "an IP address",
+  "created": "Wed Apr 04 11:59:15 EET 2012",
+  "ip": "192.168.10.1",
+  "hostname": "marios.local",
+  "allocation": "static",
+  "defaultGateway": "192.168.0.1",
+  "dns": "192.168.0.10",
+  "macAddress": "",
+  "protocol": "IPv4",
+  "mask": "255.255.0.0",
+  "network": {"href": "http://cimi.example.org/networks/network1"},
+  "resource": {},
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/addresses/address1" },
+    { "rel": "delete", "href": "http://cimi.example.org/addresses/address1" }
+  ]
+}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/1e76228c/server/lib/deltacloud/drivers/mock/data/cimi/address/address2.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/address/address2.json b/server/lib/deltacloud/drivers/mock/data/cimi/address/address2.json
new file mode 100644
index 0000000..13891eb
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/address/address2.json
@@ -0,0 +1,19 @@
+{ "id": "http://cimi.example.org/addresses/address2",
+  "name": "address2",
+  "description": "an IP address",
+  "created": "Thu Apr 05 12:57:59 EET 2012",
+  "ip": "192.168.10.2",
+  "hostname": "foo.bar",
+  "allocation": "static",
+  "defaultGateway": "192.168.0.1",
+  "dns": "192.168.0.10",
+  "macAddress": "",
+  "protocol": "IPv4",
+  "mask": "255.255.0.0",
+  "network": {"href": "http://cimi.example.org/networks/network1"},
+  "resource": {},
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/addresses/address2" },
+    { "rel": "delete", "href": "http://cimi.example.org/addresses/address2" }
+  ]
+}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/1e76228c/server/lib/deltacloud/drivers/mock/data/cimi/address/address3.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/address/address3.json b/server/lib/deltacloud/drivers/mock/data/cimi/address/address3.json
new file mode 100644
index 0000000..6dc72cb
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/address/address3.json
@@ -0,0 +1,19 @@
+{ "id": "http://cimi.example.org/addresses/address3",
+  "name": "address3",
+  "description": "an IP address",
+  "created": "Wed Apr 04 11:59:15 EET 2012",
+  "ip": "192.168.10.3",
+  "hostname": "jsmith.local",
+  "allocation": "static",
+  "defaultGateway": "192.168.0.1",
+  "dns": "192.168.0.10",
+  "macAddress": "",
+  "protocol": "IPv4",
+  "mask": "255.255.0.0",
+  "network": {"href": "http://cimi.example.org/networks/network1"},
+  "resource": {},
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/addresses/address3" },
+    { "rel": "delete", "href": "http://cimi.example.org/addresses/address3" }
+  ]
+}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/1e76228c/server/lib/deltacloud/drivers/mock/data/cimi/address_template/addr_template1.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/address_template/addr_template1.json
b/server/lib/deltacloud/drivers/mock/data/cimi/address_template/addr_template1.json
new file mode 100644
index 0000000..fd5140b
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/address_template/addr_template1.json
@@ -0,0 +1,18 @@
+{ "id": "http://cimi.example.org/address_templates/addr_template1",
+  "name": "addr_template1",
+  "description": "an IP address",
+  "created": "Tue Apr 03 10:34:45 EET 2012",
+  "ip": "192.168.10.1",
+  "hostname": "marios.local",
+  "allocation": "static",
+  "defaultGateway": "192.168.0.1",
+  "dns": "192.168.0.10",
+  "macAddress": "",
+  "protocol": "IPv4",
+  "mask": "255.255.0.0",
+  "network": {"href": "http://cimi.example.org/networks/network1"},
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/address_templates/addr_template1" },
+    { "rel": "delete", "href": "http://cimi.example.org/address_templates/addr_template1"
}
+  ]
+}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/1e76228c/server/lib/deltacloud/drivers/mock/data/cimi/address_template/addr_template2.json
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/data/cimi/address_template/addr_template2.json
b/server/lib/deltacloud/drivers/mock/data/cimi/address_template/addr_template2.json
new file mode 100644
index 0000000..f4bdb56
--- /dev/null
+++ b/server/lib/deltacloud/drivers/mock/data/cimi/address_template/addr_template2.json
@@ -0,0 +1,18 @@
+{ "id": "http://cimi.example.org/address_templates/addr_template2",
+  "name": "addr_template2",
+  "description": "an IP address",
+  "created": "Wed Apr 04 13:27:15 EET 2012",
+  "ip": "192.168.10.1",
+  "hostname": "foo.bar",
+  "allocation": "static",
+  "defaultGateway": "192.168.0.1",
+  "dns": "192.168.0.10",
+  "macAddress": "",
+  "protocol": "IPv4",
+  "mask": "255.255.0.0",
+  "network": {"href": "http://cimi.example.org/networks/network1"},
+  "operations": [
+    { "rel": "edit", "href": "http://cimi.example.org/address_templates/addr_template2" },
+    { "rel": "delete", "href": "http://cimi.example.org/address_templates/addr_template2"
}
+  ]
+}

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/1e76228c/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
index 81f13c2..781be1e 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
@@ -152,6 +152,28 @@ module Deltacloud::Drivers::Mock
       end
     end
 
+    def addresses(credentials, opts={})
+      check_credentials(credentials)
+      if opts[:id].nil?
+        addresses = @client.load_all_cimi(:address).map{|addr| CIMI::Model::Address.from_json(addr)}
+        addresses.map{|addr|convert_cimi_mock_urls(:address, addr, opts[:env])}.flatten
+      else
+        address = CIMI::Model::Address.from_json(@client.load_cimi(:address, opts[:id]))
+        convert_cimi_mock_urls(:address, address, opts[:env])
+      end
+    end
+
+    def address_templates(credentials, opts={})
+      check_credentials(credentials)
+      if opts[:id].nil?
+        address_templates = @client.load_all_cimi(:address_template).map{|addr_templ| CIMI::Model::AddressTemplate.from_json(addr_templ)}
+        address_templates.map{|addr_templ|convert_cimi_mock_urls(:address_template, addr_templ,
opts[:env])}.flatten
+      else
+        address_template = CIMI::Model::AddressTemplate.from_json(@client.load_cimi(:address_template,
opts[:id]))
+        convert_cimi_mock_urls(:address_template, address_template, opts[:env])
+      end
+    end
+
     private
 
     def convert_cimi_mock_urls(model_name, cimi_object, context)


Mime
View raw message