Beispiel #1
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.function_engine

        function_id = parsed_args.function
        if not uuidutils.is_uuid_like(function_id):
            # Try to find the function id with name
            function_id = q_utils.find_resource_id_by_name(
                client.functions, function_id)

        version = client.function_versions.create(
            function_id,
            description=parsed_args.description,
        )

        return self.columns, utils.get_item_properties(version, self.columns)
Beispiel #2
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.function_engine

        function = parsed_args.function
        if not uuidutils.is_uuid_like(function):
            # Try to find the function id with name
            function = q_utils.find_resource_id_by_name(
                client.functions, function)

        execution = client.function_executions.create(
            function=function,
            version=parsed_args.function_version,
            sync=parsed_args.sync,
            input=parsed_args.input)

        return self.columns, utils.get_item_properties(execution, self.columns)
Beispiel #3
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.function_engine

        function_id = parsed_args.function
        if not uuidutils.is_uuid_like(function_id):
            # Try to find the function id with name
            function_id = q_utils.find_resource_id_by_name(
                client.functions, function_id)

        job = client.jobs.create(
            function_id,
            function_version=parsed_args.function_version,
            name=parsed_args.name,
            first_execution_time=parsed_args.first_execution_time,
            pattern=parsed_args.pattern,
            function_input=parsed_args.function_input,
            count=parsed_args.count)

        return self.columns, osc_utils.get_item_properties(job, self.columns)
    def take_action(self, parsed_args):
        client = self.app.client_manager.function_engine
        code_type = None

        if (parsed_args.file or parsed_args.package):
            code_type = 'package'
        elif (parsed_args.container or parsed_args.object):
            code_type = 'swift'
        elif parsed_args.image:
            code_type = 'image'

        runtime = parsed_args.runtime
        if runtime and not uuidutils.is_uuid_like(runtime):
            # Try to find the runtime id with name
            runtime = q_utils.find_resource_id_by_name(
                client.runtimes, runtime)

        if code_type == 'package':
            if not runtime:
                raise exceptions.QinlingClientException(
                    'Runtime needs to be specified for package type function.'
                )

            zip_file = _get_package_file(parsed_args.package, parsed_args.file)
            md5sum = q_utils.md5(file=zip_file)
            code = {"source": "package", "md5sum": md5sum}

            with open(zip_file, 'rb') as package:
                function = client.functions.create(
                    name=parsed_args.name,
                    runtime=runtime,
                    code=code,
                    package=package,
                    entry=parsed_args.entry,
                    cpu=parsed_args.cpu,
                    memory_size=parsed_args.memory_size
                )

            # Delete zip file the client created
            if parsed_args.file and not parsed_args.package:
                os.remove(zip_file)

        elif code_type == 'swift':
            if not (parsed_args.container and parsed_args.object):
                raise exceptions.QinlingClientException(
                    'Container name and object name need to be specified.'
                )
            if not runtime:
                raise exceptions.QinlingClientException(
                    'Runtime needs to be specified for package type function.'
                )

            code = {
                "source": "swift",
                "swift": {
                    "container": parsed_args.container,
                    "object": parsed_args.object
                }
            }

            function = client.functions.create(
                name=parsed_args.name,
                runtime=runtime,
                code=code,
                entry=parsed_args.entry,
                cpu=parsed_args.cpu,
                memory_size=parsed_args.memory_size
            )

        elif code_type == 'image':
            code = {
                "source": "image",
                "image": parsed_args.image
            }

            function = client.functions.create(
                name=parsed_args.name,
                code=code,
                entry=parsed_args.entry,
                cpu=parsed_args.cpu,
                memory_size=parsed_args.memory_size
            )

        return self.columns, utils.get_item_properties(function, self.columns)