fog-maestrodev 1.18.0.20131209091424 → 1.18.0.20131218202447
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/CONTRIBUTING.md +22 -0
- data/LICENSE.md +20 -0
- data/README.md +29 -42
- data/fog.gemspec +3 -3
- data/lib/fog/aws/compute.rb +1 -0
- data/lib/fog/aws/models/compute/subnet.rb +4 -0
- data/lib/fog/aws/models/compute/vpc.rb +5 -0
- data/lib/fog/aws/models/rds/server.rb +2 -0
- data/lib/fog/aws/models/storage/file.rb +2 -2
- data/lib/fog/aws/parsers/compute/assign_private_ip_addresses.rb +25 -0
- data/lib/fog/aws/requests/compute/assign_private_ip_addresses.rb +60 -0
- data/lib/fog/aws/requests/compute/describe_subnets.rb +8 -0
- data/lib/fog/aws/requests/compute/describe_vpcs.rb +8 -0
- data/lib/fog/cloudstack.rb +1 -1
- data/lib/fog/core/connection.rb +1 -2
- data/lib/fog/core/hmac.rb +3 -3
- data/lib/fog/core/mock.rb +2 -2
- data/lib/fog/core/wait_for.rb +1 -1
- data/lib/fog/core/{timeout.rb → wait_for_defaults.rb} +10 -0
- data/lib/fog/core.rb +1 -1
- data/lib/fog/google/compute.rb +19 -11
- data/lib/fog/google/examples/create.rb +12 -1
- data/lib/fog/google/examples/eric-fail.rb +13 -2
- data/lib/fog/google/examples/image_create.rb +0 -1
- data/lib/fog/google/examples/launch_micro_instance.rb +1 -2
- data/lib/fog/google/examples/metadata.rb +14 -2
- data/lib/fog/google/examples/network.rb +13 -2
- data/lib/fog/google/models/compute/disk.rb +10 -8
- data/lib/fog/google/models/compute/image.rb +8 -3
- data/lib/fog/google/models/compute/server.rb +19 -4
- data/lib/fog/google/models/compute/servers.rb +25 -9
- data/lib/fog/google/requests/compute/insert_disk.rb +6 -3
- data/lib/fog/google/requests/compute/insert_image.rb +1 -5
- data/lib/fog/google/requests/compute/insert_server.rb +8 -21
- data/lib/fog/openstack/compute.rb +3 -0
- data/lib/fog/openstack/models/compute/host.rb +1 -0
- data/lib/fog/openstack/models/compute/security_group.rb +18 -4
- data/lib/fog/openstack/models/compute/security_group_rule.rb +32 -0
- data/lib/fog/openstack/models/compute/security_group_rules.rb +22 -0
- data/lib/fog/openstack/network.rb +33 -3
- data/lib/fog/openstack/requests/compute/create_security_group.rb +3 -3
- data/lib/fog/openstack/requests/compute/create_security_group_rule.rb +1 -1
- data/lib/fog/openstack/requests/compute/create_server.rb +12 -5
- data/lib/fog/openstack/requests/compute/delete_security_group.rb +1 -1
- data/lib/fog/openstack/requests/compute/delete_security_group_rule.rb +2 -0
- data/lib/fog/openstack/requests/compute/get_security_group.rb +14 -24
- data/lib/fog/openstack/requests/compute/get_security_group_rule.rb +38 -0
- data/lib/fog/openstack/requests/compute/list_hosts.rb +3 -3
- data/lib/fog/openstack/volume.rb +3 -1
- data/lib/fog/rackspace/docs/auto_scale.md +9 -9
- data/lib/fog/rackspace/docs/getting_started.md +1 -0
- data/lib/fog/rackspace/docs/queues.md +312 -0
- data/lib/fog/vcloud_director/README.md +2 -0
- data/lib/fog/vcloud_director/compute.rb +78 -8
- data/lib/fog/vcloud_director/generators/compute/org_vdc_network.rb +91 -0
- data/lib/fog/vcloud_director/generators/compute/vapp.rb +30 -0
- data/lib/fog/vcloud_director/models/compute/vm_customization.rb +2 -0
- data/lib/fog/vcloud_director/parsers/compute/vm_customization.rb +2 -0
- data/lib/fog/vcloud_director/requests/compute/delete_network.rb +64 -0
- data/lib/fog/vcloud_director/requests/compute/get_execute_query.rb +433 -333
- data/lib/fog/vcloud_director/requests/compute/get_vapp_metadata.rb +3 -1
- data/lib/fog/vcloud_director/requests/compute/post_attach_disk.rb +1 -1
- data/lib/fog/vcloud_director/requests/compute/post_create_org_vdc_network.rb +83 -0
- data/lib/fog/vcloud_director/requests/compute/post_detach_disk.rb +1 -1
- data/lib/fog/vcloud_director/requests/compute/post_eject_cd_rom.rb +1 -1
- data/lib/fog/vcloud_director/requests/compute/post_insert_cd_rom.rb +1 -1
- data/lib/fog/vcloud_director/requests/compute/put_guest_customization_section_vapp.rb +1 -0
- data/lib/fog/vcloud_director/requests/compute/put_vapp_name_and_description.rb +37 -0
- data/lib/fog/vsphere/models/compute/server.rb +1 -1
- data/lib/fog/xenserver/compute.rb +35 -0
- data/lib/fog/xenserver/models/compute/blob.rb +22 -0
- data/lib/fog/xenserver/models/compute/blobs.rb +25 -0
- data/lib/fog/xenserver/models/compute/bond.rb +23 -0
- data/lib/fog/xenserver/models/compute/bonds.rb +25 -0
- data/lib/fog/xenserver/models/compute/console.rb +3 -1
- data/lib/fog/xenserver/models/compute/crash_dump.rb +19 -0
- data/lib/fog/xenserver/models/compute/crash_dumps.rb +25 -0
- data/lib/fog/xenserver/models/compute/dr_task.rb +17 -0
- data/lib/fog/xenserver/models/compute/dr_tasks.rb +25 -0
- data/lib/fog/xenserver/models/compute/gpu_group.rb +22 -0
- data/lib/fog/xenserver/models/compute/gpu_groups.rb +25 -0
- data/lib/fog/xenserver/models/compute/guest_metrics.rb +2 -1
- data/lib/fog/xenserver/models/compute/host.rb +41 -8
- data/lib/fog/xenserver/models/compute/host_cpu.rb +2 -1
- data/lib/fog/xenserver/models/compute/host_crash_dump.rb +20 -0
- data/lib/fog/xenserver/models/compute/host_crash_dumps.rb +25 -0
- data/lib/fog/xenserver/models/compute/host_metrics.rb +1 -1
- data/lib/fog/xenserver/models/compute/host_patch.rb +25 -0
- data/lib/fog/xenserver/models/compute/host_patchs.rb +25 -0
- data/lib/fog/xenserver/models/compute/network.rb +7 -6
- data/lib/fog/xenserver/models/compute/pbd.rb +3 -1
- data/lib/fog/xenserver/models/compute/pci.rb +22 -0
- data/lib/fog/xenserver/models/compute/pcis.rb +25 -0
- data/lib/fog/xenserver/models/compute/pgpu.rb +20 -0
- data/lib/fog/xenserver/models/compute/pgpus.rb +25 -0
- data/lib/fog/xenserver/models/compute/pif.rb +19 -8
- data/lib/fog/xenserver/models/compute/pif_metrics.rb +28 -0
- data/lib/fog/xenserver/models/compute/pifs_metrics.rb +25 -0
- data/lib/fog/xenserver/models/compute/pool.rb +18 -1
- data/lib/fog/xenserver/models/compute/pool_patch.rb +24 -0
- data/lib/fog/xenserver/models/compute/pool_patchs.rb +25 -0
- data/lib/fog/xenserver/models/compute/role.rb +19 -0
- data/lib/fog/xenserver/models/compute/roles.rb +25 -0
- data/lib/fog/xenserver/models/compute/server.rb +59 -26
- data/lib/fog/xenserver/models/compute/server_appliance.rb +21 -0
- data/lib/fog/xenserver/models/compute/server_appliances.rb +25 -0
- data/lib/fog/xenserver/models/compute/storage_manager.rb +28 -0
- data/lib/fog/xenserver/models/compute/storage_managers.rb +25 -0
- data/lib/fog/xenserver/models/compute/storage_repository.rb +4 -1
- data/lib/fog/xenserver/models/compute/tunnel.rb +20 -0
- data/lib/fog/xenserver/models/compute/tunnels.rb +25 -0
- data/lib/fog/xenserver/models/compute/vbd.rb +3 -2
- data/lib/fog/xenserver/models/compute/vbd_metrics.rb +1 -1
- data/lib/fog/xenserver/models/compute/vdi.rb +4 -1
- data/lib/fog/xenserver/models/compute/vif.rb +11 -2
- data/lib/fog/xenserver/models/compute/vlan.rb +2 -1
- data/lib/fog/xenserver/models/compute/vmpp.rb +35 -0
- data/lib/fog/xenserver/models/compute/vmpps.rb +25 -0
- data/lib/fog/xenserver/models/compute/vtpm.rb +18 -0
- data/lib/fog/xenserver/models/compute/vtpms.rb +25 -0
- data/tests/aws/requests/compute/assign_private_ip_tests.rb +52 -0
- data/tests/google/models/compute/servers_tests.rb +12 -1
- data/tests/google/requests/compute/image_tests.rb +0 -1
- data/tests/helpers/mock_helper.rb +1 -1
- data/tests/openstack/models/compute/security_group_tests.rb +54 -0
- data/tests/openstack/requests/compute/security_group_tests.rb +22 -20
- data/tests/openstack/requests/network/network_tests.rb +8 -8
- data/tests/vcloud_director/requests/compute/edge_gateway_tests.rb +17 -8
- data/tests/vcloud_director/requests/compute/network_tests.rb +25 -1
- data/tests/vcloud_director/requests/compute/query_tests.rb +67 -2
- metadata +125 -132
- checksums.yaml +0 -15
@@ -4,9 +4,20 @@ def test
|
|
4
4
|
# we create a new private network
|
5
5
|
connection.insert_network('my-private-network', '10.240.0.0/16')
|
6
6
|
|
7
|
+
name = "fog-smoke-test-#{Time.now.to_i}"
|
8
|
+
|
9
|
+
disk = connection.disks.create({
|
10
|
+
:name => name,
|
11
|
+
:size_gb => 10,
|
12
|
+
:zone_name => 'us-central1-a',
|
13
|
+
:source_image => 'debian-7-wheezy-v20131120',
|
14
|
+
})
|
15
|
+
|
16
|
+
disk.wait_for { disk.ready? }
|
17
|
+
|
7
18
|
server = connection.servers.create({
|
8
|
-
:name =>
|
9
|
-
:
|
19
|
+
:name => name,
|
20
|
+
:disks => [disk],
|
10
21
|
:machine_type => "n1-standard-1",
|
11
22
|
:zone_name => "us-central1-a",
|
12
23
|
:private_key_path => File.expand_path("~/.ssh/id_rsa"),
|
@@ -57,20 +57,22 @@ module Fog
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
60
|
+
def get_object(writable=true, boot=false, device_name=nil)
|
61
61
|
mode = writable ? 'READ_WRITE' : 'READ_ONLY'
|
62
62
|
return {
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
63
|
+
'boot' => boot,
|
64
|
+
'source' => self_link,
|
65
|
+
'mode' => mode,
|
66
|
+
'deviceName' => device_name
|
67
|
+
}.select { |k, v| !v.empty? }
|
68
|
+
end
|
69
|
+
|
70
|
+
def get_as_boot_disk(writable=true)
|
71
|
+
get_object(writable, true)
|
69
72
|
end
|
70
73
|
|
71
74
|
def ready?
|
72
75
|
data = service.get_disk(self.name, self.zone_name).body
|
73
|
-
data['zone_name'] = self.zone_name
|
74
76
|
self.merge_attributes(data)
|
75
77
|
self.status == RUNNING_STATE
|
76
78
|
end
|
@@ -11,7 +11,6 @@ module Fog
|
|
11
11
|
attribute :kind
|
12
12
|
attribute :creation_timestamp, :aliases => 'creationTimestamp'
|
13
13
|
attribute :description
|
14
|
-
attribute :preferred_kernel, :aliases => 'preferredKernel'
|
15
14
|
|
16
15
|
# This attribute is not available in the representation of an
|
17
16
|
# 'image' returned by the GCE servser (see GCE API). However,
|
@@ -30,6 +29,14 @@ module Fog
|
|
30
29
|
|
31
30
|
attribute :status
|
32
31
|
|
32
|
+
def preferred_kernel=(args)
|
33
|
+
Fog::Logger.deprecation("preferred_kernel= is no longer used [light_black](#{caller.first})[/]")
|
34
|
+
end
|
35
|
+
def preferred_kernel
|
36
|
+
Fog::Logger.deprecation("preferred_kernel is no longer used [light_black](#{caller.first})[/]")
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
33
40
|
def reload
|
34
41
|
requires :name
|
35
42
|
|
@@ -41,11 +48,9 @@ module Fog
|
|
41
48
|
|
42
49
|
def save
|
43
50
|
requires :name
|
44
|
-
requires :preferred_kernel
|
45
51
|
requires :raw_disk
|
46
52
|
|
47
53
|
options = {
|
48
|
-
'preferredKernel' => preferred_kernel,
|
49
54
|
'rawDisk' => raw_disk,
|
50
55
|
'description' => description,
|
51
56
|
}
|
@@ -8,7 +8,7 @@ module Fog
|
|
8
8
|
class Server < Fog::Compute::Server
|
9
9
|
|
10
10
|
identity :name
|
11
|
-
|
11
|
+
|
12
12
|
attribute :network_interfaces, :aliases => 'networkInterfaces'
|
13
13
|
attribute :network, :aliases => 'network'
|
14
14
|
attribute :external_ip, :aliases => 'externalIP'
|
@@ -16,10 +16,24 @@ module Fog
|
|
16
16
|
attribute :zone_name, :aliases => 'zone'
|
17
17
|
attribute :machine_type, :aliases => 'machineType'
|
18
18
|
attribute :disks, :aliases => 'disks'
|
19
|
-
attribute :kernel, :aliases => 'kernel'
|
20
19
|
attribute :metadata
|
21
20
|
attribute :tags, :squash => 'items'
|
22
21
|
|
22
|
+
def image_name=(args)
|
23
|
+
Fog::Logger.deprecation("image_name= is no longer used [light_black](#{caller.first})[/]")
|
24
|
+
end
|
25
|
+
def image_name
|
26
|
+
Fog::Logger.deprecation("image_name is deprecated, use source_image from boot disk [light_black](#{caller.first})[/]")
|
27
|
+
disks.first.source_image
|
28
|
+
end
|
29
|
+
def kernel=(args)
|
30
|
+
Fog::Logger.deprecation("kernel= is no longer used [light_black](#{caller.first})[/]")
|
31
|
+
end
|
32
|
+
def kernel
|
33
|
+
Fog::Logger.deprecation("kernel is no longer used [light_black](#{caller.first})[/]")
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
|
23
37
|
def flavor_id
|
24
38
|
machine_type
|
25
39
|
end
|
@@ -39,7 +53,9 @@ module Fog
|
|
39
53
|
operation
|
40
54
|
end
|
41
55
|
|
56
|
+
# not used since v1
|
42
57
|
def image
|
58
|
+
Fog::Logger.deprecation("Server.image is deprecated, get source_image from boot disk")
|
43
59
|
service.get_image(self.image_name.split('/')[-1])
|
44
60
|
end
|
45
61
|
|
@@ -112,6 +128,7 @@ module Fog
|
|
112
128
|
requires :name
|
113
129
|
requires :machine_type
|
114
130
|
requires :zone_name
|
131
|
+
requires :disks
|
115
132
|
|
116
133
|
if not service.zones.find{ |zone| zone.name == self.zone_name }
|
117
134
|
raise ArgumentError.new "#{self.zone_name.inspect} is either down or you don't have permission to use it."
|
@@ -120,13 +137,11 @@ module Fog
|
|
120
137
|
self.add_ssh_key(self.username, self.public_key) if self.public_key
|
121
138
|
|
122
139
|
options = {
|
123
|
-
'image' => image_name,
|
124
140
|
'machineType' => machine_type,
|
125
141
|
'networkInterfaces' => network_interfaces,
|
126
142
|
'network' => network,
|
127
143
|
'externalIp' => external_ip,
|
128
144
|
'disks' => disks,
|
129
|
-
'kernel' => kernel,
|
130
145
|
'metadata' => metadata,
|
131
146
|
'tags' => tags
|
132
147
|
}.delete_if {|key, value| value.nil?}
|
@@ -45,22 +45,38 @@ module Fog
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def bootstrap(new_attributes = {})
|
48
|
+
name = "fog-#{Time.now.to_i}"
|
49
|
+
zone = "us-central1-b"
|
50
|
+
|
51
|
+
disks = new_attributes[:disks]
|
52
|
+
|
53
|
+
if disks.nil? or disks.empty?
|
54
|
+
# create the persistent boot disk
|
55
|
+
disk_defaults = {
|
56
|
+
:name => name,
|
57
|
+
:size_gb => 10,
|
58
|
+
:zone_name => zone,
|
59
|
+
:source_image => "debian-7-wheezy-v20131120",
|
60
|
+
}
|
61
|
+
|
62
|
+
# backwards compatibility to pre-v1
|
63
|
+
new_attributes[:source_image] = new_attributes[:image_name] if new_attributes[:image_name]
|
64
|
+
|
65
|
+
disk = service.disks.create(disk_defaults.merge(new_attributes))
|
66
|
+
disk.wait_for { disk.ready? }
|
67
|
+
disks = [disk]
|
68
|
+
end
|
69
|
+
|
48
70
|
defaults = {
|
49
|
-
:name =>
|
50
|
-
:
|
71
|
+
:name => name,
|
72
|
+
:disks => disks,
|
51
73
|
:machine_type => "n1-standard-1",
|
52
|
-
:zone_name =>
|
74
|
+
:zone_name => zone,
|
53
75
|
:private_key_path => File.expand_path("~/.ssh/id_rsa"),
|
54
76
|
:public_key_path => File.expand_path("~/.ssh/id_rsa.pub"),
|
55
77
|
:username => ENV['USER'],
|
56
78
|
}
|
57
79
|
|
58
|
-
if new_attributes[:disks]
|
59
|
-
new_attributes[:disks].each do |disk|
|
60
|
-
defaults.delete :image_name if disk['boot']
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
80
|
server = create(defaults.merge(new_attributes))
|
65
81
|
server.wait_for { sshable? }
|
66
82
|
|
@@ -9,9 +9,12 @@ module Fog
|
|
9
9
|
image_project = nil
|
10
10
|
unless image_name.nil?
|
11
11
|
([ @project ] + Fog::Compute::Google::Images::GLOBAL_PROJECTS).each do |project|
|
12
|
-
|
13
|
-
|
12
|
+
if data(project)[:images][image_name]
|
13
|
+
image_project = project
|
14
|
+
break;
|
15
|
+
end
|
14
16
|
end
|
17
|
+
raise ArgumentError.new("Invalid image specified: #{image_name}") unless image_project
|
15
18
|
get_image(image_name, image_project) # ok if image exists, will fail otherwise
|
16
19
|
end
|
17
20
|
get_zone(zone_name)
|
@@ -61,7 +64,7 @@ module Fog
|
|
61
64
|
|
62
65
|
if image_name
|
63
66
|
image = images.get(image_name)
|
64
|
-
raise ArgumentError.new(
|
67
|
+
raise ArgumentError.new("Invalid image specified: #{image_name}") unless image
|
65
68
|
@image_url = @api_url + image.resource_url
|
66
69
|
parameters['sourceImage'] = @image_url
|
67
70
|
end
|
@@ -19,14 +19,10 @@ module Fog
|
|
19
19
|
'project' => @project,
|
20
20
|
}
|
21
21
|
|
22
|
-
kernel_url = @api_url + 'google/global/kernels/' + \
|
23
|
-
options.delete('preferredKernel').to_s
|
24
|
-
|
25
22
|
body_object = {
|
26
23
|
'sourceType' => 'RAW',
|
27
24
|
'name' => image_name,
|
28
|
-
'rawDisk' => options.delete('rawDisk')
|
29
|
-
'preferredKernel' => kernel_url,
|
25
|
+
'rawDisk' => options.delete('rawDisk')
|
30
26
|
}
|
31
27
|
|
32
28
|
# Merge in the remaining params (only 'description' should remain)
|
@@ -26,15 +26,7 @@ module Fog
|
|
26
26
|
|
27
27
|
def insert_server(server_name, zone_name, options={}, *deprecated_args)
|
28
28
|
|
29
|
-
# check that
|
30
|
-
image_project = nil
|
31
|
-
if options.has_key? 'image'
|
32
|
-
([ @project ] + Fog::Compute::Google::Images::GLOBAL_PROJECTS).each do |project|
|
33
|
-
image_project = project
|
34
|
-
break if data(project)[:images][options['image']]
|
35
|
-
end
|
36
|
-
get_image(options['image'], image_project) # ok if image exists, will fail otherwise
|
37
|
-
end
|
29
|
+
# check that zone exists
|
38
30
|
get_zone(zone_name)
|
39
31
|
|
40
32
|
id = Fog::Mock.random_numbers(19).to_s
|
@@ -47,8 +39,6 @@ module Fog
|
|
47
39
|
"name" => server_name,
|
48
40
|
"tags" => { "fingerprint" => "42WmSpB8rSM=" },
|
49
41
|
"machineType" => "https://www.googleapis.com/compute/#{api_version}/projects/#{@project}/zones/#{zone_name}/machineTypes/#{options['machineType']}",
|
50
|
-
"image" => "https://www.googleapis.com/compute/#{api_version}/projects/#{image_project}/global/images/#{options['image']}",
|
51
|
-
"kernel" => "https://www.googleapis.com/compute/#{api_version}/projects/google/global/kernels/gce-v20130813",
|
52
42
|
"canIpForward" => false,
|
53
43
|
"networkInterfaces" => [
|
54
44
|
{
|
@@ -113,6 +103,8 @@ module Fog
|
|
113
103
|
|
114
104
|
def handle_disks(options)
|
115
105
|
disks = []
|
106
|
+
# An array of persistent disks. You must supply a boot disk as the first disk in
|
107
|
+
# this array and mark it as a boot disk using the disks[].boot property.
|
116
108
|
options.delete('disks').each do |disk|
|
117
109
|
if disk.is_a? Disk
|
118
110
|
disks << disk.get_object
|
@@ -120,6 +112,7 @@ module Fog
|
|
120
112
|
disks << disk
|
121
113
|
end
|
122
114
|
end
|
115
|
+
disks.first['boot'] = true
|
123
116
|
disks
|
124
117
|
end
|
125
118
|
|
@@ -139,12 +132,6 @@ module Fog
|
|
139
132
|
}
|
140
133
|
body_object = {:name => server_name}
|
141
134
|
|
142
|
-
if options.has_key? 'image'
|
143
|
-
image_name = options.delete 'image'
|
144
|
-
image = images.get(image_name)
|
145
|
-
@image_url = @api_url + image.resource_url
|
146
|
-
body_object['image'] = @image_url
|
147
|
-
end
|
148
135
|
body_object['machineType'] = @api_url + @project + "/zones/#{zone_name}/machineTypes/#{options.delete 'machineType'}"
|
149
136
|
network = nil
|
150
137
|
if options.has_key? 'network'
|
@@ -170,15 +157,15 @@ module Fog
|
|
170
157
|
# TODO: add other networks
|
171
158
|
body_object['networkInterfaces'] = networkInterfaces
|
172
159
|
|
173
|
-
|
160
|
+
if options['disks'].nil? or options['disks'].empty?
|
161
|
+
raise ArgumentError.new "Empty value for field 'disks'. Boot disk must be specified"
|
162
|
+
end
|
163
|
+
body_object['disks'] = handle_disks(options)
|
174
164
|
|
175
165
|
options['metadata'] = format_metadata options['metadata'] if options['metadata']
|
176
166
|
|
177
167
|
body_object['tags'] = { 'items' => options.delete('tags') } if options['tags']
|
178
168
|
|
179
|
-
if options['kernel']
|
180
|
-
body_object['kernel'] = @api_url + "google/global/kernels/#{options.delete 'kernel'}"
|
181
|
-
end
|
182
169
|
body_object.merge!(options) # Adds in all remaining options that weren't explicitly handled.
|
183
170
|
|
184
171
|
result = self.build_result(api_method, parameters,
|
@@ -28,6 +28,8 @@ module Fog
|
|
28
28
|
collection :addresses
|
29
29
|
model :security_group
|
30
30
|
collection :security_groups
|
31
|
+
model :security_group_rule
|
32
|
+
collection :security_group_rules
|
31
33
|
model :key_pair
|
32
34
|
collection :key_pairs
|
33
35
|
model :tenant
|
@@ -128,6 +130,7 @@ module Fog
|
|
128
130
|
request :create_security_group_rule
|
129
131
|
request :delete_security_group
|
130
132
|
request :delete_security_group_rule
|
133
|
+
request :get_security_group_rule
|
131
134
|
|
132
135
|
# Key Pair
|
133
136
|
request :list_key_pairs
|
@@ -3,16 +3,30 @@ require 'fog/core/model'
|
|
3
3
|
module Fog
|
4
4
|
module Compute
|
5
5
|
class OpenStack
|
6
|
-
|
7
6
|
class SecurityGroup < Fog::Model
|
8
7
|
|
9
8
|
identity :id
|
10
9
|
|
11
10
|
attribute :name
|
12
11
|
attribute :description
|
13
|
-
attribute :rules
|
12
|
+
attribute :security_group_rules, :aliases => "rules"
|
14
13
|
attribute :tenant_id
|
15
14
|
|
15
|
+
def security_group_rules
|
16
|
+
Fog::Compute::OpenStack::SecurityGroupRules.new(:service => service).load(attributes[:security_group_rules])
|
17
|
+
end
|
18
|
+
|
19
|
+
def rules
|
20
|
+
Fog::Logger.deprecation('#rules is deprecated. Use #security_group_rules instead')
|
21
|
+
attributes[:security_group_rules]
|
22
|
+
end
|
23
|
+
|
24
|
+
# no one should be calling this because it doesn't do anything
|
25
|
+
# useful but we deprecated the rules attribute and need to maintain the API
|
26
|
+
def rules=(new_rules)
|
27
|
+
Fog::Logger.deprecation('#rules= is deprecated. Use the Fog::Compute::Openstack::SecurityGroupRules collection to create new rules.')
|
28
|
+
attributes[:security_group_rules] = new_rules
|
29
|
+
end
|
16
30
|
|
17
31
|
def save
|
18
32
|
requires :name, :description
|
@@ -21,7 +35,6 @@ module Fog
|
|
21
35
|
true
|
22
36
|
end
|
23
37
|
|
24
|
-
|
25
38
|
def destroy
|
26
39
|
requires :id
|
27
40
|
service.delete_security_group(id)
|
@@ -29,15 +42,16 @@ module Fog
|
|
29
42
|
end
|
30
43
|
|
31
44
|
def create_security_group_rule(min, max, ip_protocol = "tcp", cidr = "0.0.0.0/0", group_id = nil)
|
45
|
+
Fog::Logger.deprecation('#create_security_group_rule is deprecated. Use the Fog::Compute::Openstack::SecurityGroupRules collection to create new rules.')
|
32
46
|
requires :id
|
33
47
|
service.create_security_group_rule(id, ip_protocol, min, max, cidr, group_id)
|
34
48
|
end
|
35
49
|
|
36
50
|
def delete_security_group_rule(rule_id)
|
51
|
+
Fog::Logger.deprecation('#create_security_group_rule is deprecated. Use the Fog::Compute::Openstack::SecurityGroupRule objects to destroy rules.')
|
37
52
|
service.delete_security_group_rule(rule_id)
|
38
53
|
true
|
39
54
|
end
|
40
|
-
|
41
55
|
end
|
42
56
|
end
|
43
57
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class OpenStack
|
6
|
+
class SecurityGroupRule < Fog::Model
|
7
|
+
identity :id
|
8
|
+
|
9
|
+
attribute :from_port
|
10
|
+
attribute :group
|
11
|
+
attribute :ip_protocol
|
12
|
+
attribute :to_port
|
13
|
+
attribute :parent_group_id
|
14
|
+
attribute :ip_range
|
15
|
+
|
16
|
+
def save
|
17
|
+
requires :ip_protocol, :from_port, :to_port, :parent_group_id
|
18
|
+
cidr = ip_range && ip_range["cidr"]
|
19
|
+
if rule = service.create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group).data[:body]
|
20
|
+
merge_attributes(rule["security_group_rule"])
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def destroy
|
25
|
+
requires :id
|
26
|
+
service.delete_security_group_rule(id)
|
27
|
+
true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/openstack/models/compute/security_group_rule'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Compute
|
6
|
+
class OpenStack
|
7
|
+
class SecurityGroupRules < Fog::Collection
|
8
|
+
|
9
|
+
model Fog::Compute::OpenStack::SecurityGroupRule
|
10
|
+
|
11
|
+
def get(security_group_rule_id)
|
12
|
+
if security_group_rule_id
|
13
|
+
body = service.get_security_group_rule(security_group_rule_id).body
|
14
|
+
new(body['security_group_rule'])
|
15
|
+
end
|
16
|
+
rescue Fog::Compute::OpenStack::NotFound
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -118,10 +118,40 @@ module Fog
|
|
118
118
|
class Mock
|
119
119
|
def self.data
|
120
120
|
@data ||= Hash.new do |hash, key|
|
121
|
+
network_id = Fog::UUID.uuid
|
122
|
+
subnet_id = Fog::UUID.uuid
|
123
|
+
tenant_id = Fog::Mock.random_hex(8)
|
124
|
+
|
121
125
|
hash[key] = {
|
122
|
-
:networks => {
|
126
|
+
:networks => {
|
127
|
+
network_id => {
|
128
|
+
'id' => network_id,
|
129
|
+
'name' => 'Public',
|
130
|
+
'subnets' => [subnet_id],
|
131
|
+
'shared' => true,
|
132
|
+
'status' => 'ACTIVE',
|
133
|
+
'tenant_id' => tenant_id,
|
134
|
+
'provider_network_type' => 'vlan',
|
135
|
+
'router:external' => false,
|
136
|
+
'admin_state_up' => true,
|
137
|
+
}
|
138
|
+
},
|
123
139
|
:ports => {},
|
124
|
-
:subnets => {
|
140
|
+
:subnets => {
|
141
|
+
subnet_id => {
|
142
|
+
'id' => subnet_id,
|
143
|
+
'name' => "Public",
|
144
|
+
'network_id' => network_id,
|
145
|
+
'cidr' => "192.168.0.0/22",
|
146
|
+
'ip_version' => 4,
|
147
|
+
'gateway_ip' => Fog::Mock.random_ip,
|
148
|
+
'allocation_pools' => [],
|
149
|
+
'dns_nameservers' => [Fog::Mock.random_ip, Fog::Mock.random_ip],
|
150
|
+
'host_routes' => [Fog::Mock.random_ip],
|
151
|
+
'enable_dhcp' => true,
|
152
|
+
'tenant_id' => tenant_id,
|
153
|
+
}
|
154
|
+
},
|
125
155
|
:floating_ips => {},
|
126
156
|
:routers => {},
|
127
157
|
:lb_pools => {},
|
@@ -140,7 +170,7 @@ module Fog
|
|
140
170
|
"subnet" => 10,
|
141
171
|
"network" => 10,
|
142
172
|
"floatingip" => 50,
|
143
|
-
"tenant_id" =>
|
173
|
+
"tenant_id" => tenant_id,
|
144
174
|
"router" => 10,
|
145
175
|
"port" => 30
|
146
176
|
}
|
@@ -23,10 +23,10 @@ module Fog
|
|
23
23
|
|
24
24
|
class Mock
|
25
25
|
def create_security_group(name, description)
|
26
|
-
Fog::Identity.new(:
|
26
|
+
Fog::Identity::OpenStack.new(:openstack_auth_url => credentials[:openstack_auth_url])
|
27
27
|
tenant_id = Fog::Identity::OpenStack::Mock.data[current_tenant][:tenants].keys.first
|
28
28
|
security_group_id = Fog::Mock.random_numbers(2).to_i
|
29
|
-
self.data[:security_groups][security_group_id] = {
|
29
|
+
self.data[:security_groups][security_group_id.to_s] = {
|
30
30
|
'tenant_id' => tenant_id,
|
31
31
|
'rules' => [],
|
32
32
|
'id' => security_group_id,
|
@@ -42,7 +42,7 @@ module Fog
|
|
42
42
|
'Content-Length' => Fog::Mock.random_numbers(3).to_s,
|
43
43
|
'Date' => Date.new}
|
44
44
|
response.body = {
|
45
|
-
'security_group' => self.data[:security_groups][security_group_id]
|
45
|
+
'security_group' => self.data[:security_groups][security_group_id.to_s]
|
46
46
|
}
|
47
47
|
response
|
48
48
|
end
|
@@ -13,7 +13,7 @@ module Fog
|
|
13
13
|
}
|
14
14
|
|
15
15
|
vanilla_options = ['metadata', 'accessIPv4', 'accessIPv6',
|
16
|
-
'availability_zone', 'user_data', 'key_name',
|
16
|
+
'availability_zone', 'user_data', 'key_name',
|
17
17
|
'adminPass', 'config_drive', 'min_count', 'max_count',
|
18
18
|
'return_reservation_id'
|
19
19
|
]
|
@@ -107,7 +107,6 @@ module Fog
|
|
107
107
|
response.body["user"]["id"]
|
108
108
|
end
|
109
109
|
|
110
|
-
|
111
110
|
mock_data = {
|
112
111
|
'addresses' => {},
|
113
112
|
'flavor' => {"id" => flavor_ref, "links"=>[{"href"=>"http://nova1:8774/admin/flavors/1", "rel"=>"bookmark"}]},
|
@@ -127,10 +126,18 @@ module Fog
|
|
127
126
|
'config_drive' => options['config_drive'] || '',
|
128
127
|
}
|
129
128
|
|
129
|
+
if nics = options['nics']
|
130
|
+
nics.each do |nic|
|
131
|
+
mock_data["addresses"].merge!(
|
132
|
+
"Public" => [{ 'addr' => Fog::Mock.random_ip }]
|
133
|
+
)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
130
137
|
response_data = {}
|
131
138
|
if options['return_reservation_id'] == 'True' then
|
132
139
|
response_data = { 'reservation_id' => "r-#{Fog::Mock.random_numbers(6).to_s}" }
|
133
|
-
else
|
140
|
+
else
|
134
141
|
response_data = {
|
135
142
|
'adminPass' => 'password',
|
136
143
|
'id' => server_id,
|
@@ -156,12 +163,12 @@ module Fog
|
|
156
163
|
self.data[:last_modified][:servers][server_id] = Time.now
|
157
164
|
self.data[:servers][server_id] = mock_data
|
158
165
|
if options['return_reservation_id'] == 'True' then
|
159
|
-
response.body = response_data
|
166
|
+
response.body = response_data
|
160
167
|
else
|
161
168
|
response.body = { 'server' => response_data }
|
162
169
|
end
|
163
170
|
response
|
164
|
-
end
|
171
|
+
end
|
165
172
|
end
|
166
173
|
end
|
167
174
|
end
|
@@ -15,6 +15,8 @@ module Fog
|
|
15
15
|
|
16
16
|
class Mock
|
17
17
|
def delete_security_group_rule(security_group_rule_id)
|
18
|
+
security_group = self.data[:security_groups].values.detect{|sg| sg["rules"].detect{ |sgr| sgr["id"].to_s == security_group_rule_id.to_s }}
|
19
|
+
security_group["rules"].reject! { |sgr| sgr["id"] == security_group_rule_id }
|
18
20
|
response = Excon::Response.new
|
19
21
|
response.status = 202
|
20
22
|
response.headers = {
|
@@ -15,32 +15,22 @@ module Fog
|
|
15
15
|
|
16
16
|
class Mock
|
17
17
|
def get_security_group(security_group_id)
|
18
|
+
security_group = self.data[:security_groups][security_group_id.to_s]
|
18
19
|
response = Excon::Response.new
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
response.body = {
|
27
|
-
"security_group" => {
|
28
|
-
"rules" => [{
|
29
|
-
"from_port" => 44,
|
30
|
-
"group" => {},
|
31
|
-
"ip_protocol" => "tcp",
|
32
|
-
"to_port" => 55,
|
33
|
-
"parent_group_id" => 1,
|
34
|
-
"ip_range" => {
|
35
|
-
"cidr" => "10.10.10.10/24"
|
36
|
-
}, "id"=>1
|
37
|
-
}],
|
38
|
-
"tenant_id" => "d5183375ab0343f3a0b4b05f547aefc2",
|
39
|
-
"id"=>security_group_id,
|
40
|
-
"name"=>"default",
|
41
|
-
"description"=>"default"
|
20
|
+
if security_group
|
21
|
+
response.status = 200
|
22
|
+
response.headers = {
|
23
|
+
"X-Compute-Request-Id" => "req-63a90344-7c4d-42e2-936c-fd748bced1b3",
|
24
|
+
"Content-Type" => "application/json",
|
25
|
+
"Content-Length" => "167",
|
26
|
+
"Date" => Date.new
|
42
27
|
}
|
43
|
-
|
28
|
+
response.body = {
|
29
|
+
"security_group" => security_group
|
30
|
+
}
|
31
|
+
else
|
32
|
+
raise Fog::Compute::OpenStack::NotFound, "Security group #{security_group_id} does not exist"
|
33
|
+
end
|
44
34
|
response
|
45
35
|
end
|
46
36
|
end # mock
|