Misc fixes for several errors

* aci: Correct usage in fail_json
* Fixes incorrect usage of fail_json
* Raise exception object

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/47995/head
Abhijeet Kasurde 6 years ago committed by Brian Coca
parent 638834dc4e
commit ab86051c0b

@ -1155,7 +1155,7 @@ class _BaseNetwork(_IPAddressBase):
try:
# Always false if one is v4 and the other is v6.
if a._version != b._version:
raise TypeError("%s and %s are not of the same version" (a, b))
raise TypeError("%s and %s are not of the same version" % (a, b))
return (b.network_address <= a.network_address and
b.broadcast_address >= a.broadcast_address)
except AttributeError:

@ -210,7 +210,7 @@ class MSCModule(object):
if len(objs) == 0:
return {}
if len(objs) > 1:
self.fail_json('More than one object matches unique filter: {1}'.format(kwargs))
self.fail_json(msg='More than one object matches unique filter: {0}'.format(kwargs))
return objs[0]
def sanitize(self, updates, collate=False):

@ -426,7 +426,7 @@ def main():
if module.params['event_source'].lower() in ('stream', 'sqs'):
results = lambda_event_stream(module, aws)
else:
module.fail_json('Please select `stream` or `sqs` as the event type')
module.fail_json(msg='Please select `stream` or `sqs` as the event type')
module.exit_json(**results)

@ -492,7 +492,7 @@ def main():
checksum = None
if checksum is None:
module.fail_json("Unable to find a checksum for file '%s' in '%s'" % (filename, checksum_url))
module.fail_json(msg="Unable to find a checksum for file '%s' in '%s'" % (filename, checksum_url))
# Remove any non-alphanumeric characters, including the infamous
# Unicode zero-width space
checksum = re.sub(r'\W+', '', checksum).lower()

@ -596,7 +596,7 @@ class ModuleManager(object):
def exists(self):
if not self.pool_exist():
F5ModuleError('The specified pool does not exist')
raise F5ModuleError('The specified pool does not exist')
uri = "https://{0}:{1}/mgmt/tm/ltm/pool/{2}/members/{3}".format(
self.client.provider['server'],

@ -77,7 +77,7 @@ class OnyxIgmpInterfaceModule(BaseOnyxModule):
self._required_config = dict(module_params)
match = self.IF_NAME_REGEX.match(self._required_config["name"])
if not match:
AttributeError("Please Insert Valide Interface Name")
raise AttributeError("Please Insert Valid Interface Name")
self.validate_param_values(self._required_config)

@ -226,20 +226,20 @@ class IscsiInterface(object):
self.module.fail_json(msg="The provided mtu is invalid, it must be > 1500 and < 9000 bytes.")
if self.config_method == 'dhcp' and any([self.address, self.subnet_mask, self.gateway]):
self.module.fail_json(
'A config_method of dhcp is mutually exclusive with the address, subnet_mask, and gateway options.')
self.module.fail_json(msg='A config_method of dhcp is mutually exclusive with the address,'
' subnet_mask, and gateway options.')
# A relatively primitive regex to validate that the input is formatted like a valid ip address
address_regex = re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}')
if self.address and not address_regex.match(self.address):
self.module.fail_json("An invalid ip address was provided for address.")
self.module.fail_json(msg="An invalid ip address was provided for address.")
if self.subnet_mask and not address_regex.match(self.subnet_mask):
self.module.fail_json("An invalid ip address was provided for subnet_mask.")
self.module.fail_json(msg="An invalid ip address was provided for subnet_mask.")
if self.gateway and not address_regex.match(self.gateway):
self.module.fail_json("An invalid ip address was provided for gateway.")
self.module.fail_json(msg="An invalid ip address was provided for gateway.")
@property
def interfaces(self):

Loading…
Cancel
Save