Skip to content
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
4 changes: 4 additions & 0 deletions src/horizondb/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

1.0.0b2
+++++++
* Add support for updating HorizonDB clusters through `az horizondb update`.

1.0.0b1
+++++++
* Add create, list, and delete commands for HorizonDB clusters.
Expand Down
9 changes: 9 additions & 0 deletions src/horizondb/azext_horizondb/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@
"""


helps['horizondb update'] = """
type: command
short-summary: Update an existing Azure HorizonDB cluster.
examples:
- name: Update an existing HorizonDB cluster to have 6 vCores.
text: az horizondb update --name examplecluster --resource-group exampleresourcegroup --v-cores 6
"""


helps['horizondb delete'] = """
type: command
short-summary: Delete an Azure HorizonDB cluster.
Expand Down
5 changes: 5 additions & 0 deletions src/horizondb/azext_horizondb/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def _horizondb_params():
c.argument('v_cores', arg_type=v_cores_arg_type)
c.argument('zone_placement_policy', arg_type=zone_placement_policy_arg_type)

with self.argument_context('horizondb update') as c:
c.argument('tags', tags_type)
c.argument('administrator_login_password', arg_type=administrator_login_password_arg_type)
c.argument('v_cores', arg_type=v_cores_arg_type)

with self.argument_context('horizondb delete') as c:
c.argument('yes', arg_type=yes_arg_type)

Expand Down
1 change: 1 addition & 0 deletions src/horizondb/azext_horizondb/cluster_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def load_command_table(self, _):
custom_command_type=custom_commands,
client_factory=cf_horizondb_clusters) as g:
g.custom_command('create', 'horizondb_cluster_create', table_transformer=table_transform_output)
g.custom_command('update', 'horizondb_cluster_update', supports_no_wait=True)
g.custom_command('delete', 'horizondb_cluster_delete')
g.custom_command('list', 'horizondb_cluster_list')
g.show_command('show', 'get')
36 changes: 34 additions & 2 deletions src/horizondb/azext_horizondb/commands/custom_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# pylint: disable=line-too-long, too-many-locals

from knack.log import get_logger
from azure.cli.core.azclierror import ArgumentUsageError, CLIInternalError
from azure.cli.core.util import sdk_no_wait, user_confirmation
from azure.cli.core.azclierror import AzCLIError

logger = get_logger(__name__)

Expand Down Expand Up @@ -42,6 +42,38 @@ def horizondb_cluster_create(client, resource_group_name, cluster_name, location
resource=resource)


def horizondb_cluster_update(client, resource_group_name, cluster_name,
administrator_login_password=None, tags=None,
v_cores=None,
no_wait=False):
from azext_horizondb.vendored_sdks.models import (
HorizonDbClusterForPatchUpdate,
HorizonDbClusterPropertiesForPatchUpdate,
)

cluster_properties = {}
if administrator_login_password is not None:
cluster_properties["administrator_login_password"] = administrator_login_password
if v_cores is not None:
cluster_properties["v_cores"] = v_cores

patch_properties = {}
if tags is not None:
patch_properties["tags"] = tags
if cluster_properties:
patch_properties["properties"] = HorizonDbClusterPropertiesForPatchUpdate(**cluster_properties)

if not patch_properties:
raise ArgumentUsageError("Specify at least one argument to update.")

properties = HorizonDbClusterForPatchUpdate(**patch_properties)

return sdk_no_wait(no_wait, client.begin_update,
resource_group_name=resource_group_name,
cluster_name=cluster_name,
properties=properties)
Comment thread
nasc17 marked this conversation as resolved.


def horizondb_cluster_delete(cmd, client, resource_group_name, cluster_name, no_wait=False, yes=False):
if not yes:
user_confirmation(
Expand All @@ -56,7 +88,7 @@ def horizondb_cluster_delete(cmd, client, resource_group_name, cluster_name, no_
local_context_file.remove_option('horizondb', 'cluster_name')
except Exception as ex: # pylint: disable=broad-except
logger.error(ex)
raise AzCLIError(ex)
raise CLIInternalError(str(ex)) from ex
return result


Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ def _test_horizondb_cluster_mgmt(self, resource_group):
# self.cmd('horizondb list',
# checks=[JMESPathCheck("[?name=='{}'] | length(@)".format(cluster_name), 1)])

# Update cluster
v_cores_update = v_cores - 2
show_result = self.cmd('horizondb update -g {} -n {} --v-cores {}'.format(
resource_group, cluster_name, v_cores_update)).get_output_in_json()

self.assertEqual(show_result['properties']['vCores'], v_cores_update)
Comment thread
nasc17 marked this conversation as resolved.

# Delete cluster
self.cmd('horizondb delete -g {} -n {} --yes'.format(resource_group, cluster_name),
checks=NoneCheck())
2 changes: 1 addition & 1 deletion src/horizondb/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from distutils import log as logger
logger.warn("Wheel is not available, disabling bdist_wheel hook")

VERSION = '1.0.0b1'
VERSION = '1.0.0b2'

CLASSIFIERS = [
'Development Status :: 4 - Beta',
Expand Down
Loading