Ejemplo n.º 1
0
    def test_modify_compute_tags(self):
        computes = db.get_root()['oms_root']['computes']
        cmpt = self.make_compute()
        cid = computes.add(cmpt)
        transaction.commit()

        self._cmd('set computes/%s tags=taga,tagb' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write(
                'Tags:                  arch:centos, arch:linux, arch:x86_64, label:taga, label:tagb, state:active, type:compute\n'
            )

        self._cmd('set computes/%s tags=taga,-tagb' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write(
                'Tags:                  arch:centos, arch:linux, arch:x86_64, label:taga, state:active, type:compute\n'
            )
Ejemplo n.º 2
0
    def test_cat_l_compute(self):
        self.terminal.reset_mock()

        computes = db.get_root()['oms_root']['computes']
        cid = computes.add(self.make_compute())
        transaction.commit()

        self._cmd('cat -l computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write('Architecture:          x86_64\n'
                    '                       linux\n'
                    '                       centos\n')
            whatever(t)
            t.write('Diskspace Utilization: boot: 49.3\n'
                    '                       storage: 748.3\n'
                    '                       root: 249.0\n')
Ejemplo n.º 3
0
    def test_cat_l_compute(self):
        self.terminal.reset_mock()

        computes = db.get_root()['oms_root']['computes']
        cid = computes.add(self.make_compute())
        transaction.commit()

        self._cmd('cat -l computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write('Architecture:          x86_64\n'
                    '                       linux\n'
                    '                       centos\n')
            whatever(t)
            t.write('Diskspace Utilization: boot: 49.3\n'
                    '                       storage: 748.3\n'
                    '                       root: 249.0\n')
Ejemplo n.º 4
0
    def test_modify_compute_tags(self):
        computes = db.get_root()['oms_root']['computes']
        cmpt = self.make_compute()
        cid = computes.add(cmpt)
        transaction.commit()

        self._cmd('set computes/%s tags=taga,tagb' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write('Tags:                  arch:centos, arch:linux, arch:x86_64, label:taga, label:tagb, state:active, type:compute\n')

        self._cmd('set computes/%s tags=taga,-tagb' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write('Tags:                  arch:centos, arch:linux, arch:x86_64, label:taga, state:active, type:compute\n')
Ejemplo n.º 5
0
    def test_modify_compute(self):
        computes = db.get_root()['oms_root']['computes']
        cid = computes.add(self.make_compute())
        transaction.commit()

        self._cmd('set computes/%s hostname=TUX-FOR-TEST' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            t.write('Host name:             TUX-FOR-TEST\n')
            whatever(t)
            t.write('Architecture:          x86_64, linux, centos\n')
            whatever(t)
            t.write('State:                 active\n')
            whatever(t)
            t.write('RAM Size:              2000\n')

        self.terminal.reset_mock()
        self._cmd('set computes/123')
        with assert_mock(self.terminal) as t:
            t.write("No such object: computes/123\n")

        self.terminal.reset_mock()
        self._cmd('set computes')
        with assert_mock(self.terminal) as t:
            t.write("No schema found for object\n")
Ejemplo n.º 6
0
    def test_rm_compute(self):
        self._cmd('cat computes/1')
        with assert_mock(self.terminal) as t:
            t.write("No such object: computes/1\n")

        self.terminal.reset_mock()

        computes = db.get_root()['oms_root']['computes']
        cid = computes.add(self.make_compute())
        transaction.commit()

        self._cmd('cat computes/%s' % cid)

        with assert_mock(self.terminal) as t:
            t.write('Host name:             tux-for-test\n')
            whatever(t)
            t.write('Architecture:          x86_64, linux, centos\n')
            whatever(t)
            t.write('State:                 active\n')
            whatever(t)
            t.write('RAM Size:              2000\n')

        self._cmd('rm computes/%s' % cid)

        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            t.write("No such object: computes/%s\n" % cid)

        self.terminal.reset_mock()

        self._cmd('rm computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            t.write("No such object: computes/%s\n" % cid)
Ejemplo n.º 7
0
    def test_modify_compute(self):
        computes = db.get_root()['oms_root']['computes']
        cid = computes.add(self.make_compute())
        transaction.commit()

        self._cmd('set computes/%s hostname=TUX-FOR-TEST' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            t.write('Host name:             TUX-FOR-TEST\n')
            whatever(t)
            t.write('Architecture:          x86_64, linux, centos\n')
            whatever(t)
            t.write('State:                 active\n')
            whatever(t)
            t.write('RAM Size:              2000\n')

        self.terminal.reset_mock()
        self._cmd('set computes/123')
        with assert_mock(self.terminal) as t:
            t.write("No such object: computes/123\n")

        self.terminal.reset_mock()
        self._cmd('set computes')
        with assert_mock(self.terminal) as t:
            t.write("No schema found for object\n")
Ejemplo n.º 8
0
    def test_rm_compute(self):
        self._cmd('cat computes/1')
        with assert_mock(self.terminal) as t:
            t.write("No such object: computes/1\n")

        self.terminal.reset_mock()

        computes = db.get_root()['oms_root']['computes']
        cid = computes.add(self.make_compute())
        transaction.commit()

        self._cmd('cat computes/%s' % cid)

        with assert_mock(self.terminal) as t:
            t.write('Host name:             tux-for-test\n')
            whatever(t)
            t.write('Architecture:          x86_64, linux, centos\n')
            whatever(t)
            t.write('State:                 active\n')
            whatever(t)
            t.write('RAM Size:              2000\n')

        self._cmd('rm computes/%s' % cid)

        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            t.write("No such object: computes/%s\n" % cid)

        self.terminal.reset_mock()

        self._cmd('rm computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            t.write("No such object: computes/%s\n" % cid)
Ejemplo n.º 9
0
    def test_create_compute(self):
        self._cmd("cd /computes")
        self._cmd("mk compute hostname=TUX-FOR-TEST memory=2000 state=active")
        cid = self.terminal.method_calls[-2][1][0]

        self.terminal.reset_mock()
        self._cmd('cat %s' % cid)

        with assert_mock(self.terminal) as t:
            t.write('Host name:             TUX-FOR-TEST\n')
            whatever(t)
            t.write('Architecture:          x86_64, linux, centos\n')
            whatever(t)
            t.write('State:                 active\n')
            whatever(t)
            t.write('RAM Size:              2000\n')
Ejemplo n.º 10
0
    def test_create_compute(self):
        self._cmd("cd /computes")
        self._cmd("mk compute hostname=TUX-FOR-TEST memory=2000 state=active")
        cid = self.terminal.method_calls[-2][1][0]

        self.terminal.reset_mock()
        self._cmd('cat %s' % cid)

        with assert_mock(self.terminal) as t:
            t.write('Host name:             TUX-FOR-TEST\n')
            whatever(t)
            t.write('Architecture:          x86_64, linux, centos\n')
            whatever(t)
            t.write('State:                 active\n')
            whatever(t)
            t.write('RAM Size:              2000\n')
Ejemplo n.º 11
0
 def test_quit(self):
     self._cmd('quit')
     with assert_mock(self.terminal) as t:
         whatever(t)
         t.write('user@oms:/# ')
Ejemplo n.º 12
0
    def test_special_compute_tags(self):
        computes = db.get_root()['oms_root']['computes']
        cmpt = self.make_compute()
        cid = computes.add(cmpt)
        transaction.commit()

        self._cmd('set computes/%s tags=foo' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write('Tags:                  arch:centos, arch:linux, arch:x86_64, label:foo, state:active, type:compute\n')

        self._cmd('set computes/%s tags=label:foo' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write('Tags:                  arch:centos, arch:linux, arch:x86_64, label:foo, state:active, type:compute\n')

        self._cmd('set computes/%s tags=+type:foo' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write('Tags:                  arch:centos, arch:linux, arch:x86_64, label:foo, state:active, type:compute\n')

        self._cmd('set computes/%s tags="+space: ship"' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write('Tags:                  arch:centos, arch:linux, arch:x86_64, label:foo, space:ship, state:active, type:compute\n')

        self._cmd('set computes/%s tags=stuff:' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write('Tags:                  arch:centos, arch:linux, arch:x86_64, state:active, type:compute\n')

        self._cmd('set computes/%s tags=:stuff' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write('Tags:                  arch:centos, arch:linux, arch:x86_64, state:active, type:compute\n')

        self._cmd('set computes/%s tags=,,' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write('Tags:                  arch:centos, arch:linux, arch:x86_64, state:active, type:compute\n')
Ejemplo n.º 13
0
 def test_quit(self):
     self._cmd('quit')
     with assert_mock(self.terminal) as t:
         whatever(t)
         t.write('user@oms:/# ')
Ejemplo n.º 14
0
    def test_special_compute_tags(self):
        computes = db.get_root()['oms_root']['computes']
        cmpt = self.make_compute()
        cid = computes.add(cmpt)
        transaction.commit()

        self._cmd('set computes/%s tags=foo' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write(
                'Tags:                  arch:centos, arch:linux, arch:x86_64, label:foo, state:active, type:compute\n'
            )

        self._cmd('set computes/%s tags=label:foo' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write(
                'Tags:                  arch:centos, arch:linux, arch:x86_64, label:foo, state:active, type:compute\n'
            )

        self._cmd('set computes/%s tags=+type:foo' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write(
                'Tags:                  arch:centos, arch:linux, arch:x86_64, label:foo, state:active, type:compute\n'
            )

        self._cmd('set computes/%s tags="+space: ship"' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write(
                'Tags:                  arch:centos, arch:linux, arch:x86_64, label:foo, space:ship, state:active, type:compute\n'
            )

        self._cmd('set computes/%s tags=stuff:' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write(
                'Tags:                  arch:centos, arch:linux, arch:x86_64, state:active, type:compute\n'
            )

        self._cmd('set computes/%s tags=:stuff' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write(
                'Tags:                  arch:centos, arch:linux, arch:x86_64, state:active, type:compute\n'
            )

        self._cmd('set computes/%s tags=,,' % cid)
        self.terminal.reset_mock()

        self._cmd('cat computes/%s' % cid)
        with assert_mock(self.terminal) as t:
            whatever(t)
            t.write(
                'Tags:                  arch:centos, arch:linux, arch:x86_64, state:active, type:compute\n'
            )