【问题标题】:List VMs - Google Compute Engine Node.js Client Library列出 VM - Google Compute Engine Node.js 客户端库
【发布时间】:2019-04-14 06:49:52
【问题描述】:

当我从 Compute 对象的构造函数中排除 keyFilename 时,我得到了所有 VM 的列表。

const Compute = require('@google-cloud/compute');
const compute = new Compute();
const vms = await compute.getVMs(); // populated with right results

但是,一旦我在 Compute 对象的构造函数中指定了 keyFilename,我的虚拟机都不会显示在结果中,尽管它们共享与 keyFilename 中指定的相同的 Google Cloud 项目 ID。

const Compute = require('@google-cloud/compute');
const compute = new Compute({
    keyFilename: 'gcp.json'
});
const vms = await compute.getVMs(); // empty array

请帮忙!

【问题讨论】:

    标签: google-cloud-platform google-compute-engine


    【解决方案1】:

    也许对keyFilename使用绝对路径并添加参数是个好主意

    projectId: 'your-project-id'
    

    到构造函数。

    除此之外,根据documentation,您的代码看起来很普通,所以我认为没有问题,应该可以工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-08
      • 2020-10-25
      • 2016-03-25
      • 2014-08-29
      相关资源
      最近更新 更多