diff --git a/octaviaclient/osc/v2/utils.py b/octaviaclient/osc/v2/utils.py index 45d9e38..637839c 100644 --- a/octaviaclient/osc/v2/utils.py +++ b/octaviaclient/osc/v2/utils.py @@ -10,12 +10,10 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -# import functools import ipaddress -import munch from openstackclient.identity import common as identity_common from osc_lib import exceptions as osc_exc from osc_lib import utils @@ -716,9 +714,13 @@ def get_unsets(parsed_args): return unsets +class _Munch(dict): + __getattr__ = dict.get + + def wait_for_active(status_f, res_id): success = utils.wait_for_status( - status_f=lambda x: munch.Munch(status_f(x)), + status_f=lambda x: _Munch(status_f(x)), res_id=res_id, status_field=constants.PROVISIONING_STATUS, sleep_time=3 @@ -734,7 +736,7 @@ def wait_for_delete(status_f, res_id, class Getter(object): @staticmethod def get(id): - return munch.Munch(status_f(id)) + return _Munch(status_f(id)) try: success = utils.wait_for_delete( diff --git a/octaviaclient/tests/unit/osc/v2/test_load_balancer.py b/octaviaclient/tests/unit/osc/v2/test_load_balancer.py index 4008b37..af64a99 100644 --- a/octaviaclient/tests/unit/osc/v2/test_load_balancer.py +++ b/octaviaclient/tests/unit/osc/v2/test_load_balancer.py @@ -9,12 +9,12 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -# + +import argparse import copy import itertools from unittest import mock -import munch from osc_lib import exceptions from oslo_utils import uuidutils @@ -496,9 +496,12 @@ class TestLoadBalancerCreate(TestLoadBalancer): # subtract comb's keys from attrs_list filtered_attrs = {k: v for k, v in attrs_list.items() if ( k not in comb)} + # Add the 'wait' attribute, which isn't part of an LB directly filtered_attrs['wait'] = False mock_client.return_value = filtered_attrs + parsed_args = argparse.Namespace(**filtered_attrs) + if not any(k in filtered_attrs for k in args) or all( k in filtered_attrs for k in ("vip_network_id", "vip_port_id") @@ -506,10 +509,11 @@ class TestLoadBalancerCreate(TestLoadBalancer): self.assertRaises( exceptions.CommandError, self.cmd.take_action, - filtered_attrs) + parsed_args + ) else: try: - self.cmd.take_action(munch.Munch(filtered_attrs)) + self.cmd.take_action(parsed_args) except exceptions.CommandError as e: self.fail("%s raised unexpectedly" % e) diff --git a/requirements.txt b/requirements.txt index 3a5a224..3a1783f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,4 +15,3 @@ oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0 oslo.utils>=3.33.0 # Apache-2.0 pbr!=2.1.0,>=2.0.0 # Apache-2.0 requests>=2.14.2 # Apache-2.0 -munch>=2.1.0 # MIT