Class: Environment
- Inherits:
-
Object
- Object
- Environment
- Defined in:
- lib/it_tools/environment.rb
Instance Attribute Summary collapse
-
#ops ⇒ Object
Returns the value of attribute ops.
Instance Method Summary collapse
- #deploy(env, options = {}) ⇒ Object
- #get_deploy_command(env, file, options = {}) ⇒ Object
- #get_deploy_dir(environment) ⇒ Object
- #get_deploy_user(environment) ⇒ Object
- #get_hostname(environment) ⇒ Object
- #get_scp_command(src_artifact_name, login_as_who, dest_hostname, dest_dir, dest_artifact_name = nil) ⇒ Object
- #get_solr_base_url(env) ⇒ Object
-
#initialize(options = {}) ⇒ Environment
constructor
A new instance of Environment.
- #set_options(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Environment
Returns a new instance of Environment.
6 7 8 9 10 11 |
# File 'lib/it_tools/environment.rb', line 6 def initialize( = {}) defaults = { :jar_with_dependencies => false, :debug => true, :dry_run => false } @ops = defaults.merge command_line_opts = Options.new @ops = @ops.merge command_line_opts. end |
Instance Attribute Details
#ops ⇒ Object
Returns the value of attribute ops.
4 5 6 |
# File 'lib/it_tools/environment.rb', line 4 def ops @ops end |
Instance Method Details
#deploy(env, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/it_tools/environment.rb', line 17 def deploy(env, = {}) defaults = { :jar_with_dependencies => false } = defaults.merge() @ops = @ops.merge() puts self.inspect if ops[:debug] cmd = get_deploy_command(env) puts "[Command]: " + cmd if ops[:debug] unless ops[:dry_run] system(cmd) end end |
#get_deploy_command(env, file, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/it_tools/environment.rb', line 29 def get_deploy_command(env,file, = {}) @ops = @ops.merge() dd = get_deploy_dir(env) dh = get_hostname(env) du = get_deploy_user(env) mvn = Maven.new(file, @ops) an = mvn.get_artifact_name(file) ban = mvn.get_built_artifact_name_with_version(file) puts "[Built maven artifact]: " + ban if ops[:debug] sc = get_scp_command(an, du, dh, dd, ban) end |
#get_deploy_dir(environment) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/it_tools/environment.rb', line 59 def get_deploy_dir(environment) user = { 'dev' => '/scratch/ngsp/hrmsToCrmod', 'stg' => '/u02/webapps/myhelp/custom', 'prod' => '/u01/app/oracle/ngsp/wls4/user_projects/domains/base_domain2/deployments' } return user[environment]; end |
#get_deploy_user(environment) ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/it_tools/environment.rb', line 67 def get_deploy_user(environment) f = 'ftravers' user = { 'dev' => f, 'stg' => 'oracle', 'prod' => f } return user[environment]; end |
#get_hostname(environment) ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/it_tools/environment.rb', line 76 def get_hostname(environment) domain = ".us.oracle.com" hosts = { 'loc' => 'localhost', 'dev' => 'sta00418' + domain, 'stg' => 'wd1125' + domain, 'prod' => 'amtv1062' + domain } return hosts[environment] end |
#get_scp_command(src_artifact_name, login_as_who, dest_hostname, dest_dir, dest_artifact_name = nil) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/it_tools/environment.rb', line 41 def get_scp_command(src_artifact_name, login_as_who, dest_hostname, dest_dir, dest_artifact_name = nil) deploy_cmd = "rsync -avP --stats " if @ops[:use_scp] deploy_cmd = "scp " end deploy_cmd += "target/#{src_artifact_name} #{login_as_who}@#{dest_hostname}:#{dest_dir}" if dest_dir deploy_cmd += "/#{dest_artifact_name}" end return deploy_cmd; end |
#get_solr_base_url(env) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/it_tools/environment.rb', line 53 def get_solr_base_url(env) solr_base_url = { 'loc' => 'http://localhost:8983/solr/' } return solr_base_url[env] end |
#set_options(options = {}) ⇒ Object
13 14 15 |
# File 'lib/it_tools/environment.rb', line 13 def ( = {}) @ops = @ops.merge() end |