infra/google/kubernetes/index.js
function createVpcNetwork(mCb) {
			let networksOptions = Object.assign({}, options);
			networksOptions.params = {
				name,
				returnGlobalOperation: true
			};
			networks.add(networksOptions, (error, globalOperationResponse) => {
				if (error) return cb(error);
				
				//assign network name to deployment entry
				oneDeployment.options.network = name;
				
				//check if network is ready then update firewall rules
				checkVpcNetwork(globalOperationResponse, mCb);
			});
			
			function checkVpcNetwork(globalOperationResponse, mCb) {
				
				function globalOperations(miniCB) {
					options.soajs.log.debug("Checking network Create Status");
					//Ref https://cloud.google.com/compute/docs/reference/latest/globalOperations/get
					let request = getConnector(options.infra.api);
					delete request.projectId;
					request.operation = globalOperationResponse.name;
					v1Compute().globalOperations.get(request, (error, response) => {
						if (error) {
							return miniCB(error);
						}
						if (!response || response.status !== "DONE") {
							setTimeout(function () {
								globalOperations(miniCB);
							}, (process.env.SOAJS_CLOOSTRO_TEST) ? 1 : 5000);
						} else {
							return miniCB(null, response);
						}
					});
				}
				
				globalOperations(function (err) {
					if (err) {
						return mCb(err);
					} else {
						//Ref: https://cloud.google.com/compute/docs/reference/latest/firewalls/insert
						let firewallRules = getFirewallRules(oneDeployment.options.network);
						
						let request = getConnector(options.infra.api);
						async.eachSeries(firewallRules, (oneRule, vCb) => {
							options.soajs.log.debug("Registering new firewall rule:", oneRule.name);
							request.resource = oneRule;
							v1Compute().firewalls.insert(request, vCb);
						}, mCb);
					}
				});
				
			}
		}
function createVpcNetwork(mCb) {
			let networksOptions = Object.assign({}, options);
			networksOptions.params = {
				name,
				returnGlobalOperation: true
			};
			networks.add(networksOptions, (error, globalOperationResponse) => {
				if (error) return cb(error);
				
				//assign network name to deployment entry
				oneDeployment.options.network = name;
				
				//check if network is ready then update firewall rules
				checkVpcNetwork(globalOperationResponse, mCb);
			});
			
			function checkVpcNetwork(globalOperationResponse, mCb) {
				
				function globalOperations(miniCB) {
					options.soajs.log.debug("Checking network Create Status");
					//Ref https://cloud.google.com/compute/docs/reference/latest/globalOperations/get
					let request = getConnector(options.infra.api);
					delete request.projectId;
					request.operation = globalOperationResponse.name;
					v1Compute().globalOperations.get(request, (error, response) => {
						if (error) {
							return miniCB(error);
						}
						if (!response || response.status !== "DONE") {
							setTimeout(function () {
								globalOperations(miniCB);
							}, (process.env.SOAJS_CLOOSTRO_TEST) ? 1 : 5000);
						} else {
							return miniCB(null, response);
						}
					});
				}
				
				globalOperations(function (err) {
					if (err) {
						return mCb(err);
					} else {
						//Ref: https://cloud.google.com/compute/docs/reference/latest/firewalls/insert
						let firewallRules = getFirewallRules(oneDeployment.options.network);
						
						let request = getConnector(options.infra.api);
						async.eachSeries(firewallRules, (oneRule, vCb) => {
							options.soajs.log.debug("Registering new firewall rule:", oneRule.name);
							request.resource = oneRule;
							v1Compute().firewalls.insert(request, vCb);
						}, mCb);
					}
				});
				
			}
		}
function createVpcNetwork ( mCb ) { let networksOptions = Object . assign ( { } , options ) ; networksOptions . params = { name , returnGlobalOperation : true } ; networks . add ( networksOptions , ( error , globalOperationResponse ) => { if ( error ) return cb ( error ) ; //assign network name to deployment entry oneDeployment . options . network = name ; //check if network is ready then update firewall rules checkVpcNetwork ( globalOperationResponse , mCb ) ; } ) ; function checkVpcNetwork ( globalOperationResponse , mCb ) { function globalOperations ( miniCB ) { options . soajs . log . debug ( "Checking network Create Status" ) ; //Ref https://cloud.google.com/compute/docs/reference/latest/globalOperations/get let request = getConnector ( options . infra . api ) ; delete request . projectId ; request . operation = globalOperationResponse . name ; v1Compute ( ) . globalOperations . get ( request , ( error , response ) => { if ( error ) { return miniCB ( error ) ; } if ( ! response || response . status !== "DONE" ) { setTimeout ( function ( ) { globalOperations ( miniCB ) ; } , ( process . env . SOAJS_CLOOSTRO_TEST ) ? 1 : 5000 ) ; } else { return miniCB ( null , response ) ; } } ) ; } globalOperations ( function ( err ) { if ( err ) { return mCb ( err ) ; } else { //Ref: https://cloud.google.com/compute/docs/reference/latest/firewalls/insert let firewallRules = getFirewallRules ( oneDeployment . options . network ) ; let request = getConnector ( options . infra . api ) ; async . eachSeries ( firewallRules , ( oneRule , vCb ) => { options . soajs . log . debug ( "Registering new firewall rule:" , oneRule . name ) ; request . resource = oneRule ; v1Compute ( ) . firewalls . insert ( request , vCb ) ; } , mCb ) ; } } ) ; } }
method used to create a google vpc network
@returns {*}
method used to create a google vpc network