mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
fixing more warnings
This commit is contained in:
parent
9ff06a8768
commit
c53b5e273c
19 changed files with 97 additions and 99 deletions
2
bin/fog
2
bin/fog
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env ruby
|
||||
require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'fog'))
|
||||
require 'irb'
|
||||
require 'yaml'
|
||||
require File.join('fog', 'core', 'credentials')
|
||||
|
|
|
@ -74,8 +74,8 @@ module Fog
|
|||
def self.data
|
||||
@data ||= Hash.new do |hash, region|
|
||||
owner_id = Fog::AWS::Mock.owner_id
|
||||
hash[region] = Hash.new do |hash, key|
|
||||
hash[key] = {
|
||||
hash[region] = Hash.new do |region_hash, key|
|
||||
region_hash[key] = {
|
||||
:deleted_at => {},
|
||||
:addresses => {},
|
||||
:instances => {},
|
||||
|
|
|
@ -48,13 +48,13 @@ module Fog
|
|||
|
||||
# make sure port 22 is open in the first security group
|
||||
security_group = connection.security_groups.get(server.groups.first)
|
||||
ip_permission = security_group.ip_permissions.detect do |ip_permission|
|
||||
authorized = security_group.ip_permissions.detect do |ip_permission|
|
||||
ip_permission['ipRanges'].first && ip_permission['ipRanges'].first['cidrIp'] == '0.0.0.0/0' &&
|
||||
ip_permission['fromPort'] == 22 &&
|
||||
ip_permission['ipProtocol'] == 'tcp' &&
|
||||
ip_permission['toPort'] == 22
|
||||
end
|
||||
unless ip_permission
|
||||
unless authorized
|
||||
security_group.authorize_port_range(22..22)
|
||||
end
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ module Fog
|
|||
@image[name] = @value
|
||||
when 'blockDeviceMapping'
|
||||
@in_block_device_mapping = false
|
||||
when 'deviceName', 'virtualName', 'snapshotId', 'volumeSize', 'deleteOnTermination'
|
||||
when 'deviceName', 'virtualName', 'snapshotId', 'deleteOnTermination'
|
||||
@block_device_mapping[name] = @value
|
||||
when 'isPublic'
|
||||
if @value == 'true'
|
||||
|
|
|
@ -33,7 +33,7 @@ module Fog
|
|||
@response['MaxKeys'] = @value.to_i
|
||||
when 'Size'
|
||||
@object['Size'] = @value.to_i
|
||||
when 'Delimeter', 'Key', 'Name', 'StorageClass'
|
||||
when 'Delimeter', 'Key', 'StorageClass'
|
||||
@object[name] = @value
|
||||
end
|
||||
end
|
||||
|
|
|
@ -65,17 +65,17 @@ module Fog
|
|||
elsif @in_version
|
||||
@version
|
||||
end['LastModified'] = Time.parse(@value)
|
||||
when 'KeyMarker', 'Name', 'Prefix', 'VersionIdMarker'
|
||||
@response[name] = @value
|
||||
when 'MaxKeys'
|
||||
@response['MaxKeys'] = @value.to_i
|
||||
when 'Size'
|
||||
@version['Size'] = @value.to_i
|
||||
when 'Key', 'Name', 'StorageClass', 'VersionId'
|
||||
when 'Key', 'KeyMarker', 'Name', 'Prefix', 'StorageClass', 'VersionId', 'VersionIdMarker'
|
||||
if @in_delete_marker
|
||||
@delete_marker
|
||||
elsif @in_version
|
||||
@version
|
||||
else
|
||||
@response
|
||||
end[name] = @value
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,8 +53,8 @@ module Fog
|
|||
response.status = 200
|
||||
response.body = {
|
||||
'requestId' => Fog::AWS::Mock.request_id,
|
||||
'keySet' => key_set.map do |key|
|
||||
key.reject {|key,value| !['keyFingerprint', 'keyName'].include?(key)}
|
||||
'keySet' => key_set.map do |key_pair|
|
||||
key_pair.reject {|key,value| !['keyFingerprint', 'keyName'].include?(key)}
|
||||
end
|
||||
}
|
||||
response
|
||||
|
|
|
@ -75,8 +75,8 @@ module Fog
|
|||
|
||||
def self.data
|
||||
@data ||= Hash.new do |hash, region|
|
||||
hash[region] = Hash.new do |hash, key|
|
||||
hash[key] = {
|
||||
hash[region] = Hash.new do |region_hash, key|
|
||||
region_hash[key] = {
|
||||
:buckets => {}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -6,51 +6,51 @@ module Fog
|
|||
|
||||
class BlockInstantiationError < StandardError; end
|
||||
|
||||
class Server < Fog::Model
|
||||
class Server < Fog::Model
|
||||
|
||||
identity :id
|
||||
identity :id
|
||||
|
||||
attribute :name
|
||||
attribute :image_id # id or name
|
||||
attribute :ip
|
||||
attribute :memory # server.ram
|
||||
attribute :state
|
||||
attribute :description # Optional
|
||||
attribute :sandbox # Optional. Default: False
|
||||
attribute :name
|
||||
attribute :image_id # id or name
|
||||
attribute :ip
|
||||
attribute :memory # server.ram
|
||||
attribute :state
|
||||
attribute :description # Optional
|
||||
attribute :sandbox # Optional. Default: False
|
||||
|
||||
def initialize(attributes={})
|
||||
super
|
||||
end
|
||||
def initialize(attributes={})
|
||||
super
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
connection.grid_server_destroy(@id)
|
||||
true
|
||||
end
|
||||
def destroy
|
||||
requires :id
|
||||
connection.grid_server_destroy(@id)
|
||||
true
|
||||
end
|
||||
|
||||
def image
|
||||
requires :image_id
|
||||
connection.grid_image_get(@image_id)
|
||||
end
|
||||
def image
|
||||
requires :image_id
|
||||
connection.grid_image_get(@image_id)
|
||||
end
|
||||
|
||||
def ready?
|
||||
@state == 'On'
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :name, :image_id, :ip, :memory
|
||||
options['isSandbox'] = sandbox if sandbox
|
||||
options['server.ram'] = memory
|
||||
options['image'] = image_id
|
||||
data = connection.grid_server_add(name, image, ip, options)
|
||||
merge_attributes(data.body)
|
||||
true
|
||||
end
|
||||
def ready?
|
||||
@state == 'On'
|
||||
end
|
||||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :name, :image_id, :ip, :memory
|
||||
options['isSandbox'] = sandbox if sandbox
|
||||
options['server.ram'] = memory
|
||||
options['image'] = image_id
|
||||
data = connection.grid_server_add(name, image, ip, options)
|
||||
merge_attributes(data.body)
|
||||
true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ module Fog
|
|||
@response['MaxKeys'] = @value.to_i
|
||||
when 'Size'
|
||||
@object['Size'] = @value.to_i
|
||||
when 'Delimeter', 'Key', 'Name', 'StorageClass'
|
||||
when 'Delimeter', 'Key', 'StorageClass'
|
||||
@object[name] = @value
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,10 +45,7 @@ module Fog
|
|||
file.close
|
||||
new(data)
|
||||
else
|
||||
body = nil
|
||||
::File.open(path) do |file|
|
||||
body = file.read
|
||||
end
|
||||
body = ::File.read(path)
|
||||
new(data.merge!(:body => body))
|
||||
end
|
||||
else
|
||||
|
|
|
@ -22,7 +22,7 @@ module Fog
|
|||
|
||||
def delete_image(image_id)
|
||||
response = Excon::Response.new
|
||||
if image = list_images_detail.body['images'].detect {|image| image['id'] == image_id}
|
||||
if image = list_images_detail.body['images'].detect {|_| _['id'] == image_id}
|
||||
if image['status'] == 'SAVING'
|
||||
response.status = 409
|
||||
raise(Excon::Errors.status_error({:expects => 202}, response))
|
||||
|
|
|
@ -22,7 +22,7 @@ module Fog
|
|||
|
||||
def delete_server(server_id)
|
||||
response = Excon::Response.new
|
||||
if server = list_servers_detail.body['servers'].detect { |server| server['id'] == server_id }
|
||||
if server = list_servers_detail.body['servers'].detect {|_| _['id'] == server_id}
|
||||
if server['status'] == 'BUILD'
|
||||
response.status = 409
|
||||
raise(Excon::Errors.status_error({:expects => 202}, response))
|
||||
|
|
|
@ -37,7 +37,7 @@ module Fog
|
|||
|
||||
def get_server_details(server_id)
|
||||
response = Excon::Response.new
|
||||
if server = list_servers_detail.body['servers'].detect { |server| server['id'] == server_id }
|
||||
if server = list_servers_detail.body['servers'].detect {|_| _['id'] == server_id}
|
||||
response.status = [200, 203][rand(1)]
|
||||
response.body = { 'server' => server }
|
||||
response
|
||||
|
|
|
@ -28,7 +28,7 @@ module Fog
|
|||
|
||||
def list_addresses(server_id)
|
||||
response = Excon::Response.new
|
||||
if server = list_servers_detail.body['servers'].detect { |server| server['id'] == server_id }
|
||||
if server = list_servers_detail.body['servers'].detect {|_| _['id'] == server_id}
|
||||
response.status = [200, 203][rand(1)]
|
||||
response.body = { 'addresses' => server['addresses'] }
|
||||
response
|
||||
|
|
|
@ -26,7 +26,7 @@ module Fog
|
|||
|
||||
def list_private_addresses(server_id)
|
||||
response = Excon::Response.new
|
||||
if server = list_servers_detail.body['servers'].detect { |server| server['id'] == server_id }
|
||||
if server = list_servers_detail.body['servers'].detect {|_| _['id'] == server_id}
|
||||
response.status = [200, 203][rand(1)]
|
||||
response.body = { 'private' => server['addresses']['private'] }
|
||||
response
|
||||
|
|
|
@ -26,7 +26,7 @@ module Fog
|
|||
|
||||
def list_public_addresses(server_id)
|
||||
response = Excon::Response.new
|
||||
if server = list_servers_detail.body['servers'].detect { |server| server['id'] == server_id }
|
||||
if server = list_servers_detail.body['servers'].detect {|_| _['id'] == server_id}
|
||||
response.status = [200, 203][rand(1)]
|
||||
response.body = { 'public' => server['addresses']['public'] }
|
||||
response
|
||||
|
|
|
@ -25,7 +25,7 @@ module Fog
|
|||
|
||||
def update_server(server_id, options)
|
||||
response = Excon::Response.new
|
||||
if server = list_servers_detail.body['servers'].detect { |server| server['id'] == server_id }
|
||||
if server = list_servers_detail.body['servers'].detect {|_| _['id'] == server_id}
|
||||
if options['adminPass']
|
||||
server['adminPass'] = options['adminPass']
|
||||
end
|
||||
|
|
|
@ -1,39 +1,40 @@
|
|||
module Fog
|
||||
module Terremark
|
||||
module Ecloud
|
||||
module Ecloud
|
||||
|
||||
module Bin
|
||||
end
|
||||
module Bin
|
||||
end
|
||||
|
||||
module Defaults
|
||||
HOST = 'services.enterprisecloud.terremark.com'
|
||||
PATH = '/api/v0.8a-ext2.0'
|
||||
PORT = 443
|
||||
SCHEME = 'https'
|
||||
end
|
||||
module Defaults
|
||||
HOST = 'services.enterprisecloud.terremark.com'
|
||||
PATH = '/api/v0.8a-ext2.0'
|
||||
PORT = 443
|
||||
SCHEME = 'https'
|
||||
end
|
||||
|
||||
extend Fog::Terremark::Shared
|
||||
extend Fog::Terremark::Shared
|
||||
|
||||
def self.new(options={})
|
||||
def self.new(options={})
|
||||
|
||||
unless @required
|
||||
shared_requires
|
||||
@required = true
|
||||
end
|
||||
unless @required
|
||||
shared_requires
|
||||
@required = true
|
||||
end
|
||||
|
||||
check_shared_options(options)
|
||||
check_shared_options(options)
|
||||
|
||||
if Fog.mocking?
|
||||
if Fog.mocking?
|
||||
Fog::Terremark::Ecloud::Mock.new(options)
|
||||
else
|
||||
else
|
||||
Fog::Terremark::Ecloud::Real.new(options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Real
|
||||
end
|
||||
|
||||
include Fog::Terremark::Shared::Real
|
||||
include Fog::Terremark::Shared::Parser
|
||||
class Real
|
||||
|
||||
include Fog::Terremark::Shared::Real
|
||||
include Fog::Terremark::Shared::Parser
|
||||
|
||||
def initialize(options={})
|
||||
@terremark_password = options[:terremark_ecloud_password]
|
||||
|
@ -45,22 +46,22 @@ module Fog
|
|||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
include Fog::Terremark::Shared::Mock
|
||||
include Fog::Terremark::Shared::Parser
|
||||
|
||||
def initialize(option = {})
|
||||
super
|
||||
@base_url = Fog::Terremark::Ecloud::Defaults::SCHEME + "://" +
|
||||
Fog::Terremark::Ecloud::Defaults::HOST +
|
||||
Fog::Terremark::Ecloud::Defaults::PATH
|
||||
@data = self.class.data[:terremark_ecloud_username]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
include Fog::Terremark::Shared::Mock
|
||||
include Fog::Terremark::Shared::Parser
|
||||
|
||||
def initialize(option = {})
|
||||
super
|
||||
@base_url = Fog::Terremark::Ecloud::Defaults::SCHEME + "://" +
|
||||
Fog::Terremark::Ecloud::Defaults::HOST +
|
||||
Fog::Terremark::Ecloud::Defaults::PATH
|
||||
@data = self.class.data[:terremark_ecloud_username]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue