VMware Cloud Community
palkot
Contributor
Contributor
Jump to solution

How to create distributed vSwitch using vicfg-vswitch?

I was looking at vSphere Command-Line Interface documentation for creating distributed vswitches using CLI.

http://www.vmware.com/support/developer/vcli/

But I could not figure out a way. So I would like to know, is it possible to create dvSwitches using this CLI ?

If it is not possible through CLI, then what is the other way?

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

Unfortunately my development environment is still down, else I can whip up a quick example.

Though when you say there aren't any examples around, there's actually plenty of examples using the various SDK's including the vSphere SDK for Perl. If you look at the source code of any of the vCLI commands, you'll notice they're all written in Perl and not surprisingly, it utilizes the vSphere SDK for Perl. Yes, there may not be examples for every single use case or operation that can be performed against a given ESX/ESXi host or vCenter, which is the same for PowerCLI, the functionality is there in the API.

If you're new to VMware SDK/APIs and is interested in developing or creating your own scripts, I would take a look at this document first - . Depending on your comfort level, you'll choose an appropriate SDK (vSphere SDK for Perl, PowerCLI, VI Java, C#, .NET,etc) to script and/or program in. Certain SDK's will be easier to learn such as PowerCLI, VMware has done a great job utilizing the Powershell language to abstract away much of the complexity of the vSphere API and made it really simple to jump right in, though you still need to understand what's going on and how the operations are actually being called. The default 100-200+ cmdlets cover most of the basic use cases but once you start going into more complicated scenarios, then you'll need to really understand the vSphere API to further extend the functionality including things like creating a vDS and distributed portgroups/etc.

Here a guide on getting started with vSphere SDK for Perl - and here are a collection of vSphere SDK for Perl scripts that I've written . Another great resource is the developer forums as well for the various vSphere API/SDKs - http://communities.vmware.com/community/developer

Bottom line is, everything that can be performed via the vSphere Client can be done using the vSphere API and with one of the vSphere SDK's, it may not always be trivial, but the functionality is there, you just may need to create it if an example/sample code does not exists.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

0 Kudos
5 Replies
RParker
Immortal
Immortal
Jump to solution

You can use graphical from VI Client, under networking.

palkot
Contributor
Contributor
Jump to solution

Yeah. VI client GUI is helpful.But I am looking to do it through CLI script.

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

The short answer is no, the vCLI does not offer any canned scripts to create vDS, though this is something that is definitely possible, you would just need to create your own vSphere SDK for Perl script that does this just like how esxcfg-vswitch is implemented to create standard vSwitch (vSS).

The vSphere API method that needs to be used is CreateDVS_Task and of course you need to connect to vCenter to create/manage your vDS.

This also the same for PowerCLI, there are no default cmdlets to create/manage vDS, here is a great blog post series on how you can create vDS using PowerCLI - http://www.lucd.info/2009/10/09/dvswitch-scripting-part-1-creation/

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

palkot
Contributor
Contributor
Jump to solution

Thanks for the information and clarifying that it is not possible with vCLI.

I wish there is some example in using perl object like that of powerCLI example which you mentioned in your post.

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

Unfortunately my development environment is still down, else I can whip up a quick example.

Though when you say there aren't any examples around, there's actually plenty of examples using the various SDK's including the vSphere SDK for Perl. If you look at the source code of any of the vCLI commands, you'll notice they're all written in Perl and not surprisingly, it utilizes the vSphere SDK for Perl. Yes, there may not be examples for every single use case or operation that can be performed against a given ESX/ESXi host or vCenter, which is the same for PowerCLI, the functionality is there in the API.

If you're new to VMware SDK/APIs and is interested in developing or creating your own scripts, I would take a look at this document first - . Depending on your comfort level, you'll choose an appropriate SDK (vSphere SDK for Perl, PowerCLI, VI Java, C#, .NET,etc) to script and/or program in. Certain SDK's will be easier to learn such as PowerCLI, VMware has done a great job utilizing the Powershell language to abstract away much of the complexity of the vSphere API and made it really simple to jump right in, though you still need to understand what's going on and how the operations are actually being called. The default 100-200+ cmdlets cover most of the basic use cases but once you start going into more complicated scenarios, then you'll need to really understand the vSphere API to further extend the functionality including things like creating a vDS and distributed portgroups/etc.

Here a guide on getting started with vSphere SDK for Perl - and here are a collection of vSphere SDK for Perl scripts that I've written . Another great resource is the developer forums as well for the various vSphere API/SDKs - http://communities.vmware.com/community/developer

Bottom line is, everything that can be performed via the vSphere Client can be done using the vSphere API and with one of the vSphere SDK's, it may not always be trivial, but the functionality is there, you just may need to create it if an example/sample code does not exists.

=========================================================================

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos