Browse Source

Support backup members

Story: 2001777
Task: 12486

Change-Id: I81095ec47eaf0f5d41e91ea66b3a0c9a00d8f95b
changes/30/576530/6
huangshan 3 years ago
parent
commit
eee91e826a
6 changed files with 47 additions and 7 deletions
  1. +3
    -1
      octaviaclient/osc/v2/constants.py
  2. +26
    -0
      octaviaclient/osc/v2/member.py
  3. +2
    -0
      octaviaclient/osc/v2/utils.py
  4. +1
    -0
      octaviaclient/tests/unit/osc/v2/constants.py
  5. +10
    -6
      octaviaclient/tests/unit/osc/v2/test_member.py
  6. +5
    -0
      releasenotes/notes/add_backup_member_support-8b406bb72654ba88.yaml

+ 3
- 1
octaviaclient/osc/v2/constants.py View File

@ -122,7 +122,9 @@ MEMBER_ROWS = (
'updated_at',
'weight',
'monitor_port',
'monitor_address')
'monitor_address',
'backup'
)
MEMBER_COLUMNS = (
'id',


+ 26
- 0
octaviaclient/osc/v2/member.py View File

@ -101,6 +101,19 @@ class CreateMember(command.ShowOne):
metavar='<name>',
help="Name of the member."
)
backup = parser.add_mutually_exclusive_group()
backup.add_argument(
'--disable-backup',
action='store_true',
default=None,
help="Disable member backup (default)"
)
backup.add_argument(
'--enable-backup',
action='store_true',
default=None,
help="Enable member backup"
)
parser.add_argument(
'--weight',
metavar='<weight>',
@ -197,6 +210,19 @@ class SetMember(command.Command):
metavar='<name>',
help="Set the name of the member"
)
backup = parser.add_mutually_exclusive_group()
backup.add_argument(
'--disable-backup',
action='store_true',
default=None,
help="Disable member backup (default)"
)
backup.add_argument(
'--enable-backup',
action='store_true',
default=None,
help="Enable member backup"
)
parser.add_argument(
'--weight',
metavar='<weight>',


+ 2
- 0
octaviaclient/osc/v2/utils.py View File

@ -269,6 +269,8 @@ def get_member_attrs(client_manager, parsed_args):
'pool',
client_manager.load_balancer.member_list
),
'enable_backup': ('backup', lambda x: True),
'disable_backup': ('backup', lambda x: False),
'weight': ('weight', int),
'subnet_id': (
'subnet_id',


+ 1
- 0
octaviaclient/tests/unit/osc/v2/constants.py View File

@ -115,6 +115,7 @@ L7RULE_ATTRS = {
MEMBER_ATTRS = {
"project_id": uuidutils.generate_uuid(dashed=True),
"name": "test-member",
"backup": False,
"weight": 1,
"admin_state_up": True,
"subnet_id": uuidutils.generate_uuid(dashed=True),


+ 10
- 6
octaviaclient/tests/unit/osc/v2/test_member.py View File

@ -90,11 +90,12 @@ class TestCreateMember(TestMember):
'protocol_port': self._mem.protocol_port,
'weight': self._mem.weight,
'admin_state_up': True,
'pool_id': self._mem.pool_id}
'pool_id': self._mem.pool_id,
'backup': False}
arglist = ['pool_id', '--address', '192.0.2.122',
'--protocol-port', '80',
'--weight', '1', '--enable']
'--weight', '1', '--enable', '--disable-backup']
verifylist = [
('address', '192.0.2.122'),
('protocol_port', 80),
@ -108,7 +109,8 @@ class TestCreateMember(TestMember):
'member': {'ip_address': '192.0.2.122',
'protocol_port': self._mem.protocol_port,
'weight': self._mem.weight,
'admin_state_up': True}})
'admin_state_up': True,
'backup': False}})
class TestMemberDelete(TestMember):
@ -140,9 +142,10 @@ class TestMemberSet(TestMember):
def test_member_set(self, mock_attrs):
mock_attrs.return_value = {'pool_id': 'test_pool_id',
'member_id': 'test_mem_id',
'name': 'new_name'}
'name': 'new_name',
'backup': True}
arglist = ['test_pool_id', 'test_mem_id', '--name',
'new_name']
'new_name', '--enable-backup']
verifylist = [
('pool', 'test_pool_id'),
('member', 'test_mem_id'),
@ -153,7 +156,8 @@ class TestMemberSet(TestMember):
self.cmd.take_action(parsed_args)
self.api_mock.member_set.assert_called_with(
pool_id='test_pool_id', member_id='test_mem_id',
json={'member': {'name': 'new_name'}})
json={'member': {'name': 'new_name',
'backup': True}})
class TestMemberShow(TestMember):


+ 5
- 0
releasenotes/notes/add_backup_member_support-8b406bb72654ba88.yaml View File

@ -0,0 +1,5 @@
---
features:
- |
Optional backup argument for member, in loadbalancer member create,
and loadbalancer member set.

Loading…
Cancel
Save