Skip to content

Commit

Permalink
connectedvmware 1.1.0 (#7565)
Browse files Browse the repository at this point in the history
* prompt for creds in GM

* 1.1.0

* use prompting from knack
  • Loading branch information
nascarsayan committed Jun 5, 2024
1 parent b7ffd20 commit 9561cbe
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/connectedvmware/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Release History
===============
1.1.0
++++++
* Prompt credentials if not provided for Guest Agent.

1.0.1
++++++
* Fix bug in `az connectedvmware create` command when RG of machine is different from RG of vCenter.
Expand Down
31 changes: 29 additions & 2 deletions src/connectedvmware/azext_connectedvmware/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.core.exceptions import ResourceNotFoundError # type: ignore
from msrestazure.tools import is_valid_resource_id, parse_resource_id
from knack.prompting import prompt, prompt_y_n

from .pwinput import pwinput
from .vmware_utils import get_logger, get_resource_id
Expand Down Expand Up @@ -2089,8 +2090,8 @@ def enable_guest_agent(
client: VMInstanceGuestAgentsOperations,
resource_group_name,
vm_name,
username,
password,
username=None,
password=None,
https_proxy=None,
private_link_scope=None,
no_wait=False,
Expand All @@ -2099,6 +2100,32 @@ def enable_guest_agent(
Enable guest agent on the given virtual machine.
"""

creds_ok = all(inp is not None for inp in [username, password])
while not creds_ok:
creds = {
"username": username,
"password": password,
}
while not creds["username"]:
creds["username"] = prompt("Please provide VM username: ")
if not creds["username"]:
print("Parameter is required, please try again")
while not creds["password"]:
creds["password"] = pwinput("Please provide VM password: ")
if not creds["password"]:
print("Parameter is required, please try again")
continue
passwdConfim = pwinput("Please confirm VM password: ")
if creds["password"] != passwdConfim:
print("Passwords do not match, please try again")
creds["password"] = None
if prompt_y_n("Confirm VM credentials?", default="y"):
username, password = (
creds["username"],
creds["password"],
)
creds_ok = True

machine_client = cf_machine(cmd.cli_ctx)
machine = machine_client.get(resource_group_name, vm_name)
assert machine.id is not None
Expand Down
2 changes: 1 addition & 1 deletion src/connectedvmware/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# TODO: Confirm this is the right version number you want and it matches your
# HISTORY.rst entry.

VERSION = '1.0.1'
VERSION = '1.1.0'

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down

0 comments on commit 9561cbe

Please sign in to comment.