Skip to content

Commit

Permalink
Adding Vlan class to IBM SmartCloud
Browse files Browse the repository at this point in the history
  • Loading branch information
BrindleFly committed Mar 25, 2012
1 parent 62488b4 commit 2ade6c3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/fog/ibm/compute.rb
Expand Up @@ -20,6 +20,8 @@ class IBM < Fog::Service
collection :keys
model :location
collection :locations
model :vlan
collection :vlans

request_path 'fog/ibm/requests/compute'

Expand Down
15 changes: 15 additions & 0 deletions lib/fog/ibm/models/compute/vlan.rb
@@ -0,0 +1,15 @@
require 'fog/core/model'

module Fog
module Compute
class IBM
class Vlan < Fog::Model

identity :id
attribute :name
attribute :location

end
end
end
end
28 changes: 28 additions & 0 deletions lib/fog/ibm/models/compute/vlans.rb
@@ -0,0 +1,28 @@
require 'fog/core/collection'
require 'fog/ibm/models/compute/vlan'

module Fog
module Compute
class IBM

class Vlans < Fog::Collection

model Fog::Compute::IBM::Vlan

def all
load(connection.list_vlans.body['vlan'])
end

def get(vlan_id)
begin
vlan = connection.list_vlans.body
new(vlan['vlan'].find{|vlan| vlan['id'] == vlan_id.to_s })
rescue Fog::Compute::IBM::NotFound
nil
end
end

end
end
end
end

0 comments on commit 2ade6c3

Please sign in to comment.