1
0
mirror of https://github.com/vmware/vsphere-automation-sdk-python.git synced 2024-11-21 17:29:59 -05:00

differentiating required and optional arguments in the help text for … (#175)

* differentiating required and optional arguments in the help text for vmc samples
Signed-off-by: Anusha Hegde <hegdeanusha25@gmail.com>
This commit is contained in:
Anusha Hegde 2019-08-20 12:24:24 +05:30 committed by Tianhao He
parent 206ca3dc16
commit 2d2f32b923
27 changed files with 201 additions and 412 deletions

View File

@ -0,0 +1,48 @@
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2019. All Rights Reserved.
* SPDX-License-Identifier: MIT
* *******************************************************
*
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
"""
__author__ = 'VMware, Inc.'
__copyright__ = 'Copyright 2019 VMware, Inc. All rights reserved.'
import argparse
"""
Builds a standard argument parser with required and optional argument groups
Most of the VMC samples require these three standard required arguments.
If any of these arguments are not required, then build your own parser
--refresh_token
--org_id
--sddc_id
"""
parser = argparse.ArgumentParser()
required_args = parser.add_argument_group(
'required arguments')
optional_args = parser.add_argument_group(
'optional arguments')
required_args.add_argument(
'--refresh_token',
required=True,
help='Refresh token obtained from CSP')
required_args.add_argument(
'--org_id',
required=True,
help='Orgization ID')
required_args.add_argument(
'--sddc_id',
required=True,
help='SDDC ID')

View File

@ -16,8 +16,8 @@
__author__ = 'VMware, Inc.'
__vcenter_version__ = '6.8.0+'
import argparse
import requests
from samples.vmc.helpers.sample_cli import parser
from com.vmware.nsx_policy_client_for_vmc import create_nsx_policy_client_for_vmc
from com.vmware.nsx_policy.model_client import IPAddressExpression
from com.vmware.nsx_policy.model_client import Group
@ -36,21 +36,6 @@ class NSXPolicyCGWFirewall(object):
"""
def __init__(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--refresh_token',
required=True,
help='Refresh token obtained from CSP')
parser.add_argument('--org_id',
required=True,
help='Orgization ID')
parser.add_argument('--sddc_id',
required=True,
help='Sddc ID')
args = parser.parse_args()
self.nsx_client = create_nsx_policy_client_for_vmc(

View File

@ -16,8 +16,8 @@
__author__ = 'VMware, Inc.'
__vcenter_version__ = '6.8.0+'
import argparse
import requests
from samples.vmc.helpers.sample_cli import parser
from com.vmware.nsx_policy_client_for_vmc import create_nsx_policy_client_for_vmc
from com.vmware.nsx_policy.model_client import IPAddressExpression
from com.vmware.nsx_policy.model_client import Group
@ -38,21 +38,6 @@ class NSXPolicyDFWFirewall(object):
"""
def __init__(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--refresh_token',
required=True,
help='Refresh token obtained from CSP')
parser.add_argument('--org_id',
required=True,
help='Orgization ID')
parser.add_argument('--sddc_id',
required=True,
help='Sddc ID')
args = parser.parse_args()
self.nsx_client = create_nsx_policy_client_for_vmc(

View File

@ -15,9 +15,8 @@
__author__ = 'VMware, Inc.'
import argparse
import pprint
from samples.vmc.helpers.sample_cli import parser
from com.vmware.nsx_policy_client_for_vmc import (
create_nsx_policy_client_for_vmc)
@ -33,20 +32,6 @@ class AuthExample(object):
"""
def __init__(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-r', '--refresh-token',
required=True,
help='VMware Cloud API refresh token')
parser.add_argument('-o', '--org-id',
required=True,
help='Organization identifier.')
parser.add_argument('-s', '--sddc-id',
required=True,
help='Sddc Identifier.')
args = parser.parse_args()
self.org_id = args.org_id

View File

@ -15,7 +15,7 @@
__author__ = 'VMware, Inc.'
import argparse
from samples.vmc.helpers.sample_cli import parser, required_args
from com.vmware.nsx_policy_client_for_vmc import create_nsx_policy_client_for_vmc
from vmware.vapi.bindings.struct import PrettyPrinter as NsxPrettyPrinter
from com.vmware.nsx_policy.model_client import ApiError
@ -39,26 +39,11 @@ class NSXPolicyL3VPN(object):
"""
def __init__(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--refresh_token',
required=True,
help='Refresh token obtained from CSP')
parser.add_argument('--org_id',
required=True,
help='Orgization ID')
parser.add_argument('--sddc_id',
required=True,
help='Sddc ID')
parser.add_argument('--remote_endpoint_public_ip',
required_args.add_argument('--remote_endpoint_public_ip',
required=True,
help='L3 VPN Remote end point\'s public ip')
parser.add_argument('--passphrase',
required_args.add_argument('--passphrase',
required=True,
help='Passphrase used for VPN')

View File

@ -16,8 +16,9 @@
__author__ = 'VMware, Inc.'
__vcenter_version__ = '6.8.1+'
import argparse
import requests
from samples.vmc.helpers.sample_cli import parser
from com.vmware.nsx_policy_client_for_vmc import create_nsx_policy_client_for_vmc
from com.vmware.nsx_vmc_app_client_for_vmc import create_nsx_vmc_app_client_for_vmc
from com.vmware.nsx_vmc_app.model_client import PublicIp
@ -36,21 +37,6 @@ class NSXPolicyNAT(object):
"""
def __init__(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--refresh_token',
required=True,
help='Refresh token obtained from CSP')
parser.add_argument('--org_id',
required=True,
help='Orgization ID')
parser.add_argument('--sddc_id',
required=True,
help='Sddc ID')
args = parser.parse_args()
self.nsx_client = create_nsx_policy_client_for_vmc(

View File

@ -15,10 +15,11 @@
__author__ = 'VMware, Inc'
__vcenter_version__ = 'VMware Cloud on AWS'
import argparse
import random
import requests
from samples.vmc.helpers.sample_cli import parser, required_args, optional_args
from com.vmware.nsx_policy.infra_client import Domains
from com.vmware.nsx_policy.model_client import (Expression, Group,
IPAddressExpression)
@ -35,34 +36,19 @@ Create a new NSX-T Group on MGW or CGW
Sample Prerequisites:
- SDDC deployed in VMware Cloud on AWS
"""
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--refresh_token',
required=True,
help='Refresh token obtained from CSP')
parser.add_argument('--org_id',
required=True,
help='Orgization ID')
parser.add_argument('--sddc_id',
required=True,
help='Sddc ID')
parser.add_argument('--gateway_type',
optional_args.add_argument('--gateway_type',
default='mgw',
help='Gateway type. Either mgw or cgw')
parser.add_argument('--name',
required_args.add_argument('--name',
required=True,
help='Name of the security group to be created')
parser.add_argument('--ip_address',
optional_args.add_argument('--ip_address',
default='172.31.0.0/24',
help='IP address for the expression')
parser.add_argument('--group_id',
optional_args.add_argument('--group_id',
help='ID of the group. A random ID will be used by default')
args = parser.parse_args()

View File

@ -16,10 +16,10 @@
__author__ = 'VMware, Inc'
__vcenter_version__ = 'VMware Cloud on AWS'
import argparse
import random
import requests
from samples.vmc.helpers.sample_cli import parser, optional_args
from com.vmware.nsx_policy.infra_client import Domains
from com.vmware.nsx_policy.model_client import (Expression, Group,
IPAddressExpression)
@ -39,26 +39,11 @@ Sample Prerequisites:
- SDDC deployed in VMware Cloud on AWS
- A NSX-T security group
"""
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--refresh_token',
required=True,
help='Refresh token obtained from CSP')
parser.add_argument('--org_id',
required=True,
help='Orgization ID')
parser.add_argument('--sddc_id',
required=True,
help='Sddc ID')
parser.add_argument('--gateway_type',
optional_args.add_argument('--gateway_type',
default='mgw',
help='Gateway type. Either mgw or cgw')
parser.add_argument('--group_id',
optional_args.add_argument('--group_id',
help='ID of the group to be deleted')
args = parser.parse_args()

View File

@ -17,8 +17,8 @@ __author__ = 'VMware, Inc'
__vcenter_version__ = 'VMware Cloud on AWS'
import requests
import argparse
from samples.vmc.helpers.sample_cli import parser, optional_args
from com.vmware.nsx_policy.infra_client import Domains
from com.vmware.nsx_policy_client_for_vmc import create_nsx_policy_client_for_vmc
from vmware.vapi.bindings.struct import PrettyPrinter
@ -34,22 +34,7 @@ List all Network Security Groups
Sample Prerequisites:
- SDDC deployed in VMware Cloud on AWS
"""
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--refresh_token',
required=True,
help='Refresh token obtained from CSP')
parser.add_argument('--org_id',
required=True,
help='Orgization ID')
parser.add_argument('--sddc_id',
required=True,
help='Sddc ID')
parser.add_argument('--gateway_type',
optional_args.add_argument('--gateway_type',
default='mgw',
help='Gateway type. Either mgw or cgw')

View File

@ -16,10 +16,10 @@
__author__ = 'VMware, Inc'
__vcenter_version__ = 'VMware Cloud on AWS'
import argparse
import random
import requests
from samples.vmc.helpers.sample_cli import parser, required_args, optional_args
from com.vmware.nsx_policy.infra_client import Domains
from com.vmware.nsx_policy.model_client import (Expression, Group,
IPAddressExpression)
@ -40,29 +40,14 @@ Sample Prerequisites:
- SDDC deployed in VMware Cloud on AWS
- A NSX-T security group
"""
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--refresh_token',
required=True,
help='Refresh token obtained from CSP')
parser.add_argument('--org_id',
required=True,
help='Orgization ID')
parser.add_argument('--sddc_id',
required=True,
help='Sddc ID')
parser.add_argument('--gateway_type',
optional_args.add_argument('--gateway_type',
default='mgw',
help='Gateway type. Either mgw or cgw')
parser.add_argument('--group_id',
optional_args.add_argument('--group_id',
help='ID of the group to be updated')
parser.add_argument('--name',
required_args.add_argument('--name',
required=True,
help='New name of the security group to be updated')

View File

@ -15,9 +15,8 @@
__author__ = 'VMware, Inc.'
import argparse
import requests
from samples.vmc.helpers.sample_cli import parser
from com.vmware.nsx_policy_client_for_vmc import create_nsx_policy_client_for_vmc
from com.vmware.nsx_policy.model_client import Rule
from vmware.vapi.bindings.struct import PrettyPrinter as NsxPrettyPrinter
@ -34,21 +33,6 @@ class NSXPolicySegmentFirewall(object):
"""
def __init__(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--refresh_token',
required=True,
help='Refresh token obtained from CSP')
parser.add_argument('--org_id',
required=True,
help='Orgization ID')
parser.add_argument('--sddc_id',
required=True,
help='Sddc ID')
args = parser.parse_args()
self.nsx_client = create_nsx_policy_client_for_vmc(

View File

@ -15,8 +15,7 @@
__author__ = 'VMware, Inc.'
import argparse
from samples.vmc.helpers.sample_cli import parser, optional_args
from com.vmware.vmc.model_client import DnsForwarders
from vmware.vapi.vmc.client import create_vmc_client
@ -31,27 +30,13 @@ class DNSCrud(object):
"""
def __init__(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-r', '--refresh-token',
required=True,
help='VMware Cloud API refresh token')
parser.add_argument('-o', '--org-id',
required=True,
help='Organization identifier.')
parser.add_argument('-s', '--sddc-id',
required=True,
help='Sddc Identifier.')
parser.add_argument('--use-compute-gateway',
optional_args.add_argument('--use-compute-gateway',
action='store_true',
default=False,
help='Use compute gateway. Default is using '
'management gateway')
parser.add_argument('-c', '--cleardata',
optional_args.add_argument('--cleardata',
action='store_true',
help='Clean up after sample run')
args = parser.parse_args()

View File

@ -16,9 +16,9 @@
__author__ = 'VMware, Inc.'
__vcenter_version__ = 'VMware Cloud on AWS'
import argparse
import random
from samples.vmc.helpers.sample_cli import parser, required_args, optional_args
from com.vmware.vmc.model_client import *
from vmware.vapi.vmc.client import create_vmc_client
from samples.vmc.helpers.vmc_task_helper import wait_for_task
@ -36,37 +36,23 @@ class ExposePublicIP(object):
"""
def __init__(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-r', '--refresh-token',
required=True,
help='VMware Cloud API refresh token')
parser.add_argument('-o', '--org-id',
required=True,
help='Organization identifier.')
parser.add_argument('-s', '--sddc-id',
required=True,
help='Sddc Identifier.')
parser.add_argument('--notes',
optional_args.add_argument('--notes',
default='Sample public IP ' + str(random.randint(0, 100)),
help='Notes of the new public IP')
parser.add_argument('--fw-rule-name',
optional_args.add_argument('--fw-rule-name',
default='Sample firewall rule ' + str(random.randint(0, 100)),
help='Name of the compute gae')
parser.add_argument('--nat-rule-description',
optional_args.add_argument('--nat-rule-description',
default='Sample NAT rule ' + str(random.randint(0, 100)),
help='Description for the NAT rule')
parser.add_argument('--internal-ip',
required_args.add_argument('--internal-ip',
required=True,
help='Private IP of the VM')
parser.add_argument('-c', '--cleardata',
optional_args.add_argument('--cleardata',
action='store_true',
help='Clean up after sample run')
args = parser.parse_args()

View File

@ -14,8 +14,7 @@
__author__ = 'VMware, Inc.'
import argparse
from samples.vmc.helpers.sample_cli import parser, optional_args
from com.vmware.vmc.model_client import (AddressFWSourceDestination,
Application, FirewallRules,
Nsxfirewallrule, Nsxfirewallservice)
@ -32,34 +31,19 @@ class FirewallRulesCrud(object):
"""
def __init__(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'-r',
'--refresh-token',
required=True,
help='VMware Cloud API refresh token')
parser.add_argument(
'-o', '--org-id', required=True, help='Organization identifier.')
parser.add_argument(
'-s', '--sddc-id', required=True, help='Sddc Identifier.')
parser.add_argument(
optional_args.add_argument(
'--rule-name',
default='Sample Firewall Rule',
help='Name of the new firewall rule')
parser.add_argument(
optional_args.add_argument(
'--use-compute-gateway',
action='store_true',
default=False,
help='Use compute gateway. Default is using '
'management gateway')
parser.add_argument(
'-c',
optional_args.add_argument(
'--cleardata',
action='store_true',
help='Clean up after sample run')

View File

@ -14,8 +14,7 @@
__author__ = 'VMware, Inc.'
import argparse
from samples.vmc.helpers.sample_cli import parser, optional_args
from com.vmware.vmc.model_client import Ipsec, IpsecSite, IpsecSites, Subnets
from vmware.vapi.vmc.client import create_vmc_client
@ -30,59 +29,44 @@ class IpsecVPNsCrud(object):
"""
def __init__(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'-r',
'--refresh-token',
required=True,
help='VMware Cloud API refresh token')
parser.add_argument(
'-o', '--org-id', required=True, help='Organization identifier.')
parser.add_argument(
'-s', '--sddc-id', required=True, help='Sddc Identifier.')
parser.add_argument(
optional_args.add_argument(
'--use-compute-gateway',
action='store_true',
default=False,
help='Use compute gateway. Default is using '
'management gateway')
parser.add_argument(
optional_args.add_argument(
'--vpn-name',
default='Sample IPsec VPN',
help='Name of the new VPN')
parser.add_argument(
optional_args.add_argument(
'--public-ip',
default='10.10.10.10',
help='IP (IPv4) address or FQDN of the Peer')
parser.add_argument(
optional_args.add_argument(
'--private-ip',
default='192.168.10.10',
help='Local IP of the IPsec Site')
parser.add_argument(
optional_args.add_argument(
'--remote-networks',
default='192.168.20.10/24',
help='Peer subnets for which VPN is configured')
parser.add_argument(
optional_args.add_argument(
'--local-networks',
default='192.168.30.10/24',
help='Local subnets for which VPN is configured')
parser.add_argument(
optional_args.add_argument(
'--key',
default='00000000',
help='Pre Shared Key for the IPsec Site')
parser.add_argument(
'-c',
optional_args.add_argument(
'--cleardata',
action='store_true',
help='Clean up after sample run')

View File

@ -14,8 +14,7 @@
__author__ = 'VMware, Inc.'
import argparse
from samples.vmc.helpers.sample_cli import parser, optional_args
from com.vmware.vmc.model_client import (L2Extension, SddcNetwork,
SddcNetworkAddressGroups,
SddcNetworkAddressGroup,
@ -34,37 +33,22 @@ class LogicalNetworkCrud(object):
"""
def __init__(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'-r',
'--refresh-token',
required=True,
help='VMware Cloud API refresh token')
parser.add_argument(
'-o', '--org-id', required=True, help='Organization identifier.')
parser.add_argument(
'-s', '--sddc-id', required=True, help='Sddc Identifier.')
parser.add_argument(
optional_args.add_argument(
'--network-name',
default='Sample Logical Network',
help='Name of the new logical network')
parser.add_argument(
optional_args.add_argument(
'--subnet',
default='192.168.100.1/24',
help='Logical network subnet')
parser.add_argument(
optional_args.add_argument(
'--dhcp-range',
default='192.168.100.2-192.168.100.254',
help='DHCP IP range for the logical network')
parser.add_argument(
'-c',
optional_args.add_argument(
'--cleardata',
action='store_true',
help='Clean up after sample run')

View File

@ -14,7 +14,7 @@
__author__ = 'VMware, Inc.'
import argparse
from samples.vmc.helpers.sample_cli import parser, optional_args
from com.vmware.vmc.model_client import Nsxnatrule, NatRules
from vmware.vapi.vmc.client import create_vmc_client
@ -29,35 +29,20 @@ class NatRuleCrud(object):
"""
def __init__(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'-r',
'--refresh-token',
required=True,
help='VMware Cloud API refresh token')
parser.add_argument(
'-o', '--org-id', required=True, help='Organization identifier.')
parser.add_argument(
'-s', '--sddc-id', required=True, help='Sddc Identifier.')
parser.add_argument(
optional_args.add_argument(
'--public-ip', help='Public IP range for the NAT rule')
parser.add_argument(
optional_args.add_argument(
'--rule-description',
default='Sample NAT rule',
help='Description for the rule')
parser.add_argument(
optional_args.add_argument(
'--internal-ip',
default='192.168.200.1/24',
help='NAT rule subnet')
parser.add_argument(
'-c',
optional_args.add_argument(
'--cleardata',
action='store_true',
help='Clean up after sample run')

View File

@ -14,7 +14,7 @@
__author__ = 'VMware, Inc.'
import argparse
from samples.vmc.helpers.sample_cli import parser, optional_args
from com.vmware.vmc.model_client import SddcAllocatePublicIpSpec
from vmware.vapi.vmc.client import create_vmc_client
@ -31,27 +31,12 @@ class PublicIPsCrud(object):
"""
def __init__(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'-r',
'--refresh-token',
required=True,
help='VMware Cloud API refresh token')
parser.add_argument(
'-o', '--org-id', required=True, help='Organization identifier.')
parser.add_argument(
'-s', '--sddc-id', required=True, help='Sddc Identifier.')
parser.add_argument(
optional_args.add_argument(
'--notes',
default='Sample public IP',
help='Notes of the new public IP')
parser.add_argument(
'-c',
optional_args.add_argument(
'--cleardata',
action='store_true',
help='Clean up after sample run')

View File

@ -38,10 +38,10 @@ class OperationsOnOrganizations(object):
def options(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument(
'-r',
'--refresh-token',
required_args = parser.add_argument_group(
'required arguments')
required_args.add_argument(
'--refresh_token',
required=True,
help='VMware Cloud API refresh token')

View File

@ -15,10 +15,10 @@
__author__ = 'VMware, Inc.'
import argparse
import atexit
import requests
from samples.vmc.helpers.sample_cli import parser, optional_args
from com.vmware.vmc.model_client import EsxConfig, ErrorResponse
from com.vmware.vapi.std.errors_client import InvalidRequest
from vmware.vapi.vmc.client import create_vmc_client
@ -43,22 +43,7 @@ class AddRemoveHosts(object):
self.interval_sec = None
def options(self):
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-r', '--refresh-token',
required=True,
help='VMware Cloud API refresh token')
parser.add_argument('-o', '--org-id',
required=True,
help='Organization identifier.')
parser.add_argument('-s', '--sddc-id',
required=True,
help='Sddc Identifier.')
parser.add_argument('-i', '--interval-sec',
optional_args.add_argument('--interval-sec',
default=60,
help='Task pulling interval in sec')

View File

@ -15,11 +15,11 @@
__author__ = 'VMware, Inc.'
__vcenter_version__ = 'VMware Cloud on AWS'
import argparse
from com.vmware.vapi.std.errors_client import NotFound
from com.vmware.vmc.model_client import ErrorResponse
from six.moves.urllib import parse
from samples.vmc.helpers.sample_cli import parser
from vmware.vapi.vmc.client import create_vmc_client
from vmware.vapi.vsphere.client import create_vsphere_client
@ -35,18 +35,6 @@ class ConnectTovSphereWithDefaultCredentials(object):
"""
def __init__(self):
parser = argparse.ArgumentParser()
parser.add_argument(
'-r',
'--refresh-token',
required=True,
help='VMware Cloud API refresh token')
parser.add_argument(
'-o', '--org-id', required=True, help='Organization identifier.')
parser.add_argument(
'-s', '--sddc-id', required=True, help='Sddc Identifier.')
args = parser.parse_args()
self.refresh_token = args.refresh_token

View File

@ -41,28 +41,30 @@ class DeployOvfTemplate:
self.vm_name = 'deployed-vm-' + str(generate_random_uuid())
parser = sample_cli.build_arg_parser()
parser.add_argument('--libitemname',
required_args = parser.add_argument_group(
'required arguments')
required_args.add_argument('--libitemname',
required=True,
help='(Required) The name of the library item to deploy. '
help='The name of the library item to deploy. '
'The library item should contain an OVF package.')
parser.add_argument('--vmname',
default=self.vm_name,
help='(Optional) The name of the Virtual Machine to be deployed. '
help='The name of the Virtual Machine to be deployed. '
'Default: "{}"'.format(self.vm_name))
parser.add_argument('--resourcepoolname',
default='Compute-ResourcePool',
help='(Optional) The name of the resource pool to be used. '
help='The name of the resource pool to be used. '
'Default: "Compute-ResourcePool"')
parser.add_argument('--foldername',
default='Workloads',
help='(Optional) The name of the folder to be used. '
help='The name of the folder to be used. '
'Default: "Workloads"')
parser.add_argument('--opaquenetworkname',
help='(Optional) The name of the opaque network to be added '
help='The name of the opaque network to be added '
'to the deployed vm')
args = sample_util.process_cli_args(parser.parse_args())

View File

@ -14,14 +14,13 @@
__author__ = 'VMware, Inc.'
import argparse
import os
from random import randrange
import argparse
from com.vmware.vapi.std.errors_client import InvalidRequest
from com.vmware.vmc.model_client import AwsSddcConfig, ErrorResponse, AccountLinkSddcConfig, SddcConfig
from vmware.vapi.vmc.client import create_vmc_client
from samples.vmc.helpers.vmc_task_helper import wait_for_task
@ -36,49 +35,49 @@ class CreateDeleteSDDC(object):
def __init__(self):
parser = argparse.ArgumentParser()
parser.add_argument(
'-r',
'--refresh-token',
required_args = parser.add_argument_group(
'required arguments')
optional_args = parser.add_argument_group(
'optional arguments')
required_args.add_argument(
'--refresh_token',
required=True,
help='VMware Cloud API refresh token')
help='Refresh token obtained from CSP')
parser.add_argument(
'-o', '--org-id', required=True, help='Organization identifier.')
required_args.add_argument(
'--org_id',
required=True,
help='Organization identifier.')
parser.add_argument(
'-sn',
optional_args.add_argument(
'--sddc-name',
help="Name of the SDDC to be created. "
"Default is 'Sample SDDC xx'")
parser.add_argument('--region', default='US_WEST_2', help='AWS Region')
optional_args.add_argument('--region', default='US_WEST_2', help='AWS Region')
parser.add_argument(
'-i',
optional_args.add_argument(
'--interval-sec',
default=60,
help='Task pulling interval in sec')
parser.add_argument(
'-ls',
optional_args.add_argument(
'--listsddc',
action='store_true',
help='List SDDCs in the specified Org')
parser.add_argument(
'-cs',
optional_args.add_argument(
'--createsddc',
action='store_true',
help='Create an SDDC in the specified Org')
parser.add_argument(
'-ds',
optional_args.add_argument(
'--deletesddc',
action='store_true',
help='Deletes the SDDC in the specified Org ')
parser.add_argument(
'-c',
optional_args.add_argument(
'--cleardata',
action='store_true',
help='Clean up after sample run')

View File

@ -14,7 +14,6 @@
__author__ = 'VMware, Inc.'
import argparse
from com.vmware.vmc.model_client import Task
from vmware.vapi.vmc.client import create_vmc_client
@ -27,19 +26,25 @@ Sample Prerequisites:
"""
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--refresh-token',
required=True,
help='VMware Cloud API refresh token')
required_args = parser.add_argument_group(
'required arguments')
parser.add_argument('--org-id',
required=True,
help='Organization identifier.')
required_args.add_argument(
'--refresh_token',
required=True,
help='Refresh token obtained from CSP')
parser.add_argument('--task-id',
required=True,
help='Task ID to be cancelled')
required_args.add_argument(
'--org-id',
required=True,
help='Organization identifier.')
required_args.add_argument(
'--task-id',
required=True,
help='Task ID to be cancelled')
args = parser.parse_args()

View File

@ -14,7 +14,6 @@
__author__ = 'VMware, Inc.'
import argparse
from com.vmware.vmc.model_client import Task
from vmware.vapi.vmc.client import create_vmc_client
@ -28,19 +27,25 @@ Sample Prerequisites:
accepted = [Task.STATUS_STARTED, Task.STATUS_CANCELING, Task.STATUS_FINISHED,
Task.STATUS_FAILED, Task.STATUS_CANCELED]
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--refresh-token',
required=True,
help='VMware Cloud API refresh token')
required_args = parser.add_argument_group(
'required arguments')
parser.add_argument('--org-id',
required=True,
help='Organization identifier.')
required_args.add_argument(
'--refresh_token',
required=True,
help='Refresh token obtained from CSP')
required_args.add_argument(
'--org-id',
required=True,
help='Organization identifier.')
parser.add_argument('--task-status',
help='Task status to filter. Possible values are: {} \
Show all tasks if no value is passed'.format(accepted))
required_args.add_argument(
'--task-status',
help='Task status to filter. Possible values are: {} \
Show all tasks if no value is passed'.format(accepted))
args = parser.parse_args()

View File

@ -14,7 +14,6 @@
__author__ = 'VMware, Inc.'
import argparse
from com.vmware.vmc.model_client import Task
from vmware.vapi.vmc.client import create_vmc_client
@ -28,19 +27,28 @@ Sample Prerequisites:
accepted = [Task.STATUS_STARTED, Task.STATUS_CANCELING, Task.STATUS_FINISHED,
Task.STATUS_FAILED, Task.STATUS_CANCELED]
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--refresh-token',
required=True,
help='VMware Cloud API refresh token')
required_args = parser.add_argument_group(
'required arguments')
optional_args = parser.add_argument_group(
'optional arguments')
parser.add_argument('--org-id',
required=True,
help='Organization identifier.')
required_args.add_argument(
'--refresh_token',
required=True,
help='Refresh token obtained from CSP')
parser.add_argument('--task-status',
help='Task status to filter. Possible values are: {} \
Show all tasks if no value is passed'.format(accepted))
required_args.add_argument(
'--org-id',
required=True,
help='Organization identifier.')
optional_args.add_argument(
'--task-status',
help='Task status to filter. Possible values are: {} \
Show all tasks if no value is passed'.format(accepted))
args = parser.parse_args()

View File

@ -31,16 +31,21 @@ def build_arg_parser():
parser = argparse.ArgumentParser(
description='Standard Arguments for talking to vCenter')
parser.add_argument('-s', '--server',
required_args = parser.add_argument_group(
'required arguments')
required_args.add_argument('-s', '--server',
action='store',
required=True,
help='vSphere service IP to connect to')
parser.add_argument('-u', '--username',
required_args.add_argument('-u', '--username',
action='store',
required=True,
help='Username to use when connecting to vc')
parser.add_argument('-p', '--password',
required_args.add_argument('-p', '--password',
action='store',
required=True,
help='Password to use when connecting to vc')
parser.add_argument('-c', '--cleardata',