summaryrefslogtreecommitdiffstats
path: root/.gitreview
blob: c088dd69b380ea1976e29c4e39e6736ac8e3ba07 (plain)
1
2
3
4
[gerrit]
host=gerrit.onap.org
port=29418
project=doc.git
r: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
from netconf_constant import CONFIG_TARGET_RUNNING, CONFIG_TARGET_CANDIDATE, \
  CONFIG_DEFAULT_OPERATION_REPLACE


class NetconfClient:

  def __init__(self, log, component_function, requirement_name):
    self.log = log
    self.component_function = component_function
    netconf_device = self.component_function.initializeNetconfConnection(
        requirement_name)
    self.netconf_rpc_client = netconf_device.netconfRpcService
    self.netconf_session = netconf_device.netconfSession

  def disconnect(self):
    self.netconf_session.disconnect()
    return

  def connect(self):
    self.netconf_session.connect()
    return

  def lock(self, config_target=CONFIG_TARGET_CANDIDATE):
    device_response = self.netconf_rpc_client.lock(config_target)
    return device_response

  def get_config(self, filter="", config_target=CONFIG_TARGET_RUNNING):
    device_response = self.netconf_rpc_client.getConfig(filter, config_target)
    return device_response

  def edit_config(self, message_content, config_target=CONFIG_TARGET_CANDIDATE,
      edit_default_peration=CONFIG_DEFAULT_OPERATION_REPLACE):
    device_response = self.netconf_rpc_client.editConfig(message_content,
                                                         config_target,
                                                         edit_default_peration)
    return device_response

  def commit(self):
    device_response = self.netconf_rpc_client.commit()
    return device_response

  def unlock(self, config_target=CONFIG_TARGET_CANDIDATE):
    device_response = self.netconf_rpc_client.unLock(config_target)
    return device_response

  def validate(self, config_target=CONFIG_TARGET_CANDIDATE):
    device_response = self.netconf_rpc_client.validate(config_target)
    return device_response

  def discard_change(self):
    device_response = self.netconf_rpc_client.discardConfig()
    return device_response