Class: Chef::Provider::AzurePublicIPAddress

Inherits:
Chef::Provisioning::AzureRM::AzureProvider show all
Defined in:
lib/chef/provider/azure_public_ip_address.rb

Instance Method Summary collapse

Methods inherited from Chef::Provisioning::AzureRM::AzureProvider

#action_handler, #compute_management_client, #network_management_client, #resource_management_client, #resource_manager_endpoint_url, #storage_management_client, #try_azure_operation

Instance Method Details

#create_public_ip_addressObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/chef/provider/azure_public_ip_address.rb', line 37

def create_public_ip_address
  public_ip_address = Azure::ARM::Network::Models::PublicIpAddress.new
  public_ip_address.location = new_resource.location
  public_ip_address.tags = new_resource.tags

  public_ip_address_properties = Azure::ARM::Network::Models::PublicIpAddressPropertiesFormat.new
  public_ip_address_properties.public_ipallocation_method = new_resource.public_ip_allocation_method
  public_ip_address_properties.idle_timeout_in_minutes = new_resource.idle_timeout_in_minutes

  if new_resource.domain_name_label || new_resource.reverse_fqdn
    public_ip_address_properties.dns_settings = create_public_ip_dns_settings(new_resource.domain_name_label, new_resource.reverse_fqdn)
  end

  public_ip_address.properties = public_ip_address_properties

  try_azure_operation('creating or updating public ip') do
    network_management_client.public_ip_addresses.create_or_update(new_resource.resource_group, new_resource.name, public_ip_address)
  end
end

#create_public_ip_dns_settings(domain_name_label, reverse_fqdn) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/chef/provider/azure_public_ip_address.rb', line 63

def create_public_ip_dns_settings(domain_name_label, reverse_fqdn)
  dns_settings = Azure::ARM::Network::Models::PublicIpAddressDnsSettings.new
  dns_settings.domain_name_label = domain_name_label
  dns_settings.reverse_fqdn = reverse_fqdn

  dns_settings
end

#destroy_public_ip_addressObject



57
58
59
60
61
# File 'lib/chef/provider/azure_public_ip_address.rb', line 57

def destroy_public_ip_address
  try_azure_operation('destroying public ip') do
    network_management_client.public_ip_addresses.delete(new_resource.resource_group, new_resource.name)
  end
end

#public_ip_address_existsObject



28
29
30
31
32
33
34
35
# File 'lib/chef/provider/azure_public_ip_address.rb', line 28

def public_ip_address_exists
  public_ip_address_list = network_management_client.public_ip_addresses.list(new_resource.resource_group)
  public_ip_address_list.value.each do |public_ip_address|
    return true if public_ip_address.name == new_resource.name
  end

  false
end

#whyrun_supported?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/chef/provider/azure_public_ip_address.rb', line 8

def whyrun_supported?
  true
end