Skip to content

Commit

Permalink
[linode] avail_kernels, linode_create, linode_delete, linode_list, li…
Browse files Browse the repository at this point in the history
…node_reboot
  • Loading branch information
geemus committed Jul 16, 2010
1 parent 56592d0 commit 50ed143
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/fog/linode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ module Linode
request 'avail_distributions'
request 'avail_kernels'
request 'avail_linodeplans'
request 'avail_stackscripts'
request 'linode_create'
request 'linode_delete'
request 'linode_list'
request 'linode_reboot'

class Mock
include Collections
Expand Down
2 changes: 1 addition & 1 deletion lib/fog/linode/requests/avail_distributions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def avail_distributions(options={})

class Mock

def avail_distributions(distribution_id)
def avail_distributions(options={})
Fog::Mock.not_implemented
end

Expand Down
2 changes: 1 addition & 1 deletion lib/fog/linode/requests/avail_kernels.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def avail_kernels(options={})

class Mock

def avail_kernels(distribution_id)
def avail_kernels(options={})
Fog::Mock.not_implemented
end

Expand Down
35 changes: 35 additions & 0 deletions lib/fog/linode/requests/avail_stackscripts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module Fog
module Linode
class Real

# Get available stack scripts
#
# ==== Parameters
# * options<~Hash>:
# * distributionId<~Integer>: Limit the results to Stackscripts that can be applied to this distribution id
# * distributionVendor<~String>: Debian, Ubuntu, Fedora, etc.
# * keywords<~String>: Search terms
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# TODO: docs
def avail_stackscripts(options={})
request(
:expects => 200,
:method => 'GET',
:query => { :api_action => 'avail.stackscripts' }.merge!(options)
)
end

end

class Mock

def avail_stackscripts(options={})
Fog::Mock.not_implemented
end

end
end
end
39 changes: 39 additions & 0 deletions lib/fog/linode/requests/linode_create.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module Fog
module Linode
class Real

# Creates a linode and assigns you full privileges
#
# ==== Parameters
# * datacenter_id<~Integer>: id of datacenter to place new linode in
# * payment_term<~Integer>: Subscription term in months, in [1, 12, 24]
# * plan_id<~Integer>: id of plan to boot new linode with
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# TODO: docs
def linode_create(datacenter_id, payment_term, plan_id)
request(
:expects => 200,
:method => 'GET',
:query => {
:api_action => 'linode.create',
:datacenterId => datacenter_id,
:paymentTerm => payment_term,
:planId => plan_id
}
)
end

end

class Mock

def linode_create(datacenter_id, payment_term, plan_id)
Fog::Mock.not_implemented
end

end
end
end
34 changes: 34 additions & 0 deletions lib/fog/linode/requests/linode_delete.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module Fog
module Linode
class Real

# List all linodes user has access or delete to
#
# ==== Parameters
# * linode_id<~Integer>: id of linode to delete
# * options<~Hash>:
# * skipChecks<~Boolean>: skips safety checks and always deletes
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# TODO: docs
def linode_delete(linode_id, options={})
request(
:expects => 200,
:method => 'GET',
:query => { :api_action => 'linode.delete', :linodeId => linode_id }.merge!(options)
)
end

end

class Mock

def linode_delete(linode_id, options={})
Fog::Mock.not_implemented
end

end
end
end
33 changes: 33 additions & 0 deletions lib/fog/linode/requests/linode_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module Fog
module Linode
class Real

# List all linodes user has access or delete to
#
# ==== Parameters
# * options<~Hash>:
# * linodeId<~Integer>: Limit the list to the specified LinodeID
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# TODO: docs
def linode_list(options={})
request(
:expects => 200,
:method => 'GET',
:query => { :api_action => 'linode.list' }.merge!(options)
)
end

end

class Mock

def linode_list(options={})
Fog::Mock.not_implemented
end

end
end
end
34 changes: 34 additions & 0 deletions lib/fog/linode/requests/linode_reboot.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module Fog
module Linode
class Real

# Issues a shutdown, and then a boot job for a given linode
#
# ==== Parameters
# * linode_id<~Integer>: id of linode to reboot
# * options<~Hash>:
# * configId<~Boolean>: id of config to boot server with
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Array>:
# TODO: docs
def linode_reboot(linode_id, options={})
request(
:expects => 200,
:method => 'GET',
:query => { :api_action => 'linode.reboot', :linodeId => linode_id }.merge!(options)
)
end

end

class Mock

def linode_reboot(linode_id, options={})
Fog::Mock.not_implemented
end

end
end
end

0 comments on commit 50ed143

Please sign in to comment.