小编Van*_*ano的帖子

PyVmomi使用未连接的dv添加NIC('config.distributedVirtualSwitch'未设置)

我使用下面的代码来添加配置DistributedVirtualSwitch到现有VM 的NIC (通过pyVmomi):

def __AddNIC(si, vmconf_dict, network_name):
    vm = __get_vm(si, vmconf_dict)
    print " Network label : " + network_name

    devices = []
    nicspec = vim.vm.device.VirtualDeviceSpec()
    nicspec.operation = vim.vm.device.VirtualDeviceSpec.Operation.add
    nicspec.device = vim.vm.device.VirtualVmxnet3()
    nicspec.device.wakeOnLanEnabled = True
    nicspec.device.deviceInfo = vim.Description()
    nicspec.device.connectable = vim.vm.device.VirtualDevice.ConnectInfo()
    nicspec.device.connectable.startConnected = True
    nicspec.device.connectable.allowGuestControl = True

    network_objref = _get_mor_by_property(si, vim.dvs.DistributedVirtualPortgroup, network_name)
    dswitch_port_connection = vim.dvs.PortConnection(
        portgroupKey=network_objref.key,
        switchUuid=network_objref.config.distributedVirtualSwitch.uuid
    )
    nicspec.device.backing = vim.vm.device.VirtualEthernetCard.DistributedVirtualPortBackingInfo()
    nicspec.device.backing.port = dswitch_port_connection

    devices.append(nicspec)
    vmconf = vim.vm.ConfigSpec(deviceChange=devices)
    task = vm.ReconfigVM_Task(vmconf)
    tasks.wait_for_tasks(si, [task])
Run Code Online (Sandbox Code Playgroud)

我收到以下异常:

switchUuid = network_objref.config.distributedVirtualSwitch.uuid …

python vmware nic vcenter pyvmomi

13
推荐指数
1
解决办法
1592
查看次数

Groovy .each vs .collect

作为初学者Groovy研讨会的一部分,我们一直在迭代以下列表(fromJson.secrets):

[[floors:10, street:emaseS, url:http://plywoodpeople.com/wp-content/uploads/2012/03/kermit_the_frog.jpg], [floors:2, street:emaseS, url:http://36.media.tumblr.com/tumblr_lp9bg9Lh2x1r0h9bqo1_500.jpg], [floors:2, street:yawdaorB, url:https://montclairdispatch.com/wp-content/uploads/2013/07/broadway1.jpg], [floors:5, street:emaseS, url:AAA], [floors:2, street:yawdaorB, url:AAA], [floors:6, street:albmaR aL, url:AAA], [floors:1, street:teertS llaW, url:AAA], [floors:6, street:daoR yebbA, url:AAA], [floors:3, street:teertS llaW, url:AAA], [floors:4, street:dlican someone help me to understand the difference between the 2 methods in rehstoR, url:AAA]]
Run Code Online (Sandbox Code Playgroud)

最初的计划是使用.collect,但它看起来像使用.each产生了相同的结果(迭代在列表上......).

问题是,有人可以帮助我理解有关我的用例和一般方法之间的区别

每:

reversed_streets = fromJson.secrets.each {
    it.street = it.street.reverse()
    it
}
Run Code Online (Sandbox Code Playgroud)


搜集:

reversed_streets = fromJson.secrets.collect {
    it.street = it.street.reverse()
    it
}
Run Code Online (Sandbox Code Playgroud)

groovy iterator

13
推荐指数
1
解决办法
6679
查看次数

具有多个分支的 Jenkinspipline Git SCM 签出

我在 Jenkins Pipeline SCM Step 文档中看到多个分支可以传递到结帐步骤: https: //www.jenkins.io/doc/pipeline/steps/workflow-scm-step/#checkout-general-scm

例如

checkout([$class: 'GitSCM', 
    branches: [[name: 'release-1.2'], [name: 'master']], 
    doGenerateSubmoduleConfigurations: false, 
    extensions: [], 
    submoduleCfg: [], 
    userRemoteConfigs: [[]]
])
Run Code Online (Sandbox Code Playgroud)

由于一次只能签出一个分支,所以在 git 术语中传递多个分支实际上意味着什么?上面的文档没有详细说明该细节。

git jenkins git-branch jenkins-plugins jenkins-pipeline

7
推荐指数
0
解决办法
2866
查看次数

terraform ebs_block_device 与 aws_ebs_volume 资源

有人可以指出使用实例参数之间的区别吗:

ebs_块_设备

并使用资源:

aws_ebs_volume + aws_volume_attachment

从 terraform 文档来看,似乎达到了相同的结果。当我们谈论基础设施管理时,我想提前知道其中的细微差别,但找不到任何差异。

如果有人能指出每个问题的陷阱和用例,我将不胜感激。

terraform terraform-provider-aws

5
推荐指数
1
解决办法
2846
查看次数

gitea - 创建存储库 API

尝试通过 API 创建存储库。使用 swagger 执行模式:

\n\n
curl -X POST "https://URL/git/api/v1/user/repos?access_token=XXXXX" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \\"auto_init\\": true, \\"description\\": \\"blablabla\\", \\"gitignores\\": \\"string\\", \\"issue_labels\\": \\"string\\", \\"license\\": \\"string\\", \\"name\\": \\"blablabla\\", \\"private\\": true, \\"readme\\": \\"string\\"}"\n
Run Code Online (Sandbox Code Playgroud)\n\n

产生 500 错误,抱怨自述文件。

\n\n
{"message":"initRepository: prepareRepoCommit: getRepoInitFile[string]: open /readme/string: file does not exist","url":"URLr"}\n
Run Code Online (Sandbox Code Playgroud)\n\n

猜测是因为这个参数:

\n\n
\n

“自述文件\\”:\\“字符串\\”

\n
\n\n

我不知道 xe2x80x99 的建议值是什么,但在 swagger 文档中它是 xe2x80x99。
\n有什么想法吗?

\n

gitea

3
推荐指数
1
解决办法
1861
查看次数

python 数据结构(类似设置)在添加重复项时抛出异常

我正在寻找一种在添加重复元素时会引发异常的数据结构。

我发现的最接近的是collections.Counter

>>> from collections import Counter as counter
>>> c = counter()
>>> c.update("A")
>>> c.update("A")
>>> c
Counter({'A': 2})
Run Code Online (Sandbox Code Playgroud)

我稍后可以查询。

有没有办法直接实现我正在寻找的东西?

python data-structures

2
推荐指数
1
解决办法
410
查看次数

有没有办法在没有仆从的情况下运行“sys.list_modules”命令?

就文档而言,如果想查询可用的执行模块,应使用以下命令:

salt '<minion_name>' sys.list_modules
Run Code Online (Sandbox Code Playgroud)

我的问题是, - 是否可以在没有仆从的情况下运行上述内容?
(例如salt sys.list_modules,它不是更干净吗?)

salt-stack

1
推荐指数
1
解决办法
328
查看次数