Beispiel #1
0
    def testCreateSubscription(self, getStubMock):
        stubMock = mock.Mock()
        stubMock.CreateSubscription.return_value = show_pb2.ShowCreateSubscriptionResponse(
            subscription=subscription_pb2.Subscription(
                name=TEST_SUBSCRIPTION_NAME,
                size=TEST_SUBSCRIPTION_SIZE,
                burst=TEST_SUBSCRIPTION_BURST))
        getStubMock.return_value = stubMock

        show = opencue.wrappers.show.Show(show_pb2.Show(name=TEST_SHOW_NAME))
        allocation = opencue.wrappers.allocation.Allocation(
            facility_pb2.Allocation(id=TEST_ALLOCATION_ID))
        subscription = show.createSubscription(allocation,
                                               TEST_SUBSCRIPTION_SIZE,
                                               TEST_SUBSCRIPTION_BURST)

        stubMock.CreateSubscription.assert_called_with(
            show_pb2.ShowCreateSubscriptionRequest(
                show=show.data,
                allocation_id=TEST_ALLOCATION_ID,
                size=TEST_SUBSCRIPTION_SIZE,
                burst=TEST_SUBSCRIPTION_BURST),
            timeout=mock.ANY)
        self.assertEqual(subscription.size(), TEST_SUBSCRIPTION_SIZE)
        self.assertEqual(subscription.burst(), TEST_SUBSCRIPTION_BURST)
Beispiel #2
0
 def createSubscription(self, allocation, size, burst):
     """Creates a new subscription
     @type allocation: Allocation
     @param allocation: Allocation object
     @type size: float
     @param size: Allocation size
     @type burst: float
     @param burst: Allocation burst
     @rtype: Subscription
     @return: The created subscription object
     """
     response = self.stub.CreateSubscription(show_pb2.ShowCreateSubscriptionRequest(
         show=self.data, allocation_id=allocation.id, size=size, burst=burst),
         timeout=Cuebot.Timeout)
     return opencue.wrappers.subscription.Subscription(response.subscription)
Beispiel #3
0
    def createSubscription(self, allocation, size, burst):
        """Creates a new subscription for the show.

        A subscription links a show to an allocation, and determines how many cores the show
        can utilize within that allocation.

        :type  allocation: opencue.wrappers.allocation.Allocation
        :param allocation: allocation to subscribe to
        :type  size: float
        :param size: number of cores the show is allowed to use consistently
        :type  burst: float
        :param burst: number of cores the show is allowed to burst to
        :rtype:  opencue.wrappers.subscription.Subscription
        :return: the created subscription object
        """
        response = self.stub.CreateSubscription(show_pb2.ShowCreateSubscriptionRequest(
            show=self.data, allocation_id=allocation.id(), size=size, burst=burst),
            timeout=Cuebot.Timeout)
        return opencue.wrappers.subscription.Subscription(response.subscription)