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,26 @@
|
|
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
|
+
module Fog
|
23
|
+
module AZURE
|
24
|
+
VERSION = "0.0.1"
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,84 @@
|
|
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
|
+
module Azure # deviates from other bin stuff to accomodate gem
|
23
|
+
class << self
|
24
|
+
def class_for(key)
|
25
|
+
case key
|
26
|
+
when :compute
|
27
|
+
Fog::Compute::Azure
|
28
|
+
else
|
29
|
+
raise ArgumentError, "Unrecognized service: #{key}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def [](service)
|
34
|
+
@@connections ||= Hash.new do |hash, key|
|
35
|
+
hash[key] = case key
|
36
|
+
when :compute
|
37
|
+
Fog::Logger.warning("Azure[:compute] is not recommended, use Compute[:azure] for portability")
|
38
|
+
Fog::Compute.new(:provider => 'Azure')
|
39
|
+
else
|
40
|
+
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
@@connections[service]
|
44
|
+
end
|
45
|
+
|
46
|
+
def available?
|
47
|
+
availability = true
|
48
|
+
for service in services
|
49
|
+
begin
|
50
|
+
service = self.class_for(service)
|
51
|
+
availability &&= service.requirements.all? { |requirement| Fog.credentials.include?(requirement) }
|
52
|
+
rescue ArgumentError => e
|
53
|
+
Fog::Logger.warning(e.message)
|
54
|
+
availability = false
|
55
|
+
rescue => e
|
56
|
+
availability = false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
if availability
|
61
|
+
for service in services
|
62
|
+
for collection in self.class_for(service).collections
|
63
|
+
unless self.respond_to?(collection)
|
64
|
+
self.class_eval <<-EOS, __FILE__, __LINE__
|
65
|
+
def self.#{collection}
|
66
|
+
self[:#{service}].#{collection}
|
67
|
+
end
|
68
|
+
EOS
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
availability
|
74
|
+
end
|
75
|
+
|
76
|
+
def collections
|
77
|
+
services.map {|service| self[service].collections}.flatten.sort_by {|service| service.to_s}
|
78
|
+
end
|
79
|
+
|
80
|
+
def services
|
81
|
+
Fog::Azure.services
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,84 @@
|
|
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
|
+
|
23
|
+
def azure_service
|
24
|
+
Fog::Compute[:azure]
|
25
|
+
end
|
26
|
+
|
27
|
+
def vm_attributes
|
28
|
+
image = azure_service.images.select{|image| image.os_type == "Linux"}.first
|
29
|
+
location = image.locations.split(";").first
|
30
|
+
|
31
|
+
{
|
32
|
+
:image => image.name,
|
33
|
+
:location => location,
|
34
|
+
:vm_name => vm_name,
|
35
|
+
:vm_user => "foguser",
|
36
|
+
:password => "ComplexPassword!123",
|
37
|
+
:storage_account_name => storage_name
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def vm_name
|
42
|
+
"fog-test-server"
|
43
|
+
end
|
44
|
+
|
45
|
+
def storage_name
|
46
|
+
"fogteststorageaccount"
|
47
|
+
end
|
48
|
+
|
49
|
+
def fog_server
|
50
|
+
server = azure_service.servers.select { |s| s.vm_name == vm_name }.first
|
51
|
+
unless server
|
52
|
+
server = azure_service.servers.create(
|
53
|
+
vm_attributes
|
54
|
+
)
|
55
|
+
end
|
56
|
+
server
|
57
|
+
end
|
58
|
+
|
59
|
+
def storage_account
|
60
|
+
storage = azure_service.storage_accounts.select { |s| s.name == storage_name }.first
|
61
|
+
unless storage
|
62
|
+
storage = azure_service.storage_accounts.create(
|
63
|
+
{:name => storage_name, :location => "West US"}
|
64
|
+
)
|
65
|
+
end
|
66
|
+
azure_service.storage_accounts.get(storage_name)
|
67
|
+
end
|
68
|
+
|
69
|
+
def vm_destroy
|
70
|
+
server = azure_service.servers.select { |s| s.vm_name == vm_name }.first
|
71
|
+
server.destroy if server
|
72
|
+
end
|
73
|
+
|
74
|
+
def storage_destroy
|
75
|
+
storage = azure_service.storage_accounts.select { |s| s.name == storage_name }.first
|
76
|
+
storage.destroy if storage
|
77
|
+
end
|
78
|
+
|
79
|
+
at_exit do
|
80
|
+
unless Fog.mocking?
|
81
|
+
storage_destroy
|
82
|
+
vm_destroy
|
83
|
+
end
|
84
|
+
end
|
data/tests/helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
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
|
+
|
23
|
+
require File.expand_path('../../lib/fog/azure', __FILE__)
|
24
|
+
|
25
|
+
Bundler.require(:test)
|
26
|
+
|
27
|
+
Excon.defaults.merge!(:debug_request => true, :debug_response => true)
|
28
|
+
|
29
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'mock_helper'))
|
30
|
+
|
31
|
+
# This overrides the default 600 seconds timeout during live test runs
|
32
|
+
if Fog.mocking?
|
33
|
+
Fog.timeout = ENV['FOG_TEST_TIMEOUT'] || 2000
|
34
|
+
Fog::Logger.warning "Setting default fog timeout to #{Fog.timeout} seconds"
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,36 @@
|
|
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
|
+
# Use so you can run in mock mode from the command line
|
23
|
+
#
|
24
|
+
# FOG_MOCK=true fog
|
25
|
+
|
26
|
+
if ENV["FOG_MOCK"] == "true"
|
27
|
+
Fog.mock!
|
28
|
+
end
|
29
|
+
|
30
|
+
# if in mocked mode, fill in some fake credentials for us
|
31
|
+
if Fog.mock?
|
32
|
+
Fog.credentials = {
|
33
|
+
:azure_sub_id => 'azure_sub_id',
|
34
|
+
:azure_pem => 'path_of_pem'
|
35
|
+
}.merge(Fog.credentials)
|
36
|
+
end
|
@@ -0,0 +1,50 @@
|
|
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
|
+
Shindo.tests("Fog::Compute[:azure] | image model", ["azure", "compute"]) do
|
23
|
+
|
24
|
+
service = Fog::Compute[:azure]
|
25
|
+
|
26
|
+
tests("The image model should") do
|
27
|
+
image = service.images.first
|
28
|
+
tests("have the action") do
|
29
|
+
test("reload") { image.respond_to? "reload" }
|
30
|
+
end
|
31
|
+
tests("have attributes") do
|
32
|
+
model_attribute_hash = image.attributes
|
33
|
+
attributes = [
|
34
|
+
:name,
|
35
|
+
:os_type
|
36
|
+
]
|
37
|
+
tests("The image model should respond to") do
|
38
|
+
attributes.each do |attribute|
|
39
|
+
test("#{attribute}") { image.respond_to? attribute }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
tests("The attributes hash should have key") do
|
43
|
+
attributes.each do |attribute|
|
44
|
+
test("#{attribute}") { model_attribute_hash.key? attribute }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,84 @@
|
|
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
|
+
Shindo.tests("Fog::Compute[:azure] | server model", ["azure", "compute"]) do
|
23
|
+
|
24
|
+
server = fog_server
|
25
|
+
|
26
|
+
tests("The server model should") do
|
27
|
+
pending if Fog.mocking?
|
28
|
+
tests("have the action") do
|
29
|
+
test("reload") { server.respond_to? "reload" }
|
30
|
+
%w{
|
31
|
+
destroy
|
32
|
+
reboot
|
33
|
+
shutdown
|
34
|
+
start
|
35
|
+
}.each do |action|
|
36
|
+
test(action) { server.respond_to? action }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
tests("have attributes") do
|
41
|
+
attributes = [
|
42
|
+
:vm_name,
|
43
|
+
:status,
|
44
|
+
:ipaddress,
|
45
|
+
:cloud_service_name,
|
46
|
+
:image,
|
47
|
+
:location,
|
48
|
+
:os_type,
|
49
|
+
:storage_account_name
|
50
|
+
]
|
51
|
+
tests("The server model should respond to") do
|
52
|
+
attributes.each do |attribute|
|
53
|
+
test("#{attribute}") { server.respond_to? attribute }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
test("#reboot") do
|
59
|
+
server.reboot
|
60
|
+
server = fog_server
|
61
|
+
%w(ReadyRole Provisioning RoleStateUnknown).include? server.status
|
62
|
+
end
|
63
|
+
|
64
|
+
test("#start") do
|
65
|
+
server.start
|
66
|
+
server = fog_server
|
67
|
+
status = %w(ReadyRole Provisioning RoleStateUnknown)
|
68
|
+
status.include? server.status
|
69
|
+
end
|
70
|
+
|
71
|
+
test("#shutdown") do
|
72
|
+
server.shutdown
|
73
|
+
server = fog_server
|
74
|
+
%w(StoppedVM StoppedDeallocated).include? server.status
|
75
|
+
end
|
76
|
+
|
77
|
+
test("#destroy") do
|
78
|
+
server.destroy
|
79
|
+
server = azure_service.servers.select { |s| s.vm_name == vm_name }.first
|
80
|
+
server.nil?
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
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
|
+
Shindo.tests("Fog::Compute[:azure] | storage account model", ["azure", "compute"]) do
|
23
|
+
|
24
|
+
storage = storage_account
|
25
|
+
|
26
|
+
tests("The storage account model should") do
|
27
|
+
|
28
|
+
tests("have the action") do
|
29
|
+
test("reload") { storage.respond_to? "reload" }
|
30
|
+
end
|
31
|
+
tests("have attributes") do
|
32
|
+
model_attribute_hash = storage.attributes
|
33
|
+
attributes = [
|
34
|
+
:name,
|
35
|
+
:location,
|
36
|
+
:status
|
37
|
+
]
|
38
|
+
tests("The storage account model should respond to") do
|
39
|
+
attributes.each do |attribute|
|
40
|
+
test("#{attribute}") { storage.respond_to? attribute }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
tests("The attributes hash should have key") do
|
44
|
+
attributes.each do |attribute|
|
45
|
+
test("#{attribute}") { model_attribute_hash.key? attribute }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|