mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #14697 from privateip/shared_module_openswitch
bugfixes for openswitch shared module
This commit is contained in:
commit
ca2871de20
1 changed files with 21 additions and 18 deletions
|
@ -35,7 +35,7 @@ NET_COMMON_ARGS = dict(
|
||||||
port=dict(type='int'),
|
port=dict(type='int'),
|
||||||
username=dict(),
|
username=dict(),
|
||||||
password=dict(no_log=True),
|
password=dict(no_log=True),
|
||||||
use_ssl=dict(default=True, type='int'),
|
use_ssl=dict(default=True, type='bool'),
|
||||||
transport=dict(default='ssh', choices=['ssh', 'cli', 'rest']),
|
transport=dict(default='ssh', choices=['ssh', 'cli', 'rest']),
|
||||||
provider=dict()
|
provider=dict()
|
||||||
)
|
)
|
||||||
|
@ -48,35 +48,38 @@ def to_list(val):
|
||||||
else:
|
else:
|
||||||
return list()
|
return list()
|
||||||
|
|
||||||
def get_idl():
|
def get_runconfig():
|
||||||
manager = OvsdbConnectionManager(settings.get('ovs_remote'),
|
manager = OvsdbConnectionManager(settings.get('ovs_remote'),
|
||||||
settings.get('ovs_schema'))
|
settings.get('ovs_schema'))
|
||||||
manager.start()
|
manager.start()
|
||||||
idl = manager.idl
|
|
||||||
|
|
||||||
init_seq_no = 0
|
timeout = 10
|
||||||
while (init_seq_no == idl.change_seqno):
|
interval = 0
|
||||||
idl.run()
|
init_seq_no = manager.idl.change_seqno
|
||||||
|
|
||||||
|
while (init_seq_no == manager.idl.change_seqno):
|
||||||
|
if interval > timeout:
|
||||||
|
raise TypeError('timeout')
|
||||||
|
manager.idl.run()
|
||||||
|
interval += 1
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
return idl
|
schema = restparser.parseSchema(settings.get('ext_schema'))
|
||||||
|
return runconfig.RunConfigUtil(manager.idl, schema)
|
||||||
def get_schema():
|
|
||||||
return restparser.parseSchema(settings.get('ext_schema'))
|
|
||||||
|
|
||||||
def get_runconfig():
|
|
||||||
idl = get_idl()
|
|
||||||
schema = get_schema()
|
|
||||||
return runconfig.RunConfigUtil(idl, schema)
|
|
||||||
|
|
||||||
class Response(object):
|
class Response(object):
|
||||||
|
|
||||||
def __init__(self, resp, hdrs):
|
def __init__(self, resp, hdrs):
|
||||||
self.body = resp.read()
|
self.body = None
|
||||||
self.headers = hdrs
|
self.headers = hdrs
|
||||||
|
|
||||||
|
if resp:
|
||||||
|
self.body = resp.read()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def json(self):
|
def json(self):
|
||||||
|
if not self.body:
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
return json.loads(self.body)
|
return json.loads(self.body)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -95,11 +98,11 @@ class Rest(object):
|
||||||
if self.module.params['use_ssl']:
|
if self.module.params['use_ssl']:
|
||||||
proto = 'https'
|
proto = 'https'
|
||||||
if not port:
|
if not port:
|
||||||
port = 443
|
port = 18091
|
||||||
else:
|
else:
|
||||||
proto = 'http'
|
proto = 'http'
|
||||||
if not port:
|
if not port:
|
||||||
port = 80
|
port = 8091
|
||||||
|
|
||||||
self.baseurl = '%s://%s:%s/rest/v1' % (proto, host, port)
|
self.baseurl = '%s://%s:%s/rest/v1' % (proto, host, port)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue