add Ssh transport class to openswitch shared module
This adds a Ssh transport class for working directly with DC config on OpenSwitch enabled nodes.
This commit is contained in:
parent
f65a3ce547
commit
4ed8306099
1 changed files with 26 additions and 1 deletions
|
@ -57,6 +57,7 @@ def get_opsidl():
|
||||||
|
|
||||||
return (extschema, opsidl)
|
return (extschema, opsidl)
|
||||||
|
|
||||||
|
|
||||||
class Response(object):
|
class Response(object):
|
||||||
|
|
||||||
def __init__(self, resp, hdrs):
|
def __init__(self, resp, hdrs):
|
||||||
|
@ -76,6 +77,7 @@ class Response(object):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
class Rest(object):
|
class Rest(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.url = None
|
self.url = None
|
||||||
self.url_args = ModuleStub(url_argument_spec(), self._error)
|
self.url_args = ModuleStub(url_argument_spec(), self._error)
|
||||||
|
@ -229,4 +231,27 @@ class Cli(CliBase):
|
||||||
def save_config(self):
|
def save_config(self):
|
||||||
self.execute(['copy running-config startup-config'])
|
self.execute(['copy running-config startup-config'])
|
||||||
|
|
||||||
Cli = register_transport('cli', default=True)(Cli)
|
Cli = register_transport('cli')(Cli)
|
||||||
|
|
||||||
|
class Ssh(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
if not HAS_OPS:
|
||||||
|
msg = 'ops.dc lib is required but does not appear to be available'
|
||||||
|
raise NetworkError(msg)
|
||||||
|
self._opsidl = None
|
||||||
|
|
||||||
|
def configure(self, config):
|
||||||
|
if not self._opsidl:
|
||||||
|
(self._extschema, self._opsidl) = get_opsidl()
|
||||||
|
return ops.dc.write(self._extschema, self._opsidl)
|
||||||
|
|
||||||
|
def get_config(self):
|
||||||
|
if not self._opsidl:
|
||||||
|
(self._extschema, self._opsidl) = get_opsidl()
|
||||||
|
return ops.dc.read(self._extschema, self._opsidl)
|
||||||
|
|
||||||
|
def load_config(self, config):
|
||||||
|
return self.configure(config)
|
||||||
|
|
||||||
|
Ssh = register_transport('ssh', default=True)(Ssh)
|
||||||
|
|
Loading…
Reference in a new issue