fog 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/Gemfile.lock +5 -5
- data/README.rdoc +29 -29
- data/fog.gemspec +24 -2
- data/lib/fog.rb +4 -15
- data/lib/fog/aws.rb +2 -2
- data/lib/fog/aws/ec2.rb +64 -101
- data/lib/fog/aws/elb.rb +19 -27
- data/lib/fog/aws/models/ec2/addresses.rb +1 -9
- data/lib/fog/aws/models/ec2/flavors.rb +1 -7
- data/lib/fog/aws/models/ec2/images.rb +1 -7
- data/lib/fog/aws/models/ec2/key_pairs.rb +1 -7
- data/lib/fog/aws/models/ec2/security_groups.rb +1 -7
- data/lib/fog/aws/models/ec2/servers.rb +1 -7
- data/lib/fog/aws/models/ec2/snapshots.rb +1 -9
- data/lib/fog/aws/models/ec2/volumes.rb +1 -9
- data/lib/fog/aws/models/s3/directories.rb +1 -7
- data/lib/fog/aws/models/s3/file.rb +5 -0
- data/lib/fog/aws/requests/ec2/allocate_address.rb +2 -0
- data/lib/fog/aws/requests/ec2/attach_volume.rb +2 -0
- data/lib/fog/aws/requests/ec2/create_key_pair.rb +2 -0
- data/lib/fog/aws/requests/ec2/create_snapshot.rb +2 -0
- data/lib/fog/aws/requests/ec2/create_volume.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_addresses.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_availability_zones.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_images.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_instances.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_key_pairs.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_regions.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_reserved_instances.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_security_groups.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_snapshots.rb +2 -0
- data/lib/fog/aws/requests/ec2/describe_volumes.rb +2 -0
- data/lib/fog/aws/requests/ec2/detach_volume.rb +2 -0
- data/lib/fog/aws/requests/ec2/get_console_output.rb +2 -0
- data/lib/fog/aws/requests/ec2/run_instances.rb +2 -0
- data/lib/fog/aws/requests/ec2/terminate_instances.rb +2 -0
- data/lib/fog/aws/requests/elb/create_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/delete_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/deregister_instances_from_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/describe_instance_health.rb +2 -0
- data/lib/fog/aws/requests/elb/describe_load_balancers.rb +2 -0
- data/lib/fog/aws/requests/elb/disable_availability_zones_for_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/enable_availability_zones_for_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/elb/register_instances_with_load_balancer.rb +2 -0
- data/lib/fog/aws/requests/s3/copy_object.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_acl.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_location.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_logging.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_object_versions.rb +2 -0
- data/lib/fog/aws/requests/s3/get_bucket_versioning.rb +2 -0
- data/lib/fog/aws/requests/s3/get_object_acl.rb +2 -0
- data/lib/fog/aws/requests/s3/get_request_payment.rb +2 -0
- data/lib/fog/aws/requests/s3/get_service.rb +2 -0
- data/lib/fog/aws/requests/s3/put_object.rb +2 -2
- data/lib/fog/aws/requests/simpledb/domain_metadata.rb +2 -0
- data/lib/fog/aws/requests/simpledb/get_attributes.rb +2 -0
- data/lib/fog/aws/requests/simpledb/list_domains.rb +2 -0
- data/lib/fog/aws/requests/simpledb/select.rb +2 -0
- data/lib/fog/aws/s3.rb +68 -85
- data/lib/fog/aws/simpledb.rb +15 -29
- data/lib/fog/bluebox.rb +23 -40
- data/lib/fog/bluebox/models/flavors.rb +1 -7
- data/lib/fog/bluebox/models/images.rb +1 -9
- data/lib/fog/bluebox/models/servers.rb +1 -7
- data/lib/fog/credentials.rb +2 -0
- data/lib/fog/errors.rb +20 -0
- data/lib/fog/hmac.rb +48 -0
- data/lib/fog/local.rb +9 -22
- data/lib/fog/local/models/directories.rb +1 -7
- data/lib/fog/rackspace.rb +2 -6
- data/lib/fog/rackspace/files.rb +46 -48
- data/lib/fog/rackspace/models/files/directories.rb +1 -7
- data/lib/fog/rackspace/models/servers/flavors.rb +1 -7
- data/lib/fog/rackspace/models/servers/images.rb +1 -9
- data/lib/fog/rackspace/models/servers/server.rb +37 -1
- data/lib/fog/rackspace/models/servers/servers.rb +8 -7
- data/lib/fog/rackspace/requests/files/put_object.rb +1 -1
- data/lib/fog/rackspace/servers.rb +33 -45
- data/lib/fog/service.rb +82 -0
- data/lib/fog/slicehost.rb +28 -42
- data/lib/fog/slicehost/models/flavors.rb +1 -7
- data/lib/fog/slicehost/models/images.rb +1 -9
- data/lib/fog/slicehost/models/servers.rb +1 -7
- data/lib/fog/ssh.rb +1 -1
- data/lib/fog/vcloud.rb +20 -3
- data/lib/fog/vcloud/collection.rb +25 -5
- data/lib/fog/vcloud/model.rb +4 -0
- data/lib/fog/vcloud/parsers/get_organization.rb +2 -2
- data/lib/fog/vcloud/parsers/get_vdc.rb +2 -2
- data/lib/fog/vcloud/parsers/get_versions.rb +1 -1
- data/lib/fog/vcloud/parsers/login.rb +2 -2
- data/lib/fog/vcloud/parsers/network.rb +53 -0
- data/lib/fog/vcloud/requests/get_network.rb +54 -0
- data/lib/fog/vcloud/requests/get_organization.rb +1 -2
- data/lib/fog/vcloud/terremark/ecloud.rb +17 -4
- data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +35 -0
- data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +9 -9
- data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +18 -0
- data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +36 -0
- data/lib/fog/vcloud/terremark/ecloud/models/network.rb +32 -0
- data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +38 -0
- data/lib/fog/vcloud/terremark/ecloud/models/public_ip.rb +3 -1
- data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +1 -1
- data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +9 -0
- data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +2 -0
- data/lib/fog/vcloud/terremark/ecloud/parsers/network.rb +28 -0
- data/lib/fog/vcloud/terremark/ecloud/parsers/network_ips.rb +31 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +10 -7
- data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +99 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +54 -0
- data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +51 -0
- data/spec/aws/models/s3/file_spec.rb +15 -0
- data/spec/vcloud/requests/get_network_spec.rb +55 -0
- data/spec/vcloud/spec_helper.rb +1 -0
- data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +15 -0
- data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +35 -0
- data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +28 -0
- data/spec/vcloud/terremark/ecloud/models/network_spec.rb +65 -0
- data/spec/vcloud/terremark/ecloud/models/networks_spec.rb +26 -0
- data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +0 -2
- data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +44 -0
- data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +54 -0
- data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +63 -0
- data/tests/aws/requests/ec2/volume_tests.rb +2 -2
- data/tests/helper.rb +2 -0
- metadata +25 -3
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'fog/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Vcloud
|
5
|
+
module Terremark
|
6
|
+
module Ecloud
|
7
|
+
class Network < Fog::Vcloud::Model
|
8
|
+
|
9
|
+
identity :href
|
10
|
+
|
11
|
+
attribute :name
|
12
|
+
attribute :features
|
13
|
+
attribute :configuration
|
14
|
+
attribute :ips_link
|
15
|
+
attribute :type
|
16
|
+
attribute :xmlns
|
17
|
+
|
18
|
+
def ips
|
19
|
+
unless @loaded
|
20
|
+
reload
|
21
|
+
end
|
22
|
+
@ips ||= Fog::Vcloud::Terremark::Ecloud::Ips.
|
23
|
+
new( :connection => connection,
|
24
|
+
:href => ips_link.href )
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Fog
|
2
|
+
module Vcloud
|
3
|
+
module Terremark
|
4
|
+
module Ecloud
|
5
|
+
|
6
|
+
module Mock
|
7
|
+
def networks(options = {})
|
8
|
+
@networks ||= Fog::Vcloud::Terremark::Ecloud::Networks.new(options.merge(:connection => self))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module Real
|
13
|
+
def networks(options = {})
|
14
|
+
@networks ||= Fog::Vcloud::Terremark::Ecloud::Networks.new(options.merge(:connection => self))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Networks < Fog::Vcloud::Collection
|
19
|
+
|
20
|
+
undef_method :create
|
21
|
+
|
22
|
+
model Fog::Vcloud::Terremark::Ecloud::Network
|
23
|
+
|
24
|
+
get_request :get_network
|
25
|
+
vcloud_type "application/vnd.vmware.vcloud.network+xml"
|
26
|
+
all_request lambda { |networks| networks.connection.get_vdc(networks.href).body.networks }
|
27
|
+
|
28
|
+
#def all
|
29
|
+
# pp connection.get_vdc(href).body.networks
|
30
|
+
# load(connection.get_vdc(href).body.networks.map { |network| { } } )
|
31
|
+
#end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -13,11 +13,13 @@ module Fog
|
|
13
13
|
attribute :id
|
14
14
|
|
15
15
|
def internet_services
|
16
|
+
unless @loaded
|
17
|
+
reload
|
18
|
+
end
|
16
19
|
@internet_services ||= Fog::Vcloud::Terremark::Ecloud::InternetServices.
|
17
20
|
new( :connection => connection,
|
18
21
|
:href => href.to_s + "/internetServices" )
|
19
22
|
end
|
20
|
-
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|
@@ -14,6 +14,9 @@ module Fog
|
|
14
14
|
attribute :instantiated_vm_quota
|
15
15
|
|
16
16
|
def public_ips
|
17
|
+
unless @loaded
|
18
|
+
reload
|
19
|
+
end
|
17
20
|
@public_ips ||= Fog::Vcloud::Terremark::Ecloud::PublicIps.new( :connection => connection,
|
18
21
|
:href => other_links.detect { |link| link.type == "application/vnd.tmrk.ecloud.publicIpsList+xml" }.href )
|
19
22
|
end
|
@@ -24,6 +27,12 @@ module Fog
|
|
24
27
|
:href => href.to_s.gsub('vdc','extensions/vdc') + "/internetServices" )
|
25
28
|
end
|
26
29
|
|
30
|
+
def networks
|
31
|
+
@networks ||= Fog::Vcloud::Terremark::Ecloud::Networks.
|
32
|
+
new( :connection => connection,
|
33
|
+
:href => href )
|
34
|
+
end
|
35
|
+
|
27
36
|
end
|
28
37
|
end
|
29
38
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Vcloud
|
4
|
+
module Terremark
|
5
|
+
module Ecloud
|
6
|
+
|
7
|
+
class Network < Fog::Parsers::Vcloud::Network
|
8
|
+
|
9
|
+
def reset
|
10
|
+
@response = Struct::TmrkEcloudNetwork.new([])
|
11
|
+
end
|
12
|
+
|
13
|
+
def start_element(name,attributes=[])
|
14
|
+
super
|
15
|
+
case name
|
16
|
+
when "Link"
|
17
|
+
@response.ips_link = generate_link(attributes)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Fog
|
2
|
+
module Parsers
|
3
|
+
module Vcloud
|
4
|
+
module Terremark
|
5
|
+
module Ecloud
|
6
|
+
|
7
|
+
class NetworkIps< Fog::Parsers::Vcloud::Base
|
8
|
+
|
9
|
+
def reset
|
10
|
+
@response = Struct::TmrkEcloudNetworkIps.new([])
|
11
|
+
@ip_address = Struct::TmrkEcloudNetworkIp.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def end_element(name)
|
15
|
+
case name
|
16
|
+
when 'Name', 'Status', 'Server'
|
17
|
+
@ip_address[name.downcase] = @value
|
18
|
+
when 'IpAddress'
|
19
|
+
@response.addresses << @ip_address
|
20
|
+
@ip_address = Struct::TmrkEcloudNetworkIp.new
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
@@ -17,15 +17,18 @@ module Fog
|
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.
|
20
|
+
def self.validate_internet_service_data(service_data, configure=false)
|
21
21
|
valid_opts = [:name, :protocol, :port, :description, :enabled, :description]
|
22
|
+
if configure
|
23
|
+
valid_opts + [ :id, :href, :timeout ]
|
24
|
+
end
|
22
25
|
unless valid_opts.all? { |opt| service_data.keys.include?(opt) }
|
23
26
|
raise ArgumentError.new("Required Internet Service data missing: #{(valid_opts - service_data.keys).map(&:inspect).join(", ")}")
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
27
|
-
def add_internet_service(
|
28
|
-
Fog::Vcloud::Terremark::Ecloud::Real.
|
30
|
+
def add_internet_service(internet_services_uri, service_data)
|
31
|
+
Fog::Vcloud::Terremark::Ecloud::Real.validate_internet_service_data(service_data)
|
29
32
|
|
30
33
|
request(
|
31
34
|
:body => Fog::Vcloud::Terremark::Ecloud::Real.generate_internet_service_request(service_data),
|
@@ -33,7 +36,7 @@ module Fog
|
|
33
36
|
:headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'},
|
34
37
|
:method => 'POST',
|
35
38
|
:parser => Fog::Parsers::Vcloud::Terremark::Ecloud::InternetService.new,
|
36
|
-
:uri =>
|
39
|
+
:uri => internet_services_uri
|
37
40
|
)
|
38
41
|
end
|
39
42
|
|
@@ -45,10 +48,10 @@ module Fog
|
|
45
48
|
# http://support.theenterprisecloud.com/kb/default.asp?id=561&Lang=1&SID=
|
46
49
|
#
|
47
50
|
|
48
|
-
def add_internet_service(
|
49
|
-
Fog::Vcloud::Terremark::Ecloud::Real.
|
51
|
+
def add_internet_service(internet_services_uri, service_data)
|
52
|
+
Fog::Vcloud::Terremark::Ecloud::Real.validate_internet_service_data(service_data)
|
50
53
|
|
51
|
-
if ip = Fog::Vcloud::Mock.ip_from_uri(
|
54
|
+
if ip = Fog::Vcloud::Mock.ip_from_uri(internet_services_uri.to_s)
|
52
55
|
new_service = service_data.merge!( { :id => rand(1000), :timeout => 2 } )
|
53
56
|
ip[:services] << new_service
|
54
57
|
builder = Builder::XmlMarkup.new
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Fog
|
2
|
+
module Vcloud
|
3
|
+
module Terremark
|
4
|
+
module Ecloud
|
5
|
+
module Real
|
6
|
+
|
7
|
+
def self.generate_configure_internet_service_request(service_data,ip_address_data)
|
8
|
+
builder = Builder::XmlMarkup.new
|
9
|
+
builder.InternetService(:"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance",
|
10
|
+
:xmlns => "urn:tmrk:eCloudExtensions-2.0") {
|
11
|
+
builder.Id(service_data[:id])
|
12
|
+
builder.Href(service_data[:href].to_s)
|
13
|
+
builder.Name(service_data[:name])
|
14
|
+
builder.Protocol(service_data[:protocol])
|
15
|
+
builder.Port(service_data[:port])
|
16
|
+
builder.Enabled(service_data[:enabled])
|
17
|
+
builder.Description(service_data[:description])
|
18
|
+
builder.Timeout(service_data[:timeout])
|
19
|
+
builder.PublicIpAddress {
|
20
|
+
builder.Id(ip_address_data[:id])
|
21
|
+
builder.Href(ip_address_data[:href].to_s)
|
22
|
+
builder.Name(ip_address_data[:name])
|
23
|
+
}
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.validate_public_ip_address_data(ip_address_data)
|
28
|
+
valid_opts = [:name, :href, :id]
|
29
|
+
unless valid_opts.all? { |opt| ip_address_data.keys.include?(opt) }
|
30
|
+
raise ArgumentError.new("Required Internet Service data missing: #{(valid_opts - ip_address_data.keys).map(&:inspect).join(", ")}")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def configure_internet_service(internet_service_uri, service_data, ip_address_data)
|
35
|
+
Fog::Vcloud::Terremark::Ecloud::Real.validate_internet_service_data(service_data, true)
|
36
|
+
|
37
|
+
Fog::Vcloud::Terremark::Ecloud::Real.validate_public_ip_address_data(ip_address_data)
|
38
|
+
|
39
|
+
request(
|
40
|
+
:body => Fog::Vcloud::Terremark::Ecloud::Real.generate_configure_internet_service_request(service_data, ip_address_data),
|
41
|
+
:expects => 200,
|
42
|
+
:headers => {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'},
|
43
|
+
:method => 'PUT',
|
44
|
+
:parser => Fog::Parsers::Vcloud::Terremark::Ecloud::InternetService.new,
|
45
|
+
:uri => internet_service_uri
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
module Mock
|
52
|
+
#
|
53
|
+
# Based on
|
54
|
+
# http://support.theenterprisecloud.com/kb/default.asp?id=583&Lang=1&SID=
|
55
|
+
#
|
56
|
+
|
57
|
+
def configure_internet_service(internet_service_uri, service_data, ip_address_data)
|
58
|
+
Fog::Vcloud::Terremark::Ecloud::Real.validate_internet_service_data(service_data, true)
|
59
|
+
|
60
|
+
Fog::Vcloud::Terremark::Ecloud::Real.validate_public_ip_address_data(ip_address_data)
|
61
|
+
|
62
|
+
found = false
|
63
|
+
xml = nil
|
64
|
+
if ip = Fog::Vcloud::Mock.ip_from_uri(ip_address_data[:href])
|
65
|
+
if service = ip[:services].detect { |service| service[:id] == internet_service_uri.to_s.split('/')[-1].to_i }
|
66
|
+
found = true
|
67
|
+
ip[:services][ip[:services].index(service)] = service_data
|
68
|
+
|
69
|
+
builder = Builder::XmlMarkup.new
|
70
|
+
xml = builder.InternetService(:xmlns => "urn:tmrk:eCloudExtensions-2.0",
|
71
|
+
:"xmlns:i" => "http://www.w3.org/2001/XMLSchema-instance") {
|
72
|
+
builder.Id(service_data[:id])
|
73
|
+
builder.Href(Fog::Vcloud::Terremark::Ecloud::Mock.internet_service_href(service_data))
|
74
|
+
builder.Name(service_data[:name])
|
75
|
+
builder.PublicIpAddress {
|
76
|
+
builder.Id(ip[:id])
|
77
|
+
builder.Href(Fog::Vcloud::Terremark::Ecloud::Mock.public_ip_href(ip))
|
78
|
+
builder.Name(ip[:name])
|
79
|
+
}
|
80
|
+
builder.Protocol(service_data[:protocol])
|
81
|
+
builder.Port(service_data[:port])
|
82
|
+
builder.Enabled(service_data[:enabled])
|
83
|
+
builder.Description(service_data[:description])
|
84
|
+
builder.Timeout(service_data[:timeout])
|
85
|
+
}
|
86
|
+
end
|
87
|
+
end
|
88
|
+
if found
|
89
|
+
mock_it Fog::Parsers::Vcloud::Terremark::Ecloud::InternetService.new, 200, xml, {'Content-Type' => 'application/vnd.tmrk.ecloud.internetService+xml'}
|
90
|
+
else
|
91
|
+
mock_error 200, "401 Unauthorized"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Fog
|
2
|
+
module Vcloud
|
3
|
+
module Terremark
|
4
|
+
module Ecloud
|
5
|
+
module Real
|
6
|
+
|
7
|
+
def get_network(network_uri)
|
8
|
+
request(
|
9
|
+
:expects => 200,
|
10
|
+
:method => 'GET',
|
11
|
+
:parser => Fog::Parsers::Vcloud::Terremark::Ecloud::Network.new,
|
12
|
+
:uri => network_uri
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
module Mock
|
19
|
+
|
20
|
+
def get_network(network_uri)
|
21
|
+
#
|
22
|
+
# Based off of:
|
23
|
+
# http://support.theenterprisecloud.com/kb/default.asp?id=546&Lang=1&SID=
|
24
|
+
#
|
25
|
+
type = "application/vnd.vmware.vcloud.network+xml"
|
26
|
+
response = Excon::Response.new
|
27
|
+
if network = mock_data[:organizations].map { |org| org[:vdcs].map { |vdc| vdc[:networks] } }.flatten.detect { |network| network[:href] == network_uri.to_s }
|
28
|
+
xml = Builder::XmlMarkup.new
|
29
|
+
mock_it Fog::Parsers::Vcloud::Terremark::Ecloud::Network.new, 200,
|
30
|
+
xml.Network(xmlns.merge(:href => network[:href], :name => network[:name], :type => type)) {
|
31
|
+
xml.Link( :rel => "down", :href => network[:href] + "/ips", :type => "application/xml", :name => "IP Addresses" )
|
32
|
+
xml.Configuration {
|
33
|
+
xml.Gateway(network[:gateway])
|
34
|
+
xml.Netmask(network[:netmask])
|
35
|
+
}
|
36
|
+
if network[:features]
|
37
|
+
xml.Features {
|
38
|
+
if feature = network[:features].detect { |feature| feature[:type] == :fencemode }
|
39
|
+
xml.FenceMode(feature[:value])
|
40
|
+
end
|
41
|
+
}
|
42
|
+
end
|
43
|
+
},
|
44
|
+
{ 'Content-Type' => type }
|
45
|
+
else
|
46
|
+
mock_error 200, "401 Unauthorized"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Fog
|
2
|
+
module Vcloud
|
3
|
+
module Terremark
|
4
|
+
module Ecloud
|
5
|
+
module Real
|
6
|
+
|
7
|
+
def get_network_ips(network_ips_uri)
|
8
|
+
request(
|
9
|
+
:expects => 200,
|
10
|
+
:method => 'GET',
|
11
|
+
:parser => Fog::Parsers::Vcloud::Terremark::Ecloud::NetworkIps.new,
|
12
|
+
:uri => network_ips_uri
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
module Mock
|
19
|
+
require 'ipaddr'
|
20
|
+
|
21
|
+
def get_network_ips(network_ips_uri)
|
22
|
+
response = Excon::Response.new
|
23
|
+
if network = mock_data[:organizations].map { |org| org[:vdcs].map { |vdc| vdc[:networks] } }.flatten.detect { |network| network[:href] == network_ips_uri.to_s.gsub(%r:/ips$:,'') }
|
24
|
+
xml = Builder::XmlMarkup.new
|
25
|
+
mock_it Fog::Parsers::Vcloud::Terremark::Ecloud::NetworkIps.new, 200,
|
26
|
+
xml.IpAddresses {
|
27
|
+
IPAddr.new(network[:name]).to_range.to_a[3..-2].each do |ip|
|
28
|
+
xml.IpAddress {
|
29
|
+
xml.Name(ip.to_s)
|
30
|
+
if network[:ips].has_key?(ip.to_s)
|
31
|
+
xml.Status("Assigned")
|
32
|
+
xml.Server(network[:ips][ip.to_s])
|
33
|
+
else
|
34
|
+
xml.Status("Available")
|
35
|
+
end
|
36
|
+
}
|
37
|
+
end
|
38
|
+
},
|
39
|
+
{ 'Content-Type' => 'application/vnd.tmrk.ecloud.ipAddressesList+xml' }
|
40
|
+
else
|
41
|
+
mock_error 200, "401 Unauthorized"
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -103,4 +103,19 @@ describe 'Fog::AWS::S3::File' do
|
|
103
103
|
|
104
104
|
end
|
105
105
|
|
106
|
+
describe "#url" do
|
107
|
+
|
108
|
+
it "should return a signed expiring url" do
|
109
|
+
data = File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r')
|
110
|
+
file = @directory.files.create(:key => 'fogfilename', :body => data)
|
111
|
+
url = file.url(Time.now + 60 * 10)
|
112
|
+
url.should include("fogfilename", "Expires")
|
113
|
+
unless Fog.mocking?
|
114
|
+
open(url).read.should == File.open(File.dirname(__FILE__) + '/../../../lorem.txt', 'r').read
|
115
|
+
end
|
116
|
+
file.destroy
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
106
121
|
end
|