Example #1
0
    def commit_configuration(self):
        """Use hh3c-config-man-mib to save running config to startup"""

        running_to_startup = 1
        create_and_go = 4

        # Find the next available row for configuring and store it as a suffix
        active_rows = [
            OID(o[0])[-1] for o in self._bulkwalk(self.hh3cCfgOperateRowStatus)
        ]
        try:
            suffix = str(max(active_rows) + 1)
        except ValueError:
            suffix = '1'

        operation_type_oid = '.'.join([self.hh3cCfgOperateType, suffix])
        operation_status_oid = '.'.join([self.hh3cCfgOperateRowStatus, suffix])

        handle = self._get_read_write_handle()
        handle.multi_set(
            [
                Snmp.PDUVarbind(operation_type_oid, 'i', running_to_startup),
                Snmp.PDUVarbind(operation_status_oid, 'i', create_and_go),
            ]
        )
Example #2
0
 def _get_read_only_handle(self):
     """Get a read only SNMP-handle."""
     if self.read_only_handle is None:
         self.read_only_handle = Snmp.Snmp(self.netbox.ip, self.netbox.read_only,
                                      self.netbox.snmp_version,
                                      retries=self.retries,
                                      timeout=self.timeout)
     return self.read_only_handle
Example #3
0
    def _get_read_write_handle(self):
        """Get a read and write SNMP-handle.

        :rtype: nav.Snmp.Snmp
        """
        if self.read_write_handle is None:
            self.read_write_handle = Snmp.Snmp(
                self.netbox.ip, self.netbox.read_write,
                self.netbox.snmp_version, retries=self.retries,
                timeout=self.timeout)
        return self.read_write_handle