-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added local accounts workflow sample code for Vcenter Appliance #191
base: master
Are you sure you want to change the base?
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
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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<[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method is not needed.
self.list_accounts() | ||
account_created = True | ||
except AlreadyExists as e: | ||
print("local account is already present") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-raise exceptions instead of print, so the issues are more obvious.
No description provided.