     cmd.on 'close', (code) ->
       console.log 'lxc-execute process exited with code ', code
 
-
 manifest.name = "Deployer_#{os.hostname()}_#{uuid.v4()}"
 console.log "deployer:", manifest.name
 
 kite.worker manifest, 
 
   deploy: (options, callback) ->
-    {zipUrl, name} = options
-    lxc = new LXC(name)
-    lxc.createLxc () ->
-      console.log ">>>", name
-      deployment = new Deployment(zipUrl, name, lxc)
+    {id, kiteName, zipUrl} = options
+    deployment = new Deployment(id, kiteName, zipUrl)
+    deployment.create-lxc () ->
       deployment.downloadAndExtractKite deployment.runKite.bind deployment
 
     return callback null, "Hello, I'm #{name}! This is Deployer"

      response.on "end", () ->
        console.log "file download complete", response.statusCode
        if response.statusCode is 200
          console.log "chdirpath", kitePath
          process.chdir kitePath
          
          cmd = spawn "unzip", ["#{name}.zip"]
          console.log 'unziping kite'
          
          cmd.stdout.on 'data', (data) ->

uuid = require 'node-uuid'


class Deployment
  @pathToContainers = "/var/lib/lxc"

  constructor: (@id, @kiteName, @zipUrl) ->
    console.log "......Deployment constructor"
    @kitesPath = path.join Deployment.pathToContainers, @id, "overlay", "opt", "kites"

  createLxc: (callback) ->
    cmd = spawn "create-lxc", [@kiteName]
    console.log 'create lxc'
    cmd.stdout.on 'data', (data) ->
      console.log 'stdout: ', data.toString()
