Class: Chef::Knife::AzureVnetCreate

Inherits:
Chef::Knife show all
Includes:
AzureBase
Defined in:
lib/chef/knife/azure_vnet_create.rb

Instance Method Summary collapse

Methods included from AzureBase

#fetch_chef_client_logs, #fetch_deployment, #fetch_extension, #fetch_role, #fetch_substatus, #find_file, #get_azure_profile_file_path, #get_default_subscription, included, #is_image_windows?, #msg_pair, #msg_server_summary, #parse_azure_profile, #parse_publish_settings_file, #pretty_key, #service, #validate!, #validate_asm_keys!, #validate_params!

Instance Method Details

#runObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/chef/knife/azure_vnet_create.rb', line 46

def run
  $stdout.sync = true

  Chef::Log.info("validating...")
  validate_asm_keys!(:azure_network_name, :azure_affinity_group, :azure_address_space)

  params = {
    azure_vnet_name: config[:azure_network_name],
    azure_ag_name: config[:azure_affinity_group],
    azure_address_space: config[:azure_address_space],
    azure_subnet_name: config[:azure_subnet_name] || "Subnet-#{Random.rand(10)}",
  }

  rsp = service.create_vnet(params)
  print "\n"
  if rsp.at_css("Status").nil?
    if rsp.at_css("Code").nil? || rsp.at_css("Message").nil?
      puts "Unknown Error. try -VV"
    else
      puts "#{rsp.at_css("Code").content}: "\
           "#{rsp.at_css("Message").content}"
    end
  else
    puts "Creation status: #{rsp.at_css("Status").content}"
  end
end