Custom service definitions in VMware Cloud on AWS
Demonstrates using the open source PyVMC project to add custom service definitions
PyVMC is an open-source Python-based command line tool for VMware Cloud on AWS. PyVMC enables users to automate the consumption of their VMware Cloud on AWS SDDC without needing to know underlying APIs.
The Services section of the VMware CSP is where you define ports and protocols for use in firewall rules. A long list of well-known entries is deployed in every SDDC.
To make defining services easier for AWS customers, I contributed a feature allowing a customer to import a list of AWS service definitions into the Services list. Here's how it works:
Help
The command has been added to the inventory
section of PyVMC. I named it import-service
. Here is the built-in help you see if you pass the -h
parameter
C:\pyvmc> python .\pyVMC.py inventory import-service -h usage: inventory import-service [-h] [--oauth [OAUTH]] [--nsxm [NSXM]] [-l] [-p PROVIDER_NAME] [-t] [-d] options: -h, --help show this help message and exit --oauth [OAUTH] Used to specify use of OAuth app ID and secret in config.ini instead of 'refresh_token' (default). --nsxm [NSXM] Used to specify NSX Manager instead of NSX proxy (Default). -l, --list-providers Display a list available providers for import - all other arguments are ignored if you use this argument -p PROVIDER_NAME, --provider-name PROVIDER_NAME Use the named provider - providers are JSON files located in imports folder. Default is to add services, optional flag to delete -t, --test-only Displays a list of the provider's services - does not modify the SDDC configuration -d, --delete-mode Changes to delete mode - the services in the provider's list will be deleted from the SDDC
Listing Providers
I designed the command to be extensible. I only added an AWS provider in the initial contribution, but any community contributions are welcomed. Here is how to list the available providers:
C:\pyvmc> python .\pyVMC.py inventory import-service -l +-----------+ | Providers | +-----------+ | aws.json | +-----------+
Import test
Now I specify the aws.json
provider, and I also specify -t
for test mode. These are the service definitions that can be added to the Services list.
C:\pyvmc> python .\pyVMC.py inventory import-service -p aws.json -t
Live import
I remove the -t
flag and perform a live import.
C:\pyvmc> python .\pyVMC.py inventory import-service -p aws.json Importing services in provider aws.json... Importing AWS_Directory_Service... Success Importing AWS_EFS... Success Importing AWS_FSX_ISCSI... Success Importing AWS_FSX_NFS... Success Importing AWS_FSX_WINDOWS_SMB... Success Importing AWS_FSX_WINDOWS_WINRM... Success Importing AWS_RDS_Aurora... Success Importing AWS_RDS_MariaDB... Success Importing AWS_RDS_MySQL... Success Importing AWS_RDS_MSSQL... Success Importing AWS_RDS_Oracle... Success Importing AWS_RDS_Postgres... Success Import results:
The Amazon services defined in the provider are now imported into my SDDC.
Deleting
I can delete the services from my SDDC with the delete switch. Note that the delete operation will fail if any of the services are in use in a firewall rule.
C:\Users\kremerpt\git\Flings\python-client-for-vmware-cloud-on-aws [development ≡]> python .\pyVMC.py inventory import-service -p aws.json -d Deleting services in provider aws.json... Deleting AWS_Directory_Service... Success Deleting AWS_EFS... Success Deleting AWS_FSX_ISCSI... Success Deleting AWS_FSX_NFS... Success Deleting AWS_FSX_WINDOWS_SMB... Success Deleting AWS_FSX_WINDOWS_WINRM... Success Deleting AWS_RDS_Aurora... Success Deleting AWS_RDS_MariaDB... Success Deleting AWS_RDS_MySQL... Success Deleting AWS_RDS_MSSQL... Success Deleting AWS_RDS_Oracle... Success Deleting AWS_RDS_Postgres... Success Delete results:
Conclusion
If you have any ideas for adding a new provider, or adding additional services to the AWS provider, please log a feature request in PyVMC's Github repo. Alternatively, build it yourself! Adding to this feature makes for a great first-time contribution as it doesn't require any Python knowledge. If you want to learn, I'd be happy to show you how to contribute to this project - just comment below!
関連するコンテンツ
- 質問済み 2年前lg...
- 質問済み 2ヶ月前lg...
- AWS公式更新しました 1年前
- AWS公式更新しました 7ヶ月前