gitlab-fog-azure-rm 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +7 -0
  2. data/.arclint +8 -0
  3. data/.codeclimate.yml +17 -0
  4. data/.gitignore +6 -0
  5. data/.gitlab-ci.yml +17 -0
  6. data/.hound.yml +2 -0
  7. data/.rubocop.yml +5 -0
  8. data/.rubocop_todo.yml +274 -0
  9. data/.travis.yml +49 -0
  10. data/CHANGELOG.md +414 -0
  11. data/CONTRIBUTING.md +40 -0
  12. data/CONTRIBUTORS.md +12 -0
  13. data/Gemfile +3 -0
  14. data/LICENSE.md +20 -0
  15. data/README.md +100 -0
  16. data/gitlab-fog-azure-rm.gemspec +31 -0
  17. data/lib/fog/azurerm.rb +30 -0
  18. data/lib/fog/azurerm/async_response.rb +44 -0
  19. data/lib/fog/azurerm/config.rb +1 -0
  20. data/lib/fog/azurerm/constants.rb +72 -0
  21. data/lib/fog/azurerm/credentials.rb +40 -0
  22. data/lib/fog/azurerm/custom_fog_errors.rb +52 -0
  23. data/lib/fog/azurerm/docs/storage.md +398 -0
  24. data/lib/fog/azurerm/docs/structure.md +53 -0
  25. data/lib/fog/azurerm/models/resources/azure_resource.rb +25 -0
  26. data/lib/fog/azurerm/models/resources/azure_resources.rb +40 -0
  27. data/lib/fog/azurerm/models/resources/dependency.rb +27 -0
  28. data/lib/fog/azurerm/models/resources/deployment.rb +65 -0
  29. data/lib/fog/azurerm/models/resources/deployments.rb +30 -0
  30. data/lib/fog/azurerm/models/resources/provider.rb +27 -0
  31. data/lib/fog/azurerm/models/resources/provider_resource_type.rb +22 -0
  32. data/lib/fog/azurerm/models/resources/resource_group.rb +34 -0
  33. data/lib/fog/azurerm/models/resources/resource_groups.rb +29 -0
  34. data/lib/fog/azurerm/models/storage/directories.rb +75 -0
  35. data/lib/fog/azurerm/models/storage/directory.rb +151 -0
  36. data/lib/fog/azurerm/models/storage/file.rb +265 -0
  37. data/lib/fog/azurerm/models/storage/files.rb +183 -0
  38. data/lib/fog/azurerm/models/storage/kind.rb +12 -0
  39. data/lib/fog/azurerm/models/storage/sku_name.rb +15 -0
  40. data/lib/fog/azurerm/models/storage/sku_tier.rb +12 -0
  41. data/lib/fog/azurerm/models/storage/storage_account.rb +92 -0
  42. data/lib/fog/azurerm/models/storage/storage_accounts.rb +47 -0
  43. data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +32 -0
  44. data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +32 -0
  45. data/lib/fog/azurerm/requests/storage/check_container_exists.rb +30 -0
  46. data/lib/fog/azurerm/requests/storage/commit_blob_blocks.rb +30 -0
  47. data/lib/fog/azurerm/requests/storage/compare_container_blobs.rb +148 -0
  48. data/lib/fog/azurerm/requests/storage/copy_blob.rb +30 -0
  49. data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +30 -0
  50. data/lib/fog/azurerm/requests/storage/copy_object.rb +20 -0
  51. data/lib/fog/azurerm/requests/storage/create_block_blob.rb +108 -0
  52. data/lib/fog/azurerm/requests/storage/create_container.rb +40 -0
  53. data/lib/fog/azurerm/requests/storage/create_disk.rb +62 -0
  54. data/lib/fog/azurerm/requests/storage/create_page_blob.rb +31 -0
  55. data/lib/fog/azurerm/requests/storage/delete_blob.rb +32 -0
  56. data/lib/fog/azurerm/requests/storage/delete_blob_https_url.rb +39 -0
  57. data/lib/fog/azurerm/requests/storage/delete_container.rb +31 -0
  58. data/lib/fog/azurerm/requests/storage/delete_disk.rb +36 -0
  59. data/lib/fog/azurerm/requests/storage/delete_object_url.rb +30 -0
  60. data/lib/fog/azurerm/requests/storage/get_blob.rb +163 -0
  61. data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +39 -0
  62. data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +39 -0
  63. data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +55 -0
  64. data/lib/fog/azurerm/requests/storage/get_blob_url.rb +28 -0
  65. data/lib/fog/azurerm/requests/storage/get_container_acl.rb +30 -0
  66. data/lib/fog/azurerm/requests/storage/get_container_properties.rb +41 -0
  67. data/lib/fog/azurerm/requests/storage/get_container_url.rb +34 -0
  68. data/lib/fog/azurerm/requests/storage/get_object_url.rb +21 -0
  69. data/lib/fog/azurerm/requests/storage/list_blobs.rb +168 -0
  70. data/lib/fog/azurerm/requests/storage/list_containers.rb +73 -0
  71. data/lib/fog/azurerm/requests/storage/multipart_save_block_blob.rb +110 -0
  72. data/lib/fog/azurerm/requests/storage/put_blob_block.rb +30 -0
  73. data/lib/fog/azurerm/requests/storage/put_blob_https_url.rb +39 -0
  74. data/lib/fog/azurerm/requests/storage/put_blob_metadata.rb +31 -0
  75. data/lib/fog/azurerm/requests/storage/put_blob_pages.rb +30 -0
  76. data/lib/fog/azurerm/requests/storage/put_blob_properties.rb +31 -0
  77. data/lib/fog/azurerm/requests/storage/put_container_acl.rb +31 -0
  78. data/lib/fog/azurerm/requests/storage/put_container_metadata.rb +31 -0
  79. data/lib/fog/azurerm/requests/storage/put_object_url.rb +30 -0
  80. data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +30 -0
  81. data/lib/fog/azurerm/requests/storage/release_container_lease.rb +30 -0
  82. data/lib/fog/azurerm/requests/storage/save_page_blob.rb +111 -0
  83. data/lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb +56 -0
  84. data/lib/fog/azurerm/storage.rb +126 -0
  85. data/lib/fog/azurerm/utilities/general.rb +186 -0
  86. data/lib/fog/azurerm/utilities/logger_messages.yml +19 -0
  87. data/lib/fog/azurerm/version.rb +5 -0
  88. data/rake-script.sh +10 -0
  89. data/rakefile +29 -0
  90. data/test/api_stub.rb +147 -0
  91. data/test/api_stub/models/storage/directory.rb +178 -0
  92. data/test/api_stub/models/storage/file.rb +181 -0
  93. data/test/api_stub/requests/storage/directory.rb +89 -0
  94. data/test/api_stub/requests/storage/file.rb +252 -0
  95. data/test/integration/README.md +14 -0
  96. data/test/integration/blob.rb +297 -0
  97. data/test/integration/container.rb +160 -0
  98. data/test/integration/credentials/azure.yml +5 -0
  99. data/test/integration/storage_account.rb +135 -0
  100. data/test/models/storage/test_directories.rb +74 -0
  101. data/test/models/storage/test_directory.rb +178 -0
  102. data/test/models/storage/test_file.rb +294 -0
  103. data/test/models/storage/test_files.rb +234 -0
  104. data/test/requests/storage/test_acquire_blob_lease.rb +36 -0
  105. data/test/requests/storage/test_acquire_container_lease.rb +36 -0
  106. data/test/requests/storage/test_check_container_exists.rb +18 -0
  107. data/test/requests/storage/test_commit_blob_blocks.rb +34 -0
  108. data/test/requests/storage/test_compare_container_blobs.rb +36 -0
  109. data/test/requests/storage/test_copy_blob.rb +39 -0
  110. data/test/requests/storage/test_copy_blob_from_uri.rb +36 -0
  111. data/test/requests/storage/test_create_block_blob.rb +80 -0
  112. data/test/requests/storage/test_create_container.rb +36 -0
  113. data/test/requests/storage/test_create_disk.rb +70 -0
  114. data/test/requests/storage/test_create_page_blob.rb +34 -0
  115. data/test/requests/storage/test_delete_blob.rb +42 -0
  116. data/test/requests/storage/test_delete_blob_https_url.rb +32 -0
  117. data/test/requests/storage/test_delete_container.rb +42 -0
  118. data/test/requests/storage/test_delete_disk.rb +30 -0
  119. data/test/requests/storage/test_get_blob.rb +141 -0
  120. data/test/requests/storage/test_get_blob_http_url.rb +30 -0
  121. data/test/requests/storage/test_get_blob_https_url.rb +32 -0
  122. data/test/requests/storage/test_get_blob_properties.rb +47 -0
  123. data/test/requests/storage/test_get_blob_url.rb +75 -0
  124. data/test/requests/storage/test_get_container_acl.rb +37 -0
  125. data/test/requests/storage/test_get_container_properties.rb +45 -0
  126. data/test/requests/storage/test_get_container_url.rb +33 -0
  127. data/test/requests/storage/test_list_blobs.rb +77 -0
  128. data/test/requests/storage/test_list_containers.rb +54 -0
  129. data/test/requests/storage/test_multipart_save_block_blob.rb +105 -0
  130. data/test/requests/storage/test_put_blob_block.rb +34 -0
  131. data/test/requests/storage/test_put_blob_https_url.rb +32 -0
  132. data/test/requests/storage/test_put_blob_metadata.rb +36 -0
  133. data/test/requests/storage/test_put_blob_pages.rb +34 -0
  134. data/test/requests/storage/test_put_blob_properties.rb +39 -0
  135. data/test/requests/storage/test_put_container_acl.rb +34 -0
  136. data/test/requests/storage/test_put_container_metadata.rb +36 -0
  137. data/test/requests/storage/test_release_blob_lease.rb +34 -0
  138. data/test/requests/storage/test_release_container_lease.rb +34 -0
  139. data/test/requests/storage/test_save_page_blob.rb +115 -0
  140. data/test/requests/storage/test_wait_blob_copy_operation_to_finish.rb +148 -0
  141. data/test/smoke_tests/compute/test_resource_group_smoke.rb +37 -0
  142. data/test/test_credentials.rb +63 -0
  143. data/test/test_helper.rb +846 -0
  144. metadata +352 -0
@@ -0,0 +1,40 @@
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
+ For structure information of fog click [here](https://github.com/fog/fog-azure-rm/blob/master/lib/fog/azurerm/docs/structure.md)
6
+
7
+ ### Coding
8
+
9
+ * Pick a task:
10
+ * Offer feedback on open [pull requests](https://github.com/fog/fog-azure-rm/pulls).
11
+ * Review open [issues](https://github.com/fog/fog-azure-rm/issues) for things to help on.
12
+ * [Create an issue](https://github.com/fog/fog-azure-rm/issues/new) to start a discussion on additions or features.
13
+ * Fork the project, add your changes and tests to cover them in a topic branch.
14
+ * [Fork](https://github.com/fog/fog-azure-rm/fork)
15
+ * Create your feature branch (`git checkout -b my-new-feature`)
16
+ * Commit your changes (`git commit -am 'Add some feature'`)
17
+ * Push to the branch (`git push origin my-new-feature`)
18
+ * Create a new pull request
19
+ * Commit your changes and rebase against `fog/fog-azure-rm` to ensure everything is up to date.
20
+ * [Submit a pull request](https://github.com/fog/fog-azure-rm/compare/).
21
+
22
+ ### Non-Coding
23
+
24
+ * Offer feedback on open [issues](https://github.com/fog/fog-azure-rm/issues).
25
+ * Organize or volunteer at events.
26
+ * Write and help edit [documentation](https://github.com/fog/fog-azure-rm/tree/master/lib/fog/azurerm/docs).
27
+
28
+ ## Testing
29
+ You can run `Minitest` tests by running this command in the root directory.
30
+
31
+ ```shell
32
+ $ rake test
33
+ ```
34
+
35
+ ## Code Coverage
36
+ We are using Simplecov Gem for code coverage. You can see the report of Code Coverage by running this command in the root directory.
37
+
38
+ ```shell
39
+ $ rake coverage
40
+ ```
@@ -0,0 +1,12 @@
1
+
2
+ * Adnan Khalil <adnan.khalil@confiz.com>
3
+ * Samawia Moin <samawia.moin@confiz.com>
4
+ * Shaffan Chaudhry <shaffan.chaudhry@confiz.com>
5
+ * Zeeshan Arshad <zeeshan.arshad@confiz.com>
6
+ * Haider Ali <haider.ali@confiz.com>
7
+ * Waqar Haider <waqar.haider@confiz.com>
8
+ * Bilal Naeem <bilal.naeem@confiz.com>
9
+ * Azeem Sajid <azeem.sajid@confiz.com>
10
+ * Maham Nazir <maham.nazir@confiz.com>
11
+ * Muhammad Asad <muhammad.asad@confiz.com>
12
+ * Muhammad Abbas Sheikh <abbas.sheikh@confiz.com>
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ # Specify your gem's dependencies in fog-azure-rm.gemspec
3
+ gemspec
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014-2015 [CONTRIBUTORS.md](https://github.com/fog/fog-azure-rm/blob/master/CONTRIBUTORS.md)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,100 @@
1
+ [![Gem Version](https://badge.fury.io/rb/fog-azure-rm.svg)](https://badge.fury.io/rb/fog-azure-rm)
2
+ [![Build Status](https://travis-ci.org/fog/fog-azure-rm.svg?branch=master)](https://travis-ci.org/fog/fog-azure-rm)
3
+ [![security](https://hakiri.io/github/fog/fog-azure-rm/master.svg)](https://hakiri.io/github/fog/fog-azure-rm/master)
4
+ [![Test Coverage](https://codeclimate.com/github/fog/fog-azure-rm/badges/coverage.svg)](https://codeclimate.com/github/fog/fog-azure-rm/coverage)
5
+ [![Code Climate](https://codeclimate.com/github/fog/fog-azure-rm/badges/gpa.svg)](https://codeclimate.com/github/fog/fog-azure-rm)
6
+
7
+ # Fog Azure Resource Manager
8
+
9
+ NOTE: This is a fork of https://github.com/fog/fog-azure-rm. This fork
10
+ is used to support blob transfers with CarrierWave and Fog v2.
11
+
12
+ This document describes how to get started with Fog using Microsoft Azure as a cloud resource management services provider.
13
+
14
+ ## Pre-requisites
15
+
16
+ * Fog-azure-rm supports Ruby version 2.0.0 or later
17
+
18
+ ## Installation
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ ```ruby
23
+ gem 'fog-azure-rm'
24
+ ```
25
+
26
+ And then execute:
27
+
28
+ $ bundle
29
+
30
+ Or install it yourself as:
31
+
32
+ $ gem install fog-azure-rm
33
+
34
+
35
+ ## Usage
36
+
37
+ You can use this gem against the Microsoft Azure Resource Manager Services in the cloud. Of course, to use the Microsoft Azure Resource Manager Services in the cloud, you need to first [create a Microsoft Azure account](http://www.azure.com/en-us/pricing/free-trial/).
38
+ * Set 'LOCATION' constant based on the Azure cloud you are using in [config.rb] (https://github.com/fog/fog-azure-rm/blob/master/lib/fog/azurerm/config.rb) file. By default it will be 'eastus'.
39
+
40
+ ### Authentication
41
+
42
+ The next step to use this gem, is authentication and permissioning. It is important to get familiar with this concept. For a reference on setting up a service principal from the command line see
43
+ [Authenticating a service principal with Azure Resource Manager](http://aka.ms/cli-service-principal) or
44
+ [Unattended Authentication](http://aka.ms/auth-unattended). For a more robust explanation of authentication in Azure,
45
+ see [Developer’s guide to auth with Azure Resource Manager API](http://aka.ms/arm-auth-dev-guide).
46
+
47
+ After creating the service principal, you should have three pieces of information, a client id (GUID), client secret
48
+ (string) and tenant id (GUID).
49
+
50
+ ### Compute
51
+
52
+ Fog-AzureRM for compute includes implementation of Virtual Machines and Availability Sets. Readme for the usage of [Compute](https://github.com/fog/fog-azure-rm/blob/master/lib/fog/azurerm/docs/compute.md) module.
53
+
54
+ ### Resources
55
+
56
+ Fog-AzureRM for resources includes implementation of Resource Groups. Readme for the usage of [Resources](https://github.com/fog/fog-azure-rm/blob/master/lib/fog/azurerm/docs/resources.md) module.
57
+
58
+ ### DNS
59
+
60
+ Fog-AzureRM for dns includes implementation of Record sets and Zones. Readme for the usage of [DNS](https://github.com/fog/fog-azure-rm/blob/master/lib/fog/azurerm/docs/dns.md) module.
61
+
62
+ ### Network
63
+
64
+ Fog-AzureRM for network includes implementation of Network Interfaces, Public IPs, Subnets and Virtual Networks. Readme for the usage of [Network](https://github.com/fog/fog-azure-rm/blob/master/lib/fog/azurerm/docs/network.md) module.
65
+
66
+ ### Storage
67
+
68
+ Fog-AzureRM for storage includes implementation of Storage Accounts. Readme for the usage of [Storage](https://github.com/fog/fog-azure-rm/blob/master/lib/fog/azurerm/docs/storage.md) module.
69
+
70
+ ### Traffic Manager
71
+
72
+ Fog-AzureRM for Traffic Manager includes implementation of Traffic Manager Profile and Traffic Manager End-points. Readme for the usage of [Traffic Manager](https://github.com/fog/fog-azure-rm/blob/master/lib/fog/azurerm/docs/traffic_manager.md) module.
73
+
74
+ ### SQL
75
+
76
+ Fog-AzureRM for SQL includes implementation of SQL Server, SQL Databases and Data Warehouse. Readme for the usage of [Azure SQL](https://github.com/fog/fog-azure-rm/blob/master/lib/fog/azurerm/docs/sql.md) module.
77
+
78
+ ## Supported Services
79
+
80
+ Use following command for the complete list of services, Fog provides for Azure Resource Manager.
81
+
82
+ ```ruby
83
+ Fog::AzureRM.services
84
+ ```
85
+ # Documentation
86
+
87
+ https://www.rubydoc.info/github/fog/fog-azure-rm/master
88
+
89
+ ## Contributing
90
+
91
+ See [CONTRIBUTING.md](https://github.com/fog/fog-azure-rm/blob/master/CONTRIBUTING.md) in this repository.
92
+
93
+ ## License
94
+
95
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
96
+
97
+
98
+
99
+
100
+
@@ -0,0 +1,31 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'fog/azurerm/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'gitlab-fog-azure-rm'
7
+ spec.version = Fog::AzureRM::VERSION
8
+ spec.authors = ['Shaffan Chaudhry', 'Samawia Moin', 'Adnan Khalil', 'Zeeshan Arshad', 'Haider Ali', 'Waqar Haider', 'Bilal Naeem', 'Muhammad Asad', 'Azeem Sajid', 'Maham Nazir', 'Abbas Sheikh']
9
+ spec.summary = "Module for the 'fog' gem to support Azure Blob Storage with CarrierWave and Fog."
10
+ spec.description = "This is a stripped-down fork of fog-azure-rm that enables Azure Blob Storage to be used with CarrierWave and Fog."
11
+ spec.files = `git ls-files`.split("\n")
12
+ spec.test_files = `git ls-files -- {spec,tests}/*`.split("\n")
13
+ spec.require_paths = %w[lib]
14
+ spec.license = 'MIT'
15
+ spec.homepage = 'https://gitlab.com/gitlab-org/gitlab-fog-azure-rm'
16
+ spec.rdoc_options = %w[--charset=UTF-8]
17
+ spec.extra_rdoc_files = %w[README.md]
18
+ spec.required_ruby_version = '>= 2.0.0'
19
+ spec.post_install_message = 'Thanks for installing!'
20
+ spec.add_development_dependency 'codeclimate-test-reporter' , '~> 1.0.0'
21
+ spec.add_development_dependency 'minitest', '~> 5.8.4'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rubocop', '~> 0.89'
24
+ spec.add_development_dependency 'simplecov'
25
+ spec.add_dependency 'azure_mgmt_storage', '~> 0.21'
26
+ spec.add_dependency 'azure-storage', '~> 0.15.0.preview'
27
+ spec.add_dependency 'fog-core', '= 2.1.0'
28
+ spec.add_dependency 'fog-json', '~> 1.2.0'
29
+ spec.add_dependency 'mime-types', '~> 3.2.2'
30
+ spec.add_dependency 'vhd', '0.0.4'
31
+ end
@@ -0,0 +1,30 @@
1
+ require 'ms_rest_azure'
2
+ require 'azure/core/http/http_error'
3
+ require 'erb'
4
+ require 'fog/azurerm/config'
5
+ require 'fog/azurerm/constants'
6
+ require 'fog/azurerm/utilities/general'
7
+ require 'fog/azurerm/version'
8
+ require 'fog/core'
9
+ require 'fog/json'
10
+ require 'fog/azurerm/models/storage/sku_name'
11
+ require 'fog/azurerm/models/storage/sku_tier'
12
+ require 'fog/azurerm/models/storage/kind'
13
+
14
+ module Fog
15
+ # Autoload Module for Credentials
16
+ module Credentials
17
+ autoload :AzureRM, File.expand_path('azurerm/credentials', __dir__)
18
+ end
19
+
20
+ # Autoload Module for Storage
21
+ module Storage
22
+ autoload :AzureRM, File.expand_path('azurerm/storage', __dir__)
23
+ end
24
+
25
+ # Main AzureRM fog Provider Module
26
+ module AzureRM
27
+ extend Fog::Provider
28
+ service(:storage, 'Storage')
29
+ end
30
+ end
@@ -0,0 +1,44 @@
1
+ module Fog
2
+ module AzureRM
3
+ # class for Async Response
4
+ class AsyncResponse
5
+ def initialize(model, promise, delete_extra_resource = false, post_method_execute = nil)
6
+ @fog_model = model
7
+ @promise = promise
8
+ @delete_extra_resource = delete_extra_resource
9
+ @post_method_execute = post_method_execute
10
+ end
11
+
12
+ def value
13
+ response = @promise.value.body
14
+ @fog_model.merge_attributes(@fog_model.class.parse(response))
15
+ @fog_model.delete_extra_resources if @delete_extra_resource
16
+ # This code block will execute the method mentioned in post_method_execute after getting the response
17
+ unless @post_method_execute.nil?
18
+ @fog_model.public_send(@post_method_execute) if @fog_model.respond_to? @post_method_execute
19
+ end
20
+ @fog_model
21
+ end
22
+
23
+ def state
24
+ @promise.state
25
+ end
26
+
27
+ def reason
28
+ @promise.reason
29
+ end
30
+
31
+ def pending?
32
+ @promise.pending?
33
+ end
34
+
35
+ def fulfilled?
36
+ @promise.fulfilled?
37
+ end
38
+
39
+ def rejected?
40
+ @promise.rejected?
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1 @@
1
+ LOCATION = 'eastus'.freeze
@@ -0,0 +1,72 @@
1
+ AZURE_RESOURCE = 'https://management.azure.com'.freeze
2
+ DEFAULT_ADDRESS_PREFIXES = ['10.2.0.0/16'].freeze
3
+ SUBNET = 'Subnet'.freeze
4
+ PUBLIC_IP = 'Public-IP-Address'.freeze
5
+ NETWORK_SECURITY_GROUP = 'Network-Security-Group'.freeze
6
+ STANDARD_STORAGE = 'Standard'.freeze
7
+ PREMIUM_STORAGE = 'Premium'.freeze
8
+ ALLOWED_STANDARD_REPLICATION = %w[LRS ZRS GRS RAGRS].freeze
9
+ API_VERSION = '2016-06-01'.freeze
10
+ FAULT_DOMAIN_COUNT = 2
11
+ UPDATE_DOMAIN_COUNT = 5
12
+ WINDOWS = 'windows'.freeze
13
+ VPN = 'Vpn'.freeze
14
+ MICROSOFT_PEERING = 'MicrosoftPeering'.freeze
15
+ RESOURCE_GROUP_NAME = 4
16
+ RESOURCE_PROVIDER_NAMESPACE = 6
17
+ RESOURCE_TYPE = 7
18
+ RESOURCE_NAME = 8
19
+ ENDPOINT_PREFIX = 'Microsoft.Network/trafficManagerProfiles'.freeze
20
+ DISK_PREFIX = 'Microsoft.Compute/disks'.freeze
21
+ SNAPSHOT_PREFIX = 'Microsoft.Compute/snapshots'.freeze
22
+ AZURE_ENDPOINTS = 'azureEndpoints'.freeze
23
+ EXTERNAL_ENDPOINTS = 'externalEndpoints'.freeze
24
+ NESTED_ENDPOINTS = 'nestedEndpoints'.freeze
25
+ GLOBAL = 'global'.freeze
26
+ UPLOAD_BLOB_WORKER_THREAD_COUNT = 8
27
+ VM_NAME_POSITION = 8
28
+ PRIMARY_NIC_INDEX = 0
29
+
30
+ ENVIRONMENT_AZURE_CLOUD = 'AzureCloud'.freeze
31
+ ENVIRONMENT_AZURE_CHINA_CLOUD = 'AzureChinaCloud'.freeze
32
+ ENVIRONMENT_AZURE_US_GOVERNMENT = 'AzureUSGovernment'.freeze
33
+ ENVIRONMENT_AZURE_GERMAN_CLOUD = 'AzureGermanCloud'.freeze
34
+
35
+ # MsRestAzure::AzureOperationError class Error Codes
36
+ ERROR_CODE_RESOURCE_NOT_FOUND = 'ResourceNotFound'.freeze
37
+ ERROR_CODE_NOT_FOUND = 'NotFound'.freeze
38
+ ERROR_CODE_RESOURCE_GROUP_NOT_FOUND = 'ResourceGroupNotFound'.freeze
39
+ ERROR_CODE_PARENT_RESOURCE_NOT_FOUND = 'ParentResourceNotFound'.freeze
40
+
41
+ PLATFORM_LINUX = 'linux'.freeze
42
+
43
+ # State of the copy operation
44
+ COPY_STATUS =
45
+ {
46
+ # The copy completed successfully.
47
+ SUCCESS: 'success',
48
+ # The copy is in progress
49
+ PENDING: 'pending'
50
+ }.freeze
51
+
52
+ # https://msdn.microsoft.com/en-us/library/azure/dd179451.aspx
53
+ # The maximum size for a block blob created via Put Blob is 64 MB. But for better performance, this size should be 32 MB.
54
+ # If your blob is larger than 32 MB, you must upload it as a set of blocks.
55
+ SINGLE_BLOB_PUT_THRESHOLD = 32 * 1024 * 1024
56
+
57
+ # Block blob: https://msdn.microsoft.com/en-us/library/azure/dd135726.aspx
58
+ # Page blob: https://msdn.microsoft.com/en-us/library/azure/ee691975.aspx
59
+ # Each block/page can be a different size, up to a maximum of 4 MB
60
+ MAXIMUM_CHUNK_SIZE = 4 * 1024 * 1024
61
+
62
+ # The hash value of 4MB empty content
63
+ HASH_OF_4MB_EMPTY_CONTENT = 'b5cfa9d6c8febd618f91ac2843d50a1c'.freeze
64
+ REST_CLIENT_API_VERSION = %w[2014-04-01-preview 2016-05-01].freeze
65
+ AS_SKU_CLASSIC = 'Classic'.freeze
66
+ AS_SKU_ALIGNED = 'Aligned'.freeze
67
+
68
+ # The tag key and tag value for creating a temporary storage account for generalized image
69
+ TEMPORARY_STORAGE_ACCOUNT_TAG_KEY = 'generalized_image'.freeze
70
+ TEMPORARY_STORAGE_ACCOUNT_TAG_VALUE = 'delete'.freeze
71
+
72
+ HTTP_NOT_FOUND = 404
@@ -0,0 +1,40 @@
1
+ module Fog
2
+ module Credentials
3
+ # This class is managing credentials token
4
+ class AzureRM
5
+ def self.get_credentials(tenant_id, client_id, client_secret, environment = ENVIRONMENT_AZURE_CLOUD)
6
+ if @credentials.nil? || new_management_credential?(tenant_id, client_id, client_secret, environment)
7
+ get_new_credentials(tenant_id, client_id, client_secret, environment)
8
+ else
9
+ @credentials
10
+ end
11
+ end
12
+
13
+ def self.get_token(tenant_id, client_id, client_secret, environment = ENVIRONMENT_AZURE_CLOUD)
14
+ get_credentials(tenant_id, client_id, client_secret, environment) if @credentials.nil?
15
+ @token_provider.get_authentication_header
16
+ end
17
+
18
+ def self.get_new_credentials(tenant_id, client_id, client_secret, environment)
19
+ @tenant_id = tenant_id
20
+ @client_id = client_id
21
+ @client_secret = client_secret
22
+ @environment = environment
23
+ return if @tenant_id.nil? || @client_id.nil? || @client_secret.nil?
24
+ @token_provider = MsRestAzure::ApplicationTokenProvider.new(@tenant_id, @client_id, @client_secret, active_directory_service_settings(environment))
25
+ @credentials = MsRest::TokenCredentials.new(@token_provider)
26
+ @credentials
27
+ end
28
+
29
+ def self.new_management_credential?(tenant_id, client_id, client_secret, environment)
30
+ @tenant_id != tenant_id ||
31
+ @client_id != client_id ||
32
+ @client_secret != client_secret ||
33
+ @environment != environment
34
+ end
35
+
36
+ private_class_method :get_new_credentials
37
+ private_class_method :new_management_credential?
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,52 @@
1
+ # This file contains any or all custom Fog errors that we create
2
+ module Fog
3
+ module AzureRM
4
+ # This is a custom Fog exception inherited from MsRestAzure::AzureOperationError
5
+ class CustomAzureOperationError < MsRestAzure::AzureOperationError
6
+ def initialize(message, azure_exception)
7
+ super(azure_exception.request, azure_exception.response, azure_exception.body, "Exception in #{message}")
8
+ end
9
+
10
+ def print_subscription_limits_information
11
+ request_method = @request.method
12
+ subscription_id = @request.path_params['subscriptionId']
13
+
14
+ limit_value = remaining_subscription_request_limits(@response)
15
+
16
+ puts "Subscription: '#{subscription_id}'. Request Method: '#{request_method}'. \nLimit Value: #{limit_value['header']}: #{limit_value['value']}\n" unless limit_value.empty?
17
+ end
18
+
19
+ def remaining_subscription_request_limits(response)
20
+ limit = {}
21
+ # handles both read and write limits
22
+ if response.headers.key? 'x-ms-ratelimit-remaining-subscription-resource-requests'
23
+ limit['header'] = 'x-ms-ratelimit-remaining-subscription-resource-requests'
24
+ limit['value'] = response.headers['x-ms-ratelimit-remaining-subscription-resource-requests']
25
+
26
+ # limit for collection API calls
27
+ elsif response.headers.key? 'x-ms-ratelimit-remaining-subscription-resource-entities-read'
28
+ limit['header'] = 'x-ms-ratelimit-remaining-subscription-resource-entities-read'
29
+ limit['value'] = response.headers['x-ms-ratelimit-remaining-subscription-resource-entities-read']
30
+
31
+ # read requests limit
32
+ elsif response.headers.key? 'x-ms-ratelimit-remaining-subscription-reads'
33
+ limit['header'] = 'x-ms-ratelimit-remaining-subscription-reads'
34
+ limit['value'] = response.headers['x-ms-ratelimit-remaining-subscription-reads']
35
+
36
+ # write requests limit
37
+ elsif response.headers.key? 'x-ms-ratelimit-remaining-subscription-writes'
38
+ limit['header'] = 'x-ms-ratelimit-remaining-subscription-writes'
39
+ limit['value'] = response.headers['x-ms-ratelimit-remaining-subscription-writes']
40
+ end
41
+ limit
42
+ end
43
+ end
44
+
45
+ # This is a custom Fog exception inherited from Azure::Core::Http::HTTPError
46
+ class CustomAzureCoreHttpError < Azure::Core::Http::HTTPError
47
+ def initialize(azure_exception)
48
+ super(azure_exception.http_response)
49
+ end
50
+ end
51
+ end
52
+ end