mirror of
				https://github.com/fog/fog.git
				synced 2022-11-09 13:51:43 -05:00 
			
		
		
		
	Adding Vlan class to IBM SmartCloud
This commit is contained in:
		
							parent
							
								
									62488b4335
								
							
						
					
					
						commit
						2ade6c329e
					
				
					 3 changed files with 45 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -20,6 +20,8 @@ module Fog
 | 
			
		|||
      collection :keys
 | 
			
		||||
      model :location
 | 
			
		||||
      collection :locations
 | 
			
		||||
      model :vlan
 | 
			
		||||
      collection :vlans
 | 
			
		||||
 | 
			
		||||
      request_path 'fog/ibm/requests/compute'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										15
									
								
								lib/fog/ibm/models/compute/vlan.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								lib/fog/ibm/models/compute/vlan.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -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
									
								
								lib/fog/ibm/models/compute/vlans.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								lib/fog/ibm/models/compute/vlans.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -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
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue