Class: EPC::Command::CreateDeploymentCommand

Inherits:
CreateCommand show all
Defined in:
lib/epc/command/deployment/create_deployment_command.rb

Constant Summary

Constants inherited from BaseCommand

BaseCommand::GIVEUP_TICKS, BaseCommand::SLEEP_TIME, BaseCommand::TICKER_TICKS

Instance Attribute Summary

Attributes inherited from BaseCommand

#client, #klass_name, #object_id, #object_type, #options, #target_id, #target_type

Instance Method Summary collapse

Methods inherited from BaseCommand

#check_options, #context_params, #context_params=, #go, include_module, inherited, #initialize, required_options, #say_err

Methods included from PersistentAttributes

#auth_token, #caller_id, #target_url

Constructor Details

This class inherits a constructor from EPC::Command::BaseCommand

Instance Method Details

#execute(args = []) ⇒ Object

Raises:



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/epc/command/deployment/create_deployment_command.rb', line 3

def execute(args = [])

  stage_name = args[0]

  path = File.expand_path(".")

  stage_name = "Development" if stage_name.nil?

  solution_id, solution_name = infer_solution_context(target_id, path, {:get_solution_name => true})

  raise FatalError, "Solution name could not be inferred from directory structure. Either run this command from a solution directory, or specify the solution name with the -s option." if solution_name.nil?

  proceed = ask_yn("You are creating a deployment for the [#{solution_name}] solution with the [#{stage_name}] stage. Correct? [Yn]: ")
  if proceed.upcase == 'N'
    return 1
  end

  versions, instances, memory = {}, {}, {}
  versions, instances, memory = parse_projects(@options[:project_name]) unless blank?(@options[:project_name])

  begin
    status, @id = create_deployment(solution_name, stage_name, versions, instances, memory)
    return status
  rescue Exception => ex
    say_err("Create deployment failed [Exception Caught (#{ex.class.name}): #{ex.to_s}].")
    return 1
  end 


  if @options[:replaces].present?
    status, response, headers = client.put(EPC::Config::DEPLOYMENTS_PATH + "/#{@id}", {:stage_name => "no_change", :replaces_id => @options[:replaces], :versions => "no_change"})
    if status.failure?
      say_err("Replacement request failed: [#{response[:message]}]")
    else
      say("Replacement request successful")
    end
    return status
  end

end

#execute_internal(stage_name = nil) ⇒ Object



44
45
46
47
# File 'lib/epc/command/deployment/create_deployment_command.rb', line 44

def execute_internal(stage_name = nil)
  execute([stage_name])
  return @id
end