mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Clean up and linting issues
This commit is contained in:
parent
fc89d6fe8b
commit
630db2b261
1 changed files with 41 additions and 53 deletions
|
@ -180,16 +180,6 @@ def list_nodes(call=None):
|
|||
)
|
||||
return _list_nodes()
|
||||
|
||||
def list_vpcs(call=None):
|
||||
"""
|
||||
Return a list of the VMs that are on the provider
|
||||
"""
|
||||
if call == "action":
|
||||
raise SaltCloudSystemExit(
|
||||
"The list_nodes function must be called with -f or --function."
|
||||
)
|
||||
return _list_vpcs()
|
||||
|
||||
def list_nodes_full(call=None, for_output=True):
|
||||
"""
|
||||
Return a list of the VMs that are on the provider
|
||||
|
@ -373,35 +363,33 @@ def create(vm_):
|
|||
)
|
||||
|
||||
if vpc_name is not None:
|
||||
vpc = _get_vpc_by_name(vpc_name)
|
||||
if vpc is None:
|
||||
raise SaltCloudConfigError(
|
||||
"Invalid VPC name provided"
|
||||
)
|
||||
else:
|
||||
kwargs["vpc_uuid"] = vpc[vpc_name]['id']
|
||||
vpc = _get_vpc_by_name(vpc_name)
|
||||
if vpc is None:
|
||||
raise SaltCloudConfigError(
|
||||
"Invalid VPC name provided"
|
||||
)
|
||||
else:
|
||||
kwargs["vpc_uuid"] = vpc[vpc_name]['id']
|
||||
else:
|
||||
private_networking = config.get_cloud_config_value(
|
||||
"private_networking",
|
||||
vm_,
|
||||
__opts__,
|
||||
search_global=False,
|
||||
default=None,
|
||||
)
|
||||
|
||||
if private_networking is not None:
|
||||
if not isinstance(private_networking, bool):
|
||||
raise SaltCloudConfigError(
|
||||
"'private_networking' should be a boolean value."
|
||||
)
|
||||
kwargs["private_networking"] = private_networking
|
||||
|
||||
if not private_networking and ssh_interface == "private":
|
||||
raise SaltCloudConfigError(
|
||||
"The DigitalOcean driver requires ssh_interface if defined as 'private' "
|
||||
"then private_networking should be set as 'True'."
|
||||
)
|
||||
|
||||
private_networking = config.get_cloud_config_value(
|
||||
"private_networking",
|
||||
vm_,
|
||||
__opts__,
|
||||
search_global=False,
|
||||
default=None,
|
||||
)
|
||||
if private_networking is not None:
|
||||
if not isinstance(private_networking, bool):
|
||||
raise SaltCloudConfigError(
|
||||
"'private_networking' should be a boolean value."
|
||||
)
|
||||
kwargs["private_networking"] = private_networking
|
||||
|
||||
if not private_networking and ssh_interface == "private":
|
||||
raise SaltCloudConfigError(
|
||||
"The DigitalOcean driver requires ssh_interface if defined as 'private' "
|
||||
"then private_networking should be set as 'True'."
|
||||
)
|
||||
backups_enabled = config.get_cloud_config_value(
|
||||
"backups_enabled",
|
||||
vm_,
|
||||
|
@ -636,11 +624,11 @@ def query(
|
|||
default="https://api.digitalocean.com/v2",
|
||||
)
|
||||
)
|
||||
# vpcs method doesn't like the / at the end.
|
||||
# vpcs method doesn't like the / at the end.
|
||||
if method == 'vpcs':
|
||||
path = "{}/{}".format(base_path, method)
|
||||
path = "{}/{}".format(base_path, method)
|
||||
else:
|
||||
path = "{}/{}/".format(base_path, method)
|
||||
path = "{}/{}/".format(base_path, method)
|
||||
|
||||
if droplet_id:
|
||||
path += "{}/".format(droplet_id)
|
||||
|
@ -1293,18 +1281,18 @@ def _get_vpc_by_name(name):
|
|||
items = query(method="vpcs", command="?page=" + str(page) + "&per_page=200")
|
||||
for node in items["vpcs"]:
|
||||
log.debug("Node returned : %s", node["name"])
|
||||
if(name == node["name"]):
|
||||
log.debug("Matched VPC node")
|
||||
ret[name] = {
|
||||
"id": node["id"],
|
||||
"urn": node["urn"],
|
||||
"name": name,
|
||||
"description": node["description"],
|
||||
"region": node["region"],
|
||||
"ip_range": node["ip_range"],
|
||||
"default": node["default"],
|
||||
}
|
||||
return ret
|
||||
if name == node["name"]:
|
||||
log.debug("Matched VPC node")
|
||||
ret[name] = {
|
||||
"id": node["id"],
|
||||
"urn": node["urn"],
|
||||
"name": name,
|
||||
"description": node["description"],
|
||||
"region": node["region"],
|
||||
"ip_range": node["ip_range"],
|
||||
"default": node["default"],
|
||||
}
|
||||
return ret
|
||||
page += 1
|
||||
try:
|
||||
fetch = "next" in items["links"]["pages"]
|
||||
|
|
Loading…
Add table
Reference in a new issue