gitlab-fog-azure-rm 0.6.0 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b58d858add0fa6eb3a7cd2e748232d32506f5d1c1c5ec91dc333137938804c8
4
- data.tar.gz: 6863876c31c86b6d8e7eae3a03fb0ced679678ffd515e508e5f854379b878019
3
+ metadata.gz: ff94ab3a5881a3709300b1a88ee3861f602a56aa675053e92a8b00f2fd9079a2
4
+ data.tar.gz: e7dbd521f7c7b0d1984ec6aa33005b12b7653741aaa4e9c80f46c66083180713
5
5
  SHA512:
6
- metadata.gz: 47e8d612e9b2144f46badfc86f7df85a8b39fc35e6b95134a94a5b79cb43786286a0e565a5fbb52e9da9d2eec0510203fe1bb0e5b769b0d32bd74313991b4a6b
7
- data.tar.gz: ff4911539b4736ad2dc4d1cd3d541904cf75ac2695c65e2317077cd9200b1aedcac35a3b39e30a2d456d35e8c8b8b6b4d6c6d88d64c63ba9577c9297bd1f270f
6
+ metadata.gz: c93fcf5a6bbaedceb13c75c3b19e75e1ce0f78c2d8909f6bb84ab9eedf08390520a69e0071667fdf0ac8c618b2476706b6e1a3231daa2f9671f5c0bb654125f7
7
+ data.tar.gz: 94abb45649b7c9d88f2a916a1a39887ad44a991c3f890df84e9ad3fb4aa73af02c5ea0f968fc1947a64e2af671fc73d53ed7f88ae0fea2196f9810c61e8e88e7
@@ -43,7 +43,6 @@ Layout/EndOfLine:
43
43
  Layout/HashAlignment:
44
44
  Exclude:
45
45
  - 'lib/fog/azurerm/models/storage/file.rb'
46
- - 'lib/fog/azurerm/requests/storage/create_disk.rb'
47
46
  - 'test/test_helper.rb'
48
47
 
49
48
  # Offense count: 1
@@ -227,7 +226,6 @@ Style/RescueStandardError:
227
226
  Exclude:
228
227
  - 'lib/fog/azurerm/models/storage/files.rb'
229
228
  - 'lib/fog/azurerm/requests/storage/create_block_blob.rb'
230
- - 'lib/fog/azurerm/requests/storage/create_disk.rb'
231
229
  - 'lib/fog/azurerm/requests/storage/multipart_save_block_blob.rb'
232
230
  - 'lib/fog/azurerm/requests/storage/save_page_blob.rb'
233
231
  - 'lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb'
@@ -19,13 +19,12 @@ Gem::Specification.new do |spec|
19
19
  spec.post_install_message = 'Thanks for installing!'
20
20
  spec.add_development_dependency 'codeclimate-test-reporter' , '~> 1.0.0'
21
21
  spec.add_development_dependency 'minitest', '~> 5.8.4'
22
- spec.add_development_dependency 'rake', '~> 10.0'
22
+ spec.add_development_dependency 'rake', '~> 13.0'
23
23
  spec.add_development_dependency 'rubocop', '~> 0.89'
24
24
  spec.add_development_dependency 'simplecov'
25
- spec.add_dependency 'azure_mgmt_storage', '~> 0.21'
26
25
  spec.add_dependency 'azure-storage', '~> 0.15.0.preview'
27
26
  spec.add_dependency 'fog-core', '= 2.1.0'
28
27
  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'
28
+ spec.add_dependency 'mime-types'
29
+ spec.add_dependency 'ms_rest_azure', '~> 0.12.0'
31
30
  end
@@ -12,32 +12,6 @@ require 'fog/azurerm'
12
12
 
13
13
  ## Create Connection
14
14
 
15
- Next, create a connection to the Storage Service:
16
-
17
- ```ruby
18
- fog_storage_service = Fog::Storage::AzureRM.new(
19
- tenant_id: '<Tenant Id>', # Tenant Id of Azure Active Directory Application
20
- client_id: '<Client Id>', # Client Id of Azure Active Directory Application
21
- client_secret: '<Client Secret>', # Client Secret of Azure Active Directory Application
22
- subscription_id: '<Subscription Id>', # Subscription Id of an Azure Account
23
- azure_storage_account_name: '<Storage Account Name>', # Name of an Azure Storage Account
24
- azure_storage_access_key: '<Storage Account Key>', # Key of an Azure Storage Account
25
- environment: '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>' # Azure cloud environment. Default is AzureCloud.
26
- )
27
- ```
28
-
29
- If you only want to manage the storage accounts, you can create the connection without the storage account information:
30
-
31
- ```ruby
32
- fog_storage_service = Fog::Storage::AzureRM.new(
33
- tenant_id: '<Tenant Id>', # Tenant Id of Azure Active Directory Application
34
- client_id: '<Client Id>', # Client Id of Azure Active Directory Application
35
- client_secret: '<Client Secret>', # Client Secret of Azure Active Directory Application
36
- subscription_id: '<Subscription Id>', # Subscription Id of an Azure Account
37
- environment: '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>' # Azure cloud environment. Default is AzureCloud.
38
- )
39
- ```
40
-
41
15
  If you only want to manage the storage data, you can create the connection without the Azure subscription information:
42
16
 
43
17
  ```ruby
@@ -48,127 +22,6 @@ fog_storage_service = Fog::Storage::AzureRM.new(
48
22
  )
49
23
  ```
50
24
 
51
- ## Check Name Availability
52
-
53
- This operation checks that account name is valid and is not already in use. _Storage Account Type_ is an optional parameter
54
-
55
- ```ruby
56
- fog_storage_service.storage_accounts.check_name_availability('<Storage Account Name>', '<Storage Account Type>')
57
- ```
58
-
59
- ## Check Storage Account Existence
60
-
61
- ```ruby
62
- fog_storage_service.storage_accounts.check_storage_account_exists('<Resource Group Name>', '<Storage Account Name>')
63
- ```
64
-
65
- ## Create Storage Account
66
-
67
- Create a new storage account. Replication attribute for Standard and Premium account types are as follows
68
-
69
- ##### Standard
70
-
71
- 1. LRS (Standard Locally-redundant storage)
72
- 2. ZRS (Standard Zone-redundant storage)
73
- 3. GRS (Standard Geo-redundant storage)
74
- 4. RAGRS (Standard Read access geo-redundant storage)
75
-
76
- ##### Premium
77
- 1. LRS (Premium Locally-redundant storage)
78
-
79
- ```ruby
80
- fog_storage_service.storage_accounts.create(
81
- name: '<Storage Account name>',
82
- location: '<Location>',
83
- resource_group: '<Resource Group Name>',
84
- account_type: '<Standard/Premium>', # [Optional] Default value 'Standard'. Allowed values can only be Standard or Premium
85
- replication: '<Replication Type>', # [Optional] Default value 'LRS'
86
- encryption: <True/False>, # [Optional] Enables encryption. Default is false.
87
- tags: { key1: 'value1', key2: 'value2', keyN: 'valueN' } # [Optional]
88
- )
89
- ```
90
- Premium Storage account store data on solid state drives (SSDs). For more details on standard and premium storage accounts, see [Introduction to Microsoft Azure Storage](https://azure.microsoft.com/en-us/documentation/articles/storage-introduction/) and [Premium Storage: High-Performance Storage for Azure Virtual Machine Workloads](https://azure.microsoft.com/en-us/documentation/articles/storage-premium-storage/).
91
-
92
- ## List storage accounts
93
-
94
- ##### List storage accounts in a subscription
95
-
96
- ```ruby
97
- fog_storage_service.storage_accounts.each do |storage_acc|
98
- puts "#{storage_acc.name}"
99
- puts "#{storage_acc.location}"
100
- end
101
- ```
102
- ##### List storage accounts in a resource group
103
-
104
- ```ruby
105
- storage_accounts = fog_storage_service.storage_accounts(resource_group: '<Resource Group Name>')
106
- storage_accounts.each do |storage_acc|
107
- puts "#{storage_acc.name}"
108
- puts "#{storage_acc.location}"
109
- end
110
- ```
111
-
112
- ## Retrieve a single Storage Account
113
-
114
- Get a single record of Storage Account
115
-
116
- ```ruby
117
- storage_acc = fog_storage_service
118
- .storage_accounts
119
- .get('<Resource Group Name>', '<Storage Account Name>')
120
- puts "#{storage_acc.name}"
121
- ```
122
-
123
- ## Enable encryption on Storage Account
124
-
125
- Get a single record of Storage Account and enable encryption on that Storage Account
126
-
127
- ```ruby
128
- storage_acc = fog_storage_service
129
- .storage_accounts
130
- .get('<Resource Group Name>', '<Storage Account Name>')
131
-
132
- storage_acc.update(encryption: true)
133
- ```
134
-
135
- ## Get Access Keys
136
-
137
- Get access keys of a storage account
138
-
139
- ```ruby
140
- keys_hash = storage_acc.get_access_keys
141
- keys_hash.each do |keys|
142
- puts "#{keys.key_name}: #{keys.value}"
143
- end
144
- ```
145
-
146
- ## Destroy a single Storage Account
147
-
148
- Get storage account object from the get method and then destroy that storage account.
149
-
150
- ```ruby
151
- storage_acc.destroy
152
- ```
153
-
154
- ## Create a Disk
155
-
156
- Create a Disk in storage account. _disk_size_in_gb_ must be an integer and the range is [1, 1023].
157
- By default the disk will be created in the container 'vhds'. You can specify other container by set options[:container_name].
158
-
159
- ```ruby
160
- fog_storage_service.create_disk('<Data Disk Name>', disk_size_in_gb, options = {})
161
- ```
162
-
163
- ## Delete a Disk
164
-
165
- Delete a Disk from a storage account. Disk must be in unlocked state i.e detached from server (virtual machine) to successfully perform this action.
166
- By default the disk will be deleted from the container 'vhds'. You can specify other container by set options[:container_name].
167
-
168
- ```ruby
169
- fog_storage_service.delete_disk('<Data Disk Name>', options = {})
170
- ```
171
-
172
25
  ## Check Storage Container Existence
173
26
 
174
27
  ```ruby
@@ -15,9 +15,6 @@ module Fog
15
15
  recognizes :debug
16
16
 
17
17
  request_path 'fog/azurerm/requests/storage'
18
- # Azure Storage Disk requests
19
- request :delete_disk
20
- request :create_disk
21
18
  # Azure Storage Container requests
22
19
  request :create_container
23
20
  request :release_container_lease
@@ -70,7 +67,6 @@ module Fog
70
67
  class Mock
71
68
  def initialize(_options = {})
72
69
  begin
73
- require 'azure_mgmt_storage'
74
70
  require 'azure/storage'
75
71
  rescue LoadError => e
76
72
  retry if require('rubygems')
@@ -83,10 +79,8 @@ module Fog
83
79
  class Real
84
80
  def initialize(options)
85
81
  begin
86
- require 'azure_mgmt_storage'
87
82
  require 'azure/storage'
88
83
  require 'securerandom'
89
- require 'vhd'
90
84
  @debug = ENV['DEBUG'] || options[:debug]
91
85
  require 'azure/core/http/debug_filter' if @debug
92
86
  rescue LoadError => e
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module AzureRM
3
- VERSION = '0.6.0'.freeze
3
+ VERSION = '0.7.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-fog-azure-rm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaffan Chaudhry
@@ -54,14 +54,14 @@ dependencies:
54
54
  requirements:
55
55
  - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: '10.0'
57
+ version: '13.0'
58
58
  type: :development
59
59
  prerelease: false
60
60
  version_requirements: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - "~>"
63
63
  - !ruby/object:Gem::Version
64
- version: '10.0'
64
+ version: '13.0'
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: rubocop
67
67
  requirement: !ruby/object:Gem::Requirement
@@ -90,20 +90,6 @@ dependencies:
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: '0'
93
- - !ruby/object:Gem::Dependency
94
- name: azure_mgmt_storage
95
- requirement: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - "~>"
98
- - !ruby/object:Gem::Version
99
- version: '0.21'
100
- type: :runtime
101
- prerelease: false
102
- version_requirements: !ruby/object:Gem::Requirement
103
- requirements:
104
- - - "~>"
105
- - !ruby/object:Gem::Version
106
- version: '0.21'
107
93
  - !ruby/object:Gem::Dependency
108
94
  name: azure-storage
109
95
  requirement: !ruby/object:Gem::Requirement
@@ -150,30 +136,30 @@ dependencies:
150
136
  name: mime-types
151
137
  requirement: !ruby/object:Gem::Requirement
152
138
  requirements:
153
- - - "~>"
139
+ - - ">="
154
140
  - !ruby/object:Gem::Version
155
- version: 3.2.2
141
+ version: '0'
156
142
  type: :runtime
157
143
  prerelease: false
158
144
  version_requirements: !ruby/object:Gem::Requirement
159
145
  requirements:
160
- - - "~>"
146
+ - - ">="
161
147
  - !ruby/object:Gem::Version
162
- version: 3.2.2
148
+ version: '0'
163
149
  - !ruby/object:Gem::Dependency
164
- name: vhd
150
+ name: ms_rest_azure
165
151
  requirement: !ruby/object:Gem::Requirement
166
152
  requirements:
167
- - - '='
153
+ - - "~>"
168
154
  - !ruby/object:Gem::Version
169
- version: 0.0.4
155
+ version: 0.12.0
170
156
  type: :runtime
171
157
  prerelease: false
172
158
  version_requirements: !ruby/object:Gem::Requirement
173
159
  requirements:
174
- - - '='
160
+ - - "~>"
175
161
  - !ruby/object:Gem::Version
176
- version: 0.0.4
162
+ version: 0.12.0
177
163
  description: This is a stripped-down fork of fog-azure-rm that enables Azure Blob
178
164
  Storage to be used with CarrierWave and Fog.
179
165
  email:
@@ -233,12 +219,10 @@ files:
233
219
  - lib/fog/azurerm/requests/storage/copy_object.rb
234
220
  - lib/fog/azurerm/requests/storage/create_block_blob.rb
235
221
  - lib/fog/azurerm/requests/storage/create_container.rb
236
- - lib/fog/azurerm/requests/storage/create_disk.rb
237
222
  - lib/fog/azurerm/requests/storage/create_page_blob.rb
238
223
  - lib/fog/azurerm/requests/storage/delete_blob.rb
239
224
  - lib/fog/azurerm/requests/storage/delete_blob_https_url.rb
240
225
  - lib/fog/azurerm/requests/storage/delete_container.rb
241
- - lib/fog/azurerm/requests/storage/delete_disk.rb
242
226
  - lib/fog/azurerm/requests/storage/delete_object_url.rb
243
227
  - lib/fog/azurerm/requests/storage/get_blob.rb
244
228
  - lib/fog/azurerm/requests/storage/get_blob_http_url.rb
@@ -293,12 +277,10 @@ files:
293
277
  - test/requests/storage/test_copy_blob_from_uri.rb
294
278
  - test/requests/storage/test_create_block_blob.rb
295
279
  - test/requests/storage/test_create_container.rb
296
- - test/requests/storage/test_create_disk.rb
297
280
  - test/requests/storage/test_create_page_blob.rb
298
281
  - test/requests/storage/test_delete_blob.rb
299
282
  - test/requests/storage/test_delete_blob_https_url.rb
300
283
  - test/requests/storage/test_delete_container.rb
301
- - test/requests/storage/test_delete_disk.rb
302
284
  - test/requests/storage/test_get_blob.rb
303
285
  - test/requests/storage/test_get_blob_http_url.rb
304
286
  - test/requests/storage/test_get_blob_https_url.rb
@@ -1,62 +0,0 @@
1
- module Fog
2
- module Storage
3
- class AzureRM
4
- # This class provides the actual implementation for service calls.
5
- class Real
6
- # Create a disk in Azure storage.
7
- #
8
- # @param disk_name [String] Name of disk
9
- # @param disk_size_in_gb [Integer] Disk size in GiB. Value range: [1, 1023]
10
- # @param options [Hash]
11
- # @option options [String] container_name Sets name of the container which contains the disk. Default is 'vhds'.
12
- #
13
- # @return [Boolean]
14
- #
15
- def create_disk(disk_name, disk_size_in_gb, options = {})
16
- msg = "Creating disk(#{disk_name}, #{disk_size_in_gb}). options: #{options}"
17
- Fog::Logger.debug msg
18
-
19
- raise ArgumentError, "disk_size_in_gb #{disk_size_in_gb} must be an integer" unless disk_size_in_gb.is_a?(Integer)
20
- raise ArgumentError, "Azure minimum disk size is 1 GiB: #{disk_size_in_gb}" if disk_size_in_gb < 1
21
- raise ArgumentError, "Azure maximum disk size is 1023 GiB: #{disk_size_in_gb}" if disk_size_in_gb > 1023
22
-
23
- container_name = options.delete(:container_name)
24
- container_name = 'vhds' if container_name.nil?
25
- blob_name = "#{disk_name}.vhd"
26
- vhd_size = disk_size_in_gb * 1024 * 1024 * 1024
27
- blob_size = vhd_size + 512
28
-
29
- opts = {
30
- type: :fixed,
31
- name: '/tmp/footer.vhd', # Only used to initialize vhd, no local file is generated.
32
- size: disk_size_in_gb
33
- }
34
- vhd_footer = Vhd::Library.new(opts).footer.values.join
35
-
36
- begin
37
- create_page_blob(container_name, blob_name, blob_size, options)
38
- put_blob_pages(container_name, blob_name, vhd_size, blob_size - 1, vhd_footer, options)
39
- rescue
40
- begin
41
- delete_blob(container_name, blob_name)
42
- rescue => ex
43
- Fog::Logger.debug "Cannot delete the blob: #{container_name}/#{blob_name} after create_disk failed. #{ex.inspect}"
44
- end
45
- raise
46
- end
47
-
48
- Fog::Logger.debug "Created a disk #{disk_name} successfully."
49
- true
50
- end
51
- end
52
-
53
- # This class provides the mock implementation for unit tests.
54
- class Mock
55
- def create_disk(*)
56
- Fog::Logger.debug 'Disk created successfully.'
57
- true
58
- end
59
- end
60
- end
61
- end
62
- end
@@ -1,36 +0,0 @@
1
- module Fog
2
- module Storage
3
- class AzureRM
4
- # This class provides the actual implementation for service calls.
5
- class Real
6
- # Delete a disk in Azure storage.
7
- #
8
- # @param disk_name [String] Name of disk
9
- # @param options [Hash]
10
- # @option options [String] container_name Sets name of the container which contains the disk. Default is 'vhds'.
11
- #
12
- # @return [Boolean]
13
- #
14
- def delete_disk(disk_name, options = {})
15
- msg = "Deleting disk(#{disk_name}). options: #{options}"
16
- Fog::Logger.debug msg
17
-
18
- container_name = options.delete(:container_name)
19
- container_name = 'vhds' if container_name.nil?
20
- delete_blob(container_name, "#{disk_name}.vhd")
21
-
22
- Fog::Logger.debug "Successfully deleted Disk: #{disk_name}."
23
- true
24
- end
25
- end
26
-
27
- # This class provides the mock implementation for unit tests.
28
- class Mock
29
- def delete_disk(*)
30
- Fog::Logger.debug 'Successfully deleted Disk'
31
- true
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,70 +0,0 @@
1
- require File.expand_path '../../test_helper', __dir__
2
-
3
- # Storage Data Disk Class
4
- class TestCreateDisk < Minitest::Test
5
- # This class posesses the test cases for the request of create disk.
6
- def setup
7
- Fog.mock!
8
- @mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
9
- Fog.unmock!
10
- @mocked_response = mocked_storage_http_error
11
-
12
- @service = Fog::Storage::AzureRM.new(storage_account_credentials)
13
- end
14
-
15
- def test_create_disk_success
16
- @service.stub :create_page_blob, true do
17
- @service.stub :put_blob_pages, true do
18
- assert @service.create_disk('test_disk', 10)
19
- end
20
- end
21
- end
22
-
23
- def test_create_disk_in_another_container_success
24
- @service.stub :create_page_blob, true do
25
- @service.stub :put_blob_pages, true do
26
- assert @service.create_disk('test_disk', 10, container_name: 'test_container')
27
- end
28
- end
29
- end
30
-
31
- def test_create_disk_with_invalid_size_exception
32
- assert_raises(ArgumentError) do
33
- @service.create_disk('test_disk', 'invalid_size')
34
- end
35
-
36
- assert_raises(ArgumentError) do
37
- @service.create_disk('test_disk', 0)
38
- end
39
-
40
- assert_raises(ArgumentError) do
41
- @service.create_disk('test_disk', 1024)
42
- end
43
- end
44
-
45
- def test_create_disk_http_exception
46
- http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
47
- @service.stub :create_page_blob, http_exception do
48
- @service.stub :delete_blob, true do
49
- assert_raises(Azure::Core::Http::HTTPError) do
50
- @service.create_disk('test_disk', 10, container_name: 'test_container')
51
- end
52
- end
53
- end
54
- end
55
-
56
- def test_create_disk_fail_when_delete_blob_http_exception
57
- http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
58
- @service.stub :create_page_blob, http_exception do
59
- @service.stub :delete_blob, http_exception do
60
- assert_raises(Azure::Core::Http::HTTPError) do
61
- @service.create_disk('test_disk', 10, container_name: 'test_container')
62
- end
63
- end
64
- end
65
- end
66
-
67
- def test_create_disk_mock
68
- assert @mock_service.create_disk('test_disk')
69
- end
70
- end
@@ -1,30 +0,0 @@
1
- require File.expand_path '../../test_helper', __dir__
2
-
3
- # Storage Data Disk Class
4
- class TestDeleteDisk < Minitest::Test
5
- # This class posesses the test cases for the requests of deleting data disks.
6
- def setup
7
- Fog.mock!
8
- @mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
9
- Fog.unmock!
10
- @mocked_response = mocked_storage_http_error
11
-
12
- @service = Fog::Storage::AzureRM.new(storage_account_credentials)
13
- end
14
-
15
- def test_delete_disk_success
16
- @service.stub :delete_blob, true do
17
- assert @service.delete_disk('test_disk')
18
- end
19
- end
20
-
21
- def test_delete_disk_in_another_container_success
22
- @service.stub :delete_blob, true do
23
- assert @service.delete_disk('test_disk', container_name: 'test_container')
24
- end
25
- end
26
-
27
- def test_delete_disk_mock
28
- assert @mock_service.delete_disk('test_disk')
29
- end
30
- end