From: marios <[email protected]>
Signed-off-by: marios <[email protected]> --- .../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(-) create mode 100644 server/lib/deltacloud/drivers/mock/data/cimi/address/address1.json create mode 100644 server/lib/deltacloud/drivers/mock/data/cimi/address/address2.json create mode 100644 server/lib/deltacloud/drivers/mock/data/cimi/address/address3.json create mode 100644 server/lib/deltacloud/drivers/mock/data/cimi/address_template/addr_template1.json create mode 100644 server/lib/deltacloud/drivers/mock/data/cimi/address_template/addr_template2.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" } + ] +} 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" } + ] +} 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" } + ] +} 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" } + ] +} 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" } + ] +} 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) -- 1.7.6.5
