mirror of
				https://github.com/fog/fog.git
				synced 2022-11-09 13:51:43 -05:00 
			
		
		
		
	rackspace models, tightening up servers, adding flavors
This commit is contained in:
		
							parent
							
								
									e8019a18cf
								
							
						
					
					
						commit
						80f30016aa
					
				
					 4 changed files with 59 additions and 2 deletions
				
			
		
							
								
								
									
										18
									
								
								lib/fog/rackspace/models/servers/flavor.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								lib/fog/rackspace/models/servers/flavor.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,18 @@
 | 
			
		|||
module Fog
 | 
			
		||||
  module Rackspace
 | 
			
		||||
    class Servers
 | 
			
		||||
 | 
			
		||||
      class Flavor < Fog::Model
 | 
			
		||||
 | 
			
		||||
        identity :id
 | 
			
		||||
 | 
			
		||||
        attribute :disk
 | 
			
		||||
        attribute :id
 | 
			
		||||
        attribute :name
 | 
			
		||||
        attribute :ram
 | 
			
		||||
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										37
									
								
								lib/fog/rackspace/models/servers/flavors.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								lib/fog/rackspace/models/servers/flavors.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,37 @@
 | 
			
		|||
module Fog
 | 
			
		||||
  module Rackspace
 | 
			
		||||
    class Servers
 | 
			
		||||
 | 
			
		||||
      def flavors
 | 
			
		||||
        Fog::Rackspace::Servers::Flavors.new(:connection => self)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      class Flavors < Fog::Collection
 | 
			
		||||
 | 
			
		||||
        model Fog::Rackspace::Servers::Flavor
 | 
			
		||||
 | 
			
		||||
        def all
 | 
			
		||||
          data = connection.list_flavors_detail.body
 | 
			
		||||
          flavors = Fog::Rackspace::Servers::Flavors.new({
 | 
			
		||||
            :connection => connection
 | 
			
		||||
          })
 | 
			
		||||
          for flavor in data['flavors']
 | 
			
		||||
            flavors << Fog::Rackspace::Servers::Flavor.new({
 | 
			
		||||
              :collection => flavors,
 | 
			
		||||
              :connection => connection
 | 
			
		||||
            }.merge!(flavor))
 | 
			
		||||
          end
 | 
			
		||||
          flavors
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        def get(flavor_id)
 | 
			
		||||
          connection.get_flavor_details(flavor_id)
 | 
			
		||||
        rescue Excon::Errors::NotFound
 | 
			
		||||
          nil
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -24,8 +24,8 @@ module Fog
 | 
			
		|||
          servers
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        def get(id)
 | 
			
		||||
          connection.get_server_details(id)
 | 
			
		||||
        def get(server_id)
 | 
			
		||||
          connection.get_server_details(server_id)
 | 
			
		||||
        rescue Excon::Errors::NotFound
 | 
			
		||||
          nil
 | 
			
		||||
        end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,6 +15,8 @@ module Fog
 | 
			
		|||
      end
 | 
			
		||||
 | 
			
		||||
      def self.reload
 | 
			
		||||
        load "fog/rackspace/models/servers/flavor.rb"
 | 
			
		||||
        load "fog/rackspace/models/servers/flavors.rb"
 | 
			
		||||
        load "fog/rackspace/models/servers/server.rb"
 | 
			
		||||
        load "fog/rackspace/models/servers/servers.rb"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue