MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / main

Function main

tpu/stopVM.js:19–54  ·  view source on GitHub ↗
(tpuClient)

Source from the content-addressed store, hash-verified

17'use strict';
18
19async function main(tpuClient) {
20 // [START tpu_vm_stop]
21 // Import the TPUClient
22 // TODO(developer): Uncomment below line before running the sample.
23 // const {TpuClient} = require('@google-cloud/tpu').v2;
24
25 // Instantiate a tpuClient
26 // TODO(developer): Uncomment below line before running the sample.
27 // tpuClient = new TpuClient();
28
29 // TODO(developer): Update these variables before running the sample.
30 // Project ID or project number of the Google Cloud project you want to stop a node.
31 const projectId = await tpuClient.getProjectId();
32
33 // The name of TPU to stop.
34 const nodeName = 'node-name-1';
35
36 // The zone, where the TPU is created.
37 const zone = 'europe-west4-a';
38
39 async function callStopTpuVM() {
40 const request = {
41 name: `projects/${projectId}/locations/${zone}/nodes/${nodeName}`,
42 };
43
44 const [operation] = await tpuClient.stopNode(request);
45 // Wait for the operation to complete.
46 const [response] = await operation.promise();
47
48 console.log(`Node: ${nodeName} stopped.`);
49 return response;
50 }
51
52 return await callStopTpuVM();
53 // [END tpu_vm_stop]
54}
55
56module.exports = main;
57

Callers

nothing calls this directly

Calls 2

callStopTpuVMFunction · 0.85
getProjectIdMethod · 0.80

Tested by

no test coverage detected