Skip to content

Commit

Permalink
NIC accelerated networking (#384)
Browse files Browse the repository at this point in the history
Added attribute in model and set default value as false
  • Loading branch information
bilal-naeem-confiz committed May 24, 2018
1 parent 3a95f7a commit 2f9f00e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion lib/fog/azurerm/models/network/network_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class NetworkInterface < Fog::Model
attribute :internal_dns_name_label
attribute :internal_fqd
attribute :tags
attribute :enable_accelerated_networking

def self.parse(nic)
hash = {}
Expand Down Expand Up @@ -54,6 +55,7 @@ def self.parse(nic)
hash['internal_dns_name_label'] = nic_dns_settings.internal_dns_name_label
hash['internal_fqd'] = nic_dns_settings.internal_fqdn
end
hash['enable_accelerated_networking'] = nic.enable_accelerated_networking
hash
end

Expand All @@ -64,7 +66,7 @@ def save
requires :subnet_id
requires :ip_configuration_name
requires :private_ip_allocation_method
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)
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)
merge_attributes(Fog::Network::AzureRM::NetworkInterface.parse(nic))
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ module Network
class AzureRM
# Real class for Network Request
class Real
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)
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)
msg = "Creating/Updating Network Interface Card: #{name}"
Fog::Logger.debug msg
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)
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)
begin
network_interface_obj = @network_client.network_interfaces.create_or_update(resource_group_name, name, network_interface)
rescue MsRestAzure::AzureOperationError => e
Expand All @@ -19,7 +19,7 @@ def create_or_update_network_interface(resource_group_name, name, location, subn

private

def 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)
def 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)
if public_ip_address_id
public_ipaddress = Azure::ARM::Network::Models::PublicIPAddress.new
public_ipaddress.id = public_ip_address_id
Expand Down Expand Up @@ -60,6 +60,7 @@ def get_network_interface_object(name, location, subnet_id, public_ip_address_id
network_interface.location = location
network_interface.ip_configurations = [ip_configs]
network_interface.tags = tags
network_interface.enable_accelerated_networking = enable_accelerated_networking

if network_security_group_id
network_security_group = Azure::ARM::Network::Models::NetworkSecurityGroup.new
Expand Down
3 changes: 2 additions & 1 deletion test/integration/network_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
public_ip_address_id: "/subscriptions/#{azure_credentials['subscription_id']}/resourceGroups/TestRG-NI/providers/Microsoft.Network/publicIPAddresses/mypubip",
ip_configuration_name: 'testIpConfiguration',
private_ip_allocation_method: 'Dynamic',
tags: { key: 'value' }
tags: { key: 'value' },
enable_accelerated_networking: true
)
puts "Created network interface: #{network_interface.name}"

Expand Down
3 changes: 2 additions & 1 deletion test/models/network/test_network_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def test_model_attributes
:applied_dns_servers,
:internal_dns_name_label,
:internal_fqd,
:tags
:tags,
:enable_accelerated_networking
]
attributes.each do |attribute|
assert_respond_to @network_interface, attribute
Expand Down

0 comments on commit 2f9f00e

Please sign in to comment.