fog-azure 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 283c5448857e1b7ddf780dd0e509bc611eed5387
|
4
|
+
data.tar.gz: 98e66131cd0cda4724f74009aaeebd314527acc0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 430e09055016c67563391434a0a591da9587cbcd5b14ac3d75a77ad1f2bc0d2544d27cb6ddb1127a95ee6b3c005182183c7a5ce3b77328fa630690e2b698fb00
|
7
|
+
data.tar.gz: f9e92e7d1ff9a91ca7ceb908b7b60639116e1f14ea318e5597341a97288d83e79c81f416e4e3e71ab91f743bc1d89b4aa0a01ab89f992a8502112af53040ab05
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
gemfiles/*.lock
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
## Getting Involved
|
2
|
+
|
3
|
+
New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another.
|
4
|
+
|
5
|
+
### Coding
|
6
|
+
|
7
|
+
* Pick a task:
|
8
|
+
* Offer feedback on open [pull requests](https://github.com/fog/fog-azure/pulls).
|
9
|
+
* Review open [issues](https://github.com/fog/fog-azure/issues) for things to help on.
|
10
|
+
* [Create an issue](https://github.com/fog/fog-azure/issues/new) to start a discussion on additions or features.
|
11
|
+
* Fork the project, add your changes and tests to cover them in a topic branch.
|
12
|
+
* Commit your changes and rebase against `fog/fog-azure` to ensure everything is up to date.
|
13
|
+
* [Submit a pull request](https://github.com/fog/fog-azure/compare/)
|
14
|
+
|
15
|
+
### Non-Coding
|
16
|
+
|
17
|
+
* Offer feedback on open [issues](https://github.com/fog/fog-azure/issues).
|
18
|
+
* Organize or volunteer at events.
|
data/CONTRIBUTORS.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,25 @@
|
|
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
|
+
source 'https://rubygems.org'
|
23
|
+
|
24
|
+
# Specify your gem's dependencies in fog-azure.gemspec
|
25
|
+
gemspec
|
data/LICENSE.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Fog::Azure
|
2
|
+
|
3
|
+
Module for the 'fog' gem to support Windows Azure
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'fog-azure'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install fog-azure
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/fog/fog-azure/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
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 "bundler/gem_tasks"
|
23
|
+
|
24
|
+
task :default => :test
|
25
|
+
|
26
|
+
mock = ENV['FOG_MOCK'] || 'true'
|
27
|
+
task :test do
|
28
|
+
sh("export FOG_MOCK=#{mock} && bundle exec shindont")
|
29
|
+
end
|
data/fog-azure.gemspec
ADDED
@@ -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
|
+
# coding: utf-8
|
23
|
+
lib = File.expand_path('../lib', __FILE__)
|
24
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
25
|
+
require 'fog/azure/version'
|
26
|
+
|
27
|
+
Gem::Specification.new do |spec|
|
28
|
+
spec.name = "fog-azure"
|
29
|
+
spec.version = Fog::AZURE::VERSION
|
30
|
+
spec.authors = ["Jeff Mendoza", "Ranjan Kumar"]
|
31
|
+
spec.email = ["jlm@jlm.name", "ranjankumar188@gmail.com"]
|
32
|
+
spec.summary = %q{Module for the 'fog' gem to support Azure cloud services.}
|
33
|
+
spec.description = %q{This library can be used as a module for `fog` or as standalone provider
|
34
|
+
to use the Azure cloud services in applications..}
|
35
|
+
spec.homepage = "http://github.com/fog/fog-azure"
|
36
|
+
spec.license = "MIT"
|
37
|
+
|
38
|
+
spec.files = `git ls-files -z`.split("\x0")
|
39
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
40
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
41
|
+
spec.require_paths = ["lib"]
|
42
|
+
|
43
|
+
#spec.add_development_dependency 'bundler', '~> 1.6'
|
44
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
45
|
+
spec.add_development_dependency 'shindo', '~> 0.3'
|
46
|
+
spec.add_development_dependency('azure', '~>0.6')
|
47
|
+
|
48
|
+
spec.add_dependency 'fog-core', '~> 1.27'
|
49
|
+
spec.add_dependency 'fog-json', '~> 1.0'
|
50
|
+
spec.add_dependency 'fog-xml', '~> 0.1'
|
51
|
+
end
|
data/lib/fog/azure.rb
ADDED
@@ -0,0 +1,29 @@
|
|
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/azure/version'
|
23
|
+
require 'fog/azure/core'
|
24
|
+
require 'fog/azure/compute'
|
25
|
+
|
26
|
+
module Fog
|
27
|
+
module Azure
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,85 @@
|
|
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/azure/core"
|
23
|
+
|
24
|
+
module Fog
|
25
|
+
module Compute
|
26
|
+
class Azure < Fog::Service
|
27
|
+
requires :azure_sub_id
|
28
|
+
requires :azure_pem
|
29
|
+
|
30
|
+
recognizes :azure_api_url
|
31
|
+
|
32
|
+
request_path "fog/azure/requests/compute"
|
33
|
+
request :list_virtual_machines
|
34
|
+
request :create_virtual_machine
|
35
|
+
request :delete_virtual_machine
|
36
|
+
request :get_storage_account
|
37
|
+
request :create_storage_account
|
38
|
+
request :list_storage_accounts
|
39
|
+
request :delete_storage_account
|
40
|
+
request :reboot_server
|
41
|
+
request :shutdown_server
|
42
|
+
request :start_server
|
43
|
+
request :list_images
|
44
|
+
|
45
|
+
model_path "fog/azure/models/compute"
|
46
|
+
model :server
|
47
|
+
collection :servers
|
48
|
+
model :storage_account
|
49
|
+
collection :storage_accounts
|
50
|
+
model :image
|
51
|
+
collection :images
|
52
|
+
|
53
|
+
class Mock
|
54
|
+
def initialize(options={})
|
55
|
+
begin
|
56
|
+
require "azure"
|
57
|
+
rescue LoadError => e
|
58
|
+
retry if require("rubygems")
|
59
|
+
raise e.message
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class Real
|
65
|
+
def initialize(options)
|
66
|
+
begin
|
67
|
+
require "azure"
|
68
|
+
rescue LoadError => e
|
69
|
+
retry if require("rubygems")
|
70
|
+
raise e.message
|
71
|
+
end
|
72
|
+
::Azure.configure do |cfg|
|
73
|
+
cfg.management_certificate = options[:azure_pem]
|
74
|
+
cfg.subscription_id = options[:azure_sub_id]
|
75
|
+
cfg.management_endpoint = options[:azure_api_url] || \
|
76
|
+
"https://management.core.windows.net"
|
77
|
+
end
|
78
|
+
@vm_svc = ::Azure::VirtualMachineManagementService.new
|
79
|
+
@stg_svc = ::Azure::StorageManagementService.new
|
80
|
+
@image_svc = ::Azure::VirtualMachineImageManagementService.new
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,29 @@
|
|
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"
|
23
|
+
|
24
|
+
module Fog
|
25
|
+
module Azure
|
26
|
+
extend Fog::Provider
|
27
|
+
service(:compute, "Compute")
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
# Getting started with Fog::Compute and Azure (2014/11/21)
|
2
|
+
|
3
|
+
You'll need a [ Management Portal](https://manage.windowsazure.com/) account and API key
|
4
|
+
to use this.
|
5
|
+
|
6
|
+
See http://msdn.microsoft.com/en-us/library/azure/ee460799.aspx.
|
7
|
+
|
8
|
+
|
9
|
+
## Setting credentials
|
10
|
+
|
11
|
+
Fog uses `~/.fog` to store credentials. To add Azure as your default provider, simply add the following:
|
12
|
+
|
13
|
+
:default:
|
14
|
+
:azure_sub_id: subscription id
|
15
|
+
:azure_pem: path-to-certificate
|
16
|
+
|
17
|
+
## Connecting, retrieving and managing server objects
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
require 'fog'
|
21
|
+
require 'pp'
|
22
|
+
|
23
|
+
azure = Fog::Compute.new(
|
24
|
+
:provider => 'Azure',
|
25
|
+
:azure_sub_id => '35a2461c-22ac-1111-5ed2-11165d755ba4',
|
26
|
+
:azure_pem => 'c:/path/abc.pem',
|
27
|
+
:azure_api_url => 'usnorth.management.core.windows.net'
|
28
|
+
)
|
29
|
+
```
|
30
|
+
|
31
|
+
## Listing servers
|
32
|
+
|
33
|
+
Listing servers and attributes:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
azure.servers.each do |server|
|
37
|
+
server.cloud_service_name
|
38
|
+
server.vm_name
|
39
|
+
server.status
|
40
|
+
server.ipaddress
|
41
|
+
server.image
|
42
|
+
server.disk_name
|
43
|
+
server.os_type
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
## Server creation and life-cycle management
|
48
|
+
|
49
|
+
Creating a new server:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
server = azure.servers.create(
|
53
|
+
:image => '604889f8753c3__OpenLogic-CentOS',
|
54
|
+
:location => 'West US',
|
55
|
+
:vm_name => 'fog-server',
|
56
|
+
:vm_user => "foguser",
|
57
|
+
:password => "ComplexPassword!123",
|
58
|
+
:storage_account_name => 'fogstorage'
|
59
|
+
)
|
60
|
+
```
|
61
|
+
|
62
|
+
|
63
|
+
## Retrieve a single record
|
64
|
+
|
65
|
+
Get a single server record:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
server = azure.servers.get('vm-name')
|
69
|
+
server.cloud_service_name
|
70
|
+
server.vm_name
|
71
|
+
server.status
|
72
|
+
server.ipaddress
|
73
|
+
server.image
|
74
|
+
server.disk_name
|
75
|
+
server.os_type
|
76
|
+
```
|
77
|
+
|
78
|
+
Rebooting a server:
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
server.reboot
|
82
|
+
```
|
83
|
+
|
84
|
+
Start a server:
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
server.start
|
88
|
+
```
|
89
|
+
|
90
|
+
Shutdown a server:
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
server.shutdown
|
94
|
+
```
|
95
|
+
|
96
|
+
Destroying the server:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
server.destroy
|
100
|
+
```
|
101
|
+
|
102
|
+
## Storage accounts creation and life-cycle management
|
103
|
+
|
104
|
+
Creating a new storage account:
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
azure.storage_accounts.create(
|
108
|
+
:name => 'storageaccountname',
|
109
|
+
:location => 'West US'
|
110
|
+
)
|
111
|
+
```
|
112
|
+
|
113
|
+
## Listing storage accounts
|
114
|
+
|
115
|
+
Listing storage accounts and attributes:
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
azure.storage_accounts.each do |storage_acc|
|
119
|
+
storage_acc.name
|
120
|
+
storage_acc.location
|
121
|
+
end
|
122
|
+
```
|
123
|
+
|
124
|
+
## Retrieve a single record
|
125
|
+
|
126
|
+
Get a single storage account record:
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
storage_acc = azure.storage_accounts.get('storageaccountname')
|
130
|
+
server.name
|
131
|
+
server.location
|
132
|
+
server.endpoints
|
133
|
+
```
|
134
|
+
|
135
|
+
Destroying the storage account:
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
storage_acc.destroy
|
139
|
+
```
|
140
|
+
|
141
|
+
## Listing images
|
142
|
+
|
143
|
+
Listing images and attributes:
|
144
|
+
|
145
|
+
```ruby
|
146
|
+
azure.images.each do |image|
|
147
|
+
image.name
|
148
|
+
image.os_type
|
149
|
+
image.category
|
150
|
+
image.locations
|
151
|
+
end
|
152
|
+
```
|
153
|
+
|
154
|
+
## Retrieve a single record
|
155
|
+
|
156
|
+
Get a single image record:
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
image = azure.image.get('image_name')
|
160
|
+
image.name
|
161
|
+
image.locations
|
162
|
+
image.category
|
163
|
+
image.os_type
|
164
|
+
```
|