Class: Chef::Knife::RackspaceNetworkCreate

Inherits:
Chef::Knife
  • Object
show all
Includes:
RackspaceBase
Defined in:
lib/chef/knife/rackspace_network_create.rb

Instance Method Summary collapse

Methods included from RackspaceBase

#auth_endpoint, #connection, #connection_params, included, #ip_address, #locate_config_value, #msg_pair, #public_dns_name, #region_warning_for_v1

Methods inherited from Chef::Knife

#get_networks, #get_node_name

Instance Method Details

#runObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/chef/knife/rackspace_network_create.rb', line 23

def run
  if version_one?
    ui.error "Networks are not supported in v1"
    exit 1
  else
    networks_list = [
      ui.color("Label", :bold),
      ui.color("CIDR", :bold),
      ui.color("ID", :bold),
    ]
  end
  options = {}
  [:cidr, :label].each do |key|
    options[key] = config[key]
  end
  net = connection.networks.create(options)

  msg_pair("Network ID", net.id)
  msg_pair("Label", net.label)
  msg_pair("CIDR", net.cidr)
end