简体   繁体   English

如何删除/禁用 gcloud CLI 命令的 output 消息

[英]How to remove/disable the output messages of gcloud CLI commands

For example:例如:

gcloud compute disks create --size=10GB my-data-disk

would print 2 things:会打印两件事:

  1. Warning:警告:

     WARNING: You have selected a disk size of under [200GB]. This may result in poor I/O performance. For more information, see: https://developers.google.com/compute/docs/disks/persistent-disks#pdperformance.

    This can be eliminated with --verbosity error这可以通过--verbosity error消除

  2. Status:地位:

     Created [https://www.googleapis.com/compute/v1/projects/sigma-project-12345/zones/europe-west1-c/disks/my-data-disk]. NAME ZONE SIZE_GB TYPE STATUS my-data-disk europe-west1-c 10 pd-standard READY

    This I don't know how to disable, other then redirecting stderr , which of course I don't want because I still have to see if an error happened.这个我不知道如何禁用,然后重定向stderr ,这当然是我不想要的,因为我仍然必须查看是否发生了错误。

The -q argument does not remove it. -q参数不会删除它。

The --no-user-output-enabled or --user-output-enabled=false flags seem to be what you are looking for. --no-user-output-enabled--user-output-enabled=false标志似乎是您要寻找的。

Try this: 尝试这个:

gcloud compute disks create --size=10GB my-data-disk --no-user-output-enabled

@Vilas's answer is correct however please note that --no-user-output-enabled broke in some cases around version 141.0. @Vilas的答案是正确的,但是请注意--no-user-output-enabled在某些情况下在141.0版本左右中断。 See this issue - https://issuetracker.google.com/issues/36076836 看到这个问题-https://issuetracker.google.com/issues/36076836

Another option is to disable all the related warnings另一种选择是禁用所有相关警告

import warnings
warnings.filterwarnings("ignore", "Your application has authenticated using end user credentials")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Gcloud pubsub 中列出/查看订阅消息? - How to list/view messages on subscription in Gcloud pubsub? gcloud:如何通过cli下载应用程序 - gcloud: how to download the app via cli 在 GCP - Google Cloud Console 中进行更改时,有没有办法查看 gcloud cli 的相应命令? - When making changes in GCP - Google Cloud Console, is there a way to view corresponding commands for gcloud cli? 如何让 shell 脚本在 PowerShell 中的 gcloud CLI 上工作? - How to get shell script to work on gcloud CLI in PowerShell? 如何解决 gcloud cli “4047: 'Failed to lookup instance'” 错误 - How to solve gcloud cli "4047: 'Failed to lookup instance'" error 如何在不使用 gcloud CLI 的情况下向 GKE 集群进行身份验证 - How to authenticate to a GKE cluster without using the gcloud CLI AWS S3 CLI 命令中 output 中的特定参数 - specific argument in an output in AWS S3 CLI commands Gcloud CLI 使用哪些 API - Gcloud CLI using what APIs 如何使用 CLI 命令更改 GCP 中的项目 - How to change the project in GCP using CLI commands 如何以我使用 gcloud CLI 进行身份验证的方式从 Java 对 google cloud API 进行身份验证 - How to auth google cloud API from Java in the same way I authenticated with gcloud CLI
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM