| 31 | const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); |
| 32 | |
| 33 | const createRegionDisk = async (projectId, region, diskName) => { |
| 34 | const [response] = await regionDisksClient.insert({ |
| 35 | project: projectId, |
| 36 | region, |
| 37 | diskResource: { |
| 38 | sizeGb: 200, |
| 39 | name: diskName, |
| 40 | replicaZones: [ |
| 41 | `projects/${projectId}/zones/europe-central2-a`, |
| 42 | `projects/${projectId}/zones/europe-central2-b`, |
| 43 | ], |
| 44 | }, |
| 45 | }); |
| 46 | let operation = response.latestResponse; |
| 47 | const operationsClient = new compute.RegionOperationsClient(); |
| 48 | |
| 49 | while (operation.status !== 'DONE') { |
| 50 | [operation] = await operationsClient.wait({ |
| 51 | operation: operation.name, |
| 52 | project: projectId, |
| 53 | region: operation.region.split('/').pop(), |
| 54 | }); |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | const createDisk = async (projectId, zone, diskName, sourceImage) => { |
| 59 | const [response] = await disksClient.insert({ |