示例#1
0
    def testUnlockHost(self):
        e = TEST_HOST
        args = Parser.parse_args(["-unlock", "-host", e, "-force"])
        common.handleArgs(args)

        self.assertEquals(
            opencue.api.findHost(e).data.lock_state, opencue.api.host_pb2.OPEN)
        opencue.api.findHost(e).unlock()
示例#2
0
    def testSetRepairStare(self):
        e = TEST_HOST
        args = Parser.parse_args(["-repair", "-host", e, "-force"])
        common.handleArgs(args)

        self.assertEquals(
            opencue.api.findHost(e).data.state, opencue.api.host_pb2.REPAIR)
        opencue.api.findHost(e).setHardwareState(opencue.api.host_pb2.UP)
示例#3
0
 def testDefaultMaxCores(self):
     show = TEST_SHOW
     args = Parser.parse_args(["-default-max-cores", show, "100", "-force"])
     common.handleArgs(args)
     s = opencue.api.findShow(show)
     self.assertEquals(100, s.data.default_max_cores)
     args = Parser.parse_args(["-default-max-cores", show, "200", "-force"])
     common.handleArgs(args)
     s = opencue.api.findShow(show)
     self.assertEquals(200, s.data.default_max_cores)
示例#4
0
 def testEnableDispatch(self):
     show = TEST_SHOW
     args = Parser.parse_args(["-dispatching", show, "off", "-force"])
     common.handleArgs(args)
     s = opencue.api.findShow(show)
     self.assertFalse(s.data.dispatch_enabled)
     args = Parser.parse_args(["-dispatching", show, "on", "-force"])
     common.handleArgs(args)
     s = opencue.api.findShow(show)
     self.assertTrue(s.data.dispatch_enabled)
示例#5
0
    def testMovesHost(self):
        e = TEST_HOST
        dst = "{0}.unassigned".format(TEST_FAC)
        back = opencue.api.findHost(e).data.alloc_name

        args = Parser.parse_args(["-move", dst, "-host", e, "-force"])
        common.handleArgs(args)

        self.assertEquals(opencue.api.findHost(e).data.alloc_name, dst)
        args = Parser.parse_args(["-move", back, "-host", e, "-force"])
        common.handleArgs(args)
        self.assertEquals(opencue.api.findHost(e).data.alloc_name, back)
示例#6
0
 def testDeleteShow(self):
     show = "test_show"
     args = Parser.parse_args(["-delete-show", show, "-force"])
     try:
         opencue.api.findShow(show)
     except opencue.EntityNotFoundException:
         opencue.api.createShow(show)
     common.handleArgs(args)
     try:
         opencue.api.findShow(show)
         assert False
     except opencue.EntityNotFoundException:
         assert True
示例#7
0
    def testCreateShow(self):
        show = "test_show"
        args = Parser.parse_args(["-create-show", show, "-force"])
        try:
            s = opencue.api.findShow(show)
            s.delete()
        except opencue.EntityNotFoundException:
            pass

        common.handleArgs(args)
        s = opencue.api.findShow(show)
        self.assertEqual(s.data.name, show)
        s.delete()
示例#8
0
    def testTagAlloc(self):
        facility = opencue.api.getFacility(TEST_FAC)
        entity = "{0}.test_alloc".format(TEST_FAC)
        new_tag = "new_tag"
        args = Parser.parse_args(["-tag-alloc", entity, new_tag, "-force"])

        deleteAlloc(entity)

        facility.createAllocation("test_alloc", entity)
        common.handleArgs(args)
        s = opencue.api.findAllocation(entity)
        self.assertEqual(s.data.tag, new_tag)
        s.delete()
示例#9
0
 def testDeleteAlloc(self):
     entity = "{0}.test_alloc".format(TEST_FAC)
     args = Parser.parse_args(["-delete-alloc", entity, "-force"])
     try:
         opencue.api.findAllocation(entity)
     except opencue.EntityNotFoundException:
         f = opencue.api.getFacility(TEST_FAC)
         f.proxy.createAllocation("test_alloc", "tulip")
     common.handleArgs(args)
     try:
         opencue.api.findAllocation(entity)
         assert False
     except opencue.EntityNotFoundException:
         assert True
示例#10
0
 def testCreateAlloc(self):
     fac = TEST_FAC
     name = "test_alloc"
     entity = "%s.%s" % (fac, name)
     args = Parser.parse_args(["-create-alloc", fac, name, "tag", "-force"])
     try:
         s = opencue.api.findAllocation(entity)
         s.delete()
     except opencue.EntityNotFoundException:
         pass
     common.handleArgs(args)
     s = opencue.api.findAllocation(entity)
     self.assertEqual(s.data.name, entity)
     s.delete()
示例#11
0
    def testTransferAlloc(self):
        facility = opencue.api.getFacility(TEST_FAC)
        e1 = "{0}.talloc1".format(TEST_FAC)
        e2 = "{0}.talloc2".format(TEST_FAC)
        args = Parser.parse_args(["-transfer", e1, e2, "-force"])

        deleteAlloc(e1)
        deleteAlloc(e2)

        facility.createAllocation("talloc1", e1)
        facility.createAllocation("talloc2", e2)
        common.handleArgs(args)

        opencue.api.findAllocation(e1).delete()
        opencue.api.findAllocation(e2).delete()
示例#12
0
    def testSetBurstPercentage(self):
        a = "{0}.unassigned".format(TEST_FAC)
        h = TEST_SHOW
        r = "%s.%s" % (a, h)
        deleteSub(r)

        show = opencue.api.findShow(h)
        show.createSubscription(
            opencue.api.findAllocation(a).data, 100.0, 110.0)

        args = Parser.parse_args(["-burst", h, a, "20%", "-force"])
        common.handleArgs(args)

        s = opencue.api.findSubscription(r)
        self.assertEquals(s.data.burst, 120.0)
        deleteSub(r)
示例#13
0
    def testCreateSub(self):
        a = "{0}.unassigned".format(TEST_FAC)
        h = TEST_SHOW
        r = "%s.%s" % (a, h)
        deleteSub(r)

        args = Parser.parse_args(["-create-sub", h, a, "100", "110", "-force"])
        common.handleArgs(args)

        s = opencue.api.findSubscription(r)
        self.assertEquals(s.data.show_name, h)
        self.assertEquals(s.data.allocation_name, a)
        self.assertEquals(s.data.name, r)
        self.assertEquals(s.data.size, float(100))
        self.assertEquals(s.data.burst, float(110))
        s.delete()
示例#14
0
    def testRenameAlloc(self):
        facility = opencue.api.getFacility(TEST_FAC)

        entity1 = "{0}.test_alloc".format(TEST_FAC)
        entity2 = "{0}.other_alloc".format(TEST_FAC)

        args = Parser.parse_args(["-rename-alloc", entity1, entity2, "-force"])

        deleteAlloc(entity1)
        deleteAlloc(entity2)

        facility.createAllocation("test_alloc", "tulip")
        common.handleArgs(args)
        s = opencue.api.findAllocation(entity2)
        self.assertEqual(s.data.name, entity2)
        s.delete()
示例#15
0
    def testDeleteSub(self):
        a = "{0}.unassigned".format(TEST_FAC)
        h = TEST_SHOW
        r = "%s.%s" % (a, h)
        deleteSub(r)

        show = opencue.api.findShow(h)
        show.createSubscription(
            opencue.api.findAllocation(a).data, 100.0, 110.0)

        args = Parser.parse_args(["-delete-sub", h, a, "-force"])
        common.handleArgs(args)

        try:
            opencue.api.findSubscription(r)
            raise Exception("subscription should have been deleted")
        except opencue.EntityNotFoundException:
            pass
示例#16
0
                          mode.lower()
                          for mode in opencue.api.host_pb2.ThreadMode.keys()
                      ])
    host.add_argument("-os",
                      action="store",
                      help="Set the host's operating system.",
                      choices=OS_LIST)

    try:
        args = parser.parse_args()
    except common.argparse.ArgumentError, exc:
        print >> sys.stderr, "Could not parse arguments, check command line flags."
        raise exc

    try:
        common.handleCommonArgs(args)
        if args.unit_test:
            runTests(parser)
        else:
            common.handleArgs(args)
    except Exception, e:
        common.handleParserException(args, e)


def runTests(parser):
    import tests
    tests.run(parser)


if __name__ == '__main__':
    main()