Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.93 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2. #
  3. # Copyright 2006 VMware, Inc.  All rights reserved.
  4. #
  5. # USAGE:
  6. #
  7. # vicfg-vswitch.pl [GENERAL_VIPERL_OPTIONS] [ADDITIONAL_OPTIONS]
  8. # where acceptable ADDITIONAL_OPTIONS are the following:
  9. #
  10. # --list                              list vswitches and port groups
  11. # --add <vswitch>                     add vswitch name
  12. # --delete <vswitch>                  delete vswitch
  13. # --link pnic <vswitch>               Sets a pnic as an uplink for the switch
  14. # --unlink pnic <vswitch>             Removes a pnic from the uplinks for the switch
  15. # --check <vswitch>                   check if vswitch exists (return 0 if no; 1 if yes)
  16. # --add-pg <pgname> <vswitch>         adds port group
  17. # --del-pg <pgname> <vswitch>         deletes port group
  18. # --add-pg-uplink pnic --pg <pgname>  add an uplink for portgroup
  19. # --del-pg-uplink pnic --pg <pgname>  delete an uplink for portgroup
  20. # --mtu num <vswitch>                 sets the mtu of the vswitch
  21. # --vlan <#> --pg <pgname> <vswitch>  Updates vlan id for port group
  22. # --check-pg --pg <pgname>            check if port group exists (return 0 if no; 1 if yes)
  23. # --check-pg --pg <pgname> <vswitch>  check if port group exists on a particular vswitch
  24. #
  25. # Example:
  26. #
  27. # vicfg-vswitch.pl --add-pg foo vSwitch0
  28. # vicfg-vswitch.pl --mtu 9000 vSwitch0
  29. #
  30.  
  31. my @options = (
  32.     ['list'],                               # esxcfg-vswitch --list
  33.     ['add'],                                # esxcfg-vswitch --add vswitch
  34.     ['delete'],                             # esxcfg-vswitch --delete vswitch
  35.     ['link', '_default_'],                  # esxcfg-vswitch --link pnic vswitch
  36.     ['unlink', '_default_'],                # esxcfg-vswitch --unlink pnic vswitch
  37.     ['check'],                              # esxcfg-vswitch --check vswitch
  38.     ['add-pg', '_default_'],                # esxcfg-vswitch --add-pg pgname vswitch
  39.     ['del-pg', '_default_'],                # esxcfg-vswitch --del-pg pgname vswitch
  40.     ['add-pg-uplink', 'pg', '_default_'],   # esxcfg-vswitch --add-pg-uplink pnic pgname vswitch
  41.     ['del-pg-uplink', 'pg', '_default_'],   # esxcfg-vswitch --del-pg-uplink pnic pgname vswitch
  42.     ['add-dvp-uplink', 'dvp', '_default_'], # esxcfg-vswitch --add-dvp-uplink pnic dvp dvsname
  43.     ['del-dvp-uplink', 'dvp', '_default_'], # esxcfg-vswitch --del-dvp-uplink pnic dvp dvsname
  44.     ['vlan', 'pg', '_default_'],            # esxcfg-vswitch --vlan n --pg name vswitch
  45.     ['check-pg', '_default_'],              # esxcfg-vswitch --check-pg pgname vswitch
  46.     ['mtu', '_default_'],                   # esxcfg-vswitch --mtu num vswitch
  47.     ['get-cdp'],                            # esxcfg-vswitch --get-cdp vswitch
  48.     ['set-cdp', '_default_'],               # esxcfg-vswitch --set-cdp value vswitch
  49.     ['check-pg']                            # esxcfg-vswitch --check-pg pgname
  50.     );
  51.  
  52. use strict;
  53. use warnings;
  54. use Getopt::Long;
  55.  
  56. use VMware::VIRuntime;
  57. use VMware::VILib;
  58. use VMware::VIExt;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement