| 31 | const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); |
| 32 | |
| 33 | const createDisk = async (projectId, zone, diskName, sourceImage) => { |
| 34 | const [response] = await disksClient.insert({ |
| 35 | project: projectId, |
| 36 | zone, |
| 37 | diskResource: { |
| 38 | sourceImage, |
| 39 | name: diskName, |
| 40 | }, |
| 41 | }); |
| 42 | let operation = response.latestResponse; |
| 43 | const operationsClient = new compute.ZoneOperationsClient(); |
| 44 | |
| 45 | while (operation.status !== 'DONE') { |
| 46 | [operation] = await operationsClient.wait({ |
| 47 | operation: operation.name, |
| 48 | project: projectId, |
| 49 | zone: operation.zone.split('/').pop(), |
| 50 | }); |
| 51 | } |
| 52 | }; |
| 53 | |
| 54 | const getInstance = async (projectId, zone, instanceName) => { |
| 55 | const [instance] = await instancesClient.get({ |