Exemple #1
0
def deploy(self, pool_id, user_id):

    msg = {
        'object_type': 'pool',
        'action': 'deploy',
        'object_id': pool_id
    }
    self.update_state(
        state='PROGRESS',
        meta=msg
    )

    pool_obj = facade.get_pool_by_id(pool_id)
    pool_serializer = serializers.PoolV3Serializer(pool_obj)
    locks_list = create_lock([pool_id], LOCK_POOL)

    user = Usuario.objects.get(id=user_id)

    try:
        facade_pool_deploy.create_real_pool(
            [pool_serializer.data], user)

    except Exception, exception:
        msg['message'] = 'Pool {} was not deployed.'.format(pool_obj)
        msg['reason'] = str(exception)

        raise Exception(msg)
Exemple #2
0
    def test_create_deploy_with_mock_success(self, test_patch):
        """
            Deploy create of one pool with success.
            Method that factory in networkapi.plugins.factory.PluginFactory
            is mock to test the flow in deploys of pool.
        """

        dp = self.load_json_file(
            'api_pools/tests/unit/json/test_pool_post_not_created.json')
        test_patch.return_value = MockPlugin()
        dp = dp.get('server_pools')
        facade_pool_deploy.create_real_pool(dp, self.user)
    def test_create_deploy_with_mock_success(self, test_patch):
        """
            Deploy create of one pool with success.
            Method that factory in networkapi.plugins.factory.PluginFactory
            is mock to test the flow in deploys of pool.
        """

        dp = self.load_json_file(
            'api_pools/tests/unit/json/test_pool_post_not_created.json')
        test_patch.return_value = MockPlugin()
        dp = dp.get('server_pools')
        facade_pool_deploy.create_real_pool(dp, self.user)
def deploy(self, pool_id, user_id):

    msg = {'object_type': 'pool', 'action': 'deploy', 'object_id': pool_id}
    self.update_state(state='PROGRESS', meta=msg)

    pool_obj = facade.get_pool_by_id(pool_id)
    pool_serializer = serializers.PoolV3Serializer(pool_obj)
    locks_list = create_lock([pool_id], LOCK_POOL)

    user = Usuario.objects.get(id=user_id)

    try:
        facade_pool_deploy.create_real_pool([pool_serializer.data], user)

    except Exception, exception:
        msg['message'] = 'Pool {} was not deployed.'.format(pool_obj)
        msg['reason'] = str(exception)

        raise Exception(msg)
    def mock_create_pool(self, id_pool, test_patch):

        pool = self.client.get(
            '/api/v3/pool/%s/' % id_pool,
            HTTP_AUTHORIZATION=self.get_http_authorization('test'))

        test_patch.return_value = MockPlugin()

        facade_pool_deploy.create_real_pool(pool.data['server_pools'],
                                            self.user)

        pool = self.client.get('/api/v3/pool/%s/' % id_pool,
                               HTTP_AUTHORIZATION=self.get_http_authorization(
                                   'test')).data['server_pools'][0]

        self.assertEqual(True, pool['pool_created'],
                         'After deploy, flag created should be True.')

        pass
Exemple #6
0
    def test_create_deploy_with_mock_error(self, test_patch):
        """
            Deploy create of one pool with error.
            Method that factory in networkapi.plugins.factory.PluginFactory
            is mock to test the flow in deploys of pool.
        """

        dp = self.load_json_file(
            'api_pools/tests/unit/json/test_pool_post_not_created.json')
        mock = MockPlugin()
        mock.status(False)
        test_patch.return_value = mock
        dp = dp.get('server_pools')
        self.assertRaises(Exception,
                          facade_pool_deploy.create_real_pool(dp, self.user))
    def post(self, request, *args, **kwargs):
        """
        Creates pools by list in equipments
        """

        pool_ids = kwargs['pool_ids'].split(';')
        pools = facade.get_pool_by_ids(pool_ids)
        pool_serializer = serializers.PoolV3Serializer(pools, many=True)
        locks_list = create_lock(pool_serializer.data, LOCK_POOL)
        try:
            response = facade_pool_deploy.create_real_pool(
                pool_serializer.data, request.user)
        except Exception, exception:
            log.error(exception)
            raise rest_exceptions.NetworkAPIException(exception)
Exemple #8
0
    def post(self, request, *args, **kwargs):
        """
        Creates pools by list in equipments
        """

        pool_ids = kwargs['obj_ids'].split(';')
        pools = facade.get_pool_by_ids(pool_ids)
        pool_serializer = serializers.PoolV3Serializer(pools, many=True)
        locks_list = create_lock(pool_serializer.data, LOCK_POOL)
        try:
            response = facade_pool_deploy.create_real_pool(
                pool_serializer.data, request.user)
        except Exception, exception:
            log.error(exception)
            raise rest_exceptions.NetworkAPIException(exception)
    def test_create_deploy_with_mock_error(self, test_patch):
        """
            Deploy create of one pool with error.
            Method that factory in networkapi.plugins.factory.PluginFactory
            is mock to test the flow in deploys of pool.
        """

        dp = self.load_json_file(
            'api_pools/tests/unit/json/test_pool_post_not_created.json')
        mock = MockPlugin()
        mock.status(False)
        test_patch.return_value = mock
        dp = dp.get('server_pools')
        self.assertRaises(
            Exception,
            facade_pool_deploy.create_real_pool(dp, self.user)
        )