Class: LogicalConstruct::GroundControl::Provision

Inherits:
Mattock::Tasklib
  • Object
show all
Defined in:
lib/logical-construct/ground-control/provision.rb

Instance Method Summary collapse

Instance Method Details

#defineObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/logical-construct/ground-control/provision.rb', line 27

def define
  manifest = nil
  in_namespace do
    directory marshalling.absolute_path

    task :collect, [:ipaddr] do |task, args|
      self.target_address = args[:ipaddr]
    end

    tunnel = LogicalConstruct::SSHTunnel.new do |tunnel|
      tunnel.target_address = proxy_value.target_address
      copy_settings_to(tunnel)
      self.local_target_port = tunnel.proxy_value.local_target_port
    end

    manifest = LogicalConstruct::GenerateManifest.new(self)

    start_flight = Mattock::Rake::RemoteCommandTask.define_task(:start_flight => :collect) do |start_flight|
      start_flight.remote_server.address = proxy_value.target_address
      start_flight.command =
        Mattock::CommandLine.new("nohup",
                                 "/opt/logical-construct/bin/flight-deck",
                                 "-C start_server")
      start_flight.command.redirect_stdin("/dev/null")
      start_flight.command.redirect_stdout("/opt/logical-construct/flight_deck_server.log")
      start_flight.command.copy_stream_to(2, 1)
      start_flight.command.redirections << "&"
    end

    start_resolution = Mattock::Rake::RemoteCommandTask.define_task(:start_resolution => :deliver_manifest) do |start_flight|
      start_flight.remote_server.address = proxy_value.target_address
      start_flight.verbose = 3
      start_flight.command =
        Mattock::CommandLine.new("nohup",
                                 "/opt/logical-construct/bin/flight-deck")
      #TODO: Mattock CommandLine needs a "background"
      #TODO: RemoteCommandTask should wrap the whole
      #nohup-redirect-background thing
      start_flight.command.redirect_stdin("/dev/null")
      start_flight.command.redirect_stdout("/opt/logical-construct/flight_deck.log")
      start_flight.command.copy_stream_to(2, 1)
      start_flight.command.redirections << "&"
    end

    task manifest.root_task => :collect

    task_spine(:start_flight, :deliver_manifest, :fulfill_manifest, :start_resolution, :complete_provision)
    task :deliver_manifest => manifest[:deliver]
    task :fulfill_manifest => manifest[:fulfill]

    tunnel.wrap(manifest[:deliver])
    tunnel.wrap(manifest[:fulfill])
    task :complete_provision => tunnel[:close_tunnel]
  end

  desc "Provision :ipaddr with specified configs"
  task root_task, [:ipaddr] => self[:complete_provision]
end

#plan_task(name, &block) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/logical-construct/ground-control/provision.rb', line 86

def plan_task(name, &block)
  plan = BuildPlan.new(self) do |build|
    build.basename = name
    yield build if block_given?
  end
  task self[:manifest] => plan.archive_path

  in_namespace do
    namespace :package do
      desc "Compile and archive plan #{name.inspect}"
      task name => plan.archive_path
    end
  end

  plan_archives << plan.archive_path
end

#plans(*names) ⇒ Object



103
104
105
106
107
# File 'lib/logical-construct/ground-control/provision.rb', line 103

def plans(*names)
  names.each do |name|
    plan_task(name)
  end
end

#resolve_configurationObject



22
23
24
25
# File 'lib/logical-construct/ground-control/provision.rb', line 22

def resolve_configuration
  resolve_paths
  super
end