Browse Source

Add load balancer flavor support to the OSC client

This patch adds the flavor fields for load balancers.

It also adds .stestr to the .gitigonre list.

Change-Id: I9153895eb5e7ebba50a2c31b5375ecf173d8bfa2
changes/45/629945/3
Michael Johnson 2 years ago
committed by Carlos Goncalves
parent
commit
98f7c574a6
7 changed files with 45 additions and 4 deletions
  1. +1
    -0
      .gitignore
  2. +1
    -1
      octaviaclient/osc/v2/constants.py
  3. +10
    -0
      octaviaclient/osc/v2/load_balancer.py
  4. +6
    -1
      octaviaclient/osc/v2/utils.py
  5. +1
    -0
      octaviaclient/tests/unit/osc/v2/constants.py
  6. +22
    -2
      octaviaclient/tests/unit/osc/v2/test_load_balancer.py
  7. +4
    -0
      releasenotes/notes/add-lb-flavor-b917faa0298c3a74.yaml

+ 1
- 0
.gitignore View File

@ -29,6 +29,7 @@ cover/
nosetests.xml
.testrepository
.venv
.stestr
# Translations
*.mo


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

@ -16,7 +16,7 @@ LOAD_BALANCER_ROWS = (
'admin_state_up',
'created_at',
'description',
'flavor',
'flavor_id',
'id',
'listeners',
'name',


+ 10
- 0
octaviaclient/osc/v2/load_balancer.py View File

@ -113,6 +113,11 @@ class CreateLoadBalancer(command.ShowOne):
default=None,
help="Disable load balancer."
)
parser.add_argument(
'--flavor',
metavar='<flavor>',
help="The name or ID of the flavor for the load balancer."
)
return parser
@ -260,6 +265,11 @@ class ListLoadBalancer(lister.Lister):
metavar='<provider>',
help="List load balancers according to their provider."
)
parser.add_argument(
'--flavor',
metavar='<flavor>',
help="List load balancers according to their flavor."
)
return parser


+ 6
- 1
octaviaclient/osc/v2/utils.py View File

@ -161,7 +161,12 @@ def get_loadbalancer_attrs(client_manager, parsed_args):
'cascade': ('cascade', lambda x: True),
'provisioning_status': ('provisioning_status', str),
'operating_status': ('operating_status', str),
'provider': ('provider', str)
'provider': ('provider', str),
'flavor': (
'flavor_id',
'flavors',
client_manager.load_balancer.flavor_list
),
}
_attrs = vars(parsed_args)


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

@ -85,6 +85,7 @@ LOADBALANCER_ATTRS = {
"provisioning_status": "ACTIVE",
"operating_status": "ONLINE",
"provider": "octavia",
"flavor_id": uuidutils.generate_uuid(dashed=True),
}
L7POLICY_ATTRS = {


+ 22
- 2
octaviaclient/tests/unit/osc/v2/test_load_balancer.py View File

@ -178,6 +178,24 @@ class TestLoadBalancerList(TestLoadBalancer):
self.assertEqual(self.columns, columns)
self.assertEqual(self.datalist, tuple(data))
@mock.patch('octaviaclient.osc.v2.utils.get_loadbalancer_attrs')
def test_load_balancer_list_with_flavor(self, mock_client):
mock_client.return_value = {
'flavor_id': self._lb.flavor_id,
}
arglist = [
'--flavor', self._lb.flavor_id,
]
verify_list = [
('flavor', self._lb.flavor_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verify_list)
columns, data = self.cmd.take_action(parsed_args)
self.assertEqual(self.columns, columns)
self.assertEqual(self.datalist, tuple(data))
class TestLoadBalancerDelete(TestLoadBalancer):
@ -225,11 +243,13 @@ class TestLoadBalancerCreate(TestLoadBalancer):
mock_client.return_value = self.lb_info
arglist = ['--name', self._lb.name,
'--vip-network-id', self._lb.vip_network_id,
'--project', self._lb.project_id]
'--project', self._lb.project_id,
'--flavor', self._lb.flavor_id]
verifylist = [
('name', self._lb.name),
('vip_network_id', self._lb.vip_network_id),
('project', self._lb.project_id)
('project', self._lb.project_id),
('flavor', self._lb.flavor_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)


+ 4
- 0
releasenotes/notes/add-lb-flavor-b917faa0298c3a74.yaml View File

@ -0,0 +1,4 @@
---
features:
- |
Adds the ``flavor`` option to loadbalancer create and loadbalancer list.

Loading…
Cancel
Save