Exemplo n.º 1
0
def lock(args):
    lock = args.LOCK

    if lock is None or lock is False:
        return False

    lock_type = args.LOCK_TYPE
    name = args.NAME
    email = args.EMAIL
    notify = False

    if lock_type is None or name is None or email is None:
        if lock_type is None:
            print("Please specify the lock type")

        if name is None:
            print("Please specify your name")

        if email is None:
            print("Please specify your pavilion email address")

        return False

    if args.NOTIFY is not None:
        notify = args.NOTIFY

    chm = chassis_manager.ChassisManager()
    success, error = chm.lock(lock_type, email, name, notify)

    if not success:
        print(error)
        return True

    print("Lock acquired successfully")
    return True
Exemplo n.º 2
0
def lock_owners(args):
    owners = args.LOCK_OWNERS

    if owners is None or owners is False:
        return False

    chm = chassis_manager.ChassisManager()
    chm.print_lock_owners()

    return True
Exemplo n.º 3
0
def lock_history(args):
    history = args.LOCK_HISTORY

    if history is None or history is False:
        return False

    chm = chassis_manager.ChassisManager()
    chm.print_lock_history()

    return True
    def test_chm_lock(self):
        chm = chassis_manager.ChassisManager()
        success, error = chm.lock(
            lock._lock_type_to_name(lock.LockType.EXCLUSIVE),
            "*****@*****.**", "gullu", False)
        self.assertEqual(success, True)
        self.assertEqual(error, None)

        success, error = chm.lock(
            lock._lock_type_to_name(lock.LockType.EXCLUSIVE),
            "*****@*****.**", "pillu", False)
        self.assertEqual(success, False)
        self.assertEqual(error, lock.ErrNotAvailable)
        self.assertEqual(len(chm._lock.waiters()), 0)
Exemplo n.º 5
0
def init(args):
    init = args.INIT

    if init is None or init is False:
        return False

    name = args.CHNAME
    ip = args.CHIP

    if name is None or ip is None:
        if name is None:
            print("Please specify the chassis name")

        if ip is None:
            print("Please specify the chassis ip")

        return False

    chm = chassis_manager.ChassisManager(name, ip)
    chm.ch_init(name, ip)
    print("Chassis initialized successfully")
    return True
Exemplo n.º 6
0
def unlock(args):
    unlock = args.UNLOCK

    if unlock is None or unlock is False:
        return False

    email = args.EMAIL

    if email is None:
        print("Please specify your pavilion email address")
        return True

    chm = chassis_manager.ChassisManager()
    success, error, notified = chm.unlock(email)

    if not success:
        print(error)
        return True

    if notified > 0:
        print(f"{notified!s} waiters notified")

    print("Lock released successfully")
    return True
 def test_chassis_manager(self):
     chm = chassis_manager.ChassisManager()
     self.assertEqual(chm._chassis_ip, "10.10.10.10")
     self.assertEqual(chm._chassis_name, "gullu")