Class: Ploy::Command::Client

Inherits:
Base
  • Object
show all
Defined in:
lib/ploy/command/client.rb

Instance Method Summary collapse

Instance Method Details

#helpObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/ploy/command/client.rb', line 44

def help
  return <<helptext
usage: ploy client OPTS

#{optparser}

Examples:

    $ ploy client -f set.yml -d foo -d bar
    $ ploy client -b bucket -n this/that/set.yml -d foo -d bar
    $ ploy client -u http://example.com/set.yml -d foo -d bar

  All of those examples will try to install the same packages, but use
  different sources for configuration. The first uses a file, the second
  uses S3, and the third uses a web service.

Summary:

  The client command is like an "install" command that uses external
  configuration instead of command-line options. It can use a file,
  or talk to S3 or a web service.

helptext
end

#installable_packages(target_packages, packages) ⇒ Object



69
70
71
72
73
# File 'lib/ploy/command/client.rb', line 69

def installable_packages(target_packages, packages)
  tph = {}
  target_packages.each { |tp| tph[tp] = true }
  installables = packages.find_all { |p| tph[p.deploy_name] }
end

#run(argv) ⇒ Object



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/ploy/command/client.rb', line 9

def run(argv)
  o = {
    :target_packages => []
  }
  optparser(o).parse!(argv)
  conf = conf_from_opts(o)
  
  if conf then
    ps = Ploy::PackageSet.new(conf)
    ips = installable_packages(o[:target_packages], ps.packages)
    ips.each do |package|
      if package.installed_version == '' then
        puts "installing #{package.deploy_name} for the first time"
        package.install
      elsif package.check_new_version then
        if package.updatevia == 'swf'
          puts "skipping update via ploy. updatevia=(#{package.updatevia})"
        else
          if ps.locked?
            puts "locked, so not updating"
          else
            puts "updating #{package.deploy_name}"
            package.install
          end
        end
      else
        puts "no new #{package.deploy_name} available"
      end
    end
  else
    puts "error reading conf"
    help()
  end
end