Module: BuckKnife::Helper
Instance Method Summary collapse
- #combine_roles_and_recipes(roles = [], recipes = [], separator = ' ') ⇒ Object
- #parse_node_ip(node, interface) ⇒ Object
- #rackspace_flavors ⇒ Object
- #read_project_data_bag(project) ⇒ Object
Instance Method Details
#combine_roles_and_recipes(roles = [], recipes = [], separator = ' ') ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/buckknife/helper.rb', line 18 def combine_roles_and_recipes(roles=[], recipes=[], separator=' ') role_array = roles.map { |role| "role[#{role}]" } recipe_array = recipes.map { |recipe| "recipe[#{recipe}]" } roles_and_recipes = role_array.concat(recipe_array).join(separator) roles_and_recipes end |
#parse_node_ip(node, interface) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/buckknife/helper.rb', line 4 def parse_node_ip(node, interface) network = node['network'] interfaces = network['interfaces'] iface = interfaces[interface] addresses = iface['addresses'] return addresses.keys.select {|key| addresses[key]['family'] == 'inet'}.first end |
#rackspace_flavors ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/buckknife/helper.rb', line 26 def rackspace_flavors { '256M' => 1, '512M' => 2, '1G' => 3, '2G' => 4, '4G' => 5, '8G' => 6, '16G' => 7 } end |
#read_project_data_bag(project) ⇒ Object
13 14 15 16 |
# File 'lib/buckknife/helper.rb', line 13 def read_project_data_bag(project) project_data_bag_file = File. File.join( BuckKnife.project_root, "#{project}.json" ) project_data = JSON.parse File.read(project_data_bag_file) end |