def test0011_TopObject_noOI(self): immom.ccb_initialize(1) self.assertRaises(immom.AisException, immom.createobject, self.topobject, 'TestClass', []) immom.ccb_finalize() immom.ccb_initialize(0) immom.createobject(self.topobject, 'TestClass', []) immom.ccb_finalize()
def test0010_TopObject(self): self.assertRaises(immom.AisException, immom.getobject, self.topobject) self.assertRaises(immom.AisException, immom.createobject, self.topobject, 'TestClass', []) immom.ccb_initialize() self.assertRaises(immom.AisException, immom.createobject,self.topobject,'InvalidClass', []) immom.createobject(self.topobject, 'TestClass', []) self.assertRaises(immom.AisException, immom.getobject, self.topobject) immom.ccb_apply() immom.ccb_finalize() o = immom.getobject(self.topobject) o.sort() self.assertEqual( o, [ ('SaImmAttrAdminOwnerName', 'SASTRINGT', ['TestAdmin']), ('SaImmAttrClassName', 'SASTRINGT', ['TestClass']), ('SaImmAttrImplementerName', 'SASTRINGT', []), ('TestClassId', 'SANAMET', ['TestClassId=1']) ]) immom.adminowner_clear('SA_IMM_SUBTREE', [self.topobject]) o = immom.getobject(self.topobject) o.sort() self.assertEqual( o, [ ('SaImmAttrAdminOwnerName', 'SASTRINGT', []), ('SaImmAttrClassName', 'SASTRINGT', ['TestClass']), ('SaImmAttrImplementerName', 'SASTRINGT', []), ('TestClassId', 'SANAMET', ['TestClassId=1']) ]) self.assertRaises(immom.AisException, immom.deleteclass, 'TestClass') immom.ccb_initialize() immom.deleteobjects([self.topobject]) immom.getobject(self.topobject) immom.ccb_apply() immom.ccb_finalize() self.assertRaises(immom.AisException, immom.getobject, self.topobject)
def test0020_ObjectTree(self): immom.ccb_initialize() immom.createobject(self.topobject, 'TestClass', []) for n in xrange(1,5): dn = "TestClassId=%d,%s" % (n, self.topobject) immom.createobject(dn, 'TestClass', []) immom.ccb_apply() immom.ccb_finalize() c = immom.getchildobjects(self.topobject) self.assertEqual( c, [ 'TestClassId=1,TestClassId=1', 'TestClassId=2,TestClassId=1', 'TestClassId=3,TestClassId=1', 'TestClassId=4,TestClassId=1' ]) immom.ccb_initialize() for n in xrange(30,35): dn = "TestClassId=%d,TestClassId=3,%s" % (n, self.topobject) immom.createobject(dn, 'TestClass', []) for n in xrange(20,23): dn = "TestClassId=%d,TestClassId=2,%s" % (n, self.topobject) immom.createobject(dn, 'TestClass', []) immom.ccb_apply() immom.ccb_finalize() c = immom.getsubtree(self.topobject) self.assertEqual( c, [ 'TestClassId=1,TestClassId=1', 'TestClassId=2,TestClassId=1', 'TestClassId=3,TestClassId=1', 'TestClassId=4,TestClassId=1', 'TestClassId=20,TestClassId=2,TestClassId=1', 'TestClassId=21,TestClassId=2,TestClassId=1', 'TestClassId=22,TestClassId=2,TestClassId=1', 'TestClassId=30,TestClassId=3,TestClassId=1', 'TestClassId=31,TestClassId=3,TestClassId=1', 'TestClassId=32,TestClassId=3,TestClassId=1', 'TestClassId=33,TestClassId=3,TestClassId=1', 'TestClassId=34,TestClassId=3,TestClassId=1' ]) immom.ccb_initialize() immom.deletesubtree(self.topobject) immom.getobject(self.topobject) immom.ccb_apply() immom.ccb_finalize() self.assertRaises(immom.AisException, immom.getobject, self.topobject)
def test0010_TopObject(self): self.assertRaises(immom.AisException, immom.getobject, self.topobject) self.assertRaises(immom.AisException, immom.createobject, self.topobject, 'TestClass', []) immom.ccb_initialize() self.assertRaises(immom.AisException, immom.createobject, self.topobject, 'InvalidClass', []) immom.createobject(self.topobject, 'TestClass', []) self.assertRaises(immom.AisException, immom.getobject, self.topobject) immom.ccb_apply() immom.ccb_finalize() o = immom.getobject(self.topobject) o.sort() self.assertEqual( o, [('SaImmAttrAdminOwnerName', 'SASTRINGT', ['TestAdmin']), ('SaImmAttrClassName', 'SASTRINGT', ['TestClass']), ('SaImmAttrImplementerName', 'SASTRINGT', []), ('TestClassId', 'SANAMET', ['TestClassId=1'])]) immom.adminowner_clear('SA_IMM_SUBTREE', [self.topobject]) o = immom.getobject(self.topobject) o.sort() self.assertEqual(o, [('SaImmAttrAdminOwnerName', 'SASTRINGT', []), ('SaImmAttrClassName', 'SASTRINGT', ['TestClass']), ('SaImmAttrImplementerName', 'SASTRINGT', []), ('TestClassId', 'SANAMET', ['TestClassId=1'])]) self.assertRaises(immom.AisException, immom.deleteclass, 'TestClass') immom.ccb_initialize() immom.deleteobjects([self.topobject]) immom.getobject(self.topobject) immom.ccb_apply() immom.ccb_finalize() self.assertRaises(immom.AisException, immom.getobject, self.topobject)
def test0020_ObjectTree(self): immom.ccb_initialize() immom.createobject(self.topobject, 'TestClass', []) for n in xrange(1, 5): dn = "TestClassId=%d,%s" % (n, self.topobject) immom.createobject(dn, 'TestClass', []) immom.ccb_apply() immom.ccb_finalize() c = immom.getchildobjects(self.topobject) self.assertEqual(c, [ 'TestClassId=1,TestClassId=1', 'TestClassId=2,TestClassId=1', 'TestClassId=3,TestClassId=1', 'TestClassId=4,TestClassId=1' ]) immom.ccb_initialize() for n in xrange(30, 35): dn = "TestClassId=%d,TestClassId=3,%s" % (n, self.topobject) immom.createobject(dn, 'TestClass', []) for n in xrange(20, 23): dn = "TestClassId=%d,TestClassId=2,%s" % (n, self.topobject) immom.createobject(dn, 'TestClass', []) immom.ccb_apply() immom.ccb_finalize() c = immom.getsubtree(self.topobject) self.assertEqual(c, [ 'TestClassId=1,TestClassId=1', 'TestClassId=2,TestClassId=1', 'TestClassId=3,TestClassId=1', 'TestClassId=4,TestClassId=1', 'TestClassId=20,TestClassId=2,TestClassId=1', 'TestClassId=21,TestClassId=2,TestClassId=1', 'TestClassId=22,TestClassId=2,TestClassId=1', 'TestClassId=30,TestClassId=3,TestClassId=1', 'TestClassId=31,TestClassId=3,TestClassId=1', 'TestClassId=32,TestClassId=3,TestClassId=1', 'TestClassId=33,TestClassId=3,TestClassId=1', 'TestClassId=34,TestClassId=3,TestClassId=1' ]) immom.ccb_initialize() immom.deletesubtree(self.topobject) immom.getobject(self.topobject) immom.ccb_apply() immom.ccb_finalize() self.assertRaises(immom.AisException, immom.getobject, self.topobject)
def test0030_ModifyObject(self): attrs = [ ('TestClassModId', 'SANAMET', [ 'CONFIG', 'RDN' ],[]), ('saint32t', 'SAINT32T', [ 'CONFIG', 'WRITABLE' ],[-11]), ('sauint32t', 'SAUINT32T', [ 'CONFIG', 'WRITABLE' ],[22]), ('saint64t', 'SAINT64T', [ 'CONFIG', 'WRITABLE' ],[-33]), ('sauint64t', 'SAUINT64T', [ 'CONFIG', 'WRITABLE' ],[44]), ('satimet', 'SATIMET', [ 'CONFIG', 'WRITABLE' ],[]), ('sanamet', 'SANAMET', [ 'CONFIG', 'WRITABLE' ],[]), ('safloatt', 'SAFLOATT', [ 'CONFIG', 'WRITABLE' ],[]), ('sadoublet', 'SADOUBLET', [ 'CONFIG', 'WRITABLE' ],[]), ('sastringt', 'SASTRINGT', ['CONFIG','WRITABLE','MULTI_VALUE'],[]), ('saanyt', 'SAANYT', [ 'CONFIG', 'WRITABLE' ],[]), ] immom.createclass('TestClassMod', 'CONFIG', attrs) nonemptyattr = lambda (n,t,v): v and not n.startswith('SaImm') # Set-up modobject = 'TestClassModId=1,' + self.topobject immom.ccb_initialize() immom.createobject(self.topobject, 'TestClass', []) immom.createobject(modobject, 'TestClassMod', []) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual( a, [ ('TestClassModId', 'SANAMET', ['TestClassModId=1']), ('saint32t', 'SAINT32T', [-11]), ('saint64t', 'SAINT64T', [-33L]), ('sauint32t', 'SAUINT32T', [22]), ('sauint64t', 'SAUINT64T', [44L]) ]) immom.ccb_initialize() immom.modifyobject(modobject, [ ('saint32t', 'SAINT32T', [-2147483648]), ('saint64t', 'SAINT64T', [-9223372036854775808L]), ]) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual( a, [ ('TestClassModId', 'SANAMET', ['TestClassModId=1']), ('saint32t', 'SAINT32T', [-2147483648]), ('saint64t', 'SAINT64T', [-9223372036854775808L]), ('sauint32t', 'SAUINT32T', [22]), ('sauint64t', 'SAUINT64T', [44L]) ]) # 'SAUINT64T' does not work. It seems like correct values are # stored, but signed values are read. immom.ccb_initialize() immom.modifyobject(modobject, [ ('saint32t', 'SAINT32T', [2147483647]), ('sauint32t', 'SAUINT32T', [ 4294967295 ]), ('saint64t', 'SAINT64T', [9223372036854775807L]), ('sauint64t', 'SAUINT64T', [9223372036854775807L]), ('sastringt', 'SASTRINGT', ['kalle', 'kula', 'was', 'here']), ('sanamet', 'SANAMET', ['a,b,c,d,e=90,f']) ]) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual( a, [ ('TestClassModId', 'SANAMET', ['TestClassModId=1']), ('saint32t', 'SAINT32T', [2147483647]), ('saint64t', 'SAINT64T', [9223372036854775807L]), ('sanamet', 'SANAMET', ['a,b,c,d,e=90,f']), ('sastringt', 'SASTRINGT', ['kalle', 'kula', 'was', 'here']), ('sauint32t', 'SAUINT32T', [4294967295]), ('sauint64t', 'SAUINT64T', [9223372036854775807L]) ]) immom.ccb_initialize() immom.modifyobject(modobject, [ ('saint32t', 'SAINT32T', []), ('saint64t', 'SAINT64T', []), ('sanamet', 'SANAMET', []), ('sastringt', 'SASTRINGT', []), ('sauint32t', 'SAUINT32T', []), ('sauint64t', 'SAUINT64T', []) ]) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual( a, [ ('TestClassModId', 'SANAMET', ['TestClassModId=1']) ]) # Clean-up immom.ccb_initialize() immom.deletesubtree(self.topobject) immom.ccb_apply() immom.ccb_finalize() immom.deleteclass('TestClassMod')
print "Too few parameters" return wo = self.getwo(argv[0], False) if not wo: print 'No Working Object (top)' return try: (c,ca) = immom.getclass(argv[1]) except immom.AisException, ex: print 'getclass: ' + str(ex) return try: if self.hasCcb: immom.createobject(wo, argv[1], parseAttrs(ca, argv[2:])) else: self.do_ccb('create') immom.createobject(wo, argv[1], parseAttrs(ca, argv[2:])) self.do_ccb('apply') except immom.AisException, ex: self.do_ccb('abort') print 'Failed (ccb aborted): ' + str(ex) def do_modify(self, args): '''Modify an object. If no CCB is active a temporary CCB is used. Syntax: modify <'..' | '-' | rdn | /dn > [attr=value ...] ''' argv = shlex.split(args) try:
def test0030_ModifyObject(self): attrs = [ ('TestClassModId', 'SANAMET', ['CONFIG', 'RDN'], []), ('saint32t', 'SAINT32T', ['CONFIG', 'WRITABLE'], [-11]), ('sauint32t', 'SAUINT32T', ['CONFIG', 'WRITABLE'], [22]), ('saint64t', 'SAINT64T', ['CONFIG', 'WRITABLE'], [-33]), ('sauint64t', 'SAUINT64T', ['CONFIG', 'WRITABLE'], [44]), ('satimet', 'SATIMET', ['CONFIG', 'WRITABLE'], []), ('sanamet', 'SANAMET', ['CONFIG', 'WRITABLE'], []), ('safloatt', 'SAFLOATT', ['CONFIG', 'WRITABLE'], []), ('sadoublet', 'SADOUBLET', ['CONFIG', 'WRITABLE'], []), ('sastringt', 'SASTRINGT', ['CONFIG', 'WRITABLE', 'MULTI_VALUE'], []), ('saanyt', 'SAANYT', ['CONFIG', 'WRITABLE'], []), ] immom.createclass('TestClassMod', 'CONFIG', attrs) nonemptyattr = lambda (n, t, v): v and not n.startswith('SaImm') # Set-up modobject = 'TestClassModId=1,' + self.topobject immom.ccb_initialize() immom.createobject(self.topobject, 'TestClass', []) immom.createobject(modobject, 'TestClassMod', []) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual(a, [('TestClassModId', 'SANAMET', ['TestClassModId=1']), ('saint32t', 'SAINT32T', [-11]), ('saint64t', 'SAINT64T', [-33L]), ('sauint32t', 'SAUINT32T', [22]), ('sauint64t', 'SAUINT64T', [44L])]) immom.ccb_initialize() immom.modifyobject(modobject, [ ('saint32t', 'SAINT32T', [-2147483648]), ('saint64t', 'SAINT64T', [-9223372036854775808L]), ]) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual(a, [('TestClassModId', 'SANAMET', ['TestClassModId=1']), ('saint32t', 'SAINT32T', [-2147483648]), ('saint64t', 'SAINT64T', [-9223372036854775808L]), ('sauint32t', 'SAUINT32T', [22]), ('sauint64t', 'SAUINT64T', [44L])]) # 'SAUINT64T' does not work. It seems like correct values are # stored, but signed values are read. immom.ccb_initialize() immom.modifyobject( modobject, [('saint32t', 'SAINT32T', [2147483647]), ('sauint32t', 'SAUINT32T', [4294967295]), ('saint64t', 'SAINT64T', [9223372036854775807L]), ('sauint64t', 'SAUINT64T', [9223372036854775807L]), ('sastringt', 'SASTRINGT', ['kalle', 'kula', 'was', 'here']), ('sanamet', 'SANAMET', ['a,b,c,d,e=90,f'])]) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual( a, [('TestClassModId', 'SANAMET', ['TestClassModId=1']), ('saint32t', 'SAINT32T', [2147483647]), ('saint64t', 'SAINT64T', [9223372036854775807L]), ('sanamet', 'SANAMET', ['a,b,c,d,e=90,f']), ('sastringt', 'SASTRINGT', ['kalle', 'kula', 'was', 'here']), ('sauint32t', 'SAUINT32T', [4294967295]), ('sauint64t', 'SAUINT64T', [9223372036854775807L])]) immom.ccb_initialize() immom.modifyobject(modobject, [('saint32t', 'SAINT32T', []), ('saint64t', 'SAINT64T', []), ('sanamet', 'SANAMET', []), ('sastringt', 'SASTRINGT', []), ('sauint32t', 'SAUINT32T', []), ('sauint64t', 'SAUINT64T', [])]) immom.ccb_apply() immom.ccb_finalize() a = filter(nonemptyattr, immom.getobject(modobject)) a.sort() self.assertEqual(a, [('TestClassModId', 'SANAMET', ['TestClassModId=1'])]) # Clean-up immom.ccb_initialize() immom.deletesubtree(self.topobject) immom.ccb_apply() immom.ccb_finalize() immom.deleteclass('TestClassMod')