Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Azure dependencies updates, some fog-core-2.0 compatibility #407

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
da7ae31
Fix save for created managed disks
ybart Nov 21, 2017
c330f8d
Try to improve consistency in managed_disk
ybart Nov 21, 2017
1f62f48
Add model snapshot
zhitongLBN Dec 4, 2017
17ff1db
Add stubs for snapshot tests
zhitongLBN Dec 4, 2017
75c1371
Add test for snapshot model
zhitongLBN Dec 4, 2017
0e85267
Add collection snapshots
zhitongLBN Dec 4, 2017
f4c23ee
Add test for collection snapshots
zhitongLBN Dec 4, 2017
9518785
Add listing snapshot methods
KevinLoiseau Dec 4, 2017
305ac12
Add 'all' method to fog collection snapshots
KevinLoiseau Dec 4, 2017
ea029bb
Add snapshot listing exemples in compute documentation
KevinLoiseau Dec 4, 2017
f310f89
Add get snapshot request
KevinLoiseau Dec 4, 2017
8beb7d3
Add 'get' method on snapshot model
KevinLoiseau Dec 4, 2017
1588cac
Add snapshot get exemple in compute documentation
KevinLoiseau Dec 4, 2017
1a07ee4
Add snapshot create_or_update request
KevinLoiseau Dec 1, 2017
018e609
Add save method to snapshot model
KevinLoiseau Dec 5, 2017
2906d74
Add snapshot destroy request
zhitongLBN Dec 4, 2017
35bcc85
Add method snapshot#destroy
zhitongLBN Dec 4, 2017
9511dbb
Add doc destroy snapshot
zhitongLBN Dec 6, 2017
3a56acc
Snapshot delete : handle asynchronious response
KevinLoiseau Jan 30, 2018
084bcb7
Apply feedbacks
KevinLoiseau Jan 30, 2018
fc96c85
Merge remote-tracking branch 'snapshot-source/feature/add_snapshot_fu…
stiller-leser Nov 7, 2018
1741beb
Merge remote-tracking branch 'disk-save-source/fix-save-for-create-ma…
stiller-leser Nov 7, 2018
88c8231
bumped version
stiller-leser Nov 7, 2018
0fd90bd
Improved fog compatibility, some fog-core-2 support
stiller-leser Nov 15, 2018
26b6472
Add gem file to repo
stiller-leser Nov 20, 2018
216a6ef
Updated azure gems and related functionality
stiller-leser Nov 22, 2018
7ece0f4
Version locked azure_mgmt_network, due to https://github.com/Azure/az…
stiller-leser Nov 29, 2018
2990cc8
added latest upstream
stiller-leser Jul 19, 2019
68e5dc3
Fixed errors with disk creation and new azure sdk
stiller-leser Jul 19, 2019
18b9274
Fixing azure:mgmt_resources
stiller-leser Oct 17, 2019
784bae0
Updated azure gems
stiller-leser Nov 13, 2019
65352cb
Updating dependencies
stiller-leser Jun 18, 2020
7d14dc0
Update azure packages
stiller-leser Apr 22, 2021
47793ac
Update version
stiller-leser Apr 22, 2021
221417c
Fix azure mgmt sql version
stiller-leser Apr 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.idea
*.gem
Gemfile.lock
.arcconfig
coverage
*/.DS_Store
*.gem
24 changes: 12 additions & 12 deletions fog-azure-rm.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'minitest', '~> 5.8.4'
spec.add_development_dependency 'simplecov'
spec.add_development_dependency 'codeclimate-test-reporter' , '~> 1.0.0'
spec.add_dependency 'fog-core', '~> 1.43'
spec.add_dependency 'fog-json', '~> 1.0.2'
spec.add_dependency 'azure_mgmt_compute', '~> 0.9.0'
spec.add_dependency 'azure_mgmt_resources', '~> 0.9.0'
spec.add_dependency 'azure_mgmt_storage', '~> 0.9.0'
spec.add_dependency 'azure_mgmt_network', '~> 0.9.0'
spec.add_dependency 'azure_mgmt_dns', '~> 0.9.0'
spec.add_dependency 'azure_mgmt_traffic_manager', '~> 0.9.0'
spec.add_dependency 'azure_mgmt_sql', '~> 0.9.0'
spec.add_dependency 'azure_mgmt_key_vault', '~> 0.9.0'
spec.add_dependency 'azure-storage', '= 0.11.5.preview'
spec.add_dependency 'fog-core', '= 2.1.0'
spec.add_dependency 'fog-json', '~> 1.2.0'
spec.add_dependency 'azure_mgmt_compute', '~> 0.22.0'
spec.add_dependency 'azure_mgmt_resources', '~> 0.18.2'
spec.add_dependency 'azure_mgmt_storage', '~> 0.23.0'
spec.add_dependency 'azure_mgmt_network', '~> 0.26.1'
spec.add_dependency 'azure_mgmt_dns', '~> 0.17.5'
spec.add_dependency 'azure_mgmt_traffic_manager', '~> 0.17.4'
spec.add_dependency 'azure_mgmt_sql', '~> 0.19.1'
spec.add_dependency 'azure_mgmt_key_vault', '~> 0.17.7'
spec.add_dependency 'azure-storage', '~> 0.15.0.preview'
spec.add_dependency 'vhd', '0.0.4'
spec.add_dependency 'mime-types', '~> 1.25'
spec.add_dependency 'mime-types', '~> 3.2.2'
end
4 changes: 2 additions & 2 deletions lib/fog/azurerm/application_gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ def initialize(options = {})
retry if require('rubygems')
raise e.message
end

telemetry = "fog-azure-rm/#{Fog::AzureRM::VERSION}"

options[:environment] = 'AzureCloud' if options[:environment].nil?

credentials = Fog::Credentials::AzureRM.get_credentials(options[:tenant_id], options[:client_id], options[:client_secret], options[:environment])
@network_client = ::Azure::ARM::Network::NetworkManagementClient.new(credentials, resource_manager_endpoint_url(options[:environment]))
@network_client = ::Azure::Network::Profiles::Latest::Mgmt::NetworkManagementClient.new(credentials, resource_manager_endpoint_url(options[:environment]))
@network_client.subscription_id = options[:subscription_id]
@network_client.add_user_agent_information(telemetry)
@tenant_id = options[:tenant_id]
Expand Down
12 changes: 10 additions & 2 deletions lib/fog/azurerm/compute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class AzureRM < Fog::Service
request :delete_virtual_machine
request :get_virtual_machine
request :list_virtual_machines
request :list_virtual_machines_in_subscription
request :list_available_sizes_for_virtual_machine
request :generalize_virtual_machine
request :deallocate_virtual_machine
Expand All @@ -44,6 +45,11 @@ class AzureRM < Fog::Service
request :create_image
request :delete_image
request :get_image
request :create_or_update_snapshot
request :list_snapshots_by_rg
request :list_snapshots_in_subscription
request :get_snapshot
request :delete_snapshot

model_path 'fog/azurerm/models/compute'
model :availability_set
Expand All @@ -54,6 +60,8 @@ class AzureRM < Fog::Service
collection :virtual_machine_extensions
model :managed_disk
collection :managed_disks
model :snapshot
collection :snapshots
model :data_disk
model :creation_data
model :disk_create_option
Expand Down Expand Up @@ -88,10 +96,10 @@ def initialize(options)

telemetry = "fog-azure-rm/#{Fog::AzureRM::VERSION}"
credentials = Fog::Credentials::AzureRM.get_credentials(options[:tenant_id], options[:client_id], options[:client_secret], options[:environment])
@compute_mgmt_client = ::Azure::ARM::Compute::ComputeManagementClient.new(credentials, resource_manager_endpoint_url(options[:environment]))
@compute_mgmt_client = ::Azure::Compute::Profiles::Latest::Mgmt::Client.new(options)
@compute_mgmt_client.subscription_id = options[:subscription_id]
@compute_mgmt_client.add_user_agent_information(telemetry)
@storage_mgmt_client = ::Azure::ARM::Storage::StorageManagementClient.new(credentials, resource_manager_endpoint_url(options[:environment]))
@storage_mgmt_client = ::Azure::Compute::Profiles::Latest::Mgmt::Client.new(options)
@storage_mgmt_client.subscription_id = options[:subscription_id]
@storage_mgmt_client.add_user_agent_information(telemetry)
@storage_service = Fog::Storage::AzureRM.new(tenant_id: options[:tenant_id], client_id: options[:client_id], client_secret: options[:client_secret], subscription_id: options[:subscription_id], environment: options[:environment])
Expand Down
1 change: 1 addition & 0 deletions lib/fog/azurerm/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
RESOURCE_NAME = 8
ENDPOINT_PREFIX = 'Microsoft.Network/trafficManagerProfiles'.freeze
DISK_PREFIX = 'Microsoft.Compute/disks'.freeze
SNAPSHOT_PREFIX = 'Microsoft.Compute/snapshots'.freeze
AZURE_ENDPOINTS = 'azureEndpoints'.freeze
EXTERNAL_ENDPOINTS = 'externalEndpoints'.freeze
NESTED_ENDPOINTS = 'nestedEndpoints'.freeze
Expand Down
105 changes: 92 additions & 13 deletions lib/fog/azurerm/docs/compute.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This document explains how to get started using Azure Compute Service with Fog. With this gem you can create, update, list or delete availability sets and virtual machines.

## Usage
## Usage

First of all, you need to require the Fog library by executing:

Expand Down Expand Up @@ -50,7 +50,7 @@ fog_compute_service.servers.create(
username: '<Username>',
disable_password_authentication: <True/False>,
network_interface_card_ids: ['/subscriptions/<Subscription Id>/resourceGroups/<Resource Group Name>/providers/Microsoft.Network/networkInterfaces/<Network Interface Id>'],
publisher: '<Publisher Name>', # Not required if custom image is being used
publisher: '<Publisher Name>', # Not required if custom image is being used
offer: '<Offer Name>', # Not required if custom image is being used
sku: '<SKU Name>', # Not required if custom image is being used
version: '<Version>', # Not required if custom image is being used
Expand Down Expand Up @@ -87,7 +87,7 @@ fog_compute_service.servers.create(
username: '<Username>',
disable_password_authentication: <True/False>,
network_interface_card_ids: ['/subscriptions/<Subscription Id>/resourceGroups/<Resource Group Name>/providers/Microsoft.Network/networkInterfaces/<Network Interface Id>'],
publisher: '<Publisher Name>', # Not required if custom image is being used
publisher: '<Publisher Name>', # Not required if custom image is being used
offer: '<Offer Name>', # Not required if custom image is being used
sku: '<SKU Name>', # Not required if custom image is being used
version: '<Version>', # Not required if custom image is being used
Expand Down Expand Up @@ -118,7 +118,7 @@ fog_compute_service.servers.create(
disable_password_authentication: <True/False>,
network_interface_card_ids: ['/subscriptions/<Subscription Id>/resourceGroups/<Resource Group Name>/providers/Microsoft.Network/networkInterfaces/<Network Interface Id>'],
publisher: '<Publisher Name>', # Not required if custom image is being used
offer: '<Offer Name>', # Not required if custom image is being used
offer: '<Offer Name>', # Not required if custom image is being used
sku: '<SKU Name>', # Not required if custom image is being used
version: '<Version>', # Not required if custom image is being used
platform: '<OS Type>',
Expand All @@ -145,11 +145,11 @@ async_response = fog_compute_service.servers.create_async(
username: '<Username for VM>',
disable_password_authentication: <True/False>,
network_interface_card_ids: ['/subscriptions/<Subscription Id>/resourceGroups/<Resource Group Name>/providers/Microsoft.Network/networkInterfaces/<Network Interface Id>'],
publisher: '<Publisher Name>', # Not required if custom image is being used
publisher: '<Publisher Name>', # Not required if custom image is being used
offer: '<Offer Name>', # Not required if custom image is being used
sku: '<SKU Name>', # Not required if custom image is being used
version: '<Version>' , # Not required if custom image is being used
platform: '<OS Type>',
platform: '<OS Type>',
availability_set_id: '<Availability Set Id>', # [Optional]
password: '<Password>', # [Optional], if 'platform' partameter is 'Linux'.
vhd_path: '<Path of VHD>', # [Optional], if you want to create the VM from a custom image.
Expand All @@ -173,7 +173,7 @@ An example of handling async response is given below:
```ruby
while 1
puts async_response.state

if async_response.pending?
sleep(2)
end
Expand All @@ -189,7 +189,7 @@ while 1
end
end
```

For more information about custom_data, see link: https://msdn.microsoft.com/en-us/library/azure/mt163591.aspx

## List Servers
Expand Down Expand Up @@ -219,7 +219,7 @@ puts "#{server.name}"

Check the status of a Server

```ruby
```ruby
status = fog_compute_service
.servers
.get('<Resource Group Name>', '<Server Name>')
Expand Down Expand Up @@ -285,7 +285,10 @@ fog_compute_service.managed_disks.create(
name: '<Disk Name>',
location: '<Location>',
resource_group_name: '<Resource Group Name>',
account_type: '<Storage Account Type>',
# See https://www.rubydoc.info/gems/azure_mgmt_compute/Azure/Compute/Mgmt/V2018_06_01/Models/DiskSku#tier-instance_method
sku: {
name: '<Storage Account Type>',
},
disk_size_gb: <Disk Size in GBs>,
creation_data: {
create_option: '<Create Option Value>'
Expand All @@ -300,7 +303,10 @@ fog_compute_service.managed_disks.create(
name: '<Disk Name>',
location: '<Location>',
resource_group_name: '<Resource Group Name>',
account_type: '<Storage Account Type>',
# See https://www.rubydoc.info/gems/azure_mgmt_compute/Azure/Compute/Mgmt/V2018_06_01/Models/DiskSku#tier-instance_method
sku: {
name: '<Storage Account Type>',
},
disk_size_gb: <Disk Size in GBs>,
creation_data: {
create_option: '<Create Option Value>'
Expand Down Expand Up @@ -330,7 +336,7 @@ List managed disks in a resource group

```ruby
managed_disks = fog_compute_service.managed_disks(resource_group: '<Resource Group Name>')
mnaged_disks.each do |disk|
managed_disks.each do |disk|
puts "#{disk.name}"
puts "#{disk.location}"
end
Expand Down Expand Up @@ -392,6 +398,79 @@ managed_disk.destroy
managed_disk.destroy(true)
```

## Create a snapshot

```ruby
fog_compute_service.create_or_update_snapshot({
name: snapshot_name,
location: location,
resource_group_name: resource_group,
creation_data: {
create_option: "Copy",
source_uri: disk.id
}
})
```

## List Snapshots in a Resource Group

List Snapshots in a Resource Group

```ruby
snapshots = fog_compute_service.snapshots(resource_group: '<Resource Group Name>')
snapshots.each do |snap|
puts "#{snap.name}"
puts "#{snap.location}"
end
```

## List Snapshots in a Subscription

List Snapshots in a subscription

```ruby
snapshots = fog_compute_service.snapshots
snapshots.each do |snap|
puts "#{snap.name}"
puts "#{snap.location}
end
```

## Get one Snapshot in a Resource Group

get one Snapshot in a Resource Group

```ruby
snap = fog_compute_service.snapshots.get('<Resource Group Name>', 'snapshot-name')
puts "#{snap.name}"
puts "#{snap.location}
```

## Create a Disk from a Snapshot

```ruby
fog_compute_service.managed_disks.create(
name: disk_name,
location: location,
resource_group_name: resource_group,
# See https://docs.microsoft.com/en-us/azure/storage/common/storage-redundancy-lrs
account_type: 'Standard_LRS',
creation_data: {
create_option: 'Copy',
source_uri: snapshot.id
},
disk_size_gb: snapshot.disk_size_gb,
)
```


## Destroy a Snapshot
Destroy a Snapshot

```ruby
snapshot.destroy
```

## Check Availability Set Existence

```ruby
Expand All @@ -412,7 +491,7 @@ fog_compute_service.availability_sets.create(
use_managed_disk: true # [Optional] Possible values true or false
)
```
## List Availability Sets
## List Availability Sets

List availability sets in a resource group

Expand Down
Loading