Skip to content

Commit 5cb7a5e

Browse files
committed
WIP: demo black and flake8 failures
Signed-off-by: Paul Belanger <[email protected]>
1 parent 435a84a commit 5cb7a5e

File tree

189 files changed

+21150
-12134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

189 files changed

+21150
-12134
lines changed

.zuul.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- project:
3+
check:
4+
jobs:
5+
- ansible-tox-linters

plugins/connection/vmware_tools.py

Lines changed: 182 additions & 79 deletions
Large diffs are not rendered by default.

plugins/doc_fragments/VmwareRestModule.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
44

55
from __future__ import absolute_import, division, print_function
6+
67
__metaclass__ = type
78

89

910
class ModuleDocFragment(object):
1011
# Parameters for VMware ReST HTTPAPI modules omits filters and state
11-
DOCUMENTATION = r'''
12+
DOCUMENTATION = r"""
1213
options:
1314
allow_multiples:
1415
description:
@@ -29,4 +30,4 @@ class ModuleDocFragment(object):
2930
required: true
3031
type: list
3132
default: [200]
32-
'''
33+
"""

plugins/doc_fragments/VmwareRestModule_filters.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
44

55
from __future__ import absolute_import, division, print_function
6+
67
__metaclass__ = type
78

89

910
class ModuleDocFragment(object):
1011
# Parameters for VMware ReST HTTPAPI modules includes filters
11-
DOCUMENTATION = r'''
12+
DOCUMENTATION = r"""
1213
options:
1314
allow_multiples:
1415
description:
@@ -34,4 +35,4 @@ class ModuleDocFragment(object):
3435
required: true
3536
type: list
3637
default: [200]
37-
'''
38+
"""

plugins/doc_fragments/VmwareRestModule_full.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
44

55
from __future__ import absolute_import, division, print_function
6+
67
__metaclass__ = type
78

89

910
class ModuleDocFragment(object):
1011
# Parameters for VMware ReST HTTPAPI modules includes filters and state
11-
DOCUMENTATION = r'''
12+
DOCUMENTATION = r"""
1213
options:
1314
allow_multiples:
1415
description:
@@ -41,4 +42,4 @@ class ModuleDocFragment(object):
4142
required: true
4243
type: list
4344
default: [200]
44-
'''
45+
"""

plugins/doc_fragments/VmwareRestModule_state.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
44

55
from __future__ import absolute_import, division, print_function
6+
67
__metaclass__ = type
78

89

910
class ModuleDocFragment(object):
1011
# Parameters for VMware ReST HTTPAPI modules includes filters and state
11-
DOCUMENTATION = r'''
12+
DOCUMENTATION = r"""
1213
options:
1314
allow_multiples:
1415
description:
@@ -36,4 +37,4 @@ class ModuleDocFragment(object):
3637
required: true
3738
type: list
3839
default: [200]
39-
'''
40+
"""

plugins/doc_fragments/vmware.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class ModuleDocFragment(object):
1010
# Parameters for VMware modules
11-
DOCUMENTATION = r'''
11+
DOCUMENTATION = r"""
1212
options:
1313
hostname:
1414
description:
@@ -59,10 +59,10 @@ class ModuleDocFragment(object):
5959
- If the value is not specified in the task, the value of environment variable C(VMWARE_PROXY_PORT) will be used instead.
6060
type: int
6161
required: False
62-
'''
62+
"""
6363

6464
# This doc fragment is specific to vcenter modules like vcenter_license
65-
VCENTER_DOCUMENTATION = r'''
65+
VCENTER_DOCUMENTATION = r"""
6666
options:
6767
hostname:
6868
description:
@@ -115,4 +115,4 @@ class ModuleDocFragment(object):
115115
type: int
116116
version_added: '2.9'
117117
required: False
118-
'''
118+
"""

plugins/doc_fragments/vmware_rest_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class ModuleDocFragment(object):
99
# Parameters for VMware REST Client based modules
10-
DOCUMENTATION = r'''
10+
DOCUMENTATION = r"""
1111
options:
1212
hostname:
1313
description:
@@ -45,4 +45,4 @@ class ModuleDocFragment(object):
4545
type: str
4646
choices: [ http, https ]
4747
default: https
48-
'''
48+
"""

plugins/httpapi/vmware.py

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
# Copyright: (c) 2019, Abhijeet Kasurde <[email protected]>
44
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
55

6-
from __future__ import (absolute_import, division, print_function)
6+
from __future__ import absolute_import, division, print_function
7+
78
__metaclass__ = type
89

9-
DOCUMENTATION = '''
10+
DOCUMENTATION = """
1011
---
1112
author: Abhijeet Kasurde (Akasurde)
1213
httpapi : vmware
1314
short_description: HttpApi Plugin for VMware REST API
1415
description:
1516
- This HttpApi plugin provides methods to connect to VMware vCenter over a HTTP(S)-based APIs.
16-
'''
17+
"""
1718

1819
import json
1920

@@ -24,54 +25,71 @@
2425
from ansible.module_utils.connection import ConnectionError
2526

2627
BASE_HEADERS = {
27-
'Content-Type': 'application/json',
28-
'Accept': 'application/json',
28+
"Content-Type": "application/json",
29+
"Accept": "application/json",
2930
}
3031

3132

3233
class HttpApi(HttpApiBase):
3334
def login(self, username, password):
3435
if username and password:
3536
payload = {}
36-
url = '/rest/com/vmware/cis/session'
37+
url = "/rest/com/vmware/cis/session"
3738
response, response_data = self.send_request(url, payload)
3839
else:
39-
raise AnsibleConnectionFailure('Username and password are required for login')
40+
raise AnsibleConnectionFailure(
41+
"Username and password are required for login"
42+
)
4043

4144
if response == 404:
4245
raise ConnectionError(response_data)
4346

44-
if not response_data.get('value'):
45-
raise ConnectionError('Server returned response without token info during connection authentication: %s' % response)
47+
if not response_data.get("value"):
48+
raise ConnectionError(
49+
"Server returned response without token info during connection authentication: %s"
50+
% response
51+
)
4652

47-
self.connection._session_uid = "vmware-api-session-id:%s" % response_data['value']
48-
self.connection._token = response_data['value']
53+
self.connection._session_uid = (
54+
"vmware-api-session-id:%s" % response_data["value"]
55+
)
56+
self.connection._token = response_data["value"]
4957

5058
def logout(self):
51-
response, dummy = self.send_request('/rest/com/vmware/cis/session', None, method='DELETE')
59+
response, dummy = self.send_request(
60+
"/rest/com/vmware/cis/session", None, method="DELETE"
61+
)
5262

5363
def get_session_uid(self):
5464
return self.connection._session_uid
5565

5666
def get_session_token(self):
5767
return self.connection._token
5868

59-
def send_request(self, path, body_params, method='POST'):
60-
data = json.dumps(body_params) if body_params else '{}'
69+
def send_request(self, path, body_params, method="POST"):
70+
data = json.dumps(body_params) if body_params else "{}"
6171

6272
try:
6373
self._display_request(method=method)
64-
response, response_data = self.connection.send(path, data, method=method, headers=BASE_HEADERS, force_basic_auth=True)
74+
response, response_data = self.connection.send(
75+
path,
76+
data,
77+
method=method,
78+
headers=BASE_HEADERS,
79+
force_basic_auth=True,
80+
)
6581
response_value = self._get_response_value(response_data)
6682

6783
return response.getcode(), self._response_to_json(response_value)
6884
except AnsibleConnectionFailure as e:
69-
return 404, 'Object not found'
85+
return 404, "Object not found"
7086
except HTTPError as e:
7187
return e.code, json.loads(e.read())
7288

73-
def _display_request(self, method='POST'):
74-
self.connection.queue_message('vvvv', 'Web Services: %s %s' % (method, self.connection._url))
89+
def _display_request(self, method="POST"):
90+
self.connection.queue_message(
91+
"vvvv", "Web Services: %s %s" % (method, self.connection._url)
92+
)
7593

7694
def _get_response_value(self, response_data):
7795
return to_text(response_data.getvalue())
@@ -81,4 +99,4 @@ def _response_to_json(self, response_text):
8199
return json.loads(response_text) if response_text else {}
82100
# JSONDecodeError only available on Python 3.5+
83101
except ValueError:
84-
raise ConnectionError('Invalid JSON response: %s' % response_text)
102+
raise ConnectionError("Invalid JSON response: %s" % response_text)

0 commit comments

Comments
 (0)