[英]Ruby - Resource can't be re-used
After the network_sg.create
I can't use the network_sg
for other purpose unless I create a new network_sg
resource.在
network_sg.create
之后,除非我创建一个新的network_sg
资源,否则我不能将network_sg
用于其他目的。
Is there a way to get past this?有没有办法克服这个问题? I tried freeze
network_sg
but I get a Frozen Error while creating a new SG.我尝试冻结
network_sg
,但在创建新 SG 时出现冻结错误。
network_sg = Azure::Armrest::Network::NetworkSecurityGroupService.new(conf)
options = {
:location => 'eastus',
}
network_sg.create('test-network_sg-4', rg, options)
# Can't re-use the `network_sg` anymore.
# And I have to recreate `network_sg = Azure::Armrest::Network::NetworkSecurityGroupService.new(conf)` before I can use it again.
network_sg.list_all.each do |network_sg|
$evm.log('info', "azure network_sg test is: #{network_sg.name} ")
end
Setting the network_sg as constant worked.将 network_sg 设置为常量有效。 It can be re-used.
它可以重复使用。
NETWORK_SG = Azure::Armrest::Network::NetworkSecurityGroupService.new(conf)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.