-
Notifications
You must be signed in to change notification settings - Fork 896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please add NumUplinkPorts= parameter to dvs.create #2314
Comments
In general, it is possible for govc to provide the same functionality as PowerCLI, since both use the same APIs. But we as maintainers of govc don't know the entire API landscape, so any additional details/context you can provide would be most helpful. Such as:
|
I'm not surprised I tried to look through the vSphere API and instantly got lost on how big it is. Thinking of possibly doing a PR myself but that could take a while, since I'm not super advanced with golang and it's been a while.. I was following Will Lamb's guide setting up Tanzu, but trying to convert it to govc: |
If you want to create a PR that'd be great, here's some info on how to start. That PowerCLI snippet helps a lot. I ran vcsim like so: % vcsim -l :8989 -trace-file vcsim.log Created the DVS like so: PS /root> Connect-VIServer -Server 10.0.0.241 -User user -Password 'pass' -Port 8989
PS /root> New-VDSwitch -Name VDS -Location (Get-Datacenter -Name DC0) -NumUplinkPorts 1 From vcsim.log, <CreateDVS_Task xmlns="urn:vim25">
<_this type="Folder">folder-6</_this>
<spec>
<configSpec xsi:type="VMwareDVSConfigSpec">
<name>VDS</name>
<uplinkPortPolicy xsi:type="DVSNameArrayUplinkPortPolicy">
<uplinkPortName>dvUplink1</uplinkPortName>
</uplinkPortPolicy>
<contact/>
</configSpec>
</spec>
</CreateDVS_Task> Doing that in govc would be something like the following (untested): modified govc/dvs/create.go
@@ -94,6 +94,15 @@ func (cmd *create) Run(ctx context.Context, f *flag.FlagSet) error {
}
}
+ numUplinkPorts := 1 // TODO: cmd.numUplinkPorts
+ if numUplinkPorts > 0 {
+ var policy types.DVSNameArrayUplinkPortPolicy
+ for i := 0; i < numUplinkPorts; i++ {
+ policy.UplinkPortName = append(policy.UplinkPortName, fmt.Sprintf("dvUplink%d", i+1))
+ }
+ cmd.configSpec.UplinkPortPolicy = &policy
+ }
+
folder, err := cmd.FolderOrDefault("network")
if err != nil {
return err |
I'm happy to give it a go, it's just going to take a bit to be able to focus/learn (currently changing jobs) |
…tributed switch Closes: vmware#2314
Your code worked :) I tested it, and plumbed the flag into the variable. I did change the name of the uplink to match the default in Center. Is there an easy way to put both our names on the commit since you wrote the meat of the code? |
adding flag to control number of uplink ports when creating a new distributed switch Closes: vmware#2314
This issue is stale because it has been open for 90 days with no |
I'm just really slow with this due to an increased workload. apologies. |
/remove-lifecycle stale |
This issue is stale because it has been open for 90 days with no |
Hi There,
I noticed that when using PowerShell you are able to specify the number of uplink ports on a Distributed Virtual Switch. Would it be possible to add that to govc as well, please?
Thanks in advance.
The text was updated successfully, but these errors were encountered: