Skip to content
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

[ Microsoft.SCVMM ] Requesting vmmserver credentials until non-empty #4863

Merged
merged 4 commits into from
Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions src/scvmm/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,31 @@
Release History
===============

0.1.0
0.1.5
+++
* Requesting VMMServer credentials from the user until they are non-empty.
* [BREAKING CHANGE] Removing default value for port. Asking for the input. If input is empty, setting port to 8100.

0.1.4
++++++
* Initial release.
* Bug fixes
* Force and retain flags in VM delete
* Generated SDK now requires updated version of azure-cli
* Long running PATCH operations

0.1.1
0.1.3
++++++
* CRUD of VMMServer, Cloud, VMTemplate, VM. Tags Supported. azdev lint passing.
* View Inventory, onboard inventory item to azure.
* CRUD for availablity sets.

0.1.2
++++++
* Interactive password.

0.1.3
0.1.1
++++++
* View Inventory, onboard inventory item to azure.
* CRUD for availablity sets.
* CRUD of VMMServer, Cloud, VMTemplate, VM. Tags Supported. azdev lint passing.

0.1.4
0.1.0
++++++
* Bug fixes
* Force and retain flags in VM delete
* Generated SDK now requires updated version of azure-cli
* Long running PATCH operations
* Initial release.
30 changes: 24 additions & 6 deletions src/scvmm/azext_scvmm/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,43 @@ def connect_vmmserver(
fqdn=None,
username=None,
password=None,
port=DEFAULT_VMMSERVER_PORT,
port=None,
tags=None,
no_wait=False,
):

creds_ok = all(inp is not None for inp in [fqdn, username, password])
creds_ok = all(inp is not None for inp in [fqdn, port, username, password])
while not creds_ok:
creds = {
'fqdn': fqdn,
'port': port,
'username': username,
'password': password,
}
if fqdn is None:
while not creds['fqdn']:
print('Please provide vmmserver FQDN or IP address: ', end='')
creds['fqdn'] = input()
if username is None:
if not creds['fqdn']:
print('Parameter is required, please try again')
while not creds['port']:
print('Please provide vmmserver port (Default: 8100): ', end='')
try:
creds['port'] = input()
if not creds['port']:
creds['port'] = DEFAULT_VMMSERVER_PORT
creds['port'] = int(creds['port'])
except ValueError:
print('Port must be a number, please try again')
creds['port'] = None
Comment on lines +109 to +118
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the automation scenario, if the CLI script does not pass in the creds['port'] parameter, the process of CLI script will get stuck. Is this in line with expectations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is in line with the expectations. We will add modify the command by adding the new param to our automation pipelines.

while not creds['username']:
print('Please provide vmmserver username: ', end='')
creds['username'] = input()
if password is None:
if not creds['username']:
print('Parameter is required, please try again')
while not creds['password']:
creds['password'] = getpass('Please provide vmmserver password: ')
if not creds['password']:
print('Parameter is required, please try again')
print('Confirm vmmserver details? [Y/n]: ', end='')
res = input().lower()
if res in ['y', '']:
Expand All @@ -118,8 +135,9 @@ def connect_vmmserver(
file=sys.stderr,
)
continue
fqdn, username, password = (
fqdn, port, username, password = (
creds['fqdn'],
creds['port'],
creds['username'],
creds['password'],
)
Expand Down
5 changes: 2 additions & 3 deletions src/scvmm/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

logger.warn("Wheel is not available, disabling bdist_wheel hook")

VERSION = '0.1.4'
VERSION = '0.1.5'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down Expand Up @@ -46,8 +46,7 @@
# TODO: Update author and email, if applicable
author='Microsoft Corporation',
author_email='[email protected]',
# TODO: consider pointing directly to your source code instead of the generic repo
url='https://github.com/Azure/azure-cli-extensions/tree/main/src/connectedvmware',
url='https://github.com/Azure/azure-cli-extensions/tree/main/src/scvmm',
long_description=README + '\n\n' + HISTORY,
license='MIT',
classifiers=CLASSIFIERS,
Expand Down