Added local accounts workflow sample code for Vcenter Appliance#191
Added local accounts workflow sample code for Vcenter Appliance#191kumahesh wants to merge 1 commit intovmware:masterfrom
Conversation
|
@kumahesh, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding
|
pgbidkar
left a comment
There was a problem hiding this comment.
Can you please run PEP8 to fix formatting issue?
d982682 to
652c3d4
Compare
|
@kumahesh, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding
|
652c3d4 to
d89d709
Compare
d89d709 to
0e38f70
Compare
Signed-off-by: Mahesh kumar<kumahesh@vmware.com>
0e38f70 to
8f792f4
Compare
|
@tianhao64 , Could you please review this. |
| def main(): | ||
| try: | ||
| local_accounts = LocalAccounts() | ||
| local_accounts.run() | ||
| except Exception: | ||
| import traceback | ||
| traceback.print_exc() |
There was a problem hiding this comment.
try except doesn't add any value. Remove it.
| parser = sample_cli.build_arg_parser() | ||
| args = sample_util.process_cli_args(parser.parse_args()) | ||
| session = get_unverified_session() if args.skipverification else None | ||
| self.client = create_vsphere_client(server=args.server, |
There was a problem hiding this comment.
Either use self.client.appliance.LocalAccounts directly in sample body, or make self.client a method scope variable.
| Deletes the created local account at the end. | ||
| """ | ||
|
|
||
| print("Listing available accounts") |
There was a problem hiding this comment.
Add /n at the beginning of each print? So it will look nicer.
| username = input("username ::") | ||
| pprint(self.local_accounts.get(username)) | ||
| except NotFound as e: | ||
| print("Local Account mentioned is not found") |
There was a problem hiding this comment.
You can raise an ValueError here, instead of just print.
| print("Local Account mentioned is not found") | ||
|
|
||
| def list_accounts(self): | ||
| pprint(self.local_accounts.list()) |
| self.list_accounts() | ||
| account_created = True | ||
| except AlreadyExists as e: | ||
| print("local account is already present") |
There was a problem hiding this comment.
Re-raise exceptions instead of print, so the issues are more obvious.
No description provided.