This method scales the deployment for the given cluster
@param options
@param cb
@returns {*}
355908
function (options, cb) {
		let cluster = options.infra.stack;
		
		//Ref: https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1/projects.zones.clusters.nodePools/autoscaling
		let request = getConnector(options.infra.api);
		let project = request.project;
		delete request.project;
		request.clusterId = cluster.id;
		request.projectId = options.infra.api.project;
		request.zone = cluster.options.zone;
		v1Container().projects.zones.clusters.get(request, (err, clusterResponse) => {
			if (err) {
				return cb(err);
			}
			request.zone = [];
			request.name = `projects/${options.infra.api.project}/locations/${cluster.options.zone}/clusters/${cluster.id}`;
			request.nodePoolId = cluster.options.nodePoolId;
			request.resource = {
				"nodeCount": options.params.number, // get this from ui
			};
			v1Container().projects.zones.clusters.nodePools.setSize(request, (err, nodePoolsResponse) => {
				if (err) {
					return cb(err);
				}
				let maxCounter = 10;
				let counter = 0;
				
				function checkIfClusterisReady(type, miniCB) {
					setTimeout(function () {
						options.soajs.log.debug("Checking if Cluster is Ready.");
						//Ref: https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1/projects.zones.operations/get
						request.operationId = nodePoolsResponse.name;
						request.name = `projects/${options.infra.api.project}/locations/${cluster.options.zone}/operations/${nodePoolsResponse.name}`;
						delete request.resource;
						delete request.nodePoolId;
						delete request.clusterId;
						request.zone = cluster.options.zone;
						v1beta1container().projects[type].operations.get(request, function (err, response) {
							if (err) {
								return miniCB(err);
							} else if (response && response.operationType === "SET_NODE_POOL_SIZE" && response.status === "DONE") {
								return miniCB(null, true);
							} else if (counter > maxCounter) {
								return miniCB(new Error("cluster failed to update node pool size"));
							} else {
								counter++;
								checkIfClusterisReady(type, miniCB);
							}
						});
					}, (process.env.SOAJS_CLOOSTRO_TEST) ? 1 : 25 * 1000);
				}
				
				function updateMachineIps(cb) {
					driver.checkZoneRegion(options, cluster.options.zone, false, (err, type) => {
						if (err) {
							return cb(err);
						}
						checkIfClusterisReady(type, function (err) {
							if (err) {
								return cb(err);
							}
							options.soajs.log.debug("Updating Cluster IP Addresses");
							if (clusterResponse) {
								request.clusterId = cluster.id;
								request.filter = "name eq gke-" + cluster.id.substring(0, 19) + "-" + cluster.options.nodePoolId + "-.*";
								driver.checkZoneRegion(options, cluster.options.zone, true, (err, zones) => {
									if (err) {
										return cb(err);
									}
									//loop over all the zone ang get the ip of each location found in the zone
									//if zonal we only have to loop once
									let machineIPs = [];
									async.each(zones, function (oneZone, callback) {
										request.zone = oneZone;
										delete request.name;
										request.project = project;
										v1Compute().instances.list(request, (error, instances) => {
											if (error) {
												return callback(error);
											}
											if (instances && instances.items) {
												//extract name and ip from response
												instances.items.forEach((oneInstance) => {
													let mIP;
													oneInstance.networkInterfaces.forEach((oneNetInterface) => {
														if (oneNetInterface.accessConfigs) {
															oneNetInterface.accessConfigs.forEach((oneAC) => {
																if (oneAC.name === 'external-nat') {
																	mIP = oneAC.natIP;
																}
															});
														}
													});
													if (mIP) {
														machineIPs.push(mIP);
													}
												});
											}
											callback();
										});
									}, (err) => {
										if (err) {
											return cb(err);
										}
										let region;
										
										function getRegion(cb) {
											if (zones.length > 1) {
												region = cluster.options.zone;
												return cb();
											} else {
												request.region = cluster.options.zone;
												v1Compute().zones.get(request, function (err, response) {
													if (err) {
														return cb(err);
													}
													if (response && response.region){
														let regionUrl = response.region.split("/");
														region = regionUrl[regionUrl.length - 1];
													}
													return cb();
												});
											}
										}
										
										getRegion((err) => {
											if (err) {
												return cb(err);
											}
											delete request.region;
											delete request.filter;
											delete request.clusterId;
											request.region = region;
											v1Compute().addresses.list(request, (err, addresses) => {
												if (err) {
													return cb(err);
												}
												
												//remove ip address
												if (clusterResponse.currentNodeCount > options.params.number && addresses && addresses.items) {
													async.eachSeries(addresses.items, (oneAddress, callback) => {
														if (machineIPs.indexOf(oneAddress.address) === -1) {
															request.address = oneAddress.name;
															//release each address in series
															v1Compute().addresses.delete(request, (err) => {
																if (err) {
																	return callback(err);
																}
																options.soajs.log.debug("IP " + oneAddress.address + " is released!");
																return callback();
															});
														} else {
															return callback();
														}
													}, cb);
												}
												
												//add ip address
												else if (clusterResponse.currentNodeCount < options.params.number) {
													let addressArray = [];
													if (addresses && addresses.items) {
														addresses.items.forEach((oneItem) => {
															addressArray.push(oneItem.address);
														});
													}
													
													async.eachSeries(machineIPs, (oneMachineIP, callback) => {
														if (addressArray.indexOf(oneMachineIP) === -1) {
															let date = new Date();
															request.resource = {
																"name": "gke-" + cluster.id.substring(0, 19) + "-" + cluster.options.nodePoolId + "-" + date.getTime(),
																"address": oneMachineIP
															};
															v1Compute().addresses.insert(request, (err) => {
																if (err) {
																	return callback(err);
																}
																options.soajs.log.debug("IP " + oneMachineIP + " is now static!");
																return callback();
															});
														} else {
															return callback();
														}
													}, cb);
												}
											});
										});
									});
								});
							}
						});
					});
				}
				
				if (clusterResponse && clusterResponse.currentNodeCount === options.params.number) {
					return cb(null, true);
				} else {
					updateMachineIps((err) => {
						if (err) {
							options.soajs.log.error(err);
						}
					});
					return cb(null, true);
				}
			});
		});
	}
29272
function runRebase(options) {
    const platforms = detectPorting(options.platform);
    if (platforms.length <= 0) {
        return Promise.resolve();
    } else {
        const target = platforms[0];
        options.platform = target;
        runBuild(options)
        .then(() => {
            if ('dev' !== target) {
                const srcDir = path.join(__dirname, '..', config.dir.pkg, config.dir.porting + '_' + target);
                const dstDir = path.join(__dirname, '..', config.dir.pkg, config.dir.porting);
                if (fs.existsSync(srcDir)) {
                    fs.moveSync(srcDir, dstDir);
                }
            }
        })
        .catch((reason) => {
            console.error(reason);
            process.exit(1);
        });
    }
}
783862
function autoscale(options) {
    options = options || {};
    return function(planet) {
      planet.onInit(function() {
        var width  = window.innerWidth + (options.extraWidth || 0);
        var height = window.innerHeight + (options.extraHeight || 0);
        planet.projection.scale(Math.min(width, height) / 2);
      });
    };
  }
125454
public static CloudBigtableScanConfiguration BuildExportConfig(ExportOptions options) {
    ValueProvider<ReadRowsRequest> request = new RequestValueProvider(options);
    CloudBigtableScanConfiguration.Builder configBuilder =
        new CloudBigtableScanConfiguration.Builder()
            .withProjectId(options.getBigtableProject())
            .withInstanceId(options.getBigtableInstanceId())
            .withTableId(options.getBigtableTableId())
            .withAppProfileId(options.getBigtableAppProfileId())
            .withRequest(request);

    return configBuilder.build();
  }
433522
function deploy(connections, dataSource, cb) {

  async.waterfall([
    function validateParams(cb) {
      var dataSourceValidator = validate(dataSource);
      //The data source parameter should have an ID property.
      dataSourceValidator.has(CONSTANTS.DATA_SOURCE_ID, function(err) {
        if (err) {
          return cb(buildErrorResponse({error: new Error("An ID Parameter Is Required To Deploy A Data Source"), code: ERROR_CODES.FH_FORMS_INVALID_PARAMETERS}));
        }

        cb(undefined, dataSource);
      });
    },
    function findDataSource(dataSource, cb) {
      var query = {

      };

      //Searching By ID.
      query[CONSTANTS.DATA_SOURCE_ID] = dataSource[CONSTANTS.DATA_SOURCE_ID];

      //Looking up a full data source document as we are updating
      lookUpDataSources(connections, {
        query: query,
        lean: false
      }, function(err, dataSources) {
        if (err) {
          return cb(buildErrorResponse({
            error: err,
            userDetail: "Unexpected Error When Searching For A Data Source",
            code: ERROR_CODES.FH_FORMS_UNEXPECTED_ERROR
          }));
        }

        //If no data sources found create, otherwise update.
        if (dataSources.length === 0) {
          connections.deploy = true;
          create(connections, dataSource, cb);
        } else {
          update(connections, dataSource, cb);
        }
      });
    }
  ], cb);
}
520764
function mergeScaleConfig(/* config objects ... */) {
	return helpers$1.merge({}, [].slice.call(arguments), {
		merger: function(key, target, source, options) {
			if (key === 'xAxes' || key === 'yAxes') {
				var slen = source[key].length;
				var i, type, scale;

				if (!target[key]) {
					target[key] = [];
				}

				for (i = 0; i < slen; ++i) {
					scale = source[key][i];
					type = valueOrDefault$8(scale.type, key === 'xAxes' ? 'category' : 'linear');

					if (i >= target[key].length) {
						target[key].push({});
					}

					if (!target[key][i].type || (scale.type && scale.type !== target[key][i].type)) {
						// new/untyped scale or type changed: let's apply the new defaults
						// then merge source scale to correctly overwrite the defaults.
						helpers$1.merge(target[key][i], [core_scaleService.getScaleDefaults(type), scale]);
					} else {
						// scales type are the same
						helpers$1.merge(target[key][i], scale);
					}
				}
			} else {
				helpers$1._merger(key, target, source, options);
			}
		}
	});
}
1291276
public void deployResources(Resource[] resources, int options)
    {
        if (resources != null)
        {
        	for (Resource resource : resources)
        	{
        		this.deployResource(resource, options);
        	}
        }
    }
98708
function as_user(options, cb) {
  var user = options.user,
      bin = options.bin,
      type = options.type,
      opts = options.opts,
      args = options.args,
      finished = false,
      runner = options.bin,
      command = options.args;

  if (!(user === system.get_running_user())) {
    if (os_name == 'windows') {
      runner = safexec_bin;
      if (type == 'exec') runner = '"' + runner + '"';
      command = ['"' + bin + '"'].concat(args.map(function(x){ return '"' + x + '"'; }));
    } else {
      runner = runner_script;
      command = [user, bin].concat(args);

      if (fs.existsSync(node_bin)) {
        command = [runner].concat(command);
        runner = node_bin;
      }
    }
  }

  if (!opts.env) opts.env = process.env;

  if (process.platform == 'linux' && !opts.env.DISPLAY) {
    opts.env.DISPLAY = ':0'; // ensure active display is used
  }

  if (type == 'exec') {
    var cmd = runner + ' ' + command.join(' '),
        child = cp.exec(cmd, opts, cb);
    child.impersonating = user;
    return child;
  }

  var done = function(e) {
    if (finished) return;

    finished = true;
    cb(e, child);
  }

  // ok, so they want spawn mode. let's fire up the command.
  var child = cp.spawn(runner, command, opts);
  child.impersonating = user;

  // set a listener on error, so if it fails the app doesn't crash!
  child.on('error', function(err) {
    if (err.code == 'ENOENT')
      err.message = 'ENOENT - Executable not found: ' + runner;

    done(err);
  })

  process.nextTick(done);
}
561114
function (options, mCb) {
		const aws = options.infra.api;
		getElbMethod(options.params.elbType || 'classic', 'list', (elbResponse) => {
			const elb = getConnector({
				api: elbResponse.api,
				region: options.params.region,
				keyId: aws.keyId,
				secretAccessKey: aws.secretAccessKey
			});
			const ec2 = getConnector({
				api: 'ec2',
				region: options.params.region,
				keyId: aws.keyId,
				secretAccessKey: aws.secretAccessKey
			});
			elb[elbResponse.method]({}, function (err, response) {
				if (err) {
					return mCb(err);
				}
				async.map(response.LoadBalancerDescriptions, function (lb, callback) {
					async.parallel({
						subnets: function (callback) {
							if (lb && lb.Subnets && Array.isArray(lb.Subnets) && lb.Subnets.length > 0) {
								let sParams = {SubnetIds: lb.Subnets};
								ec2.describeSubnets(sParams, callback);
							}
							else {
								return callback(null, null);
							}
						},
						instances: function (callback) {
							let iParams = {LoadBalancerName: lb.LoadBalancerName};
							elb.describeInstanceHealth(iParams, callback);
						}
					}, function (err, results) {
						return callback(err, helper[elbResponse.helper]({
							lb,
							region: options.params.region,
							subnets: results.subnets ? results.subnets.Subnets : [],
							instances: results.instances ? results.instances.InstanceStates : []
						}));
					});
				}, mCb);
			});
		});
	}
177139
function run(options, ast, cb) {
  var report = new Report(options, ast);
  report.run(cb);
}
818623
function (cb) {
			if (!o1.options.useCDN)
				return cb();

			o1._log('CDN enabling the container');

			container.enableCdn(function (err, _container) {
				if (err)
					return cb(err);

				// check that a parallel operation didn't just CDN enable the same container
				var index = _.findIndex(o1.aContainers, { name : sName });

				container = o1.aContainers[index] = _container;

				cb();
			});
		}
916722
function (db, options, cb) {
	this.db = db;
	this.cb = cb;
	this.updateQueryMaker = options.update;
	this.insertQueryMaker = options.insert;
	this.maxUpdateAttemptsCount = options.maxUpdateAttemptsCount || 2;
	this.transform = options.transform;
	this.insertFirst = !!options.insertFirst;
	this.nonQuery = !!options.nonQuery;

	var self = this;
	this.updateAttemptsCount = 0;
	this.updateOrInsertBound = function () {
		self.updateOrInsert();
	};
}
745918
public Vertigo deployCluster(String cluster, String group, int nodes) {
    return deployCluster(cluster, group, nodes, null);
  }
876017
function (options, cb) {
		/**
		 ==> service found in project
		 //service already has a load balancer
		 ==> case 1: ports in recipe are different than load balancer
		 ==> trigger update load balancer exposed ports
		 ==> case 2: ports in recipe are the same in load balancer
		 ==> don’t do anything
		 ==> case 3: no exposed ports in recipe but load balancer has exposed ports
		 ==> delete load balancer
		 
		 ==> service not found in project
		 ==> case1: service has no load balancer, creating load balancer for the first time
		 ==> case2: service has no load balancer, but it is being redeployed with exposed ports
		 ==> iza fi exposed ports aw ispublished true, then create and expose load balancer
		 * */
			
			//get the service
		let service = options.params.name;
		let ports = options.params.ports;
		const stack = options.infra.stack;
		const envCode = options.params.envCode.toUpperCase();
		
		options.params.info = options.infra.info;
		let listeners = [];
		options.params.ElbName = null;
		if (stack.loadBalancers && options.params.envCode.toUpperCase() && stack.loadBalancers[options.params.envCode.toUpperCase()] && stack.loadBalancers[options.params.envCode.toUpperCase()][service]) {
			options.params.ElbName = stack.loadBalancers[options.params.envCode.toUpperCase()][service];
		}
		if (ports.length === 0 && !options.params.ElbName) {
			return cb(null, true);
		}
		if (ports[0] && ports[0].published) {
			for (let i = 0; i < ports.length; i++) {
				let listener = {
					backendPort: ports[i].published,
					backendProtocol: "TCP",
					frontendPort: ports[i].target,
					frontendProtocol: "TCP",
				};
				if (ports[i].target === 80) {
					listener.frontendProtocol = 'HTTP';
					listener.backendProtocol = 'HTTP';
				}
				listeners.push(listener);
			}
		}
		
		options.params.region = stack.options.zone;
		options.params.rules = listeners;
		//service is found in project record
		if (options.params.ElbName) {
			//service have ports to be exposed
			//update listeners
			
			if (listeners.length > 0) {
				AWSLB.updateExternalLB(options, function (err) {
					return cb(err, true);
				});
			}
			//service have no ports to be exposed
			//delete load balancer
			else {
				if (!options.params.ElbName.name) {
					return cb(null, true);
				}
				else {
					options.params.name = options.params.ElbName.name;
				}
				AWSLB.delete(options, function (err) {
					if (err) {
						return cb(err);
					}
					else {
						options.params.info = options.infra.info;
						const envCode = options.params.envCode.toUpperCase();
						options.params.name = service;
						if (options.infra.deployments && options.infra.deployments[options.params.info[2]]
							&& options.infra.deployments[options.params.info[2]].loadBalancers
							&& options.infra.deployments[options.params.info[2]].loadBalancers[envCode]
							&& options.infra.deployments[options.params.info[2]].loadBalancers[envCode][service]) {
							delete options.infra.deployments[options.params.info[2]].loadBalancers[envCode][service];
						}
						return cb(null, true);
					}
				});
			}
		}
		//service is not found in project record
		else {
			//service have ports to be exposed
			if (listeners.length > 0) {
				if (!options.params.info || options.params.info.length === 0) {
					return cb(new Error("Did not find any deployment information in infra details provided!"));
				}
				const aws = options.infra.api;
				const ec2 = getConnector({
					api: 'ec2',
					region: stack.options.zone,
					keyId: aws.keyId,
					secretAccessKey: aws.secretAccessKey
				});
				const elb = getConnector({
					api: 'elb',
					region: stack.options.zone,
					keyId: aws.keyId,
					secretAccessKey: aws.secretAccessKey
				});
				
				let name = `ht${options.params.soajs_project}-External-`; //ht + projectname + service name
				
				name += randomString.generate({
					length: 31 - name.length,
					charset: 'alphanumeric',
					capitalization: 'uppercase'
				});
				let lbParams = {
					rules: listeners,
					name: name,
					securityGroups: [
						stack.options.ExternalLBSecurityGroupID
					],
					tags: [
						{
							Key: 'ht:cloudformation:stack-name', /* required */
							Value: stack.name
						},
						{
							Key: 'ht:cloudformation:stack-id', /* required */
							Value: stack.id
						},
						{
							Key: 'Type', /* required */
							Value: "External"
						},
						{
							Key: 'Name', /* required */
							Value: name
						}
					]
				};
				if (stack.options.ZonesAvailable) {
					if (!Array.isArray(stack.options.ZonesAvailable)) {
						lbParams.subnets = [stack.options.ZonesAvailable];
					}
					else {
						lbParams.subnets = stack.options.ZonesAvailable;
					}
				}
				lbParams.region = stack.options.zone;
				options.soajs.log.debug(lbParams);
				let params = JSON.parse(JSON.stringify(options.params));
				options.params = lbParams;
				AWSLB.create(options, function (err, loadBalancer) {
					if (err) {
						return cb(err);
					}
					options.params = params;
					const instanceParams = {
						Filters: [
							{
								Name: 'tag:aws:cloudformation:stack-name',
								Values: [
									stack.name
								]
							}
						]
					};
					let instanceIds = [];
					ec2.describeInstances(instanceParams, function (err, instances) {
						if (err) {
							return cb(err);
						}
						else {
							for (let i = 0; i < instances.Reservations.length; i++) {
								for (let y = 0; y < instances.Reservations[i].Instances.length; y++) {
									instanceIds.push({InstanceId: instances.Reservations[i].Instances[y].InstanceId});
								}
							}
							if (instanceIds.length === 0) {
								return cb(new Error("No instances found in stack"));
							}
							const registerParams = {
								Instances: instanceIds,
								LoadBalancerName: name
							};
							elb.registerInstancesWithLoadBalancer(registerParams, function (err) {
								if (err) {
									return cb(err);
								}
								
								//manipulate and add the record
								let deployment = options.infra.deployments;
								//if no loadBalancers object found create one
								if (!deployment[options.params.info[2]].loadBalancers) {
									deployment[options.params.info[2]].loadBalancers = {};
								}
								//if no environment in loadBalancers object found create one
								if (!deployment[options.params.info[2]].loadBalancers[envCode]) {
									deployment[options.params.info[2]].loadBalancers[envCode] = {};
								}
								deployment[options.params.info[2]].loadBalancers[envCode][options.params.name] = {
									name: name,
									DNSName: loadBalancer.DNSName,
									ports: options.params.ports
								};
								options.infra.deployments = deployment;
								return cb(null, true);
							});
						}
					});
				});
			}
			else {
				//do nothing
				return cb(null, true);
			}
		}
	}
506703
function(options, cb) {
  if (os_name == 'windows') {
    path_arg = path.resolve(options.path);
    name_arg = path.resolve(options.name);
  } else {
    path_arg = '"' + options.path + '"';
    name_arg = '"' + options.name + '"';
  }
  var opts = {
    user: options.user,
    bin: node_bin,
    type: 'exec',
    args: [path.join(__dirname, 'upload.js'), path_arg, options.user, name_arg, options.size, options.file_id, options.total, options.port],
    opts: {
      env: process.env
    }
  };

  run_as_user(opts, function(err, out) {
    if (err) {
      logger.error("Upload error: " + err.message);
      return;
    }
    logger.info("Ran as user: " + out);
    if (out.indexOf("File succesfuly uploaded") != -1) {
      files.del(options.file_id);
      return;
    }
    if (out.includes("EPIPE") || out.includes("EACCES")) {
      files.update(options.file_id, options.path, options.size, options.user, options.name, options.resumable, function(err) {
        if (err) logger.error("Database update error");
        logger.info("Resume file option activated for ID: " + options.file_id);
      });
    }
  });
}
999743
public void setClusterSize(String clusterId, String zoneId, int newSize)
      throws InterruptedException {
    setClusterSize(instanceName.toClusterName(clusterId).getClusterName(), newSize);
  }
7998
def scale_cb(self, setting, value):
        """"""
        zoomlevel = self.zoom.calc_level(value)
        self.t_.set(zoomlevel=zoomlevel)

        self.redraw(whence=0)