far-gem 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c9202be26511d57c68a4016a97d6d1f38326eb27f38184dfbf612d53bd90885
4
- data.tar.gz: caef6851e7ed997b0806a1f0a319805fb02b2fbd534ffa059edabc99e6574ea2
3
+ metadata.gz: dcecddee6c2360a57c402ccf6a5c5fbe9c3c7abe4eb5bb3163ebe3f5dff5fbd5
4
+ data.tar.gz: d66b438123d797a6110a6a8d1d054c566b55f1c7b3ea7f49a5ff49a74890ce2d
5
5
  SHA512:
6
- metadata.gz: 9708b117ba2783a4b56f94040fc86f1b4cd6d9facae77117bf5ed93244574647eb4aef95feb529413eed9126f097bfc42e2496725f86f1b336cec3fda091526d
7
- data.tar.gz: dabbcffd77648802ceec978c21c267e844240aee3958c511ba9d0c92779a32d4d77bc0c4366925141920c16468bfceb8fc733dbf07f7d0691e58a462ae03a095
6
+ metadata.gz: 58f2a4d87c61db6eda608184932db4d4e71f2d027e710c2b24dc738ec700fde1c585f41ee322446622ab03ffadf4de234345085d8ae54c5eff34b62fcf83882b
7
+ data.tar.gz: 43632992ea303726e1b6c2b9482f6a9b2b8150390db9f8b1dc4d7d31c796277cd5e3485f53fc98c77a682c206233212aa25b340674cf2639c7ba3e0f4a74f380
data/.travis.yml CHANGED
@@ -2,8 +2,8 @@ language: ruby
2
2
  sudo: false
3
3
 
4
4
  before_install:
5
- - gem install bundler
6
- - gem update bundler
5
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
6
+ - gem install bundler -v '< 2'
7
7
  - gem uninstall -aIx nokogiri -i /home/travis/.rvm/gems/ruby-2.4.1@global nokogiri
8
8
 
9
9
  script: bash ./rake-script.sh
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.4.9
2
+
3
+ **Added**
4
+ - Current Ruby versions added in .travis.yml for testing
5
+ - Asynchronous deletion of Managed Disk added
6
+
7
+ **Changed**
8
+
9
+ - List method which handles pagination by default has been updated for Network Security Group.
10
+ - .travis.yml updated to handle bundler gem dependency on Ruby 2.3+
11
+ - Mocks for Azure::Blobs updated
12
+
1
13
  ## 0.4.8
2
14
 
3
15
  **Added:**
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/fog-azure-rm.svg)](https://badge.fury.io/rb/fog-azure-rm)
2
2
  [![Build Status](https://travis-ci.org/fog/fog-azure-rm.svg?branch=master)](https://travis-ci.org/fog/fog-azure-rm)
3
- [![Dependency Status](https://gemnasium.com/badges/github.com/fog/fog-azure-rm.svg)](https://gemnasium.com/github.com/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
4
  [![Test Coverage](https://codeclimate.com/github/fog/fog-azure-rm/badges/coverage.svg)](https://codeclimate.com/github/fog/fog-azure-rm/coverage)
5
5
  [![Code Climate](https://codeclimate.com/github/fog/fog-azure-rm/badges/gpa.svg)](https://codeclimate.com/github/fog/fog-azure-rm)
6
- [![Stories in Ready](https://badge.waffle.io/fog/fog-azure-rm.svg?label=ready&title=Ready)](http://waffle.io/fog/fog-azure-rm)
7
6
 
8
7
  # Fog Azure Resource Manager
9
8
 
@@ -59,15 +59,20 @@ module Fog
59
59
  hash
60
60
  end
61
61
 
62
- def save
62
+ def save(async = false)
63
63
  requires :name
64
64
  requires :location
65
65
  requires :resource_group
66
66
  requires :subnet_id
67
67
  requires :ip_configuration_name
68
68
  requires :private_ip_allocation_method
69
- nic = service.create_or_update_network_interface(resource_group, name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_configuration_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids, tags, enable_accelerated_networking)
70
- merge_attributes(Fog::Network::AzureRM::NetworkInterface.parse(nic))
69
+
70
+ if async
71
+ service.create_or_update_network_interface(resource_group, name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_configuration_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids, tags, enable_accelerated_networking, true)
72
+ else
73
+ nic = service.create_or_update_network_interface(resource_group, name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_configuration_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids, tags, enable_accelerated_networking, false)
74
+ merge_attributes(Fog::Network::AzureRM::NetworkInterface.parse(nic))
75
+ end
71
76
  end
72
77
 
73
78
  def update(updated_attributes = {})
@@ -15,6 +15,12 @@ module Fog
15
15
  load(network_interfaces)
16
16
  end
17
17
 
18
+ def create_async(attributes = {})
19
+ network_interface = new(attributes)
20
+ promise = network_interface.save(true)
21
+ Fog::AzureRM::AsyncResponse.new(network_interface, promise)
22
+ end
23
+
18
24
  def get(resource_group_name, name)
19
25
  network_interface_card = service.get_network_interface(resource_group_name, name)
20
26
  network_interface_card_fog = Fog::Network::AzureRM::NetworkInterface.new(service: service)
@@ -4,17 +4,21 @@ module Fog
4
4
  class AzureRM
5
5
  # Real class for Network Request
6
6
  class Real
7
- def create_or_update_network_interface(resource_group_name, name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids, tags, enable_accelerated_networking = false)
7
+ def create_or_update_network_interface(resource_group_name, name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids, tags, enable_accelerated_networking = false, async = false)
8
8
  msg = "Creating/Updating Network Interface Card: #{name}"
9
9
  Fog::Logger.debug msg
10
10
  network_interface = get_network_interface_object(name, location, subnet_id, public_ip_address_id, network_security_group_id, ip_config_name, private_ip_allocation_method, private_ip_address, load_balancer_backend_address_pools_ids, load_balancer_inbound_nat_rules_ids, tags, enable_accelerated_networking)
11
11
  begin
12
- network_interface_obj = @network_client.network_interfaces.create_or_update(resource_group_name, name, network_interface)
12
+ nic_response = if async
13
+ @network_client.network_interfaces.create_or_update_async(resource_group_name, name, network_interface)
14
+ else
15
+ @network_client.network_interfaces.create_or_update(resource_group_name, name, network_interface)
16
+ end
13
17
  rescue MsRestAzure::AzureOperationError => e
14
18
  raise_azure_exception(e, msg)
15
19
  end
16
- Fog::Logger.debug "Network Interface #{name} created/updated successfully."
17
- network_interface_obj
20
+ Fog::Logger.debug "Network Interface #{name} created/updated successfully." unless async
21
+ nic_response
18
22
  end
19
23
 
20
24
  private
@@ -21,7 +21,7 @@ module Fog
21
21
  # Mock class for Network Request
22
22
  class Mock
23
23
  def list_network_security_groups(resource_group)
24
- nsg_list_result = [
24
+ [
25
25
  {
26
26
  'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{resource_group}/providers/Microsoft.Network/networkSecurityGroups/testGroup",
27
27
  'name' => 'testGroup',
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module AzureRM
3
- VERSION = '0.5.2'.freeze
3
+ VERSION = '0.5.3'.freeze
4
4
  end
5
5
  end
@@ -67,6 +67,13 @@ begin
67
67
  public_ip_allocation_method: 'Dynamic'
68
68
  )
69
69
 
70
+ network.public_ips.create(
71
+ name: 'mypubip2',
72
+ resource_group: 'TestRG-NI',
73
+ location: LOCATION,
74
+ public_ip_allocation_method: 'Dynamic'
75
+ )
76
+
70
77
  nsg = network.network_security_groups.create(
71
78
  name: 'test_nsg',
72
79
  resource_group: 'TestRG-NI',
@@ -112,6 +119,40 @@ begin
112
119
  )
113
120
  puts "Created network interface: #{network_interface.name}"
114
121
 
122
+ ########################################################################################################################
123
+ ###################### Create Network Interface Async ######################
124
+ ########################################################################################################################
125
+
126
+ async_response = network.network_interfaces.create_async(
127
+ name: 'NetInt_Async',
128
+ resource_group: 'TestRG-NI',
129
+ location: LOCATION,
130
+ network_security_group_id: nsg.id,
131
+ subnet_id: "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/TestRG-NI/providers/Microsoft.Network/virtualNetworks/testVnet/subnets/mysubnet",
132
+ public_ip_address_id: "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/TestRG-NI/providers/Microsoft.Network/publicIPAddresses/mypubip2",
133
+ ip_configuration_name: 'testIpConfiguration',
134
+ private_ip_allocation_method: 'Dynamic',
135
+ tags: { key: 'value' },
136
+ enable_accelerated_networking: true
137
+ )
138
+
139
+ loop do
140
+ if async_response.pending?
141
+ sleep(2)
142
+ print '.'
143
+ end
144
+
145
+ if async_response.fulfilled?
146
+ puts "\nCreated/Updated NIC asynchronously! [#{async_response.value.name}]"
147
+ break
148
+ end
149
+
150
+ if async_response.rejected?
151
+ puts "\nERROR: Async NIC creation failed!\n#{async_response.reason.inspect}"
152
+ break
153
+ end
154
+ end
155
+
115
156
  ########################################################################################################################
116
157
  ###################### Get Network Interface and Update Resources ######################
117
158
  ########################################################################################################################
@@ -143,6 +184,9 @@ begin
143
184
 
144
185
  puts "Deleted network interface: #{nic.destroy}"
145
186
 
187
+ nic_async = network.network_interfaces.get('TestRG-NI', 'NetInt_Async')
188
+ puts "Deleted network interface: #{nic_async.destroy}"
189
+
146
190
  pubip = network.public_ips.get('TestRG-NI', 'mypubip')
147
191
  pubip.destroy
148
192
 
@@ -14,6 +14,11 @@ class TestCreateNetworkInterface < Minitest::Test
14
14
  @network_interfaces.stub :create_or_update, mocked_response do
15
15
  assert_equal @service.create_or_update_network_interface('fog-test-rg', 'fog-test-network-interface', 'West US', 'fog-test-subnet-id', 'fog-test-ip-address-id', 'fog-test-nsg-id', 'fog-test-ip-configuration', 'Dynamic', '10.0.0.8', ['id-1', 'id-2'], ['id-1', 'id-2'], @tags), mocked_response
16
16
  end
17
+
18
+ # Async
19
+ @network_interfaces.stub :create_or_update_async, mocked_response do
20
+ assert_equal @service.create_or_update_network_interface('fog-test-rg', 'fog-test-network-interface', 'West US', 'fog-test-subnet-id', 'fog-test-ip-address-id', 'fog-test-nsg-id', 'fog-test-ip-configuration', 'Dynamic', '10.0.0.8', ['id-1', 'id-2'], ['id-1', 'id-2'], @tags, false, true), mocked_response
21
+ end
17
22
  end
18
23
 
19
24
  def test_create_network_interface_without_public_ip_success
@@ -21,6 +26,11 @@ class TestCreateNetworkInterface < Minitest::Test
21
26
  @network_interfaces.stub :create_or_update, mocked_response do
22
27
  assert_equal @service.create_or_update_network_interface('fog-test-rg', 'fog-test-network-interface', 'West US', 'fog-test-subnet-id', nil, 'fog-test-nsg-id', 'fog-test-ip-configuration', 'Dynamic', '10.0.0.8', ['id-1', 'id-2'], ['id-1', 'id-2'], @tags), mocked_response
23
28
  end
29
+
30
+ # Async
31
+ @network_interfaces.stub :create_or_update_async, mocked_response do
32
+ assert_equal @service.create_or_update_network_interface('fog-test-rg', 'fog-test-network-interface', 'West US', 'fog-test-subnet-id', nil, 'fog-test-nsg-id', 'fog-test-ip-configuration', 'Dynamic', '10.0.0.8', ['id-1', 'id-2'], ['id-1', 'id-2'], @tags, false, true), mocked_response
33
+ end
24
34
  end
25
35
 
26
36
  def test_create_network_interface_argument_error_failure
@@ -30,6 +40,13 @@ class TestCreateNetworkInterface < Minitest::Test
30
40
  @service.create_or_update_network_interface('fog-test-rg', 'fog-test-network-interface', 'West US', 'fog-test-subnet-id', 'fog-test-ip-address-id', 'fog-test-nsg-id', 'fog-test-ip-configuration', ['id-1', 'id-2'], ['id-1', 'id-2'])
31
41
  end
32
42
  end
43
+
44
+ # Async
45
+ @network_interfaces.stub :create_or_update_async, response do
46
+ assert_raises ArgumentError do
47
+ @service.create_or_update_network_interface('fog-test-rg', 'fog-test-network-interface', 'West US', 'fog-test-subnet-id', 'fog-test-ip-address-id', 'fog-test-nsg-id', 'fog-test-ip-configuration', ['id-1', 'id-2'], ['id-1', 'id-2'], false, true)
48
+ end
49
+ end
33
50
  end
34
51
 
35
52
  def test_create_network_interface_exception_failure
@@ -39,5 +56,12 @@ class TestCreateNetworkInterface < Minitest::Test
39
56
  @service.create_or_update_network_interface('fog-test-rg', 'fog-test-network-interface', 'West US', 'fog-test-subnet-id', 'fog-test-ip-address-id', 'fog-test-nsg-id', 'fog-test-ip-configuration', 'Dynamic', '10.0.0.8', ['id-1', 'id-2'], ['id-1', 'id-2'], @tags)
40
57
  end
41
58
  end
59
+
60
+ # Async
61
+ @network_interfaces.stub :create_or_update_async, response do
62
+ assert_raises MsRestAzure::AzureOperationError do
63
+ @service.create_or_update_network_interface('fog-test-rg', 'fog-test-network-interface', 'West US', 'fog-test-subnet-id', 'fog-test-ip-address-id', 'fog-test-nsg-id', 'fog-test-ip-configuration', 'Dynamic', '10.0.0.8', ['id-1', 'id-2'], ['id-1', 'id-2'], @tags, false, true)
64
+ end
65
+ end
42
66
  end
43
67
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: far-gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaffan Chaudhry
@@ -18,7 +18,7 @@ authors:
18
18
  autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
- date: 2019-01-17 00:00:00.000000000 Z
21
+ date: 2019-02-25 00:00:00.000000000 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
24
  name: rake