class TProv::Application

Public Instance Methods

create_instance(name) click to toggle source
# File lib/tprov/app.rb, line 67
def create_instance(name)
  cid = `docker run -P --volumes-from "#{name}" -d -t jamtur01/tomcat7 2>&1`.chop
  [$?.exitstatus == 0, cid]
end
delete_instance(cid) click to toggle source
# File lib/tprov/app.rb, line 72
def delete_instance(cid)
  kill = `docker kill #{cid} 2>&1`
  [$?.exitstatus == 0, kill]
end
get_war(name, url) click to toggle source
# File lib/tprov/app.rb, line 61
def get_war(name, url)
  cid = `docker run --name "#{name}" jamtur01/fetcher "#{url}" 2>&1`.chop
  puts cid
  [$?.exitstatus == 0, cid]
end
list_instances() click to toggle source
# File lib/tprov/app.rb, line 77
def list_instances
  @list = {}
  instance_ids = `docker ps -q`.split(/\n/).reject(&:empty?)
  instance_ids.each { |id|
    port = `docker port #{id} 8080`.chop
    config = JSON.parse(`docker inspect #{id}`)
    @list[id] = { 'hostname' => config[0]["Config"]["Hostname"], 'ip' => config[0]["NetworkSettings"]["IPAddress"], 'port' => port }
  }
  @list
end