Class: Chef::Knife
- Inherits:
-
Object
- Object
- Chef::Knife
- Defined in:
- lib/chef/knife/rackspace_base.rb,
lib/chef/knife/rackspace_image_list.rb,
lib/chef/knife/rackspace_flavor_list.rb,
lib/chef/knife/rackspace_server_list.rb,
lib/chef/knife/rackspace_network_list.rb,
lib/chef/knife/rackspace_server_create.rb,
lib/chef/knife/rackspace_server_delete.rb,
lib/chef/knife/rackspace_network_create.rb,
lib/chef/knife/rackspace_network_delete.rb
Direct Known Subclasses
RackspaceFlavorList, RackspaceImageList, RackspaceNetworkCreate, RackspaceNetworkDelete, RackspaceNetworkList, RackspaceServerCreate, RackspaceServerDelete, RackspaceServerList
Defined Under Namespace
Modules: RackspaceBase Classes: RackspaceFlavorList, RackspaceImageList, RackspaceNetworkCreate, RackspaceNetworkDelete, RackspaceNetworkList, RackspaceServerCreate, RackspaceServerDelete, RackspaceServerList
Instance Method Summary collapse
- #get_networks(names, rackconnect3 = false) ⇒ Object
-
#get_node_name(chef_node_name) ⇒ Object
v2 servers require a name, random if chef_node_name is empty, empty if v1.
Instance Method Details
#get_networks(names, rackconnect3 = false) ⇒ Object
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 |
# File 'lib/chef/knife/rackspace_server_create.rb', line 649 def get_networks(names, rackconnect3 = false) names = Array(names) if locate_config_value(:rackspace_version) == "v2" nets = if rackconnect3 [locate_config_value(:rackconnect_v3_network_id)] elsif locate_config_value(:default_networks) %w{ 00000000-0000-0000-0000-000000000000 11111111-1111-1111-1111-111111111111 } else [] end available_networks = connection.networks.all names.each do |name| net = available_networks.detect { |n| n.label == name || n.id == name } if net nets << net.id else ui.error("Failed to locate network: #{name}") exit 1 end end nets elsif names && !names.empty? ui.error("Custom networks are only available in v2 API") exit 1 end end |
#get_node_name(chef_node_name) ⇒ Object
v2 servers require a name, random if chef_node_name is empty, empty if v1
642 643 644 645 646 647 |
# File 'lib/chef/knife/rackspace_server_create.rb', line 642 def get_node_name(chef_node_name) return chef_node_name unless chef_node_name.nil? # lazy uuids chef_node_name = "rs-" + rand.to_s.split(".")[1] unless version_one? end |