`gCloud计算实例创建`是做什么的?-POST https://compute.googleapis.com… [英] What does `gcloud compute instances create` do? - POST https://compute.googleapis.com…

本文介绍了`gCloud计算实例创建`是做什么的?-POST https://compute.googleapis.com…的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用gcloudCLI可以轻松完成某些操作,如:

$ export network='default' instance='example-instance' firewall='ssh-http-icmp-fw'
$ gcloud compute networks       create "$network"
$ gcloud compute firewall-rules create "$firewall" --network "$network" 
                                                   --allow 'tcp:22,tcp:80,icmp'
$ gcloud compute instances      create "$instance" --network "$network" 
                                                   --tags 'http-server' 
                                                   --metadata 
  startup-script='#! /bin/bash
  # Installs apache and a custom homepage
  apt update
  apt -y install apache2
  cat <<EOF > /var/www/html/index.html
  <html><body><h1>Hello World</h1>
  <p>This page was created from a start up script.</p>
  </body></html>'
$ # sleep 15s
$ curl $(gcloud compute instances list --filter='name=('"$instance"')' 
                                       --format='value(EXTERNAL_IP)')

(要在命令中穷尽,请使用拆分)

$ gcloud compute networks       delete -q "$network"
$ gcloud compute firewall-rules delete -q "$firewall"
$ gcloud compute instances      delete -q "$instance"

…但还不清楚rest API端对应的命令是什么。特别是考虑到选项的数量巨大,例如https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert

所以当我为Google Cloud的计算引擎编写我的自定义REST API客户端时,我想只需窃取gcloud在内部所做的任何事情。


运行rg时,我发现以下几行: https://github.com/googleapis/google-auth-library-python/blob/b1a12d2/google/auth/transport/requests.py#L182

特别是lib/third_party中的这5个:

google/auth/transport/{_aiohttp_requests.py,requests.py,_http_client.py,urllib3.py}
google_auth_httplib2/__init__.py

我在每一个下面加了_LOGGER.debug("With body: %s", body)。但似乎发生了一些fancy batching,因为我几乎从来没有得到过With body行😞

现在正在与Wireshark打交道,看看我能找到什么,但我相信这是一个很难掉下来的兔子洞。https://console.cloud.google.com/home/activity同上。


如何找出gcloud设置的正文?

推荐答案

添加命令行选项--log-http以查看rest API参数。

没有简单的答案,因为CLI会随着时间的推移而变化。添加、删除新功能等。

这篇关于`gCloud计算实例创建`是做什么的?-POST https://compute.googleapis.com…的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆