Esempio n. 1
0
 def _rowstatus_action(self, session, value):
     if not session:
         raise ValueError, "no session specified"
     if self.rowstatus and self.indexoid:
         vbl = Basetypes.VarBindList()
         vbl.append(Basetypes.VarBind(self.rowstatus.OID+self.indexoid, self.rowstatus.syntaxobject(value)))
         session.set(vbl)
Esempio n. 2
0
 def set(self, session=None, **attribs):
     sess = session or self.session
     vbl = Basetypes.VarBindList()
     for colname, value in attribs.items():
         col = self.columns[colname]
         value = col.syntaxobject(value)
         vbl.append(Basetypes.VarBind(col.OID + self.indexoid, value))
     sess.set(vbl)
Esempio n. 3
0
 def refresh(self, session=None):
     if (session or self.session) and self.indexoid:
         sess = session or self.session
         vbl = Basetypes.VarBindList()
         map(lambda co: vbl.append(co.varbind.clear()), self.COLUMNS.values())
         return_vbl = sess.get_varbindlist(vbl)
         for vb in return_vbl:
             self.COLUMNS[vb.Object.__name__].set_value(vb.value)
Esempio n. 4
0
 def get_values(self, *args):
     sess = self.session
     if sess and self.indexoid:
         rv = []
         vbl = Basetypes.VarBindList()
         cols = map(lambda n: self.columns.get(n), args)
         map(lambda o: vbl.append(Basetypes.VarBind(o.OID+self.indexoid)), cols)
         return_vbl = sess.get_varbindlist(vbl)
         return tuple(map(lambda vb: vb.value, return_vbl))
Esempio n. 5
0
 def _create_vbl(self, *indexargs, **attribs):
     if not self.create:
         raise ValueError, "Cannot create object of type "+self.__class__.__name__
     self.__dict__["indexoid"] = self._make_index_oid(indexargs)
     vbl = Basetypes.VarBindList()
     for key, value in attribs.items():
         colclass = self.columns[key]
         value = colclass.syntaxobject(value)
         vbl.append(Basetypes.VarBind(colclass.OID+self.indexoid, value))
     return vbl
Esempio n. 6
0
def _decode_a_varbindlist(vbl_tuple):
    vbl = Basetypes.VarBindList()
    for [oid, value] in vbl_tuple:
        obj = _find_object(oid)
        if obj is not None:
            if value is not None:
                if obj.syntaxobject:
                    value = obj.syntaxobject(value)
                if obj.enumerations:
                    value.enumerations = obj.enumerations
            vbl.append(Basetypes.VarBind(oid, value, obj))
        else: # unknown varbind, deal with it later
            vbl.append(Basetypes.VarBind(oid, value))
    return vbl
Esempio n. 7
0
 def get(self, session, indexoid=None):
     sess = session or self.session
     if indexoid:
         self.__dict__["indexoid"] = self._make_index_oid(indexoid)
     self.__dict__["COLUMNS"] = {} # clear cache with new dict
     vbl = Basetypes.VarBindList()
     VB = Basetypes.VarBind
     map(lambda o: vbl.append(VB(o.OID+self.indexoid)), self.columns.values())
     return_vbl = sess.get_varbindlist(vbl)
     # insert in COLUMNS
     for vb in return_vbl:
         vbo = vb.Object
         colobj = vbo(vb.value, vb.name[len(vbo.OID)+1:])
         self.add_column(colobj)
     return self
Esempio n. 8
0
 def get_scalars(self, *args):
     vbl = Basetypes.VarBindList()
     for o in [self.scalars[on] for on in args]:
         vbl.append(Basetypes.VarBind(o.OID+[0]))
     return_vbl = self.session.get_varbindlist(vbl)
     return tuple([vb.value for vb in return_vbl])