forked from fog/fog
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[terremark] get_network_ips, Network#ips, Vdc(s) models
- Loading branch information
Showing
8 changed files
with
208 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,69 @@ | ||
--- | ||
specs: | ||
- rake: | ||
version: 0.8.7 | ||
- annals: | ||
version: 0.0.3 | ||
- excon: | ||
version: 0.0.21 | ||
- formatador: | ||
version: 0.0.13 | ||
- json: | ||
version: 1.4.0 | ||
- mime-types: | ||
version: "1.16" | ||
- net-ssh: | ||
version: 2.0.22 | ||
- nokogiri: | ||
version: 1.4.1 | ||
- rspec: | ||
version: 1.3.0 | ||
- ruby-hmac: | ||
version: 0.4.0 | ||
- shindo: | ||
version: 0.0.17 | ||
hash: e443f12a9a7794f2ff4fc8e8d201b12b1e8b30bb | ||
sources: | ||
- Rubygems: | ||
uri: http://gemcutter.org | ||
dependencies: | ||
formatador: | ||
version: ">= 0.0.10" | ||
group: | ||
- :default | ||
nokogiri: | ||
version: ">= 0" | ||
version: ">= 0.0.10" | ||
rake: | ||
group: | ||
- :default | ||
rake: | ||
version: ">= 0" | ||
ruby-hmac: | ||
group: | ||
- :default | ||
rspec: | ||
version: ">= 0" | ||
mime-types: | ||
group: | ||
- :default | ||
ruby-hmac: | ||
version: ">= 0" | ||
rspec: | ||
group: | ||
- :default | ||
mime-types: | ||
version: ">= 0" | ||
net-ssh: | ||
group: | ||
- :default | ||
net-ssh: | ||
version: ">= 0" | ||
json: | ||
group: | ||
- :default | ||
json: | ||
version: ">= 0" | ||
excon: | ||
group: | ||
- :default | ||
excon: | ||
version: ">= 0.0.21" | ||
shindo: | ||
group: | ||
- :default | ||
shindo: | ||
version: ">= 0" | ||
nokogiri: | ||
group: | ||
- :default | ||
version: ">= 0" | ||
specs: | ||
- rake: | ||
version: 0.8.7 | ||
- annals: | ||
version: 0.0.3 | ||
- excon: | ||
version: 0.0.21 | ||
- formatador: | ||
version: 0.0.13 | ||
- json: | ||
version: 1.4.1 | ||
- mime-types: | ||
version: "1.16" | ||
- net-ssh: | ||
version: 2.0.22 | ||
- nokogiri: | ||
version: 1.4.1 | ||
- rspec: | ||
version: 1.3.0 | ||
- ruby-hmac: | ||
version: 0.4.0 | ||
- shindo: | ||
version: 0.0.17 | ||
hash: e443f12a9a7794f2ff4fc8e8d201b12b1e8b30bb | ||
sources: | ||
- Rubygems: | ||
uri: http://gemcutter.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'fog/model' | ||
|
||
module Fog | ||
module Terremark | ||
module Shared | ||
|
||
class Vdc < Fog::Model | ||
|
||
identity :id | ||
|
||
attribute :name | ||
|
||
def networks | ||
connection.networks(:vdc_id => @id) | ||
end | ||
|
||
def addresses | ||
connection.addresses(:vdc_id => @id) | ||
end | ||
|
||
private | ||
|
||
def href=(new_href) | ||
@id = new_href.split('/').last.to_i | ||
end | ||
|
||
def type=(new_type); end | ||
|
||
def rel=(new_rel); end | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module Fog | ||
module Terremark | ||
module Shared | ||
|
||
module Mock | ||
def vdcs(options = {}) | ||
Fog::Terremark::Shared::Vdcs.new(options.merge(:connection => self)) | ||
end | ||
end | ||
|
||
module Real | ||
def vdcs(options = {}) | ||
Fog::Terremark::Shared::Vdcs.new(options.merge(:connection => self)) | ||
end | ||
end | ||
|
||
class Vdcs < Fog::Collection | ||
|
||
model Fog::Terremark::Shared::Vdc | ||
|
||
def all | ||
data = connection.get_organization(organization_id).body['Links'].select do |entity| | ||
entity['type'] == 'application/vnd.vmware.vcloud.vdc+xml' | ||
end | ||
load(data) | ||
end | ||
|
||
def get(vdc_id) | ||
if vdc_id && vdc = connection.get_vdc(vdc_id).body | ||
new(vdc) | ||
elsif !vdc_id | ||
nil | ||
end | ||
rescue Excon::Errors::Forbidden | ||
nil | ||
end | ||
|
||
def organization_id | ||
@vdc_id ||= connection.default_organization_id | ||
end | ||
|
||
private | ||
|
||
def organization_id=(new_organization_id) | ||
@organization_id = new_organization_id | ||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module Fog | ||
module Parsers | ||
module Terremark | ||
module Shared | ||
|
||
class GetNetworkIps< Fog::Parsers::Base | ||
|
||
def reset | ||
@ip_address = {} | ||
@response = { 'IpAddresses' => [] } | ||
end | ||
|
||
def start_element(name,attributes=[]) | ||
@value = '' | ||
end | ||
|
||
def end_element(name) | ||
case name | ||
when 'Name', 'Status', 'Server' | ||
@ip_address[name.downcase] = @value | ||
when 'IpAddress' | ||
@response['IpAddresses'] << @ip_address | ||
@ip_address = {} | ||
end | ||
end | ||
|
||
end | ||
|
||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module Fog | ||
module Terremark | ||
module Shared | ||
module Real | ||
|
||
# Get details for a Network | ||
# | ||
# ==== Parameters | ||
# * network_id<~Integer> - Id of the network to look up | ||
# | ||
# ==== Returns | ||
# * response<~Excon::Response>: | ||
# * body<~Hash>: | ||
# FIXME | ||
def get_network_ips(network_id) | ||
opts = { | ||
:expects => 200, | ||
:method => 'GET', | ||
:parser => Fog::Parsers::Terremark::Shared::GetNetworkIps.new, | ||
:path => "network/#{network_id}/ipAddresses" | ||
} | ||
if self.is_a?(Fog::Terremark::Ecloud::Real) | ||
opts[:path] = "/extensions/network/#{network_id}/ips" | ||
end | ||
request(opts) | ||
end | ||
|
||
end | ||
|
||
module Mock | ||
|
||
def get_network_ips(network_id) | ||
raise MockNotImplemented.new("Contributions welcome!") | ||
end | ||
|
||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters