lib/engineyard-metadata/chef_dna.rb in engineyard-metadata-0.0.2 vs lib/engineyard-metadata/chef_dna.rb in engineyard-metadata-0.0.3

- old
+ new

@@ -1,5 +1,6 @@ +require 'active_support' require 'active_support/version' %w{ active_support/json }.each do |active_support_3_requirement| require active_support_3_requirement @@ -7,15 +8,22 @@ module EY module Metadata class ChefDna PATH = '/etc/chef/dna.json' + MYSQL_BIN = '/usr/bin/mysql' + MYSQLDUMP_BIN = '/usr/bin/mysqldump' def data # :nodoc: @data ||= ActiveSupport::JSON.decode File.read(PATH) end + # The present instance's role + def present_instance_role + data['instance_role'] + end + # The present instance's public hostname. def present_public_hostname data['engineyard']['environment']['instances'].detect { |i| i['id'] == EY::Metadata.present_instance_id }['public_hostname'] end @@ -82,9 +90,19 @@ # The public hostname of the db_master, def db_master i = data['engineyard']['environment']['instances'].detect { |i| i['role'] == 'db_master' } || data['engineyard']['environment']['instances'].detect { |i| i['role'] == 'solo' } i['public_hostname'] + end + + # The shell command for mysql, including username, password, hostname and database + def mysql_command + "#{MYSQL_BIN} -h #{database_host} -u #{database_username} -p#{database_password} #{database_name}" + end + + # The shell command for mysql, including username, password, hostname and database + def mysqldump_command + "#{MYSQLDUMP_BIN} -h #{database_host} -u #{database_username} -p#{database_password} #{database_name}" end end end end