mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cloudstack: fix pep8 cloudstack inventory (#22092)
This commit is contained in:
parent
f761949cca
commit
87119479d8
1 changed files with 7 additions and 12 deletions
|
@ -72,7 +72,6 @@ usage: cloudstack.py [--list] [--host HOST] [--project PROJECT] [--domain DOMAI
|
|||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
|
@ -102,9 +101,8 @@ class CloudStackInventory(object):
|
|||
options = parser.parse_args()
|
||||
try:
|
||||
self.cs = CloudStack(**read_config())
|
||||
except CloudStackException as e:
|
||||
except CloudStackException:
|
||||
print("Error: Could not connect to CloudStack API", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
domain_id = None
|
||||
if options.domain:
|
||||
|
@ -122,8 +120,7 @@ class CloudStackInventory(object):
|
|||
data = self.get_list(project_id, domain_id)
|
||||
print(json.dumps(data, indent=2))
|
||||
else:
|
||||
print("usage: --list | --host <hostname> [--project <project>] [--domain <domain_path>]",
|
||||
file=sys.stderr)
|
||||
print("usage: --list | --host <hostname> [--project <project>] [--domain <domain_path>]", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
def get_domain_id(self, domain):
|
||||
|
@ -144,7 +141,6 @@ class CloudStackInventory(object):
|
|||
print("Error: Project %s not found." % project, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def get_host(self, name, project_id=None, domain_id=None):
|
||||
hosts = self.cs.listVirtualMachines(projectid=project_id, domainid=domain_id)
|
||||
data = {}
|
||||
|
@ -182,7 +178,6 @@ class CloudStackInventory(object):
|
|||
break
|
||||
return data
|
||||
|
||||
|
||||
def get_list(self, project_id=None, domain_id=None):
|
||||
data = {
|
||||
'all': {
|
||||
|
@ -197,7 +192,7 @@ class CloudStackInventory(object):
|
|||
if groups:
|
||||
for group in groups['instancegroup']:
|
||||
group_name = group['name']
|
||||
if group_name and not group_name in data:
|
||||
if group_name and group_name not in data:
|
||||
data[group_name] = {
|
||||
'hosts': []
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue