0
我試圖使用Ruby的谷歌API客戶端創建谷歌計算平臺(GCP)的部署。使用部署管理器的谷歌API時如何設置部署配置?
我對configuation YAML文件:
resources:
- name: my-vm
type: compute.v1.instance
properties:
zone: europe-west1-b
machineType: zones/europe-west1-b/machineTypes/f1-micro
disks:
- deviceName: boot
type: PERSISTENT
boot: true
autoDelete: true
initializeParams:
sourceImage: global/images/myvm-1487178154
networkInterfaces:
- network: $(ref.my-subnet.selfLink)
networkIP: 172.31.54.11
# Create the network for the machines
- name: my-subnet
type: compute.v1.network
properties:
IPv4Range: 172.31.54.0/24
我已經測試了這個作品使用gcloud
命令行工具。
我現在想要使用API來做到這一點的紅寶石。我有以下代碼:
require 'google/apis/deploymentmanager_v2'
require 'googleauth'
require 'googleauth/stores/file_token_store'
SCOPE = Google::Apis::DeploymentmanagerV2::AUTH_CLOUD_PLATFORM
PROJECT_ID = "my-project"
ENV['GOOGLE_APPLICATION_CREDENTIALS'] = "./service_account.json"
deployment_manager = Google::Apis::DeploymentmanagerV2::DeploymentManagerService.new
deployment_manager.authorization = Google::Auth.get_application_default([SCOPE])
所有這一切都在工作,我授權,但我有一個deployment_manager
對象我可以工作。
我想用insert_deployment
方法,具有以下特徵:
#insert_deployment(project, deployment_object = nil, preview: nil, fields: nil, quota_user: nil, user_ip: nil, options: nil) {|result, err| ... } ⇒ Google::Apis::DeploymentmanagerV2::Operation
的deployment_object
類型是 '谷歌::蜜蜂:: DeploymentmanagerV2 ::部署'。我可以創建這個對象,但是那時候我不知道如何導入YAML文件我都到這是能夠執行程式設計部署。
還有一種叫ConfigFile
類,它似乎類似於指定--config
卻又不知如何將文件加載到這個也不再把它放進了insert_deployment
正確的對象的命令行選項。