Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions src/horizondb/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
Release History
===============

1.0.0b10
++++++++
* Require both IPv4 bounds on ``cluster pool firewall-rule create``. Reject invalid
or reversed ranges on create and update, including single-bound updates.
* Correct the pool firewall rule create and update help examples.

1.0.0b9
+++++++
* Update the management API to ``2026-10-01-preview`` with PostgreSQL 17 and 18 support.
Expand Down
7 changes: 7 additions & 0 deletions src/horizondb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ az horizondb cluster update --resource-group example-resource-group --name examp
az horizondb cluster pool firewall-rule create --resource-group example-resource-group --cluster-name example-cluster --pool-name example-pool --name client-access --start-ip-address 203.0.113.10 --end-ip-address 203.0.113.10
```

`create` replaces a rule of the same name and requires both ends of the inclusive

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Create is not to be used as replace.

IPv4 range. `update` reads the existing pool rule and replaces it with the requested
changes, so you can supply just one end of the range or change the description.
Neither command changes an individual endpoint. Use `--no-wait` on create, update,
or delete to return after submission; use `firewall-rule wait --created` or
`--deleted` with the same resource group, cluster, pool, and rule name to wait.

## Included Features

### HorizonDB Cluster Management
Expand Down
3 changes: 3 additions & 0 deletions src/horizondb/azext_horizondb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ def load_command_table(self, args):
from .aaz.latest.horizondb.cluster.custom import ClusterCreate, ClusterUpdate
from .aaz.latest.horizondb.cluster.custom_restore import ClusterRestore
from .aaz.latest.horizondb.cluster.pool.custom import PoolCreate, PoolUpdate
from .aaz.latest.horizondb.cluster.pool.firewall_rule.custom import FirewallRuleCreate, FirewallRuleUpdate
from .aaz.latest.horizondb.cluster.private_link_resource.custom import PrivateLinkResourceShow
self.command_table['horizondb cluster create'] = ClusterCreate(loader=self)
self.command_table['horizondb cluster restore'] = ClusterRestore(loader=self)
self.command_table['horizondb cluster update'] = ClusterUpdate(loader=self)
self.command_table['horizondb cluster pool create'] = PoolCreate(loader=self)
self.command_table['horizondb cluster pool update'] = PoolUpdate(loader=self)
self.command_table['horizondb cluster pool firewall-rule create'] = FirewallRuleCreate(loader=self)
self.command_table['horizondb cluster pool firewall-rule update'] = FirewallRuleUpdate(loader=self)
self.command_table['horizondb cluster private-link-resource show'] = PrivateLinkResourceShow(loader=self)
return self.command_table

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
is_preview=True,
)
class Create(AAZCommand):
"""Create a HorizonDB pool firewall rule.
"""Create or replace a HorizonDB pool firewall rule.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove replace


:example: Create or replace a firewall rule on a HorizonDB pool
az horizondb cluster pool firewall-rule create --resource-group example-resource-group --cluster-name example-cluster --pool-name example-pool-01 --firewall-rule-name example-firewall-rule-01 --start-ip-address 10.0.0.1 --end-ip-address 10.0.0.254 --description Allow access from the corporate network
az horizondb cluster pool firewall-rule create --resource-group example-resource-group --cluster-name example-cluster --pool-name example-pool-01 --firewall-rule-name example-firewall-rule-01 --start-ip-address 10.0.0.1 --end-ip-address 10.0.0.254 --description "Allow access from the corporate network"
"""

_aaz_info = {
Expand Down Expand Up @@ -95,6 +95,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
options=["--end-ip-address"],
arg_group="Properties",
help="The end IPv4 address of the firewall rule in dotted-decimal notation. This address must be numerically greater than or equal to startIpAddress.",
required=True,
fmt=AAZStrArgFormat(
pattern="^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])[.]){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$",
),
Expand All @@ -103,6 +104,7 @@ def _build_arguments_schema(cls, *args, **kwargs):
options=["--start-ip-address"],
arg_group="Properties",
help="The start IPv4 address of the firewall rule in dotted-decimal notation.",
required=True,
fmt=AAZStrArgFormat(
pattern="^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])[.]){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])$",
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Update(AAZCommand):
"""Update a HorizonDB pool firewall rule.

:example: Update a firewall rule on a HorizonDB pool
az horizon-db cluster pool firewall-rule update --resource-group example-resource-group --cluster-name example-cluster --pool-name example-pool-01 --firewall-rule-name example-firewall-rule-01 --start-ip-address 10.0.0.1 --end-ip-address 10.0.0.254 --description Allow access from the corporate network
az horizondb cluster pool firewall-rule update --resource-group example-resource-group --cluster-name example-cluster --pool-name example-pool-01 --firewall-rule-name example-firewall-rule-01 --end-ip-address 10.0.0.254 --description "Allow access from the corporate network"
"""

_aaz_info = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from ipaddress import AddressValueError, IPv4Address

from azure.cli.core.azclierror import InvalidArgumentValueError

from ._create import Create
from ._update import Update


def _address(value, option):
try:
return IPv4Address(value.to_serialized_data())
except AddressValueError as exc:
raise InvalidArgumentValueError(f'{option} must be a dotted-decimal IPv4 address.') from exc


def _validate_range(properties):
start = _address(properties.start_ip_address, '--start-ip-address')
end = _address(properties.end_ip_address, '--end-ip-address')
if end < start:
raise InvalidArgumentValueError('--end-ip-address must be greater than or equal to --start-ip-address.')


class FirewallRuleCreate(Create):
def pre_operations(self):
_validate_range(self.ctx.args)


class FirewallRuleUpdate(Update):
def post_instance_update(self, instance):
# A partial update must be checked against the endpoint retained by the GET.
_validate_range(instance.properties)
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def setUp(self):
'pool_name': 'test-pool',
}

def _name_args(self, command_type, name):
args = dict(self.args, firewall_rule_name=name)
if command_type is Create:
args.update(start_ip_address='203.0.113.10', end_ip_address='203.0.113.10')
return args

def test_accepts_valid_firewall_rule_names(self):
for command_type in [Create, Update, Show, Delete, Wait]:
schema = command_type.get_arguments_schema()
Expand All @@ -38,11 +44,42 @@ def test_accepts_valid_firewall_rule_names(self):
for name in ['a', 'Allow_Office.1-rule_', 'a' * 80]:
with self.subTest(command=command_type.__name__, name=name):
command = command_type(loader=self.loader)
args = dict(self.args, firewall_rule_name=name)
args = self._name_args(command_type, name)
AAZCommand._handler(command, args) # pylint: disable=protected-access
self.assertRegex(name, pattern)
self.assertEqual(command.ctx.args.firewall_rule_name.to_serialized_data(), name)

def test_create_validates_ipv4_range_before_request(self):
name = 'horizondb cluster pool firewall-rule create'
command = self.loader.load_command_table(name.split())[name]
for start, end, error in [
('2001:db8::1', '203.0.113.10', '--start-ip-address'),
('203.0.113.10', '256.0.0.1', '--end-ip-address'),
('203.0.113.10', '203.0.113.9', 'greater than or equal')]:
with self.subTest(start=start, end=end), self.assertRaisesRegex(InvalidArgumentValueError, error):
command(command_args=dict(self.args, firewall_rule_name='office', start_ip_address=start,
end_ip_address=end, no_wait=True))

def test_update_validates_merged_range_before_put(self):
name = 'horizondb cluster pool firewall-rule update'
command = self.loader.load_command_table(name.split())[name]
args = dict(self.args, firewall_rule_name='office', end_ip_address='203.0.113.9', no_wait=True)

def load_existing():
command.ctx.set_var('instance', {'properties': {
'startIpAddress': '203.0.113.10', 'endIpAddress': '203.0.113.12',
}}, schema_builder=Update.FirewallRulesGet._build_schema_on_200) # pylint: disable=protected-access

with patch.object(command, 'FirewallRulesGet') as get, \
patch.object(command, 'FirewallRulesCreateOrReplace') as put:
get.return_value.side_effect = load_existing
with self.assertRaisesRegex(InvalidArgumentValueError, 'greater than or equal'):
command(command_args=args)
put.assert_not_called()
args['end_ip_address'] = '203.0.113.10'
command(command_args=args)
put.assert_called_once()

def test_firewall_rule_name_pattern_rejects_invalid_names(self):
for command_type in [Create, Update, Show, Delete, Wait]:
schema = command_type.get_arguments_schema()
Expand All @@ -55,6 +92,6 @@ def test_rejects_firewall_rule_names_longer_than_80_characters(self):
for command_type in [Create, Update, Show, Delete, Wait]:
with self.subTest(command=command_type.__name__):
command = command_type(loader=self.loader)
args = dict(self.args, firewall_rule_name='a' * 81)
args = self._name_args(command_type, 'a' * 81)
with self.assertRaises(InvalidArgumentValueError):
AAZCommand._handler(command, args) # pylint: disable=protected-access
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.0b9'
VERSION = '1.0.0b10'

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