Skip to content

Supporting gRPC in PyOne #7486

@ms4ons

Description

@ms4ons

Description
Adding gRPC as alternative transport mechanism to PyONE, while keeping the same public API as the current XML-RPC-based client. Users can choose XML-RPC or gRPC via a constructor parameter or environment variable. The same method calls (one.hostpool.info, one.vm.info, one.template.instantiate, etc.) work for both options and return the same Python objects.

Use case
Callers use the same PyONE API, but the endpoint and optional protocol argument might change:

import pyone

# XML-RPC (default)
one = pyone.OneServer("http://one:2633/RPC2", session="oneadmin:onepass")

# gRPC
one = pyone.OneServer("localhost:2634", session="oneadmin:onepass", protocol="grpc")

# Same calls in both cases
hostpool = one.hostpool.info()
vm = one.vm.info(0)

Interface Changes
OneServer initialization with new optional argument: protocol. If protocol="grpc", the client uses gRPC, otherwise it uses XML-RPC (default)

Additional Context
Implementation should include:

  • Protocol dispatcher in OneServer class that selects XML-RPC or gRPC based on endpoint and the optional protocol argument
  • OneServerGRPC class, as a new backend using gRPC stubs and a method mapper that translates XML-RPC-style calls to gRPC service RPCs
  • Same return types for gRPC responses as for XML-RPC
  • Backward compatibility regarding the existing code using OneServer(uri, session), which continues to work with XML-RPC by default

Progress Status

  • Code committed
  • Testing - QA
  • Documentation (Release notes - resolved issues, compatibility, known issues)

Metadata

Metadata

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions