Skip to content

Commit

Permalink
Merge pull request #56 from skanthed/apply-filters
Browse files Browse the repository at this point in the history
Apply filters to node list
  • Loading branch information
tzumainn authored May 29, 2024
2 parents 04dec16 + 9dd6db3 commit 86ab4eb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
19 changes: 18 additions & 1 deletion esileapclient/osc/v1/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,32 @@ def get_parser(self, prog_name):
default=False,
help="Show detailed information about the nodes.",
action='store_true')
parser.add_argument(
'--resource-class',
dest='resource_class',
required=False,
help="Filter nodes by resource class.")
parser.add_argument(
'--owner',
dest='owner',
required=False,
help="Filter nodes by owner.")
parser.add_argument(
'--lessee',
dest='lessee',
required=False,
help="Filter nodes by lessee.")

return parser

def take_action(self, parsed_args):

client = self.app.client_manager.lease

# No filters yet
filters = {
'resource_class': parsed_args.resource_class,
'owner': parsed_args.owner,
'lessee': parsed_args.lessee
}

data = list(client.nodes(**filters))
Expand Down
6 changes: 6 additions & 0 deletions esileapclient/tests/unit/osc/v1/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ def test_node_list(self):
columns, data = self.cmd.take_action(parsed_args)

filters = {
'resource_class': parsed_args.resource_class,
'owner': parsed_args.owner,
'lessee': parsed_args.lessee
}

self.client_mock.nodes.assert_called_with(**filters)
Expand Down Expand Up @@ -76,6 +79,9 @@ def test_node_list_long(self):
columns, data = self.cmd.take_action(parsed_args)

filters = {
'resource_class': parsed_args.resource_class,
'owner': parsed_args.owner,
'lessee': parsed_args.lessee
}

self.client_mock.nodes.assert_called_with(**filters)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ openstacksdk<1.3.0
pbr!=2.1.0,>=2.0.0 # Apache-2.0
python-openstackclient>=3.18.0
six>=1.12.0
esisdk==0.2
esisdk==0.3
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ tempest>=17.1.0
testtools>=2.2.0
tox>= 3.12.1
WebTest>=2.0.33
esisdk==0.2
esisdk==0.3

0 comments on commit 86ab4eb

Please sign in to comment.