Beispiel #1
0
 it("can get the security groups of a given instance", function (next) {
   instance.getSecurityGroups(outcome.e(next).s(function (securityGroups) {
     expect(securityGroups.length).to.be(1);
     expect(securityGroups[0].get("_id")).to.be(securityGroup.get("_id"));  
     next();
   }));
 });
Beispiel #2
0
 region.instances.create({ type: "t1.micro", imageId: helpers.images.ubuntu._id, keyPair: keyPair }, outcome.e(next).s(function (model) {
   expect(model.get("keyName")).to.be("test-keypair");
   model.getKeyPair(outcome.e(next).s(function (keyPair) {
     expect(keyPair.get("name")).to.be("test-keypair");
     model.destroy(next);
   }));
 }));
Beispiel #3
0
		return function(source, args, cb) {

			var map = [];

			loop(source, function(item, next) {
				try {
					/*var args2 = args.concat(),
					orgNext;

					if(args2[args2.length - 1] == "function") {
						orgNext = args2[args2.length - 1];
						args2[args2.length - 1] = function(result) {
							orgNext.call(null, null, result);
							map.push
						}
					}*/

					item[method].apply(item, args.concat(outcome.e(next).s(function(result) {
						// map.push(Array.prototype.slice.call(arguments, 0));
						map.push(result);
						next();
					})));	
				} catch(e) {
					return next(e);
				}
			}, outcome.e(cb).s(function() {
				cb(null, map);
			}));
		}
Beispiel #4
0
 it("can return the list of volumes for an instance ", function (next) {
   instance.getVolumes(outcome.e(next).s(function (volumes) {
     expect(volumes.length).to.be(1);
     expect(volumes[0].get("attachments.0.instanceId")).to.be(instance.get("_id"));
     next();
   }));
 });
Beispiel #5
0
 it("can authorize an array of port ranges", function (next) {
   securityGroup.authorize({ ports: [{ from: 80, to: 90 }]}, outcome.e(next).s(function () {
     expect(securityGroup.get("permissions.0.fromPort")).to.be(80);
     expect(securityGroup.get("permissions.0.toPort")).to.be(90);
     next();
   }));
 });
Beispiel #6
0
 before(function (next) {
   aws = awsm(helpers.config);
   aws.ec2.regions.findOne("us-east-1", outcome.e(next).s(function (model) {
     region = model;
     next();
   }));
 });
Beispiel #7
0
 it("can authorize a port", function (next) {
   securityGroup.authorize(80, outcome.e(next).s(function () {
     expect(securityGroup.get("permissions.0.fromPort")).to.be(80);
     expect(securityGroup.get("permissions.0.toPort")).to.be(80);
     next();
   }));
 });
Beispiel #8
0
 it("can authorize a port range", function (next) {
   securityGroup.authorize({ from: 91, to: 100 }, outcome.e(next).s(function () {
     expect(securityGroup.get("permissions.0.fromPort")).to.be(91);
     expect(securityGroup.get("permissions.0.toPort")).to.be(100);
     securityGroup.revoke({ from: 90, to: 100 }, next);
   }));
 });
 load: function (complete) {
   var self = this;
   this.app.mediator.execute("getAvailableLaunchers", outcome.e(complete).s(function (launchers) {
     self.reset(launchers.map(_.bind(self._createModel, self)));
     complete(null, self);
   }));
 },
Beispiel #10
0
  attach: function (instanceId, device, next) {

    if (typeof instanceId === "object") {
      instanceId = instanceId.get("_id");
    }

    if (arguments.length === 2) {
      next = device;
      device = "/dev/sdh"; // or xvdh
    }

    var self = this;

    var ops = {
      VolumeId   : this.get("_id"),
      InstanceId : instanceId,
      Device     : device
    };

    this.logger.notice("attach(%s)", ops);

    this.api.attachVolume(ops, outcome.e(next).s(function () {
      self.region.instances.reload(function () {
        self.reload(next);
      });
    }));
  },
Beispiel #11
0
 it("can be detached from an instance", function (next) {
   address.detach(outcome.e(next).s(function () {
     address.getInstance(function (err, instance) {
       expect(!!instance).to.be(false);
       next();
     });
   }));
 });
Beispiel #12
0
 it("can create an instance with a security group", function (next) {
   region.instances.create({ type: "t1.micro", imageId: helpers.images.ubuntu._id, securityGroup: securityGroup }, outcome.e(next).s(function (model) {
     instance = model;
     console.log(JSON.stringify(instance.context(), null, 2));
     expect(instance.get("type")).to.be("t1.micro");
     next();
   }));
 });
Beispiel #13
0
	"getAllServers": function(callback) {
		async.map(this._services, function(service, next) {
			console.log("fetching servers from %s", service.provider);
			service.getServers(function(err, servers) {
				if(!servers) return next(err);
				next(null, servers);
			});
		}, outcome.e(callback).s(function(servers) {
			callback(null, Array.prototype.concat.apply([], servers));
		}));
	},
	var init = function(entries, callback) {
		

		var on = outcome.e(callback);

		async.map(entries, includeEntry, on.s(function(entries) {

			var deps = __loaded.files;

			callback(null, { entries: entries, dependencies: deps });
		}));
	}
Beispiel #15
0
 it("can be associated with an instance", function (next) {
   address.attach(instance, outcome.e(next).s(function (address) {
     instance.getAddress(function (err, address2) {
       expect(address.get("_id")).to.be(address2.get("_id"));
       address.getInstance(function (err, instance2) {
         expect(instance.get("_id")).to.be(instance2.get("_id"));
         expect(instance.get("addresses.publicIp")).to.equal(address.get("publicIp"));
         next();
       })
     });
   }));
 });
Beispiel #16
0
 _load: function (options, next) {
   this.api.describeAvailabilityZones(outcome.e(next).s(function (result) {
     next(null, result.AvailabilityZones.map(function (zone) {
       return {
         _id    : zone.ZoneName,
         state  : zone.State,
         name   : zone.ZoneName,
         region : zone.RegionName
       }
     }))
   }));
 }
Beispiel #17
0
  detach: function (next) {
    var self = this;

    this.logger.notice("detach()");

    this.api.detachVolume({
      VolumeId: this.get("_id")
    }, outcome.e(next).s(function () {
      self.region.instances.reload(function () {
        self.reload(next);
      });
    }));
  },
Beispiel #18
0
  _load: function (options, next) {

    var ops = {};

    this.api.listHostedZones(ops, outcome.e(next).s(function (response) {
      next(null, response.HostedZones.map(function (hostedZone) {
        return {
          _id    : hostedZone.Id,
          name   : hostedZone.Name,
          config : hostedZone.Config
        }
      }));
    }));
  }
Beispiel #19
0
		return function(source, args, cb) {
			var map = [];

			loop(source, function(item, next) {
				try {
					map.push(item[method].apply(item, args));
					next();
				} catch(e) {
					next(e);
				}
			}, outcome.e(cb).s(function() {
				cb(null, map);
			}));
		}
 	var includeEntry = function(dirOrScript, callback) {
 		
 		var on = outcome.e(callback);

 		step(

 			/**
 			 */

			function() {

				fs.lstat(dirOrScript, this);

			},

			/**
			 */

			on.s(function(stats) {

				//dir specified? scan EVERYTHING
				if(stats.isDirectory()) {

					includeDir(dirOrScript, this);

				//otherwise scan for require() statements
				} else {
					var script = this.script = pathInfo.getPathInfo(dirOrScript);
					includeScript(script, this);

				}
			}),

			/**
			 */

			on.s(function() {
				this(null, this.script);
			}),

			/**
			 */

			callback
		)
 	}
	 var findDeps = module.exports.findDeps = function(entry, callback) {
			
		//incase getPathInfo stuff is passed...
		if(entry.path) entry = entry.path;

		var cwd    = path.dirname(entry),
		on         = outcome.e(callback),
		content    = null;
		
		step(

			/**
			 */

			function() {
				fs.readFile(entry, "utf8", this);
			},

			/**
			 */

			on.s(function(cn) {

				content = cn;

				var next = this, d;

				scanRequired(content, cwd, on.s(function(deps) {
					scanInclude(content, cwd, on.s(function(incDeps) {
						next(null, deps.concat(incDeps));
					}));
				}));
			}),

			
			/**
			 */

			on.success(function(deps) {
				deps.forEach(function(dep) {
					dep.source = entry;
				});
				callback(null, deps);
			})
		);
	}
 	var includeScript = function(script, callback) {

 		//script already used? skip.
 		if(isUsed(script) || !script.path) return callback();

 		//script is core, and platform is node?
 		if(script.core && ops.platform == "node") {
 			script.alias = script.moduleName;
 			return callback();
 		}

 		

 		use(script);

 		var on = outcome.e(function(e) {
 			callback(new Error("unable to include script " + script.path + " from "+script.source+", e: " + e.stack))
 		});


 		step(

 			/** 
 			 * first get the dependencies
 			 */

 			function() {
 				findDeps(script.path, this);
 			},

 			/**
 			 * deps found? load THOSE in!
 			 */

 			on.s(function(deps) {
 				script.dependencies = deps;
 				async.forEach(deps, includeScript, this);
 			}),


 			/**
 			 */

 			callback
 		)
 	}
Beispiel #23
0
module.exports = function(ops, next) {


	/**
	 * first analyze the dependencies. This works a few ways:
	 *
	 * 1. dir specified, so scan ALL scripts, including third-party modules.
	 * 2. entry point specified, so scan ONLY scripts which are used ~ (look for require() stmts)
	 */

	var entries = toarray(ops.entry || ops.entries),
	buildId = ops.buildId || Date.now();

	analyzeDeps({ 	
		entries  : entries, 
		platform : ops.platform || "browser",
		prefix   : ops.prefix
	}, outcome.e(next).s(function(result) {
		next(null, new Bundle(dependencies(result.entries), dependencies(result.dependencies)));
	}));
}
    call: function (keyPath, next) {

      if (arguments.length === 1) {
        var next = keyPath;
        keyPath = path.join(defaultKeyDir, this.get("region"), this.get("name"));
      }

      keyPath = keyPath.replace("~", process.env.HOME).replace(/^\./, process.cwd());

      this.set("keyPath", keyPath);

      var self = this;
      function onSave () {  
        next(null, self);
      }

      try {
        mkdirp.sync(path.dirname(keyPath));
      } catch (e) {

      }

      fs.writeFile(keyPath, this.get("material"), outcome.e(next).s(onSave));
    }
Beispiel #25
0
 before(function (next) {
   region.instances.create({ type: "t1.micro", securityGroup: securityGroup, imageId: helpers.images.ubuntu._id }, outcome.e(next).s(function (model) {
     instance = model;
     next();
   }));
 });
Beispiel #26
0
 it("can find items", function(done) {
   col.find({ age: {$lt: 25}}, outcome.e(done).s(function(items) {
     expect(items.length).to.be(2);
     done();
   }));
 });
Beispiel #27
0
 before(function (next) {
   region.keyPairs.create("test-keypair", outcome.e(next).s(function (model) {
     keyPair = model;
     next();
   }));
 });
Beispiel #28
0
 before(function (next) {
   region.securityGroups.create({ name: "test-sg-" + Date.now() }, outcome.e(next).s(function (model) {
     securityGroup = model;
     next();
   }));
 });
Beispiel #29
0
 it("can't find people ages < 25", function(done) {
   col.find({ age: {$lt: 25}}, outcome.e(done).s(function(items) {
     expect(items.length).to.be(0);
     done();
   }));
 })
Beispiel #30
0
 it("can find new people ages > 25", function(done) {
   col.find({ age: {$gte:25}}, outcome.e(done).s(function(items) {
     expect(items.length).to.be(1);
     done();
   }));
 });