Fix strings

This commit is contained in:
Pedro Algarvio 2021-08-03 08:40:21 +01:00 committed by Gareth J. Greenaway
parent 9c443d144b
commit 8abdd65908
502 changed files with 4722 additions and 3277 deletions

View file

@ -30,18 +30,18 @@ def validate(config):
# Configuration for adb beacon should be a dictionary with states array
if not isinstance(config, list):
log.info("Configuration for adb beacon must be a list.")
return False, ("Configuration for adb beacon must be a list.")
return False, "Configuration for adb beacon must be a list."
_config = {}
list(map(_config.update, config))
if "states" not in _config:
log.info("Configuration for adb beacon must include a states array.")
return False, ("Configuration for adb beacon must include a states array.")
return False, "Configuration for adb beacon must include a states array."
else:
if not isinstance(_config["states"], list):
log.info("Configuration for adb beacon must include a states array.")
return False, ("Configuration for adb beacon must include a states array.")
return False, "Configuration for adb beacon must include a states array."
else:
states = [
"offline",
@ -57,13 +57,12 @@ def validate(config):
]
if any(s not in states for s in _config["states"]):
log.info(
"Need a one of the following adb " "states: %s", ", ".join(states)
"Need a one of the following adb states: %s", ", ".join(states)
)
return (
False,
(
"Need a one of the following adb "
"states: {}".format(", ".join(states))
"Need a one of the following adb states: {}".format(
", ".join(states)
),
)
return True, "Valid beacon configuration"

View file

@ -16,13 +16,12 @@ def __virtual__():
"""
Only load if kernel is AIX
"""
if __grains__["kernel"] == ("AIX"):
if __grains__["kernel"] == "AIX":
return __virtualname__
return (
False,
"The aix_account beacon module failed to load: "
"only available on AIX systems.",
"The aix_account beacon module failed to load: only available on AIX systems.",
)
@ -32,14 +31,11 @@ def validate(config):
"""
# Configuration for aix_account beacon should be a dictionary
if not isinstance(config, dict):
return False, ("Configuration for aix_account beacon must be a dict.")
return False, "Configuration for aix_account beacon must be a dict."
if "user" not in config:
return (
False,
(
"Configuration for aix_account beacon must "
"include a user or ALL for all users."
),
"Configuration for aix_account beacon must include a user or ALL for all users.",
)
return True, "Valid beacon configuration"

View file

@ -55,13 +55,15 @@ def __virtual__():
return __virtualname__
return (
False,
"The {} beacon cannot be loaded. The "
"'python-dbus' dependency is missing.".format(__virtualname__),
"The {} beacon cannot be loaded. The 'python-dbus' dependency is missing.".format(
__virtualname__
),
)
return (
False,
"The {} beacon cannot be loaded. The "
"'python-avahi' dependency is missing.".format(__virtualname__),
"The {} beacon cannot be loaded. The 'python-avahi' dependency is missing.".format(
__virtualname__
),
)
@ -73,15 +75,12 @@ def validate(config):
list(map(_config.update, config))
if not isinstance(config, list):
return False, ("Configuration for avahi_announce beacon must be a list.")
return False, "Configuration for avahi_announce beacon must be a list."
elif not all(x in _config for x in ("servicetype", "port", "txt")):
return (
False,
(
"Configuration for avahi_announce beacon "
"must contain servicetype, port and txt items."
),
"Configuration for avahi_announce beacon must contain servicetype, port and txt items.",
)
return True, "Valid beacon configuration."

View file

@ -55,15 +55,12 @@ def validate(config):
list(map(_config.update, config))
if not isinstance(config, list):
return False, ("Configuration for bonjour_announce beacon must be a list.")
return False, "Configuration for bonjour_announce beacon must be a list."
elif not all(x in _config for x in ("servicetype", "port", "txt")):
return (
False,
(
"Configuration for bonjour_announce beacon "
"must contain servicetype, port and txt items."
),
"Configuration for bonjour_announce beacon must contain servicetype, port and txt items.",
)
return True, "Valid beacon configuration."

View file

@ -142,14 +142,12 @@ def _validate_time_range(trange, status, msg):
if not isinstance(trange, dict):
status = False
msg = "The time_range parameter for " "btmp beacon must " "be a dictionary."
msg = "The time_range parameter for btmp beacon must be a dictionary."
if not all(k in trange for k in ("start", "end")):
status = False
msg = (
"The time_range parameter for "
"btmp beacon must contain "
"start & end options."
"The time_range parameter for btmp beacon must contain start & end options."
)
return status, msg
@ -202,7 +200,7 @@ def validate(config):
# Configuration for load beacon should be a list of dicts
if not isinstance(config, list):
vstatus = False
vmsg = "Configuration for btmp beacon must " "be a list."
vmsg = "Configuration for btmp beacon must be a list."
else:
_config = {}
list(map(_config.update, config))
@ -210,7 +208,7 @@ def validate(config):
if "users" in _config:
if not isinstance(_config["users"], dict):
vstatus = False
vmsg = "User configuration for btmp beacon must " "be a dictionary."
vmsg = "User configuration for btmp beacon must be a dictionary."
else:
for user in _config["users"]:
_time_range = _config["users"][user].get("time_range", {})
@ -222,7 +220,7 @@ def validate(config):
if "groups" in _config:
if not isinstance(_config["groups"], dict):
vstatus = False
vmsg = "Group configuration for btmp beacon must " "be a dictionary."
vmsg = "Group configuration for btmp beacon must be a dictionary."
else:
for group in _config["groups"]:
_time_range = _config["groups"][group].get("time_range", {})
@ -233,7 +231,7 @@ def validate(config):
if "defaults" in _config:
if not isinstance(_config["defaults"], dict):
vstatus = False
vmsg = "Defaults configuration for btmp beacon must " "be a dictionary."
vmsg = "Defaults configuration for btmp beacon must be a dictionary."
else:
_time_range = _config["defaults"].get("time_range", {})
vstatus, vmsg = _validate_time_range(_time_range, vstatus, vmsg)

View file

@ -29,7 +29,7 @@ def validate(config):
"""
# Configuration for glxinfo beacon should be a dictionary
if not isinstance(config, list):
return False, ("Configuration for glxinfo beacon must be a list.")
return False, "Configuration for glxinfo beacon must be a list."
_config = {}
list(map(_config.update, config))
@ -37,10 +37,7 @@ def validate(config):
if "user" not in _config:
return (
False,
(
"Configuration for glxinfo beacon must "
"include a user as glxinfo is not available to root."
),
"Configuration for glxinfo beacon must include a user as glxinfo is not available to root.",
)
return True, "Valid beacon configuration"

View file

@ -27,30 +27,30 @@ def validate(config):
Validate the beacon configuration
"""
if not isinstance(config, list):
return False, ("Configuration for haproxy beacon must be a list.")
return False, "Configuration for haproxy beacon must be a list."
else:
_config = {}
list(map(_config.update, config))
if "backends" not in _config:
return False, ("Configuration for haproxy beacon requires backends.")
return False, "Configuration for haproxy beacon requires backends."
else:
if not isinstance(_config["backends"], dict):
return False, ("Backends for haproxy beacon must be a dictionary.")
return False, "Backends for haproxy beacon must be a dictionary."
else:
for backend in _config["backends"]:
log.debug("_config %s", _config["backends"][backend])
if "servers" not in _config["backends"][backend]:
return (
False,
("Backends for haproxy beacon require servers."),
"Backends for haproxy beacon require servers.",
)
else:
_servers = _config["backends"][backend]["servers"]
if not isinstance(_servers, list):
return (
False,
("Servers for haproxy beacon must be a list."),
"Servers for haproxy beacon must be a list.",
)
return True, "Valid beacon configuration"
@ -90,7 +90,7 @@ def beacon(config):
"threshold": threshold,
}
log.debug(
"Emit because %s > %s" " for %s in %s",
"Emit because %s > %s for %s in %s",
scur,
threshold,
server,

View file

@ -32,7 +32,7 @@ def validate(config):
Validate the beacon configuration
"""
if not isinstance(config, list):
return False, ("Configuration for telegram_bot_msg beacon must be a list.")
return False, "Configuration for telegram_bot_msg beacon must be a list."
_config = {}
list(map(_config.update, config))
@ -42,16 +42,14 @@ def validate(config):
):
return (
False,
("Not all required configuration for telegram_bot_msg are set."),
"Not all required configuration for telegram_bot_msg are set.",
)
if not isinstance(_config.get("accept_from"), list):
return (
False,
(
"Configuration for telegram_bot_msg, "
"accept_from must be a list of usernames."
),
"Configuration for telegram_bot_msg, "
"accept_from must be a list of usernames.",
)
return True, "Valid beacon configuration."

View file

@ -34,7 +34,7 @@ def validate(config):
"""
# Configuration for twilio_txt_msg beacon should be a list of dicts
if not isinstance(config, list):
return False, ("Configuration for twilio_txt_msg beacon must be a list.")
return False, "Configuration for twilio_txt_msg beacon must be a list."
else:
_config = {}
list(map(_config.update, config))
@ -44,11 +44,9 @@ def validate(config):
):
return (
False,
(
"Configuration for twilio_txt_msg beacon "
"must contain account_sid, auth_token "
"and twilio_number items."
),
"Configuration for twilio_txt_msg beacon "
"must contain account_sid, auth_token "
"and twilio_number items.",
)
return True, "Valid beacon configuration"

View file

@ -171,14 +171,12 @@ def _validate_time_range(trange, status, msg):
if not isinstance(trange, dict):
status = False
msg = "The time_range parameter for " "wtmp beacon must " "be a dictionary."
msg = "The time_range parameter for wtmp beacon must be a dictionary."
if not all(k in trange for k in ("start", "end")):
status = False
msg = (
"The time_range parameter for "
"wtmp beacon must contain "
"start & end options."
"The time_range parameter for wtmp beacon must contain start & end options."
)
return status, msg
@ -239,7 +237,7 @@ def validate(config):
if "users" in _config:
if not isinstance(_config["users"], dict):
vstatus = False
vmsg = "User configuration for wtmp beacon must " "be a dictionary."
vmsg = "User configuration for wtmp beacon must be a dictionary."
else:
for user in _config["users"]:
_time_range = _config["users"][user].get("time_range", {})
@ -251,7 +249,7 @@ def validate(config):
if "groups" in _config:
if not isinstance(_config["groups"], dict):
vstatus = False
vmsg = "Group configuration for wtmp beacon must " "be a dictionary."
vmsg = "Group configuration for wtmp beacon must be a dictionary."
else:
for group in _config["groups"]:
_time_range = _config["groups"][group].get("time_range", {})
@ -262,7 +260,7 @@ def validate(config):
if "defaults" in _config:
if not isinstance(_config["defaults"], dict):
vstatus = False
vmsg = "Defaults configuration for wtmp beacon must " "be a dictionary."
vmsg = "Defaults configuration for wtmp beacon must be a dictionary."
else:
_time_range = _config["defaults"].get("time_range", {})
vstatus, vmsg = _validate_time_range(_time_range, vstatus, vmsg)

View file

@ -293,7 +293,7 @@ def list_nodes_full(call=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes_full function must be called with -f " "or --function."
"The list_nodes_full function must be called with -f or --function."
)
ret = {}
@ -914,7 +914,7 @@ def _get_node(name):
except KeyError:
attempts -= 1
log.debug(
"Failed to get the data for node '%s'. Remaining " "attempts: %s",
"Failed to get the data for node '%s'. Remaining attempts: %s",
name,
attempts,
)
@ -929,7 +929,7 @@ def show_image(kwargs, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The show_images function must be called with " "-f or --function"
"The show_images function must be called with -f or --function"
)
if not isinstance(kwargs, dict):
@ -976,7 +976,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](

View file

@ -131,7 +131,7 @@ def get_conn():
libcloud.security.VERIFY_SSL_CERT = False
except (ImportError, AttributeError):
raise SaltCloudSystemExit(
"Could not disable SSL certificate verification. " "Not loading module."
"Could not disable SSL certificate verification. Not loading module."
)
return driver(
@ -467,7 +467,7 @@ def destroy(name, conn=None, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](

View file

@ -351,7 +351,8 @@ def create(vm_):
kwargs["ssh_interface"] = ssh_interface
else:
raise SaltCloudConfigError(
"The DigitalOcean driver requires ssh_interface to be defined as 'public' or 'private'."
"The DigitalOcean driver requires ssh_interface to be defined as 'public'"
" or 'private'."
)
private_networking = config.get_cloud_config_value(
@ -444,7 +445,8 @@ def create(vm_):
dns_domain_name = vm_["name"].split(".")
if len(dns_domain_name) > 2:
log.debug(
"create_dns_record: inferring default dns_hostname, dns_domain from minion name as FQDN"
"create_dns_record: inferring default dns_hostname, dns_domain from"
" minion name as FQDN"
)
default_dns_hostname = ".".join(dns_domain_name[:-2])
default_dns_domain = ".".join(dns_domain_name[-2:])
@ -699,7 +701,7 @@ def _get_node(name):
except KeyError:
attempts -= 1
log.debug(
"Failed to get the data for node '%s'. Remaining " "attempts: %s",
"Failed to get the data for node '%s'. Remaining attempts: %s",
name,
attempts,
)
@ -861,7 +863,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](

View file

@ -309,9 +309,9 @@ def query(
if endpoint == "":
endpoint_err = (
"Could not find a valid endpoint in the "
"requesturl: {}. Looking for something "
"like https://some.ec2.endpoint/?args"
).format(requesturl)
"requesturl: {}. Looking for something like "
"https://some.ec2.endpoint/?args".format(requesturl)
)
log.error(endpoint_err)
if return_url is True:
return {"error": endpoint_err}, requesturl
@ -515,7 +515,7 @@ def _wait_for_spot_instance(
duration = timeout
while True:
log.debug(
"Waiting for spot instance reservation. Giving up in " "00:%02d:%02d",
"Waiting for spot instance reservation. Giving up in 00:%02d:%02d",
int(timeout // 60),
int(timeout % 60),
)
@ -547,7 +547,7 @@ def _wait_for_spot_instance(
interval *= interval_multiplier
if interval > timeout:
interval = timeout + 1
log.info("Interval multiplier in effect; interval is " "now %ss", interval)
log.info("Interval multiplier in effect; interval is now %ss", interval)
def avail_sizes(call=None):
@ -567,13 +567,13 @@ def avail_sizes(call=None):
"Cluster Compute": {
"cc2.8xlarge": {
"id": "cc2.8xlarge",
"cores": "16 (2 x Intel Xeon E5-2670, eight-core with " "hyperthread)",
"cores": "16 (2 x Intel Xeon E5-2670, eight-core with hyperthread)",
"disk": "3360 GiB (4 x 840 GiB)",
"ram": "60.5 GiB",
},
"cc1.4xlarge": {
"id": "cc1.4xlarge",
"cores": "8 (2 x Intel Xeon X5570, quad-core with " "hyperthread)",
"cores": "8 (2 x Intel Xeon X5570, quad-core with hyperthread)",
"disk": "1690 GiB (2 x 840 GiB)",
"ram": "22.5 GiB",
},
@ -581,8 +581,10 @@ def avail_sizes(call=None):
"Cluster CPU": {
"cg1.4xlarge": {
"id": "cg1.4xlarge",
"cores": "8 (2 x Intel Xeon X5570, quad-core with "
"hyperthread), plus 2 NVIDIA Tesla M2050 GPUs",
"cores": (
"8 (2 x Intel Xeon X5570, quad-core with "
"hyperthread), plus 2 NVIDIA Tesla M2050 GPUs"
),
"disk": "1680 GiB (2 x 840 GiB)",
"ram": "22.5 GiB",
},
@ -1153,15 +1155,17 @@ def get_availability_zone(vm_):
# Validate user-specified AZ
if avz not in zones:
raise SaltCloudException(
"The specified availability zone isn't valid in this region: "
"{}\n".format(avz)
"The specified availability zone isn't valid in this region: {}\n".format(
avz
)
)
# check specified AZ is available
elif zones[avz] != "available":
raise SaltCloudException(
"The specified availability zone isn't currently available: "
"{}\n".format(avz)
"The specified availability zone isn't currently available: {}\n".format(
avz
)
)
return avz
@ -1785,8 +1789,9 @@ def request_instance(vm_=None, call=None):
if spot_config is not None:
if "spot_price" not in spot_config:
raise SaltCloudSystemExit(
"Spot instance config for {} requires a spot_price "
"attribute.".format(vm_["name"])
"Spot instance config for {} requires a spot_price attribute.".format(
vm_["name"]
)
)
params = {
@ -1974,7 +1979,7 @@ def request_instance(vm_=None, call=None):
# use different device identifiers
log.info(
"Attempting to look up root device name for image id %s on " "VM %s",
"Attempting to look up root device name for image id %s on VM %s",
image_id,
vm_["name"],
)
@ -1993,7 +1998,7 @@ def request_instance(vm_=None, call=None):
log.debug("EC2 Response: '%s'", rd_data)
except Exception as exc: # pylint: disable=broad-except
log.error(
"Error getting root device name for image id %s for " "VM %s: \n%s",
"Error getting root device name for image id %s for VM %s: \n%s",
image_id,
vm_["name"],
exc,
@ -2099,8 +2104,7 @@ def request_instance(vm_=None, call=None):
return data["error"]
except Exception as exc: # pylint: disable=broad-except
log.error(
"Error creating %s on EC2 when trying to run the initial "
"deployment: \n%s",
"Error creating %s on EC2 when trying to run the initial deployment: \n%s",
vm_["name"],
exc,
# Show the traceback if the debug logging level is enabled
@ -2196,7 +2200,7 @@ def request_instance(vm_=None, call=None):
)
log.debug(
"Canceled spot instance request %s. Data " "returned: %s",
"Canceled spot instance request %s. Data returned: %s",
sir_id,
data,
)
@ -2251,13 +2255,13 @@ def query_instance(vm_=None, call=None):
if isinstance(data, dict) and "error" in data:
log.warning(
"There was an error in the query. %s attempts " "remaining: %s",
"There was an error in the query. %s attempts remaining: %s",
attempts,
data["error"],
)
elif isinstance(data, list) and not data:
log.warning(
"Query returned an empty list. %s attempts " "remaining.", attempts
"Query returned an empty list. %s attempts remaining.", attempts
)
else:
break
@ -2961,7 +2965,7 @@ def create_attach_volumes(name, kwargs, call=None, wait_to_finish=True):
"""
if call != "action":
raise SaltCloudSystemExit(
"The create_attach_volumes action must be called with " "-a or --action."
"The create_attach_volumes action must be called with -a or --action."
)
if "instance_id" not in kwargs:
@ -3338,7 +3342,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
node_metadata = _get_node(name)
@ -3375,7 +3379,7 @@ def destroy(name, call=None):
newname = "{}-DEL{}".format(name, uuid.uuid4().hex)
rename(name, kwargs={"newname": newname}, call="action")
log.info(
"Machine will be identified as %s until it has been " "cleaned up.", newname
"Machine will be identified as %s until it has been cleaned up.", newname
)
ret["newname"] = newname
@ -3498,7 +3502,7 @@ def show_instance(name=None, instance_id=None, call=None, kwargs=None):
if not name and not instance_id:
raise SaltCloudSystemExit(
"The show_instance function requires " "either a name or an instance_id"
"The show_instance function requires either a name or an instance_id"
)
node = _get_node(name=name, instance_id=instance_id)
@ -3536,7 +3540,7 @@ def _get_node(name=None, instance_id=None, location=None):
except IndexError:
attempts += 1
log.debug(
"Failed to get the data for node '%s'. Remaining " "attempts: %s",
"Failed to get the data for node '%s'. Remaining attempts: %s",
instance_id or name,
attempts,
)
@ -3550,7 +3554,7 @@ def list_nodes_full(location=None, call=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes_full function must be called with -f " "or --function."
"The list_nodes_full function must be called with -f or --function."
)
return _list_nodes_full(location or get_location())
@ -3773,8 +3777,8 @@ def show_detailed_monitoring(name=None, instance_id=None, call=None, quiet=False
if not name and not instance_id:
raise SaltCloudSystemExit(
"The show_detailed_monitoring action must be provided with a name or instance\
ID"
"The show_detailed_monitoring action must be provided with a name or"
" instance ID"
)
matched = _get_node(name=name, instance_id=instance_id, location=location)
log.log(
@ -3822,7 +3826,7 @@ def enable_term_protect(name, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The enable_term_protect action must be called with " "-a or --action."
"The enable_term_protect action must be called with -a or --action."
)
return _toggle_term_protect(name, "true")
@ -3840,7 +3844,7 @@ def disable_term_protect(name, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The enable_term_protect action must be called with " "-a or --action."
"The enable_term_protect action must be called with -a or --action."
)
return _toggle_term_protect(name, "false")
@ -3852,7 +3856,7 @@ def disable_detailed_monitoring(name, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The enable_term_protect action must be called with " "-a or --action."
"The enable_term_protect action must be called with -a or --action."
)
instance_id = _get_node(name)["instanceId"]
@ -3876,7 +3880,7 @@ def enable_detailed_monitoring(name, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The enable_term_protect action must be called with " "-a or --action."
"The enable_term_protect action must be called with -a or --action."
)
instance_id = _get_node(name)["instanceId"]
@ -3907,7 +3911,7 @@ def show_delvol_on_destroy(name, kwargs=None, call=None):
if call != "action":
raise SaltCloudSystemExit(
"The show_delvol_on_destroy action must be called " "with -a or --action."
"The show_delvol_on_destroy action must be called with -a or --action."
)
if not kwargs:
@ -4091,12 +4095,14 @@ def register_image(kwargs=None, call=None):
if not block_device_mapping:
if "snapshot_id" not in kwargs:
log.error(
"snapshot_id or block_device_mapping must be specified to register an image."
"snapshot_id or block_device_mapping must be specified to register an"
" image."
)
return False
if "root_device_name" not in kwargs:
log.error(
"root_device_name or block_device_mapping must be specified to register an image."
"root_device_name or block_device_mapping must be specified to register"
" an image."
)
return False
block_device_mapping = [
@ -4459,9 +4465,7 @@ def describe_volumes(kwargs=None, call=None):
TODO: Add all of the filters.
"""
if call != "function":
log.error(
"The describe_volumes function must be called with -f " "or --function."
)
log.error("The describe_volumes function must be called with -f or --function.")
return False
if not kwargs:
@ -4634,7 +4638,7 @@ def create_snapshot(kwargs=None, call=None, wait_to_finish=False):
"""
if call != "function":
raise SaltCloudSystemExit(
"The create_snapshot function must be called with -f " "or --function."
"The create_snapshot function must be called with -f or --function."
)
if kwargs is None:
@ -4690,9 +4694,7 @@ def delete_snapshot(kwargs=None, call=None):
Delete a snapshot
"""
if call != "function":
log.error(
"The delete_snapshot function must be called with -f " "or --function."
)
log.error("The delete_snapshot function must be called with -f or --function.")
return False
if "snapshot_id" not in kwargs:
@ -4780,7 +4782,7 @@ def describe_snapshots(kwargs=None, call=None):
"""
if call != "function":
log.error(
"The describe_snapshot function must be called with -f " "or --function."
"The describe_snapshot function must be called with -f or --function."
)
return False
@ -4833,7 +4835,7 @@ def get_console_output(
"""
if call != "action":
raise SaltCloudSystemExit(
"The get_console_output action must be called with " "-a or --action."
"The get_console_output action must be called with -a or --action."
)
if location is None:
@ -4899,7 +4901,7 @@ def get_password_data(
"""
if call != "action":
raise SaltCloudSystemExit(
"The get_password_data action must be called with " "-a or --action."
"The get_password_data action must be called with -a or --action."
)
if not instance_id:
@ -5107,8 +5109,10 @@ def show_pricing(kwargs=None, call=None):
raw = ec2_price[region][size]
except KeyError:
return {
"Error": "The size ({}) in the requested profile does not have "
"a price associated with it for the {} region".format(size, region)
"Error": (
"The size ({}) in the requested profile does not have "
"a price associated with it for the {} region".format(size, region)
)
}
ret = {}
@ -5143,7 +5147,7 @@ def ssm_create_association(name=None, kwargs=None, instance_id=None, call=None):
if call != "action":
raise SaltCloudSystemExit(
"The ssm_create_association action must be called with " "-a or --action."
"The ssm_create_association action must be called with -a or --action."
)
if not kwargs:
@ -5196,7 +5200,7 @@ def ssm_describe_association(name=None, kwargs=None, instance_id=None, call=None
"""
if call != "action":
raise SaltCloudSystemExit(
"The ssm_describe_association action must be called with " "-a or --action."
"The ssm_describe_association action must be called with -a or --action."
)
if not kwargs:

View file

@ -2260,7 +2260,7 @@ def create_attach_volumes(name, kwargs, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The create_attach_volumes action must be called with " "-a or --action."
"The create_attach_volumes action must be called with -a or --action."
)
volumes = literal_eval(kwargs["volumes"])
@ -2294,8 +2294,8 @@ def request_instance(vm_):
"""
if not GCE_VM_NAME_REGEX.match(vm_["name"]):
raise SaltCloudSystemExit(
"VM names must start with a letter, only contain letters, numbers, or dashes "
"and cannot end in a dash."
"VM names must start with a letter, only contain letters, numbers, or"
" dashes and cannot end in a dash."
)
try:

View file

@ -411,7 +411,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](

View file

@ -107,7 +107,7 @@ def _connect_client():
def avail_locations(call=None):
if call == "action":
raise SaltCloudSystemExit(
"The list_locations function must be called with " "-f or --function"
"The list_locations function must be called with -f or --function"
)
client = _connect_client()
@ -120,7 +120,7 @@ def avail_locations(call=None):
def avail_images(call=None):
if call == "action":
raise SaltCloudSystemExit(
"The avail_images function must be called with " "-f or --function"
"The avail_images function must be called with -f or --function"
)
client = _connect_client()
@ -133,7 +133,7 @@ def avail_images(call=None):
def avail_sizes(call=None):
if call == "action":
raise SaltCloudSystemExit(
"The avail_sizes function must be called with " "-f or --function"
"The avail_sizes function must be called with -f or --function"
)
client = _connect_client()
@ -146,7 +146,7 @@ def avail_sizes(call=None):
def list_ssh_keys(call=None):
if call == "action":
raise SaltCloudSystemExit(
"The list_ssh_keys function must be called with " "-f or --function"
"The list_ssh_keys function must be called with -f or --function"
)
client = _connect_client()
@ -159,7 +159,7 @@ def list_ssh_keys(call=None):
def list_nodes_full(call=None):
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes_full function must be called with " "-f or --function"
"The list_nodes_full function must be called with -f or --function"
)
client = _connect_client()
@ -184,7 +184,7 @@ def list_nodes_full(call=None):
def list_nodes(call=None):
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes function must be called with " "-f or --function"
"The list_nodes function must be called with -f or --function"
)
ret = {}
@ -215,7 +215,7 @@ def wait_until(name, state, timeout=300):
def show_instance(name, call=None):
if call == "action":
raise SaltCloudSystemExit(
"The show_instance function must be called with " "-f or --function"
"The show_instance function must be called with -f or --function"
)
try:
@ -476,7 +476,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
client = _connect_client()

View file

@ -413,7 +413,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](
@ -1091,7 +1091,8 @@ def query(action=None, command=None, args=None, method="GET", location=None, dat
if not user:
log.error(
"username is required for Joyent API requests. Please set one in your provider configuration"
"username is required for Joyent API requests. Please set one in your"
" provider configuration"
)
password = config.get_cloud_config_value(
@ -1116,7 +1117,8 @@ def query(action=None, command=None, args=None, method="GET", location=None, dat
if not ssh_keyfile:
log.error(
"ssh_keyfile is required for Joyent API requests. Please set one in your provider configuration"
"ssh_keyfile is required for Joyent API requests. Please set one in your"
" provider configuration"
)
ssh_keyname = config.get_cloud_config_value(
@ -1129,7 +1131,8 @@ def query(action=None, command=None, args=None, method="GET", location=None, dat
if not ssh_keyname:
log.error(
"ssh_keyname is required for Joyent API requests. Please set one in your provider configuration"
"ssh_keyname is required for Joyent API requests. Please set one in your"
" provider configuration"
)
if not location:

View file

@ -176,7 +176,7 @@ def list_nodes(call=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes function must be called " "with -f or --function."
"The list_nodes function must be called with -f or --function."
)
providers = __opts__.get("providers", {})
@ -212,7 +212,7 @@ def list_nodes_full(call=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes_full function must be called " "with -f or --function."
"The list_nodes_full function must be called with -f or --function."
)
return list_nodes(call)
@ -224,7 +224,7 @@ def list_nodes_select(call=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes_select function must be called " "with -f or --function."
"The list_nodes_select function must be called with -f or --function."
)
selection = __opts__.get("query.selection")
@ -598,7 +598,7 @@ def destroy(name, call=None):
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
found = []

View file

@ -392,7 +392,8 @@ def _warn_for_api_v3():
log.warning(
"Linode APIv3 has been deprecated and support will be removed "
"in future releases. Please plan to upgrade to APIv4. For more "
"information, see https://docs.saltstack.com/en/latest/topics/cloud/linode.html#migrating-to-apiv4."
"information, see"
" https://docs.saltstack.com/en/latest/topics/cloud/linode.html#migrating-to-apiv4."
)
HAS_WARNED_FOR_API_V3 = True
@ -1422,8 +1423,7 @@ class LinodeAPIv3(LinodeAPI):
node_id, status=(self._get_status_id_by_name("brand_new"))
):
log.error(
"Error creating %s on LINODE\n\n"
"while waiting for initial ready status",
"Error creating %s on LINODE\n\nwhile waiting for initial ready status",
name,
exc_info_on_loglevel=logging.DEBUG,
)
@ -1703,18 +1703,16 @@ class LinodeAPIv3(LinodeAPI):
if label not in sizes:
if "GB" in label:
raise SaltCloudException(
"Invalid Linode plan ({}) specified - call avail_sizes() for all available options".format(
label
)
"Invalid Linode plan ({}) specified - call avail_sizes() for all"
" available options".format(label)
)
else:
plan = label.split()
if len(plan) != 2:
raise SaltCloudException(
"Invalid Linode plan ({}) specified - call avail_sizes() for all available options".format(
label
)
"Invalid Linode plan ({}) specified - call avail_sizes() for"
" all available options".format(label)
)
plan_type = plan[0]
@ -1734,9 +1732,8 @@ class LinodeAPIv3(LinodeAPI):
if new_label not in sizes:
raise SaltCloudException(
"Invalid Linode plan ({}) specified - call avail_sizes() for all available options".format(
new_label
)
"Invalid Linode plan ({}) specified - call avail_sizes() for"
" all available options".format(new_label)
)
log.warning(
@ -1809,9 +1806,9 @@ class LinodeAPIv3(LinodeAPI):
if not distro_id:
raise SaltCloudNotFound(
"The DistributionID for the '{}' profile could not be found.\n"
"The '{}' instance could not be provisioned. The following distributions "
"are available:\n{}".format(
"The DistributionID for the '{}' profile could not be found.\nThe '{}'"
" instance could not be provisioned. The following distributions are"
" available:\n{}".format(
vm_image_name,
vm_["name"],
pprint.pprint(
@ -2355,7 +2352,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudException(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
return _get_cloud_interface().destroy(name)

View file

@ -343,9 +343,7 @@ last message: {comment}""".format(
keys = list(ret["changes"].items())
keys.sort()
for ch, comment in keys:
sret += ("\n" " {}:\n" " {}").format(
ch, comment.replace("\n", "\n" " ")
)
sret += "\n {}:\n {}".format(ch, comment.replace("\n", "\n "))
if not ret["result"]:
if "changes" in ret:
del ret["changes"]
@ -365,7 +363,7 @@ def destroy(vm_, call=None):
action = __opts__.get("action", "")
if action != "destroy" and not destroy_opt:
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
if not get_configured_provider():
return

View file

@ -425,7 +425,7 @@ def list_nodes_full(conn=None, call=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes_full function must be called with -f or " "--function."
"The list_nodes_full function must be called with -f or --function."
)
if not conn:
@ -735,7 +735,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](

View file

@ -895,10 +895,7 @@ def _get_device_template(disk, disk_info, template=None):
for arg in args:
if arg not in disk_info:
raise SaltCloudSystemExit(
"The disk {} requires a {}\
argument".format(
disk, arg
)
"The disk {} requires a {} argument".format(disk, arg)
)
_require_disk_opts("disk_type", "size")
@ -913,8 +910,7 @@ def _get_device_template(disk, disk_info, template=None):
clone_image = get_template_image(kwargs={"name": template})
clone_image_id = get_image_id(kwargs={"name": clone_image})
temp = "DISK=[IMAGE={}, IMAGE_ID={}, CLONE=YES,\
SIZE={}]".format(
temp = "DISK=[IMAGE={}, IMAGE_ID={}, CLONE=YES, SIZE={}]".format(
clone_image, clone_image_id, size
)
return temp
@ -1030,7 +1026,8 @@ def create(vm_):
)
if "CLONE" not in str(template):
raise SaltCloudSystemExit(
"Missing an image disk to clone. Must define a clone disk alongside all other disk definitions."
"Missing an image disk to clone. Must define a clone disk alongside all"
" other disk definitions."
)
template_args = "\n".join(template)
@ -1174,7 +1171,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](
@ -1596,7 +1593,8 @@ def image_snapshot_delete(call=None, kwargs=None):
if snapshot_id is None:
raise SaltCloudSystemExit(
"The image_snapshot_delete function requires a 'snapshot_id' to be provided."
"The image_snapshot_delete function requires a 'snapshot_id' to be"
" provided."
)
if image_id:
@ -1663,7 +1661,8 @@ def image_snapshot_revert(call=None, kwargs=None):
if snapshot_id is None:
raise SaltCloudSystemExit(
"The image_snapshot_revert function requires a 'snapshot_id' to be provided."
"The image_snapshot_revert function requires a 'snapshot_id' to be"
" provided."
)
if image_id:
@ -3212,8 +3211,8 @@ def vm_disk_snapshot_create(name, kwargs=None, call=None):
if disk_id is None or description is None:
raise SaltCloudSystemExit(
"The vm_disk_snapshot_create function requires a 'disk_id' and a 'description' "
"to be provided."
"The vm_disk_snapshot_create function requires a 'disk_id' and a"
" 'description' to be provided."
)
server, user, password = _get_xml_rpc()
@ -3265,8 +3264,8 @@ def vm_disk_snapshot_delete(name, kwargs=None, call=None):
if disk_id is None or snapshot_id is None:
raise SaltCloudSystemExit(
"The vm_disk_snapshot_create function requires a 'disk_id' and a 'snapshot_id' "
"to be provided."
"The vm_disk_snapshot_create function requires a 'disk_id' and a"
" 'snapshot_id' to be provided."
)
server, user, password = _get_xml_rpc()
@ -3320,8 +3319,8 @@ def vm_disk_snapshot_revert(name, kwargs=None, call=None):
if disk_id is None or snapshot_id is None:
raise SaltCloudSystemExit(
"The vm_disk_snapshot_revert function requires a 'disk_id' and a 'snapshot_id' "
"to be provided."
"The vm_disk_snapshot_revert function requires a 'disk_id' and a"
" 'snapshot_id' to be provided."
)
server, user, password = _get_xml_rpc()
@ -3513,8 +3512,7 @@ def vm_monitoring(name, call=None):
if response[0] is False:
log.error(
"There was an error retrieving the specified VM's monitoring "
"information."
"There was an error retrieving the specified VM's monitoring information."
)
return {}
else:
@ -3882,8 +3880,7 @@ def vn_add_ar(call=None, kwargs=None):
vn_id = get_vn_id(kwargs={"name": vn_name})
else:
raise SaltCloudSystemExit(
"The vn_add_ar function requires a 'vn_id' and a 'vn_name' to "
"be provided."
"The vn_add_ar function requires a 'vn_id' and a 'vn_name' to be provided."
)
if data:
@ -4040,7 +4037,7 @@ def vn_delete(call=None, kwargs=None):
vn_id = get_vn_id(kwargs={"name": name})
else:
raise SaltCloudSystemExit(
"The vn_delete function requires a 'name' or a 'vn_id' " "to be provided."
"The vn_delete function requires a 'name' or a 'vn_id' to be provided."
)
server, user, password = _get_xml_rpc()
@ -4108,8 +4105,7 @@ def vn_free_ar(call=None, kwargs=None):
vn_id = get_vn_id(kwargs={"name": vn_name})
else:
raise SaltCloudSystemExit(
"The vn_free_ar function requires a 'vn_id' or a 'vn_name' to "
"be provided."
"The vn_free_ar function requires a 'vn_id' or a 'vn_name' to be provided."
)
server, user, password = _get_xml_rpc()
@ -4179,7 +4175,7 @@ def vn_hold(call=None, kwargs=None):
vn_id = get_vn_id(kwargs={"name": vn_name})
else:
raise SaltCloudSystemExit(
"The vn_hold function requires a 'vn_id' or a 'vn_name' to " "be provided."
"The vn_hold function requires a 'vn_id' or a 'vn_name' to be provided."
)
if data:
@ -4193,7 +4189,7 @@ def vn_hold(call=None, kwargs=None):
data = rfh.read()
else:
raise SaltCloudSystemExit(
"The vn_hold function requires either 'data' or a 'path' to " "be provided."
"The vn_hold function requires either 'data' or a 'path' to be provided."
)
server, user, password = _get_xml_rpc()
@ -4252,8 +4248,7 @@ def vn_info(call=None, kwargs=None):
vn_id = get_vn_id(kwargs={"name": name})
else:
raise SaltCloudSystemExit(
"The vn_info function requires either a 'name' or a 'vn_id' "
"to be provided."
"The vn_info function requires either a 'name' or a 'vn_id' to be provided."
)
server, user, password = _get_xml_rpc()
@ -4322,8 +4317,7 @@ def vn_release(call=None, kwargs=None):
vn_id = get_vn_id(kwargs={"name": vn_name})
else:
raise SaltCloudSystemExit(
"The vn_release function requires a 'vn_id' or a 'vn_name' to "
"be provided."
"The vn_release function requires a 'vn_id' or a 'vn_name' to be provided."
)
if data:
@ -4337,8 +4331,7 @@ def vn_release(call=None, kwargs=None):
data = rfh.read()
else:
raise SaltCloudSystemExit(
"The vn_release function requires either 'data' or a 'path' to "
"be provided."
"The vn_release function requires either 'data' or a 'path' to be provided."
)
server, user, password = _get_xml_rpc()
@ -4409,8 +4402,7 @@ def vn_reserve(call=None, kwargs=None):
vn_id = get_vn_id(kwargs={"name": vn_name})
else:
raise SaltCloudSystemExit(
"The vn_reserve function requires a 'vn_id' or a 'vn_name' to "
"be provided."
"The vn_reserve function requires a 'vn_id' or a 'vn_name' to be provided."
)
if data:
@ -4459,7 +4451,7 @@ def _get_node(name):
except KeyError:
attempts -= 1
log.debug(
"Failed to get the data for node '%s'. Remaining " "attempts: %s",
"Failed to get the data for node '%s'. Remaining attempts: %s",
name,
attempts,
)

View file

@ -608,7 +608,7 @@ def list_networks(conn=None, call=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_networks function must be called with " "-f or --function"
"The list_networks function must be called with -f or --function"
)
if conn is None:
conn = get_conn()
@ -629,7 +629,7 @@ def list_subnets(conn=None, call=None, kwargs=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_subnets function must be called with " "-f or --function."
"The list_subnets function must be called with -f or --function."
)
if conn is None:
conn = get_conn()
@ -841,7 +841,7 @@ def destroy(name, conn=None, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](
@ -901,7 +901,7 @@ def call(conn=None, call=None, kwargs=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The call function must be called with " "-f or --function."
"The call function must be called with -f or --function."
)
if "func" not in kwargs:

View file

@ -375,7 +375,7 @@ def create(vm_):
if device.state != "active":
log.error(
"Error creating %s on PACKET\n\n" "while waiting for initial ready status",
"Error creating %s on PACKET\n\nwhile waiting for initial ready status",
name,
exc_info_on_loglevel=logging.DEBUG,
)
@ -427,8 +427,7 @@ def create(vm_):
if volume.state != "active":
log.error(
"Error creating %s on PACKET\n\n"
"while waiting for initial ready status",
"Error creating %s on PACKET\n\nwhile waiting for initial ready status",
name,
exc_info_on_loglevel=logging.DEBUG,
)
@ -575,7 +574,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudException(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](

View file

@ -520,7 +520,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](

View file

@ -258,13 +258,12 @@ def list_images(call=None, kwargs=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_images function must be called with " "-f or --function."
"The list_images function must be called with -f or --function."
)
if not version_compatible("4.0"):
raise SaltCloudNotFound(
"The 'image_alias' feature requires the profitbricks "
"SDK v4.0.0 or greater."
"The 'image_alias' feature requires the profitbricks SDK v4.0.0 or greater."
)
ret = {}
@ -506,7 +505,7 @@ def list_datacenters(conn=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_datacenters function must be called with " "-f or --function."
"The list_datacenters function must be called with -f or --function."
)
datacenters = []
@ -540,7 +539,7 @@ def list_nodes(conn=None, call=None):
try:
nodes = conn.list_servers(datacenter_id=datacenter_id)
except PBNotFoundError:
log.error("Failed to get nodes list " "from datacenter: %s", datacenter_id)
log.error("Failed to get nodes list from datacenter: %s", datacenter_id)
raise
for item in nodes["items"]:
@ -558,7 +557,7 @@ def list_nodes_full(conn=None, call=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes_full function must be called with -f or " "--function."
"The list_nodes_full function must be called with -f or --function."
)
if not conn:
@ -599,7 +598,7 @@ def reserve_ipblock(call=None, kwargs=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The reserve_ipblock function must be called with -f or " "--function."
"The reserve_ipblock function must be called with -f or --function."
)
conn = get_conn()
@ -936,7 +935,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](

View file

@ -314,7 +314,7 @@ def get_resources_nodes(call=None, resFilter=None):
ret[name] = resource
if resFilter is not None:
log.debug("Filter given: %s, returning requested " "resource: nodes", resFilter)
log.debug("Filter given: %s, returning requested resource: nodes", resFilter)
return ret[resFilter]
log.debug("Filter not given: %s, returning all resource: nodes", ret)
@ -355,9 +355,7 @@ def get_resources_vms(call=None, resFilter=None, includeConfig=True):
)
if time.time() > timeoutTime:
raise SaltCloudExecutionTimeout(
"FAILED to get the proxmox " "resources vms"
)
raise SaltCloudExecutionTimeout("FAILED to get the proxmox resources vms")
# Carry on if there wasn't a bad resource return from Proxmox
if not badResource:
@ -366,7 +364,7 @@ def get_resources_vms(call=None, resFilter=None, includeConfig=True):
time.sleep(0.5)
if resFilter is not None:
log.debug("Filter given: %s, returning requested " "resource: nodes", resFilter)
log.debug("Filter given: %s, returning requested resource: nodes", resFilter)
return ret[resFilter]
log.debug("Filter not given: %s, returning all resource: nodes", ret)
@ -803,7 +801,8 @@ def create_node(vm_, newid):
if vm_["technology"] not in ["qemu", "openvz", "lxc"]:
# Wrong VM type given
log.error(
"Wrong VM type. Valid options are: qemu, openvz (proxmox3) or lxc (proxmox4)"
"Wrong VM type. Valid options are: qemu, openvz (proxmox3) or lxc"
" (proxmox4)"
)
raise SaltCloudExecutionFailure
@ -989,8 +988,7 @@ def wait_for_created(upid, timeout=300):
info = _lookup_proxmox_task(upid)
if not info:
log.error(
"wait_for_created: No task information "
"retrieved based on given criteria."
"wait_for_created: No task information retrieved based on given criteria."
)
raise SaltCloudExecutionFailure
@ -1043,7 +1041,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](

View file

@ -339,7 +339,7 @@ def show_image(kwargs, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The show_images function must be called with " "-f or --function"
"The show_images function must be called with -f or --function"
)
if not isinstance(kwargs, dict):
@ -869,7 +869,7 @@ def destroy(instance_id, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
instance_data = show_instance(instance_id, call="action")

View file

@ -413,7 +413,7 @@ def _get_node(name):
return list_nodes_full()[name]
except KeyError:
log.debug(
"Failed to get the data for node '%s'. Remaining " "attempts: %s",
"Failed to get the data for node '%s'. Remaining attempts: %s",
name,
attempt,
)
@ -433,7 +433,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](

View file

@ -614,7 +614,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](

View file

@ -418,8 +418,7 @@ def create(vm_):
def list_nodes_full(
mask="mask[id, hostname, primaryIpAddress, \
primaryBackendIpAddress, processorPhysicalCoreAmount, memoryCount]",
mask="mask[id, hostname, primaryIpAddress, primaryBackendIpAddress, processorPhysicalCoreAmount, memoryCount]",
call=None,
):
"""
@ -509,7 +508,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](

View file

@ -292,7 +292,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a, or --action."
"The destroy action must be called with -d, --destroy, -a, or --action."
)
opts = __opts__

View file

@ -71,7 +71,8 @@ def __virtual__():
if get_configured_provider() is False:
return (
False,
"The virtualbox driver cannot be loaded: 'virtualbox' provider is not configured.",
"The virtualbox driver cannot be loaded: 'virtualbox' provider is not"
" configured.",
)
# If the name of the driver used does not match the filename,
@ -271,7 +272,7 @@ def list_nodes_full(kwargs=None, call=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes_full function must be called " "with -f or --function."
"The list_nodes_full function must be called with -f or --function."
)
machines = {}
@ -316,7 +317,7 @@ def list_nodes(kwargs=None, call=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes function must be called " "with -f or --function."
"The list_nodes function must be called with -f or --function."
)
attributes = [

View file

@ -327,9 +327,8 @@ def _add_new_hard_disk_helper(
if not datastore_cluster_ref:
# datastore/datastore cluster specified does not exist
raise SaltCloudSystemExit(
"Specified datastore/datastore cluster ({}) for disk ({}) does not exist".format(
datastore, disk_label
)
"Specified datastore/datastore cluster ({}) for disk ({}) does not"
" exist".format(datastore, disk_label)
)
# datastore cluster has been specified
@ -358,9 +357,8 @@ def _add_new_hard_disk_helper(
if not datastore_ref:
# datastore cluster specified does not have any accessible datastores
raise SaltCloudSystemExit(
"Specified datastore cluster ({}) for disk ({}) does not have any accessible datastores available".format(
datastore, disk_label
)
"Specified datastore cluster ({}) for disk ({}) does not have any"
" accessible datastores available".format(datastore, disk_label)
)
datastore_path = "[" + str(datastore_ref.name) + "] " + vm_name
@ -857,7 +855,7 @@ def _manage_devices(devices, vm=None, container_ref=None, new_vm_name=None):
disk_spec = _get_mode_spec(device, mode, disk_spec)
else:
raise SaltCloudSystemExit(
"Invalid disk" " backing mode" " specified!"
"Invalid disk backing mode specified!"
)
if disk_spec is not None:
device_specs.append(disk_spec)
@ -1225,7 +1223,7 @@ def _wait_for_ip(vm_ref, max_wait):
vm_name = vm_ref.summary.config.name
resolved_ips = salt.utils.network.host_to_ips(vm_name)
log.debug(
"Timeout waiting for VMware tools. The name %s resolved " "to %s",
"Timeout waiting for VMware tools. The name %s resolved to %s",
vm_name,
resolved_ips,
)
@ -1754,8 +1752,7 @@ def test_vcenter_connection(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The test_vcenter_connection function must be called with "
"-f or --function."
"The test_vcenter_connection function must be called with -f or --function."
)
try:
@ -1779,7 +1776,7 @@ def get_vcenter_version(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The get_vcenter_version function must be called with " "-f or --function."
"The get_vcenter_version function must be called with -f or --function."
)
# Get the inventory
@ -1800,7 +1797,7 @@ def list_datacenters(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_datacenters function must be called with " "-f or --function."
"The list_datacenters function must be called with -f or --function."
)
return {"Datacenters": salt.utils.vmware.list_datacenters(_get_si())}
@ -1818,7 +1815,7 @@ def list_portgroups(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_portgroups function must be called with " "-f or --function."
"The list_portgroups function must be called with -f or --function."
)
return {"Portgroups": salt.utils.vmware.list_portgroups(_get_si())}
@ -1836,7 +1833,7 @@ def list_clusters(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_clusters function must be called with " "-f or --function."
"The list_clusters function must be called with -f or --function."
)
return {"Clusters": salt.utils.vmware.list_clusters(_get_si())}
@ -1854,8 +1851,7 @@ def list_datastore_clusters(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_datastore_clusters function must be called with "
"-f or --function."
"The list_datastore_clusters function must be called with -f or --function."
)
return {"Datastore Clusters": salt.utils.vmware.list_datastore_clusters(_get_si())}
@ -1873,7 +1869,7 @@ def list_datastores(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_datastores function must be called with " "-f or --function."
"The list_datastores function must be called with -f or --function."
)
return {"Datastores": salt.utils.vmware.list_datastores(_get_si())}
@ -1891,7 +1887,7 @@ def list_hosts(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_hosts function must be called with " "-f or --function."
"The list_hosts function must be called with -f or --function."
)
return {"Hosts": salt.utils.vmware.list_hosts(_get_si())}
@ -1909,7 +1905,7 @@ def list_resourcepools(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_resourcepools function must be called with " "-f or --function."
"The list_resourcepools function must be called with -f or --function."
)
return {"Resource Pools": salt.utils.vmware.list_resourcepools(_get_si())}
@ -1927,7 +1923,7 @@ def list_networks(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_networks function must be called with " "-f or --function."
"The list_networks function must be called with -f or --function."
)
return {"Networks": salt.utils.vmware.list_networks(_get_si())}
@ -1945,7 +1941,7 @@ def list_nodes_min(kwargs=None, call=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes_min function must be called " "with -f or --function."
"The list_nodes_min function must be called with -f or --function."
)
ret = {}
@ -1982,7 +1978,7 @@ def list_nodes(kwargs=None, call=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes function must be called " "with -f or --function."
"The list_nodes function must be called with -f or --function."
)
ret = {}
@ -2045,7 +2041,7 @@ def list_nodes_full(kwargs=None, call=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes_full function must be called " "with -f or --function."
"The list_nodes_full function must be called with -f or --function."
)
ret = {}
@ -2098,7 +2094,7 @@ def list_nodes_select(call=None):
"""
if call == "action":
raise SaltCloudSystemExit(
"The list_nodes_select function must be called " "with -f or --function."
"The list_nodes_select function must be called with -f or --function."
)
ret = {}
@ -2181,7 +2177,7 @@ def show_instance(name, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The show_instance action must be called with " "-a or --action."
"The show_instance action must be called with -a or --action."
)
vm_properties = [
@ -2321,7 +2317,7 @@ def list_templates(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_templates function must be called with " "-f or --function."
"The list_templates function must be called with -f or --function."
)
return {"Templates": avail_images(call="function")}
@ -2339,7 +2335,7 @@ def list_folders(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_folders function must be called with " "-f or --function."
"The list_folders function must be called with -f or --function."
)
return {"Folders": salt.utils.vmware.list_folders(_get_si())}
@ -2368,7 +2364,7 @@ def list_snapshots(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_snapshots function must be called with " "-f or --function."
"The list_snapshots function must be called with -f or --function."
)
ret = {}
@ -2403,7 +2399,7 @@ def start(name, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The start action must be called with " "-a or --action."
"The start action must be called with -a or --action."
)
vm_properties = ["name", "summary.runtime.powerState"]
@ -2455,9 +2451,7 @@ def stop(name, soft=False, call=None):
salt-cloud -a stop vmname soft=True
"""
if call != "action":
raise SaltCloudSystemExit(
"The stop action must be called with " "-a or --action."
)
raise SaltCloudSystemExit("The stop action must be called with -a or --action.")
vm_properties = ["name", "summary.runtime.powerState"]
@ -2503,7 +2497,7 @@ def suspend(name, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The suspend action must be called with " "-a or --action."
"The suspend action must be called with -a or --action."
)
vm_properties = ["name", "summary.runtime.powerState"]
@ -2560,7 +2554,7 @@ def reset(name, soft=False, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The reset action must be called with " "-a or --action."
"The reset action must be called with -a or --action."
)
vm_properties = ["name", "summary.runtime.powerState"]
@ -2611,7 +2605,7 @@ def terminate(name, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The terminate action must be called with " "-a or --action."
"The terminate action must be called with -a or --action."
)
vm_properties = ["name", "summary.runtime.powerState"]
@ -2656,7 +2650,7 @@ def destroy(name, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
__utils__["cloud.fire_event"](
@ -2858,7 +2852,8 @@ def create(vm_):
clone_type = "template" if object_ref.config.template else "vm"
else:
raise SaltCloudSystemExit(
"The VM/template that you have specified under clonefrom does not exist."
"The VM/template that you have specified under clonefrom does not"
" exist."
)
else:
clone_type = None
@ -2887,7 +2882,8 @@ def create(vm_):
resourcepool_ref = cluster_ref.resourcePool
elif clone_type == "template":
raise SaltCloudSystemExit(
"You must either specify a cluster or a resource pool when cloning from a template."
"You must either specify a cluster or a resource pool when cloning from a"
" template."
)
elif not clone_type:
raise SaltCloudSystemExit(
@ -2926,7 +2922,8 @@ def create(vm_):
folder_ref = datacenter_ref.vmFolder
elif not clone_type:
raise SaltCloudSystemExit(
"You must either specify a folder or a datacenter when creating not cloning."
"You must either specify a folder or a datacenter when creating not"
" cloning."
)
else:
log.debug(
@ -3260,9 +3257,9 @@ def handle_snapshot(config_spec, object_ref, reloc_spec, template, vm_):
)
if not clone_spec:
raise SaltCloudSystemExit(
"Invalid disk move type specified"
" supported types are"
" {}".format(" ".join(allowed_types))
"Invalid disk move type specified supported types are {}".format(
" ".join(allowed_types)
)
)
return clone_spec
@ -3318,7 +3315,7 @@ def create_datacenter(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The create_datacenter function must be called with " "-f or --function."
"The create_datacenter function must be called with -f or --function."
)
datacenter_name = kwargs.get("name") if kwargs and "name" in kwargs else None
@ -3377,7 +3374,7 @@ def create_cluster(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The create_cluster function must be called with " "-f or --function."
"The create_cluster function must be called with -f or --function."
)
cluster_name = kwargs.get("name") if kwargs and "name" in kwargs else None
@ -3390,7 +3387,8 @@ def create_cluster(kwargs=None, call=None):
if not datacenter:
raise SaltCloudSystemExit(
"You must specify name of the datacenter where the cluster should be created."
"You must specify name of the datacenter where the cluster should be"
" created."
)
# Get the service instance
@ -3448,7 +3446,7 @@ def rescan_hba(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The rescan_hba function must be called with " "-f or --function."
"The rescan_hba function must be called with -f or --function."
)
hba = kwargs.get("hba") if kwargs and "hba" in kwargs else None
@ -3502,7 +3500,7 @@ def upgrade_tools_all(call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The upgrade_tools_all function must be called with " "-f or --function."
"The upgrade_tools_all function must be called with -f or --function."
)
ret = {}
@ -3537,7 +3535,7 @@ def upgrade_tools(name, reboot=False, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The upgrade_tools action must be called with " "-a or --action."
"The upgrade_tools action must be called with -a or --action."
)
vm_ref = salt.utils.vmware.get_mor_by_property(_get_si(), vim.VirtualMachine, name)
@ -3568,8 +3566,7 @@ def list_hosts_by_cluster(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_hosts_by_cluster function must be called with "
"-f or --function."
"The list_hosts_by_cluster function must be called with -f or --function."
)
ret = {}
@ -3734,7 +3731,7 @@ def list_hbas(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_hbas function must be called with " "-f or --function."
"The list_hbas function must be called with -f or --function."
)
ret = {}
@ -3788,7 +3785,7 @@ def list_dvs(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_dvs function must be called with " "-f or --function."
"The list_dvs function must be called with -f or --function."
)
return {"Distributed Virtual Switches": salt.utils.vmware.list_dvs(_get_si())}
@ -3806,7 +3803,7 @@ def list_vapps(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The list_vapps function must be called with " "-f or --function."
"The list_vapps function must be called with -f or --function."
)
return {"vApps": salt.utils.vmware.list_vapps(_get_si())}
@ -3824,8 +3821,7 @@ def enter_maintenance_mode(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The enter_maintenance_mode function must be called with "
"-f or --function."
"The enter_maintenance_mode function must be called with -f or --function."
)
host_name = kwargs.get("host") if kwargs and "host" in kwargs else None
@ -3868,8 +3864,7 @@ def exit_maintenance_mode(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The exit_maintenance_mode function must be called with "
"-f or --function."
"The exit_maintenance_mode function must be called with -f or --function."
)
host_name = kwargs.get("host") if kwargs and "host" in kwargs else None
@ -3930,7 +3925,7 @@ def create_folder(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The create_folder function must be called with " "-f or --function."
"The create_folder function must be called with -f or --function."
)
# Get the service instance object
@ -4011,7 +4006,7 @@ def create_snapshot(name, kwargs=None, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The create_snapshot action must be called with " "-a or --action."
"The create_snapshot action must be called with -a or --action."
)
if kwargs is None:
@ -4093,7 +4088,7 @@ def revert_to_snapshot(name, kwargs=None, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The revert_to_snapshot action must be called with " "-a or --action."
"The revert_to_snapshot action must be called with -a or --action."
)
if kwargs is None:
@ -4154,7 +4149,7 @@ def remove_snapshot(name, kwargs=None, call=None):
if call != "action":
raise SaltCloudSystemExit(
"The create_snapshot action must be called with " "-a or --action."
"The create_snapshot action must be called with -a or --action."
)
if kwargs is None:
@ -4221,7 +4216,7 @@ def remove_all_snapshots(name, kwargs=None, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The remove_all_snapshots action must be called with " "-a or --action."
"The remove_all_snapshots action must be called with -a or --action."
)
vm_ref = salt.utils.vmware.get_mor_by_property(_get_si(), vim.VirtualMachine, name)
@ -4254,7 +4249,7 @@ def convert_to_template(name, kwargs=None, call=None):
"""
if call != "action":
raise SaltCloudSystemExit(
"The convert_to_template action must be called with " "-a or --action."
"The convert_to_template action must be called with -a or --action."
)
vm_ref = salt.utils.vmware.get_mor_by_property(_get_si(), vim.VirtualMachine, name)
@ -4319,7 +4314,7 @@ def add_host(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The add_host function must be called with " "-f or --function."
"The add_host function must be called with -f or --function."
)
host_name = kwargs.get("host") if kwargs and "host" in kwargs else None
@ -4465,7 +4460,7 @@ def remove_host(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The remove_host function must be called with " "-f or --function."
"The remove_host function must be called with -f or --function."
)
host_name = kwargs.get("host") if kwargs and "host" in kwargs else None
@ -4515,7 +4510,7 @@ def connect_host(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The connect_host function must be called with " "-f or --function."
"The connect_host function must be called with -f or --function."
)
host_name = kwargs.get("host") if kwargs and "host" in kwargs else None
@ -4561,7 +4556,7 @@ def disconnect_host(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The disconnect_host function must be called with " "-f or --function."
"The disconnect_host function must be called with -f or --function."
)
host_name = kwargs.get("host") if kwargs and "host" in kwargs else None
@ -4615,7 +4610,7 @@ def reboot_host(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The reboot_host function must be called with " "-f or --function."
"The reboot_host function must be called with -f or --function."
)
host_name = kwargs.get("host") if kwargs and "host" in kwargs else None
@ -4633,7 +4628,8 @@ def reboot_host(kwargs=None, call=None):
if host_ref.runtime.connectionState == "notResponding":
raise SaltCloudSystemExit(
"Specified host system cannot be rebooted in it's current state (not responding)."
"Specified host system cannot be rebooted in it's current state (not"
" responding)."
)
if not host_ref.capability.rebootSupported:
@ -4641,9 +4637,9 @@ def reboot_host(kwargs=None, call=None):
if not host_ref.runtime.inMaintenanceMode and not force:
raise SaltCloudSystemExit(
"Specified host system is not in maintenance mode. Specify force=True to "
"force reboot even if there are virtual machines running or other operations "
"in progress."
"Specified host system is not in maintenance mode. Specify force=True to"
" force reboot even if there are virtual machines running or other"
" operations in progress."
)
try:
@ -4690,12 +4686,14 @@ def create_datastore_cluster(kwargs=None, call=None):
if not datastore_cluster_name or len(datastore_cluster_name) >= 80:
raise SaltCloudSystemExit(
"The datastore cluster name must be a non empty string of less than 80 characters."
"The datastore cluster name must be a non empty string of less than 80"
" characters."
)
if not datacenter_name:
raise SaltCloudSystemExit(
"You must specify name of the datacenter where the datastore cluster should be created."
"You must specify name of the datacenter where the datastore cluster should"
" be created."
)
# Get the service instance
@ -4747,7 +4745,7 @@ def shutdown_host(kwargs=None, call=None):
"""
if call != "function":
raise SaltCloudSystemExit(
"The shutdown_host function must be called with " "-f or --function."
"The shutdown_host function must be called with -f or --function."
)
host_name = kwargs.get("host") if kwargs and "host" in kwargs else None
@ -4765,7 +4763,8 @@ def shutdown_host(kwargs=None, call=None):
if host_ref.runtime.connectionState == "notResponding":
raise SaltCloudSystemExit(
"Specified host system cannot be shut down in it's current state (not responding)."
"Specified host system cannot be shut down in it's current state (not"
" responding)."
)
if not host_ref.capability.rebootSupported:
@ -4773,9 +4772,9 @@ def shutdown_host(kwargs=None, call=None):
if not host_ref.runtime.inMaintenanceMode and not force:
raise SaltCloudSystemExit(
"Specified host system is not in maintenance mode. Specify force=True to "
"force reboot even if there are virtual machines running or other operations "
"in progress."
"Specified host system is not in maintenance mode. Specify force=True to"
" force reboot even if there are virtual machines running or other"
" operations in progress."
)
try:

View file

@ -466,7 +466,7 @@ def create(vm_):
)
if int(data.get("status", "200")) >= 300:
log.error(
"Error creating %s on Vultr\n\n" "Vultr API returned %s\n",
"Error creating %s on Vultr\n\nVultr API returned %s\n",
vm_["name"],
data,
)

View file

@ -420,7 +420,10 @@ def avail_sizes(session=None, call=None):
"The avail_sizes function must be called with -f or --function."
)
return {
"STATUS": "Sizes are build into templates. Consider running --list-images to see sizes"
"STATUS": (
"Sizes are build into templates. Consider running --list-images to see"
" sizes"
)
}
@ -975,7 +978,7 @@ def destroy(name=None, call=None):
"""
if call == "function":
raise SaltCloudSystemExit(
"The destroy action must be called with -d, --destroy, " "-a or --action."
"The destroy action must be called with -d, --destroy, -a or --action."
)
ret = {}
__utils__["cloud.fire_event"](

View file

@ -275,19 +275,18 @@ class _SyslogServerFactory(DatagramProtocol):
self.title = topics
if len(topics) < 2 or topics[0] != "jnpr" or topics[1] != "syslog":
log.debug(
'The topic specified in configuration should start with \
"jnpr/syslog". Using the default topic.'
"The topic specified in configuration should start with "
'"jnpr/syslog". Using the default topic.'
)
self.title = ["jnpr", "syslog", "hostname", "event"]
else:
for i in range(2, len(topics)):
if topics[i] not in data:
log.debug(
"Please check the topic specified. \
Only the following keywords can be specified \
in the topic: hostip, priority, severity, \
facility, timestamp, hostname, daemon, pid, \
message, event. Using the default topic."
"Please check the topic specified. Only the following "
"keywords can be specified in the topic: hostip, priority, "
"severity, facility, timestamp, hostname, daemon, pid, "
"message, event. Using the default topic."
)
self.title = ["jnpr", "syslog", "hostname", "event"]
break
@ -337,8 +336,8 @@ class _SyslogServerFactory(DatagramProtocol):
raise Exception("Arguments in config not specified properly")
else:
raise Exception(
"Please check the arguments given to junos engine in the\
configuration file"
"Please check the arguments given to junos engine in the "
"configuration file"
)
if send_this_event:

View file

@ -198,8 +198,8 @@ def __virtual__():
if not HAS_NAPALM_LOGS or not zmq:
return (
False,
"napalm_syslog could not be loaded. \
Please install napalm-logs library amd ZeroMQ.",
"napalm_syslog could not be loaded. Please install "
"napalm-logs library and ZeroMQ.",
)
return True

View file

@ -284,7 +284,8 @@ class SlackClient:
ret_groups[name]["targets"].update(config.get("targets", {}))
except (IndexError, AttributeError):
log.warning(
"Couldn't use group %s. Check that targets is a dictionary and not a list",
"Couldn't use group %s. Check that targets is a dictionary and not"
" a list",
name,
)
@ -516,9 +517,7 @@ class SlackClient:
)
user_id = m_data["message"]["user"]
elif "comment" in m_data and "user" in m_data["comment"]:
log.debug(
"Comment was added, " "so we look for user in " "the comment."
)
log.debug("Comment was added, so we look for user in the comment.")
user_id = m_data["comment"]["user"]
else:
user_id = m_data.get("user")
@ -581,13 +580,13 @@ class SlackClient:
loaded_groups = self.get_config_groups(groups, groups_pillar_name)
if not data.get("user_name"):
log.error(
"The user %s can not be looked up via slack. What has happened here?",
"The user %s can not be looked up via slack. What has"
" happened here?",
m_data.get("user"),
)
channel.send_message(
"The user {} can not be looked up via slack. Not running {}".format(
data["user_id"], msg_text
)
"The user {} can not be looked up via slack. Not"
" running {}".format(data["user_id"], msg_text)
)
yield {"message_data": m_data}
continue

View file

@ -90,7 +90,8 @@ def __virtual__():
if not HAS_BOTO:
return (
False,
"Cannot import engine sqs_events because the required boto module is missing",
"Cannot import engine sqs_events because the required boto module is"
" missing",
)
else:
return True

View file

@ -99,8 +99,9 @@ def _windows_iqn():
get = "iSCSINodeName"
cmd_ret = salt.modules.cmdmod.run_all(
"{} /namespace:{} path {} get {} /format:table"
"".format(wmic, namespace, path, get)
"{} /namespace:{} path {} get {} /format:table".format(
wmic, namespace, path, get
)
)
for line in cmd_ret["stdout"].splitlines():

View file

@ -256,17 +256,15 @@ def cert(
if res["retcode"] != 0:
return {
"result": False,
"comment": (
"Certificate {} renewal failed with:\n{}"
"".format(name, res["stderr"])
"comment": "Certificate {} renewal failed with:\n{}".format(
name, res["stderr"]
),
}
else:
return {
"result": False,
"comment": (
"Certificate {} renewal failed with:\n{}"
"".format(name, res["stderr"])
"comment": "Certificate {} renewal failed with:\n{}".format(
name, res["stderr"]
),
}

View file

@ -232,9 +232,7 @@ def execute(context=None, lens=None, commands=(), load_path=None):
arg = command
ret[
"error"
] = "Invalid formatted command, " "see debug log for details: {}".format(
arg
)
] = "Invalid formatted command, see debug log for details: {}".format(arg)
return ret
args = salt.utils.data.decode(args, to_str=True)

View file

@ -82,8 +82,10 @@ def _load_connection_error(hostname, error):
ret = {
"code": None,
"content": "Error: Unable to connect to the bigip device: {host}\n{error}".format(
host=hostname, error=error
"content": (
"Error: Unable to connect to the bigip device: {host}\n{error}".format(
host=hostname, error=error
)
),
}
@ -275,8 +277,9 @@ def start_transaction(hostname, username, password, label):
__salt__["grains.setval"]("bigip_f5_trans", {label: trans_id})
return "Transaction: {trans_id} - has successfully been stored in the grain: bigip_f5_trans:{label}".format(
trans_id=trans_id, label=label
return (
"Transaction: {trans_id} - has successfully been stored in the grain:"
" bigip_f5_trans:{label}".format(trans_id=trans_id, label=label)
)
else:
return data
@ -323,8 +326,8 @@ def list_transaction(hostname, username, password, label):
return _load_connection_error(hostname, e)
else:
return (
"Error: the label for this transaction was not defined as a grain. Begin a new transaction using the"
" bigip.start_transaction function"
"Error: the label for this transaction was not defined as a grain. Begin a"
" new transaction using the bigip.start_transaction function"
)
@ -372,8 +375,8 @@ def commit_transaction(hostname, username, password, label):
return _load_connection_error(hostname, e)
else:
return (
"Error: the label for this transaction was not defined as a grain. Begin a new transaction using the"
" bigip.start_transaction function"
"Error: the label for this transaction was not defined as a grain. Begin a"
" new transaction using the bigip.start_transaction function"
)
@ -417,8 +420,8 @@ def delete_transaction(hostname, username, password, label):
return _load_connection_error(hostname, e)
else:
return (
"Error: the label for this transaction was not defined as a grain. Begin a new transaction using the"
" bigip.start_transaction function"
"Error: the label for this transaction was not defined as a grain. Begin a"
" new transaction using the bigip.start_transaction function"
)

View file

@ -1383,7 +1383,7 @@ def check_upgrade_eligibility(
if str(elasticsearch_version) not in compatible_versions:
ret["result"] = True
ret["response"] = False
ret["error"] = 'Desired version "{}" not in compatible versions: {}.' "".format(
ret["error"] = 'Desired version "{}" not in compatible versions: {}.'.format(
elasticsearch_version, compatible_versions
)
return ret

View file

@ -405,7 +405,7 @@ def create_hosted_zone(
if PrivateZone:
if not _exactly_one((VPCName, VPCId)):
raise SaltInvocationError(
"Either VPCName or VPCId is required when creating a " "private zone."
"Either VPCName or VPCId is required when creating a private zone."
)
vpcs = __salt__["boto_vpc.describe_vpcs"](
vpc_id=VPCId,
@ -995,7 +995,7 @@ def get_resource_records(
"""
if not _exactly_one((HostedZoneId, Name)):
raise SaltInvocationError(
"Exactly one of either HostedZoneId or Name must " "be provided."
"Exactly one of either HostedZoneId or Name must be provided."
)
if Name:
args = {

View file

@ -415,8 +415,8 @@ def unsubscribe(SubscriptionArn, region=None, key=None, keyid=None, profile=None
# Note that anything left in PendingConfirmation will be auto-deleted by AWS after 30 days
# anyway, so this isn't as ugly a hack as it might seem at first...
log.info(
"Invalid subscription ARN `%s` passed - likely a PendingConfirmaton or such. "
"Skipping unsubscribe attempt as it would almost certainly fail...",
"Invalid subscription ARN `%s` passed - likely a PendingConfirmaton or"
" such. Skipping unsubscribe attempt as it would almost certainly fail...",
SubscriptionArn,
)
return True

View file

@ -236,7 +236,8 @@ def create_or_update_alarm(
dimensions = salt.utils.json.loads(dimensions)
if not isinstance(dimensions, dict):
log.error(
"could not parse dimensions argument: must be json encoding of a dict: '%s'",
"could not parse dimensions argument: must be json encoding of a dict:"
" '%s'",
dimensions,
)
return False

View file

@ -334,7 +334,7 @@ def release_eip_address(
"""
if not salt.utils.data.exactly_one((public_ip, allocation_id)):
raise SaltInvocationError(
"Exactly one of 'public_ip' OR " "'allocation_id' must be provided"
"Exactly one of 'public_ip' OR 'allocation_id' must be provided"
)
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
@ -693,7 +693,7 @@ def find_instances(
reservations = conn.get_all_reservations(**filter_parameters)
instances = [i for r in reservations for i in r.instances]
log.debug(
"The filters criteria %s matched the following " "instances:%s",
"The filters criteria %s matched the following instances:%s",
filter_parameters,
instances,
)
@ -758,7 +758,8 @@ def create_image(
return False
if len(instances) > 1:
log.error(
"Multiple instances found, must match exactly only one instance to create an image from"
"Multiple instances found, must match exactly only one instance to create"
" an image from"
)
return False
@ -813,7 +814,7 @@ def find_images(
filter_parameters["filters"]["tag:{}".format(tag_name)] = tag_value
images = conn.get_all_images(**filter_parameters)
log.debug(
"The filters criteria %s matched the following " "images:%s",
"The filters criteria %s matched the following images:%s",
filter_parameters,
images,
)
@ -911,7 +912,7 @@ def get_id(
return instance_ids[0]
else:
raise CommandExecutionError(
"Found more than one instance " "matching the criteria."
"Found more than one instance matching the criteria."
)
else:
log.warning("Could not find instance.")
@ -1202,7 +1203,7 @@ def run(
"""
if all((subnet_id, subnet_name)):
raise SaltInvocationError(
"Only one of subnet_name or subnet_id may be " "provided."
"Only one of subnet_name or subnet_id may be provided."
)
if subnet_name:
r = __salt__["boto_vpc.get_resource_id"](
@ -1215,7 +1216,7 @@ def run(
if all((security_group_ids, security_group_names)):
raise SaltInvocationError(
"Only one of security_group_ids or " "security_group_names may be provided."
"Only one of security_group_ids or security_group_names may be provided."
)
if security_group_names:
security_group_ids = []
@ -1513,7 +1514,8 @@ def get_attribute(
)
if instance_name and instance_id:
raise SaltInvocationError(
"Both instance_name and instance_id can not be specified in the same command."
"Both instance_name and instance_id can not be specified in the same"
" command."
)
if attribute not in attribute_list:
raise SaltInvocationError(
@ -1600,11 +1602,13 @@ def set_attribute(
]
if not any((instance_name, instance_id)):
raise SaltInvocationError(
"At least one of the following must be specified: instance_name or instance_id."
"At least one of the following must be specified: instance_name or"
" instance_id."
)
if instance_name and instance_id:
raise SaltInvocationError(
"Both instance_name and instance_id can not be specified in the same command."
"Both instance_name and instance_id can not be specified in the same"
" command."
)
if attribute not in attribute_list:
raise SaltInvocationError(
@ -1797,7 +1801,7 @@ def create_network_interface(
"""
if not salt.utils.data.exactly_one((subnet_id, subnet_name)):
raise SaltInvocationError(
"One (but not both) of subnet_id or " "subnet_name must be provided."
"One (but not both) of subnet_id or subnet_name must be provided."
)
if subnet_name:
@ -1971,7 +1975,7 @@ def detach_network_interface(
"""
if not (name or network_interface_id or attachment_id):
raise SaltInvocationError(
"Either name or network_interface_id or attachment_id must be" " provided."
"Either name or network_interface_id or attachment_id must be provided."
)
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
r = {}
@ -2049,7 +2053,7 @@ def modify_network_interface_attribute(
)
if not _value:
r["error"] = {
"message": ("Security groups do not map to valid security" " group ids")
"message": "Security groups do not map to valid security group ids"
}
return r
_attachment_id = None

View file

@ -495,7 +495,7 @@ def create_subnet_group(
"""
if not _exactly_one((subnet_ids, subnet_names)):
raise SaltInvocationError(
"Exactly one of either 'subnet_ids' or " "'subnet_names' must be provided."
"Exactly one of either 'subnet_ids' or 'subnet_names' must be provided."
)
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
if not conn:

View file

@ -409,7 +409,7 @@ def add_tags(
if ARN is None:
if DomainName is None:
raise SaltInvocationError(
"One (but not both) of ARN or " "domain must be specified."
"One (but not both) of ARN or domain must be specified."
)
domaindata = status(
DomainName=DomainName,
@ -424,7 +424,7 @@ def add_tags(
ARN = domaindata.get("domain", {}).get("ARN")
elif DomainName is not None:
raise SaltInvocationError(
"One (but not both) of ARN or " "domain must be specified."
"One (but not both) of ARN or domain must be specified."
)
conn.add_tags(ARN=ARN, TagList=tagslist)
return {"tagged": True}
@ -454,7 +454,7 @@ def remove_tags(
if ARN is None:
if DomainName is None:
raise SaltInvocationError(
"One (but not both) of ARN or " "domain must be specified."
"One (but not both) of ARN or domain must be specified."
)
domaindata = status(
DomainName=DomainName,
@ -469,7 +469,7 @@ def remove_tags(
ARN = domaindata.get("domain", {}).get("ARN")
elif DomainName is not None:
raise SaltInvocationError(
"One (but not both) of ARN or " "domain must be specified."
"One (but not both) of ARN or domain must be specified."
)
conn.remove_tags(ARN=domaindata.get("domain", {}).get("ARN"), TagKeys=TagKeys)
return {"tagged": True}
@ -501,7 +501,7 @@ def list_tags(
if ARN is None:
if DomainName is None:
raise SaltInvocationError(
"One (but not both) of ARN or " "domain must be specified."
"One (but not both) of ARN or domain must be specified."
)
domaindata = status(
DomainName=DomainName,
@ -516,7 +516,7 @@ def list_tags(
ARN = domaindata.get("domain", {}).get("ARN")
elif DomainName is not None:
raise SaltInvocationError(
"One (but not both) of ARN or " "domain must be specified."
"One (but not both) of ARN or domain must be specified."
)
ret = conn.list_tags(ARN=ARN)
log.warning(ret)

View file

@ -322,7 +322,8 @@ def create_function(
== "InvalidParameterValueException"
):
log.info(
"Function not created but IAM role may not have propagated, will retry"
"Function not created but IAM role may not have propagated,"
" will retry"
)
# exponential backoff
time.sleep(
@ -492,7 +493,8 @@ def update_function_config(
== "InvalidParameterValueException"
):
log.info(
"Function not updated but IAM role may not have propagated, will retry"
"Function not updated but IAM role may not have propagated,"
" will retry"
)
# exponential backoff
time.sleep(

View file

@ -289,7 +289,7 @@ def create(
raise SaltInvocationError("master_user_password is required")
if availability_zone and multi_az:
raise SaltInvocationError(
"availability_zone and multi_az are mutually" " exclusive arguments."
"availability_zone and multi_az are mutually exclusive arguments."
)
if wait_status:
wait_stati = ["available", "modifying", "backing-up"]
@ -355,14 +355,17 @@ def create(
# Whoops, something is horribly wrong...
return {
"created": False,
"error": "RDS instance {} should have been created but"
" now I can't find it.".format(name),
"error": (
"RDS instance {} should have been created but"
" now I can't find it.".format(name)
),
}
if stat == wait_status:
return {
"created": True,
"message": "RDS instance {} created (current status "
"{})".format(name, stat),
"message": "RDS instance {} created (current status {})".format(
name, stat
),
}
time.sleep(10)
log.info("Instance status after 10 seconds is: %s", stat)
@ -890,7 +893,7 @@ def delete(
"seconds".format(name, timeout)
)
log.info(
"Waiting up to %s seconds for RDS instance %s to be " "deleted.",
"Waiting up to %s seconds for RDS instance %s to be deleted.",
timeout,
name,
)

View file

@ -142,7 +142,7 @@ def describe_hosted_zones(
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
if zone_id and domain_name:
raise SaltInvocationError(
"At most one of zone_id or domain_name may " "be provided"
"At most one of zone_id or domain_name may be provided"
)
retries = 10
while retries:
@ -176,8 +176,8 @@ def describe_hosted_zones(
log.debug("Throttled by AWS API.")
elif "PriorRequestNotComplete" == e.code:
log.debug(
"The request was rejected by AWS API.\
Route 53 was still processing a prior request"
"The request was rejected by AWS API. "
"Route 53 was still processing a prior request."
)
time.sleep(3)
retries -= 1
@ -252,7 +252,7 @@ def zone_exists(
error_retries=5,
):
"""
Check for the existence of a Route53 hosted zone.
Check for the existence of a Route53 hosted zone.
.. versionadded:: 2015.8.0
@ -299,8 +299,8 @@ def zone_exists(
log.debug("Throttled by AWS API.")
elif "PriorRequestNotComplete" == e.code:
log.debug(
"The request was rejected by AWS API.\
Route 53 was still processing a prior request"
"The request was rejected by AWS API. "
"Route 53 was still processing a prior request "
)
time.sleep(3)
error_retries -= 1
@ -484,8 +484,8 @@ def create_healthcheck(
log.debug("Throttled by AWS API.")
elif "PriorRequestNotComplete" == exc.code:
log.debug(
"The request was rejected by AWS API.\
Route 53 was still processing a prior request"
"The request was rejected by AWS API. "
"Route 53 was still processing a prior request."
)
time.sleep(3)
error_retries -= 1
@ -545,7 +545,7 @@ def get_record(
error_retries=5,
):
"""
Get a record from a zone.
Get a record from a zone.
CLI Example:
@ -608,8 +608,8 @@ def get_record(
log.debug("Throttled by AWS API.")
elif "PriorRequestNotComplete" == e.code:
log.debug(
"The request was rejected by AWS API.\
Route 53 was still processing a prior request"
"The request was rejected by AWS API. "
"Route 53 was still processing a prior request."
)
time.sleep(3)
error_retries -= 1
@ -656,7 +656,7 @@ def add_record(
error_retries=5,
):
"""
Add a record to a zone.
Add a record to a zone.
CLI Example:
@ -710,8 +710,8 @@ def add_record(
log.debug("Throttled by AWS API.")
elif "PriorRequestNotComplete" == e.code:
log.debug(
"The request was rejected by AWS API.\
Route 53 was still processing a prior request"
"The request was rejected by AWS API. "
"Route 53 was still processing a prior request."
)
time.sleep(3)
error_retries -= 1
@ -733,8 +733,8 @@ def add_record(
log.debug("Throttled by AWS API.")
elif "PriorRequestNotComplete" == e.code:
log.debug(
"The request was rejected by AWS API.\
Route 53 was still processing a prior request"
"The request was rejected by AWS API. "
"Route 53 was still processing a prior request."
)
time.sleep(3)
error_retries -= 1
@ -763,13 +763,13 @@ def update_record(
error_retries=5,
):
"""
Modify a record in a zone.
Modify a record in a zone.
CLI Example:
CLI Example:
.. code-block:: bash
.. code-block:: bash
salt myminion boto_route53.modify_record test.example.org 1.1.1.1 example.org A
salt myminion boto_route53.modify_record test.example.org 1.1.1.1 example.org A
retry_on_errors
Continue to query if the zone exists after an error is
@ -823,8 +823,8 @@ def update_record(
log.debug("Throttled by AWS API.")
elif "PriorRequestNotComplete" == e.code:
log.debug(
"The request was rejected by AWS API.\
Route 53 was still processing a prior request"
"The request was rejected by AWS API. "
"Route 53 was still processing a prior request."
)
time.sleep(3)
error_retries -= 1
@ -852,13 +852,13 @@ def delete_record(
error_retries=5,
):
"""
Modify a record in a zone.
Modify a record in a zone.
CLI Example:
CLI Example:
.. code-block:: bash
.. code-block:: bash
salt myminion boto_route53.delete_record test.example.org example.org A
salt myminion boto_route53.delete_record test.example.org example.org A
retry_on_errors
Continue to query if the zone exists after an error is
@ -913,8 +913,8 @@ def delete_record(
log.debug("Throttled by AWS API.")
elif "PriorRequestNotComplete" == e.code:
log.debug(
"The request was rejected by AWS API.\
Route 53 was still processing a prior request"
"The request was rejected by AWS API. "
"Route 53 was still processing a prior request."
)
time.sleep(3)
error_retries -= 1
@ -1045,7 +1045,7 @@ def create_hosted_zone(
if not domain_name.endswith("."):
raise SaltInvocationError(
"Domain MUST be fully-qualified, complete " "with ending period."
"Domain MUST be fully-qualified, complete with ending period."
)
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
@ -1065,7 +1065,7 @@ def create_hosted_zone(
if private_zone:
if not _exactly_one((vpc_name, vpc_id)):
raise SaltInvocationError(
"Either vpc_name or vpc_id is required " "when creating a private zone."
"Either vpc_name or vpc_id is required when creating a private zone."
)
vpcs = __salt__["boto_vpc.describe_vpcs"](
vpc_id=vpc_id,
@ -1079,7 +1079,7 @@ def create_hosted_zone(
vpcs = [v for v in vpcs if v["region"] == vpc_region]
if not vpcs:
log.error(
"Private zone requested but a VPC matching given criteria" " not found."
"Private zone requested but a VPC matching given criteria not found."
)
return None
if len(vpcs) > 1:

View file

@ -175,7 +175,7 @@ def _get_group(
"""
if vpc_name and vpc_id:
raise SaltInvocationError(
"The params 'vpc_id' and 'vpc_name' " "are mutually exclusive."
"The params 'vpc_id' and 'vpc_name' are mutually exclusive."
)
if vpc_name:
try:
@ -409,8 +409,9 @@ def convert_to_group_ids(
return []
else:
raise CommandExecutionError(
"Could not resolve Security Group name "
"{} to a Group ID".format(group)
"Could not resolve Security Group name {} to a Group ID".format(
group
)
)
else:
group_ids.append(str(group_id))
@ -752,7 +753,7 @@ def _find_vpcs(
Borrowed from boto_vpc; these could be refactored into a common library
"""
if all((vpc_id, vpc_name)):
raise SaltInvocationError("Only one of vpc_name or vpc_id may be " "provided.")
raise SaltInvocationError("Only one of vpc_name or vpc_id may be provided.")
if not any((vpc_id, vpc_name, tags, cidr)):
raise SaltInvocationError(

View file

@ -220,7 +220,7 @@ def check_vpc(
if not _exactly_one((vpc_name, vpc_id)):
raise SaltInvocationError(
"One (but not both) of vpc_id or vpc_name " "must be provided."
"One (but not both) of vpc_id or vpc_name must be provided."
)
if vpc_name:
vpc_id = _get_id(
@ -255,8 +255,9 @@ def _create_resource(
create_resource = getattr(conn, "create_" + resource)
except AttributeError:
raise AttributeError(
"{} function does not exist for boto VPC "
"connection.".format("create_" + resource)
"{} function does not exist for boto VPC connection.".format(
"create_" + resource
)
)
if name and _get_resource_id(
@ -316,9 +317,7 @@ def _delete_resource(
"""
if not _exactly_one((name, resource_id)):
raise SaltInvocationError(
"One (but not both) of name or id must be " "provided."
)
raise SaltInvocationError("One (but not both) of name or id must be provided.")
try:
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
@ -327,8 +326,9 @@ def _delete_resource(
delete_resource = getattr(conn, "delete_" + resource)
except AttributeError:
raise AttributeError(
"{} function does not exist for boto VPC "
"connection.".format("delete_" + resource)
"{} function does not exist for boto VPC connection.".format(
"delete_" + resource
)
)
if name:
resource_id = _get_resource_id(
@ -379,9 +379,7 @@ def _get_resource(
"""
if not _exactly_one((name, resource_id)):
raise SaltInvocationError(
"One (but not both) of name or id must be " "provided."
)
raise SaltInvocationError("One (but not both) of name or id must be provided.")
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
@ -418,7 +416,7 @@ def _get_resource(
return r[0]
else:
raise CommandExecutionError(
"Found more than one " '{} named "{}"'.format(resource, name)
'Found more than one {} named "{}"'.format(resource, name)
)
else:
return None
@ -439,11 +437,11 @@ def _find_resources(
"""
if all((resource_id, name)):
raise SaltInvocationError("Only one of name or id may be " "provided.")
raise SaltInvocationError("Only one of name or id may be provided.")
if not any((resource_id, name, tags)):
raise SaltInvocationError(
"At least one of the following must be " "provided: id, name, or tags."
"At least one of the following must be provided: id, name, or tags."
)
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
@ -587,7 +585,7 @@ def _find_vpcs(
"""
if all((vpc_id, vpc_name)):
raise SaltInvocationError("Only one of vpc_name or vpc_id may be " "provided.")
raise SaltInvocationError("Only one of vpc_name or vpc_id may be provided.")
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
filter_parameters = {"filters": {}}
@ -848,13 +846,13 @@ def delete(
if name:
log.warning(
"boto_vpc.delete: name parameter is deprecated " "use vpc_name instead."
"boto_vpc.delete: name parameter is deprecated use vpc_name instead."
)
vpc_name = name
if not _exactly_one((vpc_name, vpc_id)):
raise SaltInvocationError(
"One (but not both) of vpc_name or vpc_id must be " "provided."
"One (but not both) of vpc_name or vpc_id must be provided."
)
try:
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
@ -1757,7 +1755,7 @@ def create_nat_gateway(
try:
if all((subnet_id, subnet_name)):
raise SaltInvocationError(
"Only one of subnet_name or subnet_id may be " "provided."
"Only one of subnet_name or subnet_id may be provided."
)
if subnet_name:
subnet_id = _get_resource_id(
@ -2291,7 +2289,7 @@ def create_network_acl(
if all((subnet_id, subnet_name)):
raise SaltInvocationError(
"Only one of subnet_name or subnet_id may be " "provided."
"Only one of subnet_name or subnet_id may be provided."
)
if subnet_name:
subnet_id = _get_resource_id(
@ -2531,11 +2529,11 @@ def disassociate_network_acl(
if not _exactly_one((subnet_name, subnet_id)):
raise SaltInvocationError(
"One (but not both) of subnet_id or subnet_name " "must be provided."
"One (but not both) of subnet_id or subnet_name must be provided."
)
if all((vpc_name, vpc_id)):
raise SaltInvocationError("Only one of vpc_id or vpc_name " "may be provided.")
raise SaltInvocationError("Only one of vpc_id or vpc_name may be provided.")
try:
if subnet_name:
subnet_id = _get_resource_id(
@ -2589,8 +2587,7 @@ def _create_network_acl_entry(
if not _exactly_one((network_acl_name, network_acl_id)):
raise SaltInvocationError(
"One (but not both) of network_acl_id or "
"network_acl_name must be provided."
"One (but not both) of network_acl_id or network_acl_name must be provided."
)
for v in ("rule_number", "protocol", "rule_action", "cidr_block"):
@ -2740,8 +2737,7 @@ def delete_network_acl_entry(
"""
if not _exactly_one((network_acl_name, network_acl_id)):
raise SaltInvocationError(
"One (but not both) of network_acl_id or "
"network_acl_name must be provided."
"One (but not both) of network_acl_id or network_acl_name must be provided."
)
for v in ("rule_number", "egress"):
@ -2923,7 +2919,8 @@ def route_exists(
if not any((route_table_name, route_table_id)):
raise SaltInvocationError(
"At least one of the following must be specified: route table name or route table id."
"At least one of the following must be specified: route table name or route"
" table id."
)
if not any((gateway_id, instance_id, interface_id, vpc_peering_connection_id)):
@ -3007,7 +3004,7 @@ def associate_route_table(
if all((subnet_id, subnet_name)):
raise SaltInvocationError(
"Only one of subnet_name or subnet_id may be " "provided."
"Only one of subnet_name or subnet_id may be provided."
)
if subnet_name:
subnet_id = _get_resource_id(
@ -3021,7 +3018,7 @@ def associate_route_table(
if all((route_table_id, route_table_name)):
raise SaltInvocationError(
"Only one of route_table_name or route_table_id may be " "provided."
"Only one of route_table_name or route_table_id may be provided."
)
if route_table_name:
route_table_id = _get_resource_id(
@ -3148,8 +3145,7 @@ def create_route(
if not _exactly_one((route_table_name, route_table_id)):
raise SaltInvocationError(
"One (but not both) of route_table_id or route_table_name "
"must be provided."
"One (but not both) of route_table_id or route_table_name must be provided."
)
if not _exactly_one(
@ -3166,9 +3162,9 @@ def create_route(
)
):
raise SaltInvocationError(
"Only one of gateway_id, internet_gateway_name, instance_id, "
"interface_id, vpc_peering_connection_id, nat_gateway_id, "
"nat_gateway_subnet_id, nat_gateway_subnet_name or vpc_peering_connection_name may be provided."
"Only one of gateway_id, internet_gateway_name, instance_id, interface_id,"
" vpc_peering_connection_id, nat_gateway_id, nat_gateway_subnet_id,"
" nat_gateway_subnet_name or vpc_peering_connection_name may be provided."
)
if destination_cidr_block is None:
@ -3322,8 +3318,7 @@ def delete_route(
if not _exactly_one((route_table_name, route_table_id)):
raise SaltInvocationError(
"One (but not both) of route_table_id or route_table_name "
"must be provided."
"One (but not both) of route_table_id or route_table_name must be provided."
)
if destination_cidr_block is None:
@ -3388,8 +3383,7 @@ def replace_route(
if not _exactly_one((route_table_name, route_table_id)):
raise SaltInvocationError(
"One (but not both) of route_table_id or route_table_name "
"must be provided."
"One (but not both) of route_table_id or route_table_name must be provided."
)
if destination_cidr_block is None:
@ -3728,11 +3722,11 @@ def request_vpc_peering_connection(
if not _exactly_one((requester_vpc_id, requester_vpc_name)):
raise SaltInvocationError(
"Exactly one of requester_vpc_id or " "requester_vpc_name is required"
"Exactly one of requester_vpc_id or requester_vpc_name is required"
)
if not _exactly_one((peer_vpc_id, peer_vpc_name)):
raise SaltInvocationError(
"Exactly one of peer_vpc_id or " "peer_vpc_name is required."
"Exactly one of peer_vpc_id or peer_vpc_name is required."
)
if requester_vpc_name:
@ -3877,9 +3871,7 @@ def accept_vpc_peering_connection( # pylint: disable=too-many-arguments
"""
if not _exactly_one((conn_id, name)):
raise SaltInvocationError(
"One (but not both) of "
"vpc_peering_connection_id or name "
"must be provided."
"One (but not both) of vpc_peering_connection_id or name must be provided."
)
conn = _get_conn3(region=region, key=key, keyid=keyid, profile=profile)
@ -3978,7 +3970,7 @@ def delete_vpc_peering_connection(
"""
if not _exactly_one((conn_id, conn_name)):
raise SaltInvocationError(
"Exactly one of conn_id or " "conn_name must be provided."
"Exactly one of conn_id or conn_name must be provided."
)
conn = _get_conn3(region=region, key=key, keyid=keyid, profile=profile)
@ -3986,8 +3978,7 @@ def delete_vpc_peering_connection(
conn_id = _vpc_peering_conn_id_for_name(conn_name, conn)
if not conn_id:
raise SaltInvocationError(
"Couldn't resolve VPC peering connection "
"{} to an ID".format(conn_name)
"Couldn't resolve VPC peering connection {} to an ID".format(conn_name)
)
try:
log.debug("Trying to delete vpc peering connection")

View file

@ -255,7 +255,8 @@ def _get_services_mapping():
log.error("Did not read that properly:")
log.error(line)
log.error(
"Please report the above error: %s does not seem a valid port value!",
"Please report the above error: %s does not seem a valid port"
" value!",
port,
)
_SERVICES[srv_name]["protocol"].append(protocol)
@ -372,7 +373,8 @@ def _clean_term_opts(term_opts):
clean_opts, "protocol", _services[service]["protocol"]
)
log.debug(
"Built source_port field, after processing special destination services:"
"Built source_port field, after processing special destination"
" services:"
)
log.debug(clean_opts.get("destination_service"))
log.debug(

View file

@ -263,8 +263,9 @@ def put(consul_url=None, token=None, key=None, value=None, **kwargs):
for _l2 in conflicting_args:
if _l1 in kwargs and _l2 in kwargs and _l1 != _l2:
raise SaltInvocationError(
"Using arguments `{}` and `{}`"
" together is invalid.".format(_l1, _l2)
"Using arguments `{}` and `{}` together is invalid.".format(
_l1, _l2
)
)
query_params = {}
@ -279,21 +280,19 @@ def put(consul_url=None, token=None, key=None, value=None, **kwargs):
if "cas" in kwargs:
if _current["res"]:
if kwargs["cas"] == 0:
ret["message"] = "Key {} exists, index " "must be non-zero.".format(key)
ret["message"] = "Key {} exists, index must be non-zero.".format(key)
ret["res"] = False
return ret
if kwargs["cas"] != _current["data"]["ModifyIndex"]:
ret["message"] = "Key {} exists, but indexes " "do not match.".format(
key
)
ret["message"] = "Key {} exists, but indexes do not match.".format(key)
ret["res"] = False
return ret
query_params["cas"] = kwargs["cas"]
else:
ret[
"message"
] = "Key {} does not exists, " "CAS argument can not be used.".format(key)
] = "Key {} does not exists, CAS argument can not be used.".format(key)
ret["res"] = False
return ret
@ -587,7 +586,7 @@ def agent_maintenance(consul_url=None, token=None, **kwargs):
)
if res["res"]:
ret["res"] = True
ret["message"] = "Agent maintenance mode " "{}ed.".format(kwargs["enable"])
ret["message"] = "Agent maintenance mode {}ed.".format(kwargs["enable"])
else:
ret["res"] = True
ret["message"] = "Unable to change maintenance mode for agent."
@ -1166,10 +1165,10 @@ def agent_service_maintenance(consul_url=None, token=None, serviceid=None, **kwa
if res["res"]:
ret["res"] = True
ret["message"] = "Service {} set in " "maintenance mode.".format(serviceid)
ret["message"] = "Service {} set in maintenance mode.".format(serviceid)
else:
ret["res"] = False
ret["message"] = "Unable to set service " "{} to maintenance mode.".format(
ret["message"] = "Unable to set service {} to maintenance mode.".format(
serviceid
)
return ret
@ -1552,12 +1551,12 @@ def catalog_register(consul_url=None, token=None, **kwargs):
)
if res["res"]:
ret["res"] = True
ret["message"] = "Catalog registration " "for {} successful.".format(
ret["message"] = "Catalog registration for {} successful.".format(
kwargs["node"]
)
else:
ret["res"] = False
ret["message"] = "Catalog registration " "for {} failed.".format(kwargs["node"])
ret["message"] = "Catalog registration for {} failed.".format(kwargs["node"])
ret["data"] = data
return ret
@ -1617,7 +1616,7 @@ def catalog_deregister(consul_url=None, token=None, **kwargs):
ret["message"] = "Catalog item {} removed.".format(kwargs["node"])
else:
ret["res"] = False
ret["message"] = "Removing Catalog " "item {} failed.".format(kwargs["node"])
ret["message"] = "Removing Catalog item {} failed.".format(kwargs["node"])
return ret
@ -2093,7 +2092,7 @@ def acl_create(consul_url=None, token=None, **kwargs):
ret["message"] = "ACL {} created.".format(kwargs["name"])
else:
ret["res"] = False
ret["message"] = "Removing Catalog " "item {} failed.".format(kwargs["name"])
ret["message"] = "Removing Catalog item {} failed.".format(kwargs["name"])
return ret
@ -2156,7 +2155,7 @@ def acl_update(consul_url=None, token=None, **kwargs):
ret["message"] = "ACL {} created.".format(kwargs["name"])
else:
ret["res"] = False
ret["message"] = "Adding ACL " "{} failed.".format(kwargs["name"])
ret["message"] = "Adding ACL {} failed.".format(kwargs["name"])
return ret
@ -2201,7 +2200,7 @@ def acl_delete(consul_url=None, token=None, **kwargs):
ret["message"] = "ACL {} deleted.".format(kwargs["id"])
else:
ret["res"] = False
ret["message"] = "Removing ACL " "{} failed.".format(kwargs["id"])
ret["message"] = "Removing ACL {} failed.".format(kwargs["id"])
return ret
@ -2282,7 +2281,7 @@ def acl_clone(consul_url=None, token=None, **kwargs):
ret["ID"] = ret["data"]
else:
ret["res"] = False
ret["message"] = "Cloning ACL" "item {} failed.".format(kwargs["name"])
ret["message"] = "Cloning ACL item {} failed.".format(kwargs["name"])
return ret
@ -2382,7 +2381,7 @@ def event_fire(consul_url=None, token=None, name=None, **kwargs):
ret["data"] = ret["data"]
else:
ret["res"] = False
ret["message"] = "Cloning ACL" "item {} failed.".format(kwargs["name"])
ret["message"] = "Cloning ACL item {} failed.".format(kwargs["name"])
return ret

View file

@ -25,7 +25,7 @@ from salt.exceptions import CommandExecutionError, SaltInvocationError
log = logging.getLogger(__name__)
PATH = "PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:" "/usr/local/bin:/usr/local/sbin"
PATH = "PATH=/bin:/usr/bin:/sbin:/usr/sbin:/opt/bin:/usr/local/bin:/usr/local/sbin"
def _validate(wrapped):
@ -403,8 +403,9 @@ def copy_to(
if path:
lxcattach += " -P {}".format(pipes.quote(path))
copy_cmd = (
'cat "{0}" | {4} --clear-env --set-var {1} -n {2} -- '
'tee "{3}"'.format(local_file, PATH, name, dest, lxcattach)
'cat "{0}" | {4} --clear-env --set-var {1} -n {2} -- tee "{3}"'.format(
local_file, PATH, name, dest, lxcattach
)
)
elif exec_driver == "nsenter":
pid = __salt__["{}.pid".format(container_type)](name)

View file

@ -28,8 +28,9 @@ def _temp_exists(method, ip):
on the method supplied, (tempallow, tempdeny).
"""
_type = method.replace("temp", "").upper()
cmd = "csf -t | awk -v code=1 -v type=_type -v ip=ip '$1==type && $2==ip {{code=0}} END {{exit code}}'".format(
_type=_type, ip=ip
cmd = (
"csf -t | awk -v code=1 -v type=_type -v ip=ip '$1==type && $2==ip {{code=0}}"
" END {{exit code}}'".format(_type=_type, ip=ip)
)
exists = __salt__["cmd.run_all"](cmd)
return not bool(exists["retcode"])
@ -150,7 +151,9 @@ def _access_rule(
else:
if method not in ["allow", "deny"]:
return {
"error": "Only allow and deny rules are allowed when specifying a port."
"error": (
"Only allow and deny rules are allowed when specifying a port."
)
}
return _access_rule_with_port(
method=method,

View file

@ -220,9 +220,7 @@ def post_event(
# Datadog only supports these alert types but the API doesn't return an
# error for an incorrect alert_type, so we can do it here for now.
# https://github.com/DataDog/datadogpy/issues/215
message = (
'alert_type must be one of "error", "warning", "info", or ' '"success"'
)
message = 'alert_type must be one of "error", "warning", "info", or "success"'
raise SaltInvocationError(message)
ret = {"result": False, "response": None, "comment": ""}

View file

@ -147,7 +147,7 @@ def cluster_remove(version, name="main", stop=False):
if ret.get("retcode", 0) != 0:
log.error("Error removing a Postgresql cluster %s/%s", version, name)
else:
ret["changes"] = ("Successfully removed" " cluster {}/{}").format(version, name)
ret["changes"] = "Successfully removed cluster {}/{}".format(version, name)
return ret

View file

@ -106,10 +106,7 @@ def nameservers(*ns):
for i in range(1, len(ns) + 1):
if not __execute_cmd(
"config -g cfgLanNetworking -o \
cfgDNSServer{} {}".format(
i, ns[i - 1]
)
"config -g cfgLanNetworking -o cfgDNSServer{} {}".format(i, ns[i - 1])
):
return False
@ -129,15 +126,9 @@ def syslog(server, enable=True):
salt dell drac.syslog [SYSLOG IP] [ENABLE/DISABLE]
salt dell drac.syslog 0.0.0.0 False
"""
if enable and __execute_cmd(
"config -g cfgRemoteHosts -o \
cfgRhostsSyslogEnable 1"
):
if enable and __execute_cmd("config -g cfgRemoteHosts -o cfgRhostsSyslogEnable 1"):
return __execute_cmd(
"config -g cfgRemoteHosts -o \
cfgRhostsSyslogServer1 {}".format(
server
)
"config -g cfgRemoteHosts -o cfgRhostsSyslogServer1 {}".format(server)
)
return __execute_cmd("config -g cfgRemoteHosts -o cfgRhostsSyslogEnable 0")
@ -156,15 +147,9 @@ def email_alerts(action):
"""
if action:
return __execute_cmd(
"config -g cfgEmailAlert -o \
cfgEmailAlertEnable -i 1 1"
)
return __execute_cmd("config -g cfgEmailAlert -o cfgEmailAlertEnable -i 1 1")
else:
return __execute_cmd(
"config -g cfgEmailAlert -o \
cfgEmailAlertEnable -i 1 0"
)
return __execute_cmd("config -g cfgEmailAlert -o cfgEmailAlertEnable -i 1 0")
def list_users():
@ -182,10 +167,7 @@ def list_users():
for idx in range(1, 17):
cmd = __salt__["cmd.run_all"](
"racadm getconfig -g \
cfgUserAdmin -i {}".format(
idx
)
"racadm getconfig -g cfgUserAdmin -i {}".format(idx)
)
if cmd["retcode"] != 0:
@ -227,10 +209,7 @@ def delete_user(username, uid=None):
if uid:
return __execute_cmd(
'config -g cfgUserAdmin -o \
cfgUserAdminUserName -i {} ""'.format(
uid
)
'config -g cfgUserAdmin -o cfgUserAdminUserName -i {} ""'.format(uid)
)
else:
@ -257,8 +236,7 @@ def change_password(username, password, uid=None):
if uid:
return __execute_cmd(
"config -g cfgUserAdmin -o \
cfgUserAdminPassword -i {} {}".format(
"config -g cfgUserAdmin -o cfgUserAdminPassword -i {} {}".format(
uid, password
)
)
@ -307,10 +285,7 @@ def create_user(username, password, permissions, users=None):
# Create user accountvfirst
if not __execute_cmd(
"config -g cfgUserAdmin -o \
cfgUserAdminUserName -i {} {}".format(
uid, username
)
"config -g cfgUserAdmin -o cfgUserAdminUserName -i {} {}".format(uid, username)
):
delete_user(username, uid)
return False
@ -329,10 +304,7 @@ def create_user(username, password, permissions, users=None):
# Enable users admin
if not __execute_cmd(
"config -g cfgUserAdmin -o \
cfgUserAdminEnable -i {} 1".format(
uid
)
"config -g cfgUserAdmin -o cfgUserAdminEnable -i {} 1".format(uid)
):
delete_user(username, uid)
return False
@ -389,8 +361,7 @@ def set_permissions(username, permissions, uid=None):
permission += int(privileges[perm], 16)
return __execute_cmd(
"config -g cfgUserAdmin -o \
cfgUserAdminPrivilege -i {} 0x{:08X}".format(
"config -g cfgUserAdmin -o cfgUserAdminPrivilege -i {} 0x{:08X}".format(
uid, permission
)
)
@ -408,10 +379,7 @@ def set_snmp(community):
salt dell drac.set_snmp public
"""
return __execute_cmd(
"config -g cfgOobSnmp -o \
cfgOobSnmpAgentCommunity {}".format(
community
)
"config -g cfgOobSnmp -o cfgOobSnmpAgentCommunity {}".format(community)
)
@ -493,10 +461,7 @@ def server_pxe():
salt dell drac.server_pxe
"""
if __execute_cmd(
"config -g cfgServerInfo -o \
cfgServerFirstBootDevice PXE"
):
if __execute_cmd("config -g cfgServerInfo -o cfgServerFirstBootDevice PXE"):
if __execute_cmd("config -g cfgServerInfo -o cfgServerBootOnce 1"):
return server_reboot
else:

View file

@ -62,7 +62,8 @@ def __virtual__():
return __virtualname__
return (
False,
"The ebuild execution module cannot be loaded: either the system is not Gentoo or the portage python library is not available.",
"The ebuild execution module cannot be loaded: either the system is not Gentoo"
" or the portage python library is not available.",
)

View file

@ -13,7 +13,8 @@ def __virtual__():
return "eix"
return (
False,
"The eix execution module cannot be loaded: either the system is not Gentoo or the eix binary is not in the path.",
"The eix execution module cannot be loaded: either the system is not Gentoo or"
" the eix binary is not in the path.",
)

View file

@ -203,9 +203,8 @@ def info(hosts=None, profile=None):
return es.info()
except elasticsearch.TransportError as e:
raise CommandExecutionError(
"Cannot retrieve server information, server returned code {} with message {}".format(
e.status_code, e.error
)
"Cannot retrieve server information, server returned code {} with"
" message {}".format(e.status_code, e.error)
)
@ -263,9 +262,8 @@ def cluster_health(index=None, level="cluster", local=False, hosts=None, profile
return es.cluster.health(index=index, level=level, local=local)
except elasticsearch.TransportError as e:
raise CommandExecutionError(
"Cannot retrieve health information, server returned code {} with message {}".format(
e.status_code, e.error
)
"Cannot retrieve health information, server returned code {} with"
" message {}".format(e.status_code, e.error)
)
@ -397,9 +395,8 @@ def alias_create(indices, alias, hosts=None, body=None, profile=None, source=Non
return result.get("acknowledged", False)
except elasticsearch.TransportError as e:
raise CommandExecutionError(
"Cannot create alias {} in index {}, server returned code {} with message {}".format(
alias, indices, e.status_code, e.error
)
"Cannot create alias {} in index {}, server returned code {} with"
" message {}".format(alias, indices, e.status_code, e.error)
)
@ -434,9 +431,8 @@ def alias_delete(indices, aliases, hosts=None, body=None, profile=None, source=N
return True
except elasticsearch.TransportError as e:
raise CommandExecutionError(
"Cannot delete alias {} in index {}, server returned code {} with message {}".format(
aliases, indices, e.status_code, e.error
)
"Cannot delete alias {} in index {}, server returned code {} with"
" message {}".format(aliases, indices, e.status_code, e.error)
)
@ -532,9 +528,8 @@ def document_create(
return es.index(index=index, doc_type=doc_type, body=body, id=id)
except elasticsearch.TransportError as e:
raise CommandExecutionError(
"Cannot create document in index {}, server returned code {} with message {}".format(
index, e.status_code, e.error
)
"Cannot create document in index {}, server returned code {} with"
" message {}".format(index, e.status_code, e.error)
)
@ -563,9 +558,8 @@ def document_delete(index, doc_type, id, hosts=None, profile=None):
return None
except elasticsearch.TransportError as e:
raise CommandExecutionError(
"Cannot delete document {} in index {}, server returned code {} with message {}".format(
id, index, e.status_code, e.error
)
"Cannot delete document {} in index {}, server returned code {} with"
" message {}".format(id, index, e.status_code, e.error)
)
@ -594,9 +588,8 @@ def document_exists(index, id, doc_type="_all", hosts=None, profile=None):
return False
except elasticsearch.TransportError as e:
raise CommandExecutionError(
"Cannot retrieve document {} from index {}, server returned code {} with message {}".format(
id, index, e.status_code, e.error
)
"Cannot retrieve document {} from index {}, server returned code {} with"
" message {}".format(id, index, e.status_code, e.error)
)
@ -625,9 +618,8 @@ def document_get(index, id, doc_type="_all", hosts=None, profile=None):
return None
except elasticsearch.TransportError as e:
raise CommandExecutionError(
"Cannot retrieve document {} from index {}, server returned code {} with message {}".format(
id, index, e.status_code, e.error
)
"Cannot retrieve document {} from index {}, server returned code {} with"
" message {}".format(id, index, e.status_code, e.error)
)
@ -1597,7 +1589,8 @@ def snapshot_get(
)
except elasticsearch.TransportError as e:
raise CommandExecutionError(
"Cannot obtain details of snapshot {} in repository {}, server returned code {} with message {}".format(
"Cannot obtain details of snapshot {} in repository {}, server returned"
" code {} with message {}".format(
snapshot, repository, e.status_code, e.error
)
)
@ -1632,9 +1625,8 @@ def snapshot_create(repository, snapshot, body=None, hosts=None, profile=None):
return response.get("accepted", False)
except elasticsearch.TransportError as e:
raise CommandExecutionError(
"Cannot create snapshot {} in repository {}, server returned code {} with message {}".format(
snapshot, repository, e.status_code, e.error
)
"Cannot create snapshot {} in repository {}, server returned code {} with"
" message {}".format(snapshot, repository, e.status_code, e.error)
)
@ -1667,9 +1659,8 @@ def snapshot_restore(repository, snapshot, body=None, hosts=None, profile=None):
return response.get("accepted", False)
except elasticsearch.TransportError as e:
raise CommandExecutionError(
"Cannot restore snapshot {} in repository {}, server returned code {} with message {}".format(
snapshot, repository, e.status_code, e.error
)
"Cannot restore snapshot {} in repository {}, server returned code {} with"
" message {}".format(snapshot, repository, e.status_code, e.error)
)
@ -1700,9 +1691,8 @@ def snapshot_delete(repository, snapshot, hosts=None, profile=None):
return True
except elasticsearch.TransportError as e:
raise CommandExecutionError(
"Cannot delete snapshot {} from repository {}, server returned code {} with message {}".format(
snapshot, repository, e.status_code, e.error
)
"Cannot delete snapshot {} from repository {}, server returned code {} with"
" message {}".format(snapshot, repository, e.status_code, e.error)
)

View file

@ -18,7 +18,8 @@ def __virtual__():
return "eselect"
return (
False,
"The eselect execution module cannot be loaded: either the system is not Gentoo or the eselect binary is not in the path.",
"The eselect execution module cannot be loaded: either the system is not Gentoo"
" or the eselect binary is not in the path.",
)

View file

@ -30,7 +30,8 @@ def __virtual__():
if __grains__["os"] != "FreeBSD":
return (
False,
"The freebsd_update execution module cannot be loaded: only available on FreeBSD systems.",
"The freebsd_update execution module cannot be loaded: only available on"
" FreeBSD systems.",
)
if float(__grains__["osrelease"]) < 6.2:
return (

View file

@ -25,7 +25,8 @@ def __virtual__():
return __virtualname__
return (
False,
"The freebsdkmod execution module cannot be loaded: only available on FreeBSD systems.",
"The freebsdkmod execution module cannot be loaded: only available on FreeBSD"
" systems.",
)

View file

@ -104,12 +104,14 @@ def __virtual__():
)
return (
False,
"The freebsdpkg execution module cannot be loaded: the configuration option 'providers:pkg' is set to 'pkgng'",
"The freebsdpkg execution module cannot be loaded: the configuration"
" option 'providers:pkg' is set to 'pkgng'",
)
return __virtualname__
return (
False,
"The freebsdpkg execution module cannot be loaded: either the os is not FreeBSD or the version of FreeBSD is >= 10.",
"The freebsdpkg execution module cannot be loaded: either the os is not FreeBSD"
" or the version of FreeBSD is >= 10.",
)

View file

@ -35,7 +35,8 @@ def __virtual__():
return __virtualname__
return (
False,
"The freebsdservice execution module cannot be loaded: only available on FreeBSD systems.",
"The freebsdservice execution module cannot be loaded: only available on"
" FreeBSD systems.",
)

View file

@ -137,7 +137,7 @@ def freeze(name=None, force=False, **kwargs):
if status(name) and not force:
raise CommandExecutionError(
"The state is already present. Use " "force parameter to overwrite."
"The state is already present. Use force parameter to overwrite."
)
safe_kwargs = clean_kwargs(**kwargs)
pkgs = __salt__["pkg.list_pkgs"](**safe_kwargs)

View file

@ -39,7 +39,8 @@ def __virtual__():
if HAS_LIB is False:
return (
False,
"Required dependencies 'googleapiclient' and/or 'oauth2client' were not found.",
"Required dependencies 'googleapiclient' and/or 'oauth2client' were not"
" found.",
)
return __virtualname__

View file

@ -26,8 +26,8 @@ def __virtual__():
return __virtualname__
return (
False,
"The gentoolkitmod execution module cannot be loaded: "
"either the system is not Gentoo or the gentoolkit.eclean python module not available",
"The gentoolkitmod execution module cannot be loaded: either the system is not"
" Gentoo or the gentoolkit.eclean python module not available",
)

View file

@ -87,8 +87,9 @@ def _get_config_value(profile, config_name):
config_value = config.get(config_name)
if config_value is None:
raise CommandExecutionError(
"The '{}' parameter was not found in the '{}' "
"profile.".format(config_name, profile)
"The '{}' parameter was not found in the '{}' profile.".format(
config_name, profile
)
)
return config_value

View file

@ -45,7 +45,8 @@ def __virtual__():
return __virtualname__
return (
False,
"The glanceng execution module failed to load: shade python module is not available",
"The glanceng execution module failed to load: shade python module is not"
" available",
)

View file

@ -38,8 +38,9 @@ def __virtual__():
else:
return (
False,
'The "{}" module could not be loaded: '
'"requests" is not installed.'.format(__virtualname__),
'The "{}" module could not be loaded: "requests" is not installed.'.format(
__virtualname__
),
)

View file

@ -40,8 +40,9 @@ def __virtual__():
else:
return (
False,
'The "{}" module could not be loaded: '
'"requests" is not installed.'.format(__virtualname__),
'The "{}" module could not be loaded: "requests" is not installed.'.format(
__virtualname__
),
)

View file

@ -22,7 +22,8 @@ def __virtual__():
return "hadoop"
return (
False,
"The hadoop execution module cannot be loaded: hadoop or hdfs binary not in path.",
"The hadoop execution module cannot be loaded: hadoop or hdfs binary not in"
" path.",
)
@ -111,7 +112,10 @@ def dfsadmin_report(arg=None):
if arg in ["live", "dead", "decommissioning"]:
return _hadoop_cmd("dfsadmin", "report", arg)
else:
return "Error: the arg is wrong, it must be in ['live', 'dead', 'decommissioning']"
return (
"Error: the arg is wrong, it must be in ['live', 'dead',"
" 'decommissioning']"
)
else:
return _hadoop_cmd("dfsadmin", "report")

View file

@ -39,7 +39,8 @@ def __virtual__():
return __virtualname__
return (
False,
"The haproxyconn execution module cannot be loaded: haproxyctl module not available",
"The haproxyconn execution module cannot be loaded: haproxyctl module not"
" available",
)

View file

@ -56,10 +56,8 @@ def __virtual__():
return __virtualname__
return (
False,
(
"The influxdb execution module could not be loaded:"
"influxdb library not available."
),
"The influxdb execution module could not be loaded:"
"influxdb library not available.",
)

View file

@ -257,10 +257,7 @@ class Inspector(EnvLoader):
for p_type, p_list in (
("f", files),
("d", directories),
(
"l",
links,
),
("l", links),
):
for p_obj in p_list:
stats = os.stat(p_obj)
@ -539,7 +536,10 @@ class Inspector(EnvLoader):
:return:
"""
if kiwi is None:
msg = "Unable to build the image due to the missing dependencies: Kiwi module is not available."
msg = (
"Unable to build the image due to the missing dependencies: Kiwi module"
" is not available."
)
log.error(msg)
raise CommandExecutionError(msg)

View file

@ -62,7 +62,8 @@ def status(jboss_config, host=None, server_config=None):
)
else:
raise SaltInvocationError(
"Invalid parameters. Must either pass both host and server_config or neither"
"Invalid parameters. Must either pass both host and server_config or"
" neither"
)
return __salt__["jboss7_cli.run_operation"](
jboss_config, operation, fail_on_error=False, retries=0
@ -178,7 +179,8 @@ def create_datasource(jboss_config, name, datasource_properties, profile=None):
salt '*' jboss7.create_datasource '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}' 'my_datasource' '{"driver-name": "mysql", "connection-url": "jdbc:mysql://localhost:3306/sampleDatabase", "jndi-name": "java:jboss/datasources/sampleDS", "user-name": "sampleuser", "password": "secret", "min-pool-size": 3, "use-java-context": True}'
"""
log.debug(
"======================== MODULE FUNCTION: jboss7.create_datasource, name=%s, profile=%s",
"======================== MODULE FUNCTION: jboss7.create_datasource, name=%s,"
" profile=%s",
name,
profile,
)
@ -269,7 +271,8 @@ def update_datasource(jboss_config, name, new_properties, profile=None):
"""
log.debug(
"======================== MODULE FUNCTION: jboss7.update_datasource, name=%s, profile=%s",
"======================== MODULE FUNCTION: jboss7.update_datasource, name=%s,"
" profile=%s",
name,
profile,
)
@ -290,10 +293,10 @@ def update_datasource(jboss_config, name, new_properties, profile=None):
)
if not update_result["success"]:
ret["result"] = False
ret["comment"] = ret["comment"] + (
"Could not update datasource property {} with value {},\n stdout: {}\n".format(
key, new_properties[key], update_result["stdout"]
)
ret["comment"] = ret[
"comment"
] + "Could not update datasource property {} with value {},\n stdout: {}\n".format(
key, new_properties[key], update_result["stdout"]
)
return ret
@ -301,7 +304,8 @@ def update_datasource(jboss_config, name, new_properties, profile=None):
def __get_datasource_resource_description(jboss_config, name, profile=None):
log.debug(
"======================== MODULE FUNCTION: jboss7.__get_datasource_resource_description, name=%s, profile=%s",
"======================== MODULE FUNCTION:"
" jboss7.__get_datasource_resource_description, name=%s, profile=%s",
name,
profile,
)
@ -365,13 +369,17 @@ def create_simple_binding(jboss_config, binding_name, value, profile=None):
my_binding_name my_binding_value
"""
log.debug(
"======================== MODULE FUNCTION: jboss7.create_simple_binding, binding_name=%s, value=%s, profile=%s",
"======================== MODULE FUNCTION: jboss7.create_simple_binding,"
" binding_name=%s, value=%s, profile=%s",
binding_name,
value,
profile,
)
operation = '/subsystem=naming/binding="{binding_name}":add(binding-type=simple, value="{value}")'.format(
binding_name=binding_name, value=__escape_binding_value(value)
operation = (
'/subsystem=naming/binding="{binding_name}":add(binding-type=simple,'
' value="{value}")'.format(
binding_name=binding_name, value=__escape_binding_value(value)
)
)
if profile is not None:
operation = '/profile="{profile}"'.format(profile=profile) + operation
@ -398,13 +406,17 @@ def update_simple_binding(jboss_config, binding_name, value, profile=None):
salt '*' jboss7.update_simple_binding '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}' my_binding_name my_binding_value
"""
log.debug(
"======================== MODULE FUNCTION: jboss7.update_simple_binding, binding_name=%s, value=%s, profile=%s",
"======================== MODULE FUNCTION: jboss7.update_simple_binding,"
" binding_name=%s, value=%s, profile=%s",
binding_name,
value,
profile,
)
operation = '/subsystem=naming/binding="{binding_name}":write-attribute(name=value, value="{value}")'.format(
binding_name=binding_name, value=__escape_binding_value(value)
operation = (
'/subsystem=naming/binding="{binding_name}":write-attribute(name=value,'
' value="{value}")'.format(
binding_name=binding_name, value=__escape_binding_value(value)
)
)
if profile is not None:
operation = '/profile="{profile}"'.format(profile=profile) + operation
@ -449,7 +461,8 @@ def __update_datasource_property(
jboss_config, datasource_name, name, value, ds_attributes, profile=None
):
log.debug(
"======================== MODULE FUNCTION: jboss7.__update_datasource_property, datasource_name=%s, name=%s, value=%s, profile=%s",
"======================== MODULE FUNCTION: jboss7.__update_datasource_property,"
" datasource_name=%s, name=%s, value=%s, profile=%s",
datasource_name,
name,
value,
@ -506,7 +519,8 @@ def remove_datasource(jboss_config, name, profile=None):
salt '*' jboss7.remove_datasource '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}' my_datasource_name
"""
log.debug(
"======================== MODULE FUNCTION: jboss7.remove_datasource, name=%s, profile=%s",
"======================== MODULE FUNCTION: jboss7.remove_datasource, name=%s,"
" profile=%s",
name,
profile,
)

View file

@ -171,7 +171,8 @@ def _call_cli(jboss_config, command, retries=1):
if cli_command_result["retcode"] == 127:
raise CommandExecutionError(
"Could not execute jboss-cli.sh script. Have you specified server_dir variable correctly?\nCurrent CLI path: {cli_path}. ".format(
"Could not execute jboss-cli.sh script. Have you specified server_dir"
" variable correctly?\nCurrent CLI path: {cli_path}. ".format(
cli_path=jboss_config["cli_path"]
)
)
@ -181,9 +182,9 @@ def _call_cli(jboss_config, command, retries=1):
and "Unable to authenticate against controller" in cli_command_result["stderr"]
):
raise CommandExecutionError(
"Could not authenticate against controller, please check username and password for the management console. Err code: {retcode}, stdout: {stdout}, stderr: {stderr}".format(
**cli_command_result
)
"Could not authenticate against controller, please check username and"
" password for the management console. Err code: {retcode}, stdout:"
" {stdout}, stderr: {stderr}".format(**cli_command_result)
)
# TODO add WFLYCTL code

View file

@ -581,7 +581,7 @@ def _source_encode(source, saltenv):
try:
source_url = urllib.parse.urlparse(source)
except TypeError:
return "", {}, ("Invalid format for source parameter")
return "", {}, "Invalid format for source parameter"
protos = ("salt", "http", "https", "ftp", "swift", "s3", "file")

View file

@ -86,7 +86,8 @@ def __virtual__():
return "keystone"
return (
False,
"keystone execution module cannot be loaded: keystoneclient python library not available.",
"keystone execution module cannot be loaded: keystoneclient python library not"
" available.",
)
@ -173,10 +174,8 @@ def auth(profile=None, **connection_args):
"""
__utils__["versions.warn_until"](
"Phosphorus",
(
"The keystone module has been deprecated and will be removed in {version}. "
"Please update to using the keystoneng module"
),
"The keystone module has been deprecated and will be removed in {version}. "
"Please update to using the keystoneng module",
)
kwargs = _get_kwargs(profile=profile, **connection_args)
@ -370,8 +369,9 @@ def endpoint_get(service, region=None, profile=None, interface=None, **connectio
]
if len(e) > 1:
return {
"Error": "Multiple endpoints found ({}) for the {} service. Please specify region.".format(
e, service
"Error": (
"Multiple endpoints found ({}) for the {} service. Please specify"
" region.".format(e, service)
)
}
if len(e) == 1:

View file

@ -46,7 +46,8 @@ def __virtual__():
return __virtualname__
return (
False,
"The keystoneng execution module failed to load: shade python module is not available",
"The keystoneng execution module failed to load: shade python module is not"
" available",
)

View file

@ -213,11 +213,13 @@ def _setup_conn(**kwargs):
return _setup_conn_old(**kwargs)
except Exception: # pylint: disable=broad-except
raise CommandExecutionError(
"Old style kubernetes configuration is only supported up to python-kubernetes 2.0.0"
"Old style kubernetes configuration is only supported up to"
" python-kubernetes 2.0.0"
)
else:
raise CommandExecutionError(
"Invalid kubernetes configuration. Parameter 'kubeconfig' and 'context' are required."
"Invalid kubernetes configuration. Parameter 'kubeconfig' and 'context'"
" are required."
)
kubernetes.config.load_kube_config(config_file=kubeconfig, context=context)
@ -499,9 +501,7 @@ def services(namespace="default", **kwargs):
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception(
"Exception when calling " "CoreV1Api->list_namespaced_service"
)
log.exception("Exception when calling CoreV1Api->list_namespaced_service")
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
@ -528,7 +528,7 @@ def pods(namespace="default", **kwargs):
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception("Exception when calling " "CoreV1Api->list_namespaced_pod")
log.exception("Exception when calling CoreV1Api->list_namespaced_pod")
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
@ -557,7 +557,7 @@ def secrets(namespace="default", **kwargs):
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception("Exception when calling " "CoreV1Api->list_namespaced_secret")
log.exception("Exception when calling CoreV1Api->list_namespaced_secret")
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
@ -587,7 +587,7 @@ def configmaps(namespace="default", **kwargs):
return None
else:
log.exception(
"Exception when calling " "CoreV1Api->list_namespaced_config_map"
"Exception when calling CoreV1Api->list_namespaced_config_map"
)
raise CommandExecutionError(exc)
finally:
@ -645,9 +645,7 @@ def show_service(name, namespace="default", **kwargs):
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception(
"Exception when calling " "CoreV1Api->read_namespaced_service"
)
log.exception("Exception when calling CoreV1Api->read_namespaced_service")
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
@ -674,7 +672,7 @@ def show_pod(name, namespace="default", **kwargs):
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception("Exception when calling " "CoreV1Api->read_namespaced_pod")
log.exception("Exception when calling CoreV1Api->read_namespaced_pod")
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
@ -700,7 +698,7 @@ def show_namespace(name, **kwargs):
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception("Exception when calling " "CoreV1Api->read_namespace")
log.exception("Exception when calling CoreV1Api->read_namespace")
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
@ -735,7 +733,7 @@ def show_secret(name, namespace="default", decode=False, **kwargs):
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception("Exception when calling " "CoreV1Api->read_namespaced_secret")
log.exception("Exception when calling CoreV1Api->read_namespaced_secret")
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
@ -763,7 +761,7 @@ def show_configmap(name, namespace="default", **kwargs):
return None
else:
log.exception(
"Exception when calling " "CoreV1Api->read_namespaced_config_map"
"Exception when calling CoreV1Api->read_namespaced_config_map"
)
raise CommandExecutionError(exc)
finally:
@ -883,7 +881,7 @@ def delete_pod(name, namespace="default", **kwargs):
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception("Exception when calling " "CoreV1Api->delete_namespaced_pod")
log.exception("Exception when calling CoreV1Api->delete_namespaced_pod")
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
@ -911,7 +909,7 @@ def delete_namespace(name, **kwargs):
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception("Exception when calling " "CoreV1Api->delete_namespace")
log.exception("Exception when calling CoreV1Api->delete_namespace")
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
@ -974,7 +972,7 @@ def delete_configmap(name, namespace="default", **kwargs):
return None
else:
log.exception(
"Exception when calling " "CoreV1Api->delete_namespaced_config_map"
"Exception when calling CoreV1Api->delete_namespaced_config_map"
)
raise CommandExecutionError(exc)
finally:
@ -1048,7 +1046,7 @@ def create_pod(name, namespace, metadata, spec, source, template, saltenv, **kwa
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception("Exception when calling " "CoreV1Api->create_namespaced_pod")
log.exception("Exception when calling CoreV1Api->create_namespaced_pod")
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
@ -1084,9 +1082,7 @@ def create_service(
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception(
"Exception when calling " "CoreV1Api->create_namespaced_service"
)
log.exception("Exception when calling CoreV1Api->create_namespaced_service")
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
@ -1140,9 +1136,7 @@ def create_secret(
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception(
"Exception when calling " "CoreV1Api->create_namespaced_secret"
)
log.exception("Exception when calling CoreV1Api->create_namespaced_secret")
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
@ -1187,7 +1181,7 @@ def create_configmap(
return None
else:
log.exception(
"Exception when calling " "CoreV1Api->create_namespaced_config_map"
"Exception when calling CoreV1Api->create_namespaced_config_map"
)
raise CommandExecutionError(exc)
finally:
@ -1221,7 +1215,7 @@ def create_namespace(name, **kwargs):
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception("Exception when calling " "CoreV1Api->create_namespace")
log.exception("Exception when calling CoreV1Api->create_namespace")
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
@ -1312,7 +1306,7 @@ def replace_service(
return None
else:
log.exception(
"Exception when calling " "CoreV1Api->replace_namespaced_service"
"Exception when calling CoreV1Api->replace_namespaced_service"
)
raise CommandExecutionError(exc)
finally:
@ -1368,9 +1362,7 @@ def replace_secret(
if isinstance(exc, ApiException) and exc.status == 404:
return None
else:
log.exception(
"Exception when calling " "CoreV1Api->replace_namespaced_secret"
)
log.exception("Exception when calling CoreV1Api->replace_namespaced_secret")
raise CommandExecutionError(exc)
finally:
_cleanup(**cfg)
@ -1420,7 +1412,7 @@ def replace_configmap(
return None
else:
log.exception(
"Exception when calling " "CoreV1Api->replace_namespaced_configmap"
"Exception when calling CoreV1Api->replace_namespaced_configmap"
)
raise CommandExecutionError(exc)
finally:
@ -1450,7 +1442,7 @@ def __create_object_body(
or src_obj["kind"] != kind
):
raise CommandExecutionError(
"The source file should define only " "a {} object".format(kind)
"The source file should define only a {} object".format(kind)
)
if "metadata" in src_obj:
@ -1495,8 +1487,7 @@ def __read_and_render_yaml_file(source, template, saltenv):
if not data["result"]:
# Failed to render the template
raise CommandExecutionError(
"Failed to render file path with error: "
"{}".format(data["data"])
"Failed to render file path with error: {}".format(data["data"])
)
contents = data["data"].encode("utf-8")

View file

@ -41,8 +41,7 @@ def __virtual__():
if not salt.utils.platform.is_darwin():
return (
False,
"Failed to load the mac_service module:\n"
"Only available on macOS systems.",
"Failed to load the mac_service module:\nOnly available on macOS systems.",
)
if not os.path.exists("/bin/launchctl"):

View file

@ -14,7 +14,8 @@ def __virtual__():
return "layman"
return (
False,
"layman execution module cannot be loaded: only available on Gentoo with layman installed.",
"layman execution module cannot be loaded: only available on Gentoo with layman"
" installed.",
)

View file

@ -153,7 +153,7 @@ def search(
_ldap = _connect(**kwargs)
start = time.time()
log.debug(
"Running LDAP search with filter:%s, dn:%s, scope:%s, " "attrs:%s",
"Running LDAP search with filter:%s, dn:%s, scope:%s, attrs:%s",
filter,
dn,
scope,

View file

@ -62,10 +62,12 @@ def __virtual__():
Only load if libcloud libraries exist.
"""
if not HAS_LIBCLOUD:
msg = (
"A apache-libcloud library with version at least {} was not " "found"
).format(REQUIRED_LIBCLOUD_VERSION)
return (False, msg)
return (
False,
"A apache-libcloud library with version at least {} was not found".format(
REQUIRED_LIBCLOUD_VERSION
),
)
return True

View file

@ -57,10 +57,12 @@ def __virtual__():
Only load if libcloud libraries exist.
"""
if not HAS_LIBCLOUD:
msg = (
"A apache-libcloud library with version at least {} was not " "found"
).format(REQUIRED_LIBCLOUD_VERSION)
return (False, msg)
return (
False,
"A apache-libcloud library with version at least {} was not found".format(
REQUIRED_LIBCLOUD_VERSION
),
)
return True

View file

@ -61,10 +61,12 @@ def __virtual__():
Only load if libcloud libraries exist.
"""
if not HAS_LIBCLOUD:
msg = (
"A apache-libcloud library with version at least {} was not " "found"
).format(REQUIRED_LIBCLOUD_VERSION)
return (False, msg)
return (
False,
"A apache-libcloud library with version at least {} was not found".format(
REQUIRED_LIBCLOUD_VERSION
),
)
return True

View file

@ -60,10 +60,12 @@ def __virtual__():
Only load if libcloud libraries exist.
"""
if not HAS_LIBCLOUD:
msg = (
"A apache-libcloud library with version at least {} was not " "found"
).format(REQUIRED_LIBCLOUD_VERSION)
return (False, msg)
return (
False,
"A apache-libcloud library with version at least {} was not found".format(
REQUIRED_LIBCLOUD_VERSION
),
)
return True

View file

@ -22,7 +22,8 @@ def __virtual__():
if not __detect_os():
return (
False,
"The lvs execution module cannot be loaded: the ipvsadm binary is not in the path.",
"The lvs execution module cannot be loaded: the ipvsadm binary is not in"
" the path.",
)
return "lvs"

View file

@ -76,7 +76,8 @@ def __virtual__():
#
return (
False,
"The lxc execution module cannot be loaded: the lxc-start binary is not in the path.",
"The lxc execution module cannot be loaded: the lxc-start binary is not in the"
" path.",
)
@ -1575,7 +1576,7 @@ def init(
if (
retcode(
name,
('sh -c \'touch "{0}"; test -e "{0}"\''.format(gid)),
'sh -c \'touch "{0}"; test -e "{0}"\''.format(gid),
path=path,
chroot_fallback=True,
ignore_retcode=True,
@ -1614,7 +1615,7 @@ def init(
if (
retcode(
name,
('sh -c \'touch "{0}"; test -e "{0}"\''.format(gid)),
'sh -c \'touch "{0}"; test -e "{0}"\''.format(gid),
chroot_fallback=True,
path=path,
ignore_retcode=True,
@ -1668,9 +1669,9 @@ def init(
ret["result"] = False
else:
if not result:
ret["comment"] = (
"Bootstrap failed, see minion log for " "more information"
)
ret[
"comment"
] = "Bootstrap failed, see minion log for more information"
ret["result"] = False
else:
changes.append({"bootstrap": "Container successfully bootstrapped"})
@ -1694,8 +1695,10 @@ def init(
else:
changes.append(
{
"bootstrap": "Container successfully bootstrapped "
"using seed_cmd '{}'".format(seed_cmd)
"bootstrap": (
"Container successfully bootstrapped "
"using seed_cmd '{}'".format(seed_cmd)
)
}
)
@ -1971,7 +1974,7 @@ def create(
raise SaltInvocationError("Only one of 'template' and 'image' is permitted")
elif not any((template, image, profile)):
raise SaltInvocationError(
"At least one of 'template', 'image', and 'profile' is " "required"
"At least one of 'template', 'image', and 'profile' is required"
)
options = select("options") or {}
@ -2329,8 +2332,9 @@ def _change_state(
if _cmdout["retcode"] != 0:
raise CommandExecutionError(
"Error changing state for container '{}' using command "
"'{}': {}".format(name, cmd, _cmdout["stdout"])
"Error changing state for container '{}' using command '{}': {}".format(
name, cmd, _cmdout["stdout"]
)
)
if expected is not None:
# some commands do not wait, so we will
@ -3231,7 +3235,7 @@ def running_systemd(name, cache=True, path=None):
if result["retcode"] == 0:
result = run_all(
name,
'sh -c "chmod +x {0};{0}"' "".format(script),
'sh -c "chmod +x {0};{0}"'.format(script),
path=path,
python_shell=True,
)
@ -3241,7 +3245,7 @@ def running_systemd(name, cache=True, path=None):
)
run_all(
name,
'sh -c \'if [ -f "{0}" ];then rm -f "{0}";fi\'' "".format(script),
'sh -c \'if [ -f "{0}" ];then rm -f "{0}";fi\''.format(script),
path=path,
ignore_retcode=True,
python_shell=True,
@ -3593,7 +3597,7 @@ def bootstrap(
run_all(
name,
'sh -c \'if [ -f "{0}" ];then rm -f "{0}";fi\'' "".format(script),
'sh -c \'if [ -f "{0}" ];then rm -f "{0}";fi\''.format(script),
path=path,
ignore_retcode=True,
python_shell=True,

View file

@ -85,21 +85,18 @@ def __virtual__():
if LooseVersion(pylxd_version()) < LooseVersion(_pylxd_minimal_version):
return (
False,
(
"The lxd execution module cannot be loaded:"
' pylxd "{}" is not supported,'
' you need at least pylxd "{}"'
).format(pylxd_version(), _pylxd_minimal_version),
'The lxd execution module cannot be loaded: pylxd "{}" is '
'not supported, you need at least pylxd "{}"'.format(
pylxd_version(), _pylxd_minimal_version
),
)
return __virtualname__
return (
False,
(
"The lxd execution module cannot be loaded: "
"the pylxd python module is not available."
),
"The lxd execution module cannot be loaded: "
"the pylxd python module is not available.",
)
@ -184,7 +181,7 @@ def init(
salt '*' lxd.init
"""
cmd = ("lxd init --auto" ' --storage-backend="{}"').format(storage_backend)
cmd = 'lxd init --auto --storage-backend="{}"'.format(storage_backend)
if trust_password is not None:
cmd = cmd + ' --trust-password="{}"'.format(trust_password)
@ -351,18 +348,14 @@ def pylxd_client_get(remote_addr=None, cert=None, key=None, verify_cert=True):
if not os.path.isfile(cert):
raise SaltInvocationError(
(
'You have given an invalid cert path: "{}", '
"the file does not exists or is not a file."
).format(cert)
'You have given an invalid cert path: "{}", the '
"file does not exist or is not a file.".format(cert)
)
if not os.path.isfile(key):
raise SaltInvocationError(
(
'You have given an invalid key path: "{}", '
"the file does not exists or is not a file."
).format(key)
'You have given an invalid key path: "{}", the '
"file does not exists or is not a file.".format(key)
)
log.debug(
@ -387,10 +380,8 @@ def pylxd_client_get(remote_addr=None, cert=None, key=None, verify_cert=True):
except TypeError as e:
# Happens when the verification failed.
raise CommandExecutionError(
(
'Failed to connect to "{}",'
" looks like the SSL verification failed, error was: {}"
).format(remote_addr, str(e))
'Failed to connect to "{}", looks like the SSL verification '
"failed, error was: {}".format(remote_addr, str(e))
)
_connection_pool[pool_key] = client
@ -3449,7 +3440,7 @@ def sync_config_devices(obj, newconfig, newdevices, test=False):
if not test:
config_changes[
k
] = 'Changed config key "{}" to "{}", ' 'its value was "{}"'.format(
] = 'Changed config key "{}" to "{}", its value was "{}"'.format(
k, newconfig[k], obj.config[k]
)
obj.config[k] = newconfig[k]

View file

@ -217,7 +217,7 @@ def increment(key, delta=1, host=DEFAULT_HOST, port=DEFAULT_PORT):
raise CommandExecutionError("Key '{}' does not exist".format(key))
elif not isinstance(cur, int):
raise CommandExecutionError(
"Value for key '{}' must be an integer to be " "incremented".format(key)
"Value for key '{}' must be an integer to be incremented".format(key)
)
try:
@ -248,7 +248,7 @@ def decrement(key, delta=1, host=DEFAULT_HOST, port=DEFAULT_PORT):
raise CommandExecutionError("Key '{}' does not exist".format(key))
elif not isinstance(cur, int):
raise CommandExecutionError(
"Value for key '{}' must be an integer to be " "decremented".format(key)
"Value for key '{}' must be an integer to be decremented".format(key)
)
try:

Some files were not shown because too many files have changed in this diff Show more