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

Function createDisk

compute/test/consistencyGroup.test.js:33–57  ·  view source on GitHub ↗
(diskName, zone, projectId)

Source from the content-addressed store, hash-verified

31const zoneOperationsClient = new computeLib.ZoneOperationsClient();
32
33async function createDisk(diskName, zone, projectId) {
34 const [response] = await disksClient.insert({
35 project: projectId,
36 zone,
37 diskResource: {
38 sizeGb: 10,
39 name: diskName,
40 zone,
41 type: `zones/${zone}/diskTypes/pd-balanced`,
42 },
43 });
44
45 let operation = response.latestResponse;
46
47 // Wait for the create disk operation to complete.
48 while (operation.status !== 'DONE') {
49 [operation] = await zoneOperationsClient.wait({
50 operation: operation.name,
51 project: projectId,
52 zone: operation.zone.split('/').pop(),
53 });
54 }
55
56 console.log(`Disk: ${diskName} created.`);
57}
58describe('Consistency group', async () => {
59 const consistencyGroupName = `consistency-group-name-${uuid.v4()}`;
60 const prefix = 'disk-name';

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected