fog-azure 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/CONTRIBUTING.md +18 -0
- data/CONTRIBUTORS.md +4 -0
- data/Gemfile +25 -0
- data/LICENSE.md +19 -0
- data/README.md +31 -0
- data/Rakefile +29 -0
- data/fog-azure.gemspec +51 -0
- data/lib/fog/azure.rb +29 -0
- data/lib/fog/azure/compute.rb +85 -0
- data/lib/fog/azure/core.rb +29 -0
- data/lib/fog/azure/docs/getting_started.md +164 -0
- data/lib/fog/azure/models/compute/image.rb +35 -0
- data/lib/fog/azure/models/compute/images.rb +51 -0
- data/lib/fog/azure/models/compute/server.rb +189 -0
- data/lib/fog/azure/models/compute/servers.rb +67 -0
- data/lib/fog/azure/models/compute/storage_account.rb +71 -0
- data/lib/fog/azure/models/compute/storage_accounts.rb +52 -0
- data/lib/fog/azure/requests/compute/create_storage_account.rb +43 -0
- data/lib/fog/azure/requests/compute/create_virtual_machine.rb +37 -0
- data/lib/fog/azure/requests/compute/delete_storage_account.rb +38 -0
- data/lib/fog/azure/requests/compute/delete_virtual_machine.rb +38 -0
- data/lib/fog/azure/requests/compute/get_storage_account.rb +37 -0
- data/lib/fog/azure/requests/compute/list_images.rb +43 -0
- data/lib/fog/azure/requests/compute/list_storage_accounts.rb +43 -0
- data/lib/fog/azure/requests/compute/list_virtual_machines.rb +56 -0
- data/lib/fog/azure/requests/compute/reboot_server.rb +38 -0
- data/lib/fog/azure/requests/compute/shutdown_server.rb +38 -0
- data/lib/fog/azure/requests/compute/start_server.rb +38 -0
- data/lib/fog/azure/version.rb +26 -0
- data/lib/fog/bin/azure.rb +84 -0
- data/tests/azure_test_helper.rb +84 -0
- data/tests/helper.rb +36 -0
- data/tests/helpers/mock_helper.rb +36 -0
- data/tests/models/compute/image_tests.rb +50 -0
- data/tests/models/compute/server_tests.rb +84 -0
- data/tests/models/compute/storage_account_tests.rb +51 -0
- data/tests/requests/compute/images_tests.rb +40 -0
- data/tests/requests/compute/servers_tests.rb +41 -0
- data/tests/requests/compute/storage_accounts_tests.rb +41 -0
- metadata +173 -0
@@ -0,0 +1,35 @@
|
|
1
|
+
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# The MIT License (MIT)
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
require "fog/core/model"
|
23
|
+
|
24
|
+
module Fog
|
25
|
+
module Compute
|
26
|
+
class Azure
|
27
|
+
class Image < Fog::Model
|
28
|
+
identity :name
|
29
|
+
attribute :os_type
|
30
|
+
attribute :category
|
31
|
+
attribute :locations
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# The MIT License (MIT)
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
require "fog/core/collection"
|
23
|
+
require "fog/azure/models/compute/image"
|
24
|
+
|
25
|
+
module Fog
|
26
|
+
module Compute
|
27
|
+
class Azure
|
28
|
+
class Images < Fog::Collection
|
29
|
+
model Fog::Compute::Azure::Image
|
30
|
+
|
31
|
+
def all()
|
32
|
+
images = []
|
33
|
+
service.list_images.each do |image|
|
34
|
+
hash = {}
|
35
|
+
image.instance_variables.each do |var|
|
36
|
+
hash[var.to_s.delete("@")] = image.instance_variable_get(var)
|
37
|
+
end
|
38
|
+
images << hash
|
39
|
+
end
|
40
|
+
load(images)
|
41
|
+
end
|
42
|
+
|
43
|
+
def get(identity)
|
44
|
+
all.find { |f| f.name == identity }
|
45
|
+
rescue Fog::Errors::NotFound
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,189 @@
|
|
1
|
+
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# The MIT License (MIT)
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
require "fog/compute/models/server"
|
23
|
+
require "net/ssh/proxy/command"
|
24
|
+
require "tempfile"
|
25
|
+
|
26
|
+
module Fog
|
27
|
+
module Compute
|
28
|
+
class Azure
|
29
|
+
class Server < Fog::Compute::Server
|
30
|
+
# attr names are from azure
|
31
|
+
identity :vm_name
|
32
|
+
attribute :ipaddress
|
33
|
+
attribute :deployment_status
|
34
|
+
attribute :deployment_name
|
35
|
+
attribute :status
|
36
|
+
attribute :hostname
|
37
|
+
attribute :cloud_service_name
|
38
|
+
attribute :tcp_endpoints
|
39
|
+
attribute :udp_endpoints
|
40
|
+
attribute :virtual_network_name
|
41
|
+
attribute :availability_set_name
|
42
|
+
attribute :os_type
|
43
|
+
attribute :disk_name
|
44
|
+
attribute :image
|
45
|
+
attribute :vm_user
|
46
|
+
attribute :location
|
47
|
+
attribute :private_key_file
|
48
|
+
attribute :vm_size, :aliases => "role_size"
|
49
|
+
attribute :storage_account_name, :type => :string
|
50
|
+
attribute :password
|
51
|
+
attribute :winrm_transport
|
52
|
+
attribute :ssh_port
|
53
|
+
attribute :affinity_group_name
|
54
|
+
attribute :subnet_name
|
55
|
+
attribute :certificate_file
|
56
|
+
|
57
|
+
#helper functions for more common fog names
|
58
|
+
def external_ip
|
59
|
+
ipaddress
|
60
|
+
end
|
61
|
+
|
62
|
+
def public_ip_address
|
63
|
+
ipaddress
|
64
|
+
end
|
65
|
+
|
66
|
+
def name
|
67
|
+
vm_name
|
68
|
+
end
|
69
|
+
|
70
|
+
def state
|
71
|
+
deployment_status
|
72
|
+
end
|
73
|
+
|
74
|
+
def username
|
75
|
+
vm_user
|
76
|
+
end
|
77
|
+
|
78
|
+
def machine_type
|
79
|
+
vm_size
|
80
|
+
end
|
81
|
+
|
82
|
+
def ready?
|
83
|
+
state == "Running"
|
84
|
+
end
|
85
|
+
|
86
|
+
def destroy
|
87
|
+
requires :vm_name
|
88
|
+
requires :cloud_service_name
|
89
|
+
|
90
|
+
service.delete_virtual_machine(vm_name, cloud_service_name)
|
91
|
+
end
|
92
|
+
|
93
|
+
def reboot
|
94
|
+
requires :vm_name
|
95
|
+
requires :cloud_service_name
|
96
|
+
|
97
|
+
service.reboot_server(vm_name, cloud_service_name)
|
98
|
+
end
|
99
|
+
|
100
|
+
def shutdown
|
101
|
+
requires :vm_name
|
102
|
+
requires :cloud_service_name
|
103
|
+
|
104
|
+
service.shutdown_server(vm_name, cloud_service_name)
|
105
|
+
end
|
106
|
+
|
107
|
+
def start
|
108
|
+
requires :vm_name
|
109
|
+
requires :cloud_service_name
|
110
|
+
|
111
|
+
service.start_server(vm_name, cloud_service_name)
|
112
|
+
end
|
113
|
+
|
114
|
+
def save
|
115
|
+
requires :vm_name
|
116
|
+
requires :vm_user
|
117
|
+
requires :image
|
118
|
+
requires_one :location, :affinity_group_name
|
119
|
+
#requires :vm_size
|
120
|
+
|
121
|
+
if ! private_key_file.nil? && certificate_file.nil?
|
122
|
+
key = OpenSSL::PKey.read File.read(private_key_file)
|
123
|
+
cert = OpenSSL::X509::Certificate.new
|
124
|
+
cert.version = 2 # cf. RFC 5280 - to make it a "v3" certificate
|
125
|
+
cert.serial = 1
|
126
|
+
cert.subject = OpenSSL::X509::Name.parse "/CN=Fog"
|
127
|
+
cert.issuer = cert.subject # root CA's are "self-signed"
|
128
|
+
cert.public_key = key.public_key
|
129
|
+
cert.not_before = Time.now
|
130
|
+
cert.not_after = cert.not_before + 2 * 365 * 24 * 60 * 60 # 2 years validity
|
131
|
+
ef = OpenSSL::X509::ExtensionFactory.new
|
132
|
+
ef.subject_certificate = cert
|
133
|
+
ef.issuer_certificate = cert
|
134
|
+
cert.add_extension(ef.create_extension("basicConstraints","CA:TRUE",true))
|
135
|
+
cert.add_extension(ef.create_extension("keyUsage","keyCertSign, cRLSign", true))
|
136
|
+
cert.add_extension(ef.create_extension("subjectKeyIdentifier","hash",false))
|
137
|
+
cert.add_extension(ef.create_extension("authorityKeyIdentifier","keyid:always",false))
|
138
|
+
cert.sign(key, OpenSSL::Digest::SHA256.new)
|
139
|
+
|
140
|
+
cert_file = Tempfile.new(["cert", ".pem"])
|
141
|
+
cert_file.chmod(0600)
|
142
|
+
cert_file.write(cert.to_pem)
|
143
|
+
cert_file.close
|
144
|
+
self.certificate_file = cert_file.path
|
145
|
+
end
|
146
|
+
|
147
|
+
if storage_account_name.nil?
|
148
|
+
service.storage_accounts.each do |sa|
|
149
|
+
if sa.location == location
|
150
|
+
self.storage_account_name = sa.name
|
151
|
+
break
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
if cloud_service_name.nil?
|
157
|
+
self.cloud_service_name = vm_name
|
158
|
+
end
|
159
|
+
|
160
|
+
#API to start deployment
|
161
|
+
params = {
|
162
|
+
:vm_name => vm_name,
|
163
|
+
:vm_user => vm_user,
|
164
|
+
:image => image,
|
165
|
+
:password => password,
|
166
|
+
:location => location,
|
167
|
+
}
|
168
|
+
options = {
|
169
|
+
:storage_account_name => storage_account_name,
|
170
|
+
:winrm_transport => winrm_transport,
|
171
|
+
:cloud_service_name => cloud_service_name,
|
172
|
+
:deployment_name => deployment_name,
|
173
|
+
:tcp_endpoints => tcp_endpoints,
|
174
|
+
:private_key_file => private_key_file,
|
175
|
+
:certificate_file => certificate_file,
|
176
|
+
:ssh_port => ssh_port,
|
177
|
+
:vm_size => vm_size,
|
178
|
+
:affinity_group_name => affinity_group_name,
|
179
|
+
:virtual_network_name => virtual_network_name,
|
180
|
+
:subnet_name => subnet_name,
|
181
|
+
:availability_set_name => availability_set_name,
|
182
|
+
}
|
183
|
+
service.create_virtual_machine(params, options)
|
184
|
+
cert_file.unlink unless cert_file.nil?
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# The MIT License (MIT)
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
require "fog/core/collection"
|
23
|
+
require "fog/azure/models/compute/server"
|
24
|
+
|
25
|
+
module Fog
|
26
|
+
module Compute
|
27
|
+
class Azure
|
28
|
+
class Servers < Fog::Collection
|
29
|
+
model Fog::Compute::Azure::Server
|
30
|
+
|
31
|
+
def all()
|
32
|
+
servers = []
|
33
|
+
service.list_virtual_machines.each do |vm|
|
34
|
+
hash = {}
|
35
|
+
vm.instance_variables.each do |var|
|
36
|
+
hash[var.to_s.delete("@")] = vm.instance_variable_get(var)
|
37
|
+
end
|
38
|
+
hash[:vm_user] = "azureuser" if hash[:vm_user].nil?
|
39
|
+
servers << hash
|
40
|
+
end
|
41
|
+
load(servers)
|
42
|
+
end
|
43
|
+
|
44
|
+
def get(identity, cloud_service_name)
|
45
|
+
all.find { |f| f.name == identity && f.cloud_service_name == cloud_service_name }
|
46
|
+
rescue Fog::Errors::NotFound
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def bootstrap(new_attributes = {})
|
51
|
+
defaults = {
|
52
|
+
:vm_name => "fog-#{Time.now.to_i}",
|
53
|
+
:vm_user => "azureuser",
|
54
|
+
:image => "b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_3-LTS-amd64-server-20131205-en-us-30GB",
|
55
|
+
:location => "Central US",
|
56
|
+
:private_key_file => File.expand_path("~/.ssh/id_rsa"),
|
57
|
+
:vm_size => "Small",
|
58
|
+
}
|
59
|
+
|
60
|
+
server = create(defaults.merge(new_attributes))
|
61
|
+
server.wait_for { sshable? } unless server.private_key_file.nil?
|
62
|
+
server
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# The MIT License (MIT)
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
require "fog/compute/models/server"
|
23
|
+
require "net/ssh/proxy/command"
|
24
|
+
require "tempfile"
|
25
|
+
|
26
|
+
module Fog
|
27
|
+
module Compute
|
28
|
+
class Azure
|
29
|
+
class StorageAccount < Fog::Model
|
30
|
+
identity :name
|
31
|
+
attribute :url
|
32
|
+
attribute :description
|
33
|
+
attribute :affinity_group
|
34
|
+
attribute :location
|
35
|
+
attribute :label
|
36
|
+
attribute :status
|
37
|
+
attribute :endpoints
|
38
|
+
attribute :geo_replication_enabled
|
39
|
+
attribute :geo_primary_region
|
40
|
+
attribute :status_of_primary
|
41
|
+
attribute :last_geo_failover_time
|
42
|
+
attribute :geo_secondary_region
|
43
|
+
attribute :status_of_secondary
|
44
|
+
attribute :creation_time
|
45
|
+
attribute :extended_properties
|
46
|
+
|
47
|
+
|
48
|
+
def save
|
49
|
+
requires :name
|
50
|
+
requires_one :location, :affinity_group
|
51
|
+
|
52
|
+
options = {
|
53
|
+
:label => label,
|
54
|
+
:location => location,
|
55
|
+
:description => description,
|
56
|
+
:affinity_group_name => affinity_group,
|
57
|
+
:geo_replication_enabled => geo_replication_enabled,
|
58
|
+
:extended_properties => extended_properties,
|
59
|
+
}
|
60
|
+
|
61
|
+
service.create_storage_account(name, options)
|
62
|
+
end
|
63
|
+
|
64
|
+
def destroy
|
65
|
+
requires :name
|
66
|
+
service.delete_storage_account(name)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# The MIT License (MIT)
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
require "fog/core/collection"
|
23
|
+
require "fog/azure/models/compute/storage_account"
|
24
|
+
|
25
|
+
module Fog
|
26
|
+
module Compute
|
27
|
+
class Azure
|
28
|
+
class StorageAccounts < Fog::Collection
|
29
|
+
model Fog::Compute::Azure::StorageAccount
|
30
|
+
|
31
|
+
def all()
|
32
|
+
accounts = []
|
33
|
+
service.list_storage_accounts.each do |account|
|
34
|
+
hash = {}
|
35
|
+
account.instance_variables.each do |var|
|
36
|
+
hash[var.to_s.delete("@")] = account.instance_variable_get(var)
|
37
|
+
end
|
38
|
+
accounts << hash
|
39
|
+
end
|
40
|
+
load(accounts)
|
41
|
+
end
|
42
|
+
|
43
|
+
def get(identity)
|
44
|
+
all.find { |f| f.name == identity }
|
45
|
+
rescue Fog::Errors::NotFound
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|