                         opts.cb(err)
                         return
                     if change.old_val?
-                        delete instances[change.old_val.name]
+                        delete vms[change.old_val.name]
                     if change.new_val?
-                        instances[change.new_val.name] = change.new_val
+                        vms[change.new_val.name] = change.new_val
                     @_rule1(new_val, old_val)
                     @_rule2(new_val, old_val)
 

        else
            @dbg = (f) -> (->)

    _gcloud: (opts) =>
        opts = defaults opts,
            timeout : 180
            args    : required
            verbose : @_debug
            cb      : undefined

        dbg = @dbg("gcloud")
        dbg("args=#{misc.to_json(opts.args)}")
        start = misc.walltime()
        misc_node.execute_code
            command : 'gcloud'
            args    : ['compute', '--project', PROJECT].concat(opts.args)
            timeout : opts.timeout
            verbose : opts.verbose
            cb      : (err, output) =>
                elapsed = misc.walltime(start)
                dbg("elapsed time: #{elapsed}s")
                if err
                    dbg("fail: #{err}")
                else
                    dbg("success")
                opts.cb?(err, output)

    _command: (opts) =>
        opts = defaults opts,
            category : required   # 'instances', 'disks', etc.
            action   : required   # 'start', 'stop', 'reset', etc.
            name     : required
            zone     : DEFAULT_ZONE
            args     : []
            cb       : undefined
        dbg = @dbg("_action(category=#{opts.category}, action=#{opts.action},name=#{opts.name},args=#{misc.to_json(opts.args)})")
        dbg()
        @_gcloud
            args : [opts.category, opts.action, opts.name, '--zone', opts.zone].concat(opts.args)
            cb   : opts.cb

    instance: (opts) =>
        opts = defaults opts,
            name : required
            zone : DEFAULT_ZONE
        key = "#{opts.name}-#{opts.zone}"
        # create cache if not already created
        @_instance_cache ?= {}
        # set value for key if not already set; return it
        return (@_instance_cache[key] ?= new Instance(@, opts.name, opts.zone))

    disk: (opts) =>
        opts = defaults opts,

                    winston.debug("nothing changed")
                    cb()
                else
                    winston.debug("#{objects.length} vms changed")
                    global.objects = objects
                    table.insert(objects, conflict:'update').run(cb)
        ], (err) =>
            opts.cb?(err)
        )

    watch_vms: (opts) =>
        opts = defaults opts,
            cb : required
        return if @_check_db(opts.cb)
        query = @db.table('instances')
        query.run (err, vms) =>
            if err
                opts.cb(err)
                return
