Google cloud platform 如何调试google部署管理器模板?
我在看这个例子: 使用此模板的。我向它添加了一个print语句,但是如何查看此输出Google cloud platform 如何调试google部署管理器模板?,google-cloud-platform,google-deployment-manager,Google Cloud Platform,Google Deployment Manager,我在看这个例子: 使用此模板的。我向它添加了一个print语句,但是如何查看此输出 import base64 import hashlib from StringIO import StringIO import zipfile def GenerateConfig(ctx): """Generate YAML resource configuration.""" in_memory_output_file = StringIO() function_name = ctx.en
import base64
import hashlib
from StringIO import StringIO
import zipfile
def GenerateConfig(ctx):
"""Generate YAML resource configuration."""
in_memory_output_file = StringIO()
function_name = ctx.env['deployment'] + 'cf'
zip_file = zipfile.ZipFile(
in_memory_output_file, mode='w', compression=zipfile.ZIP_DEFLATED)
####################################################
############ HOW DO I SEE THIS????? ################
print('heelo wworrld')
####################################################
####################################################
for imp in ctx.imports:
if imp.startswith(ctx.properties['codeLocation']):
zip_file.writestr(imp[len(ctx.properties['codeLocation']):],
ctx.imports[imp])
zip_file.close()
content = base64.b64encode(in_memory_output_file.getvalue())
m = hashlib.md5()
m.update(content)
source_archive_url = 'gs://%s/%s' % (ctx.properties['codeBucket'],
m.hexdigest() + '.zip')
cmd = "echo '%s' | base64 -d > /function/function.zip;" % (content)
volumes = [{'name': 'function-code', 'path': '/function'}]
build_step = {
'name': 'upload-function-code',
'action': 'gcp-types/cloudbuild-v1:cloudbuild.projects.builds.create',
'metadata': {
'runtimePolicy': ['UPDATE_ON_CHANGE']
},
'properties': {
'steps': [{
'name': 'ubuntu',
'args': ['bash', '-c', cmd],
'volumes': volumes,
}, {
'name': 'gcr.io/cloud-builders/gsutil',
'args': ['cp', '/function/function.zip', source_archive_url],
'volumes': volumes
}],
'timeout':
'120s'
}
}
cloud_function = {
'type': 'gcp-types/cloudfunctions-v1:projects.locations.functions',
'name': function_name,
'properties': {
'parent':
'/'.join([
'projects', ctx.env['project'], 'locations',
ctx.properties['location']
]),
'function':
function_name,
'labels': {
# Add the hash of the contents to trigger an update if the bucket
# object changes
'content-md5': m.hexdigest()
},
'sourceArchiveUrl':
source_archive_url,
'environmentVariables': {
'codeHash': m.hexdigest()
},
'entryPoint':
ctx.properties['entryPoint'],
'httpsTrigger': {},
'timeout':
ctx.properties['timeout'],
'availableMemoryMb':
ctx.properties['availableMemoryMb'],
'runtime':
ctx.properties['runtime']
},
'metadata': {
'dependsOn': ['upload-function-code']
}
}
resources = [build_step, cloud_function]
return {
'resources':
resources,
'outputs': [{
'name': 'sourceArchiveUrl',
'value': source_archive_url
}, {
'name': 'name',
'value': '$(ref.' + function_name + '.name)'
}]
}
编辑:这绝不是这个问题的解决方案,但我发现如果我为信息设置一堆
输出,我很想看到它的帮助。因此,我想您可以通过将信息/输出收集到python模板中的列表或其他内容中,然后将所有这些信息作为输出传递回去,来实现自己的日志功能。这不太好,但总比什么都没有好。Deployment Manager是一种基础设施部署服务,可以自动创建和管理Google云平台(GCP)资源。由于部署管理器的托管环境,您在部署管理器上尝试执行的操作是不可能的
到目前为止,排除故障的唯一方法是依赖Deployment Manager仪表板中的扩展模板。为了解决您的用例,已经有一个特性请求。我建议您启动功能请求,以便通过电子邮件获得更新,并发表评论,以显示社区的兴趣。有关该功能的所有官方通信都将发布在那里