Add pool rdp command
This commit is contained in:
Родитель
c300c0dc1c
Коммит
ed9365f769
|
@ -13,6 +13,7 @@ global configuration doc for more information.
|
|||
for a given location
|
||||
- `pool images update` command now supports updating Docker images
|
||||
in native container support pools via SSH
|
||||
- `pool rdp` sub-command added, please see usage doc for more information
|
||||
- Ability to specify an AAD authority URL via the `aad`:`authority_url`
|
||||
credential configuration, `--aad-authority-url` command line option or
|
||||
`SHIPYARD_AAD_AUTHORITY_URL` environment variable. Please see relevant
|
||||
|
|
|
@ -88,8 +88,8 @@ on all other tasks within the job
|
|||
* Support for job schedules and recurrences for automatic execution of
|
||||
tasks at set intervals
|
||||
* Support for live job and job schedule migration between pools
|
||||
* Automatic setup of SSH users to all nodes in the compute pool and optional
|
||||
tunneling to Docker Hosts on compute nodes
|
||||
* Automatic setup of SSH or RDP users to all nodes in the compute pool and
|
||||
optional creation of SSH tunneling scripts to Docker Hosts on compute nodes
|
||||
* Support for credential management through
|
||||
[Azure KeyVault](https://azure.microsoft.com/en-us/services/key-vault/)
|
||||
* Support for execution on an
|
||||
|
|
|
@ -2941,6 +2941,47 @@ def action_pool_ssh(batch_client, config, cardinal, nodeid, tty, command):
|
|||
command=command)
|
||||
|
||||
|
||||
def action_pool_rdp(batch_client, config, cardinal, nodeid, no_auto=False):
|
||||
# type: (batchsc.BatchServiceClient, dict, int, str, bool) -> None
|
||||
"""Action: Pool Rdp
|
||||
:param azure.batch.batch_service_client.BatchServiceClient batch_client:
|
||||
batch client
|
||||
:param dict config: configuration dict
|
||||
:param int cardinal: cardinal node num
|
||||
:param str nodeid: node id
|
||||
:param bool no_auto: no auto login
|
||||
"""
|
||||
_check_batch_client(batch_client)
|
||||
if cardinal is not None and nodeid is not None:
|
||||
raise ValueError('cannot specify both cardinal and nodeid options')
|
||||
if cardinal is None and nodeid is None:
|
||||
logger.warning(
|
||||
'assuming node cardinal of 0 as no cardinal or nodeid option '
|
||||
'was specified')
|
||||
cardinal = 0
|
||||
if cardinal is not None and cardinal < 0:
|
||||
raise ValueError('invalid cardinal option value')
|
||||
pool = settings.pool_settings(config)
|
||||
ip, port = batch.get_remote_login_setting_for_node(
|
||||
batch_client, config, cardinal, nodeid)
|
||||
if not no_auto and util.is_not_empty(pool.rdp.password):
|
||||
rc = util.subprocess_with_output(
|
||||
'cmdkey.exe /generic:TERMSRV/{ip} /user:{user} /pass:{pw}'.format(
|
||||
ip=ip, port=port, user=pool.rdp.username,
|
||||
pw=pool.rdp.password),
|
||||
shell=True)
|
||||
if rc != 0:
|
||||
logger.warning('cmdkey exit code: {}'.format(rc))
|
||||
util.subprocess_nowait(
|
||||
'mstsc.exe /v:{ip}:{port}'.format(ip=ip, port=port), shell=True)
|
||||
if not no_auto and util.is_not_empty(pool.rdp.password):
|
||||
time.sleep(2)
|
||||
rc = util.subprocess_with_output(
|
||||
'cmdkey.exe /delete:TERMSRV/{}'.format(ip), shell=True)
|
||||
if rc != 0:
|
||||
logger.warning('cmdkey exit code: {}'.format(rc))
|
||||
|
||||
|
||||
def action_pool_nodes_del(
|
||||
batch_client, config, all_start_task_failed, all_starting,
|
||||
all_unusable, nodeid):
|
||||
|
|
|
@ -523,6 +523,7 @@ The `pool` command has the following sub-commands:
|
|||
list List all pools in the Batch account
|
||||
listskus List available VM configurations available to...
|
||||
nodes Compute node actions
|
||||
rdp Interactively login via RDP to a node in a...
|
||||
resize Resize a pool
|
||||
ssh Interactively login via SSH to a node in a...
|
||||
stats Get statistics about a pool
|
||||
|
@ -600,6 +601,13 @@ in the specified pool
|
|||
* `--all-start-task-failed` will reboot all nodes in the start task
|
||||
failed state
|
||||
* `--nodeid` is the node id to reboot
|
||||
* `rdp` will interactively log into a compute node via RDP. If neither
|
||||
`--cardinal` or `--nodeid` are specified, `--cardinal 0` is assumed.
|
||||
* `--cardinal` is the zero-based cardinal number of the compute node in
|
||||
the pool to connect to as listed by `grls`
|
||||
* `--no-auto` will prevent automatic login via temporary credential
|
||||
saving if an RDP password is supplied via the pool configuration file
|
||||
* `--nodeid` is the node id to connect to in the pool
|
||||
* `resize` will resize the pool to the `vm_count` specified in the pool
|
||||
configuration file
|
||||
* `--wait` will wait for resize to complete
|
||||
|
|
22
shipyard.py
22
shipyard.py
|
@ -1251,6 +1251,28 @@ def pool_ssh(ctx, cardinal, nodeid, tty, command):
|
|||
ctx.batch_client, ctx.config, cardinal, nodeid, tty, command)
|
||||
|
||||
|
||||
@pool.command('rdp')
|
||||
@click.option(
|
||||
'--cardinal',
|
||||
help='Zero-based cardinal number of compute node in pool to connect to',
|
||||
type=int)
|
||||
@click.option(
|
||||
'--no-auto', is_flag=True,
|
||||
help='Do not automatically login if RDP password is present')
|
||||
@click.option(
|
||||
'--nodeid', help='NodeId of compute node in pool to connect to')
|
||||
@common_options
|
||||
@batch_options
|
||||
@keyvault_options
|
||||
@aad_options
|
||||
@pass_cli_context
|
||||
def pool_rdp(ctx, cardinal, no_auto, nodeid):
|
||||
"""Interactively login via RDP to a node in a pool"""
|
||||
ctx.initialize_for_batch()
|
||||
convoy.fleet.action_pool_rdp(
|
||||
ctx.batch_client, ctx.config, cardinal, nodeid, no_auto=no_auto)
|
||||
|
||||
|
||||
@pool.command('stats')
|
||||
@click.option('--poolid', help='Get stats on specified pool')
|
||||
@common_options
|
||||
|
|
Загрузка…
Ссылка в новой задаче