From 8f57c337e1df953fdefa0db640a3c3adec9bef29 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Mon, 12 Jan 2026 14:58:55 +0100 Subject: [PATCH] F OpenNebula/one#6778: Introduces a gRPC API server for OpenNebula Demon This commit introduces a new API server based on the gRPC/Protobuf. The API follow the design of the existing xml-rpc to ease the transition to the new server and support the current state management engine. Both API servers can be run in parallel. Main changes: - Decouple Generic and XMLRPC specific logic and add gRPC classes. - Source code re-structure to include logic for each server - New compilation options to generate gRPC stubs - Client code for C++, Ruby, Python and Go co-authored-by: Jan Orel co-authored-by: Pavel Czerny co-authored-by: MarioRobres --- .gitignore | 7 +- SConstruct | 41 + include/Client.h | 160 +- include/ClientGRPC.h | 95 + include/ClientXRPC.h | 146 + include/DispatchManager.h | 2 +- include/FedReplicaManager.h | 15 +- include/HookAPI.h | 2 - include/LifeCycleManager.h | 2 +- include/Nebula.h | 44 +- include/PoolSQL.h | 11 + include/RaftManager.h | 46 +- include/Request.h | 665 +-- include/RequestAttributes.h | 281 + include/RequestLogger.h | 105 + include/RequestManagerAcl.h | 107 - include/RequestManagerAllocate.h | 826 --- include/RequestManagerAllocateDB.h | 118 - include/RequestManagerBackupJob.h | 138 - include/RequestManagerChmod.h | 330 -- include/RequestManagerChown.h | 381 -- include/RequestManagerClone.h | 256 - include/RequestManagerCluster.h | 434 -- include/RequestManagerConnection.h | 113 - include/RequestManagerDelete.h | 421 -- include/RequestManagerDropDB.h | 85 - include/RequestManagerGroup.h | 127 - include/RequestManagerImage.h | 204 - include/RequestManagerInfo.h | 477 -- include/RequestManagerLock.h | 317 - include/RequestManagerPoolInfoFilter.h | 406 -- include/RequestManagerRename.h | 518 -- include/RequestManagerSchedAction.h | 85 - include/RequestManagerSystem.h | 230 - include/RequestManagerUpdateDB.h | 169 - include/RequestManagerUpdateTemplate.h | 460 -- include/RequestManagerUser.h | 253 - include/RequestManagerVMGroup.h | 98 - include/RequestManagerVMTemplate.h | 98 - include/RequestManagerVNTemplate.h | 85 - include/RequestManagerVdc.h | 267 - include/RequestManagerVirtualMachine.h | 833 --- include/RequestManagerVirtualNetwork.h | 253 - include/RequestManagerVirtualRouter.h | 90 - include/RequestManagerZone.h | 191 - include/VirtualRouter.h | 2 +- include/Zone.h | 4 +- include/ZonePool.h | 3 +- include/ZoneServer.h | 4 +- install.sh | 94 +- share/doc/xsd/opennebula_configuration.xsd | 3 + share/etc/oned.conf | 22 +- share/install_gems/AlmaLinux10/Gemfile.lock | 265 +- share/install_gems/AlmaLinux9/Gemfile.lock | 40 +- share/install_gems/Debian11/Gemfile.lock | 37 +- share/install_gems/Debian12/Gemfile.lock | 60 +- share/install_gems/Debian13/Gemfile.lock | 261 +- share/install_gems/Gemfile | 7 +- share/install_gems/RedHat9/Gemfile.lock | 34 +- share/install_gems/Ubuntu2204/Gemfile.lock | 40 +- share/install_gems/Ubuntu2404/Gemfile.lock | 261 +- share/install_gems/install_gems | 3 +- share/linters/.rubocop.yml | 1 + share/rubygems/generate | 31 +- share/smoke_tests/tests/04-cppcheck.sh | 4 +- src/authm_mad/remotes/ldap/ldap_auth.rb | 2 +- src/authm_mad/remotes/saml/saml_auth.rb | 2 +- src/cli/one_helper.rb | 67 +- src/cli/one_helper/oneacct_helper.rb | 2 + src/cli/one_helper/oneacl_helper.rb | 2 + src/cli/one_helper/onebackupjob_helper.rb | 2 + src/cli/one_helper/onecluster_helper.rb | 2 + src/cli/one_helper/onedatastore_helper.rb | 3 + src/cli/one_helper/onegroup_helper.rb | 4 +- src/cli/one_helper/onehook_helper.rb | 5 +- src/cli/one_helper/onehost_helper.rb | 7 +- src/cli/one_helper/oneimage_helper.rb | 2 + src/cli/one_helper/onemarket_helper.rb | 2 + src/cli/one_helper/onemarketapp_helper.rb | 3 + src/cli/one_helper/onequota_helper.rb | 1 + src/cli/one_helper/onesecgroup_helper.rb | 2 + src/cli/one_helper/onetemplate_helper.rb | 3 +- src/cli/one_helper/oneuser_helper.rb | 3 + src/cli/one_helper/onevdc_helper.rb | 2 + src/cli/one_helper/onevm_helper.rb | 6 +- src/cli/one_helper/onevmgroup_helper.rb | 2 + src/cli/one_helper/onevnet_helper.rb | 2 + src/cli/one_helper/onevntemplate_helper.rb | 3 +- src/cli/one_helper/onevrouter_helper.rb | 2 + src/cli/one_helper/onezone_helper.rb | 19 +- src/cli/onemarketapp | 3 + src/cli/onevm | 2 +- src/cli/onevntemplate | 3 +- src/cli/onezone | 16 +- src/client/Client.cc | 293 +- src/client/ClientGRPC.cc | 516 ++ src/client/ClientXRPC.cc | 696 +++ src/client/SConstruct | 4 +- src/cloud/common/CloudServer.rb | 2 +- src/form/lib/helpers/response_helper.rb | 2 +- src/hm/HookAPI.cc | 108 +- src/im/InformationManager.cc | 3 +- .../dummy-probes.d/vm/execution/exec.rb | 2 + src/market/MarketPlaceAppPool.cc | 118 +- src/market/MarketPlacePool.cc | 77 +- src/nebula/Nebula.cc | 62 +- src/oca/go/src/goca/acl.go | 15 +- src/oca/go/src/goca/acl_test.go | 85 + src/oca/go/src/goca/api/acl/acl.pb.go | 368 ++ src/oca/go/src/goca/api/acl/acl_grpc.pb.go | 170 + .../go/src/goca/api/backupjob/backupjob.pb.go | 1665 ++++++ .../goca/api/backupjob/backupjob_grpc.pb.go | 674 +++ src/oca/go/src/goca/api/cluster/cluster.pb.go | 1343 +++++ .../src/goca/api/cluster/cluster_grpc.pb.go | 602 ++ .../go/src/goca/api/datastore/datastore.pb.go | 976 ++++ .../goca/api/datastore/datastore_grpc.pb.go | 386 ++ .../go/src/goca/api/document/document.pb.go | 1186 ++++ .../src/goca/api/document/document_grpc.pb.go | 458 ++ src/oca/go/src/goca/api/group/group.pb.go | 872 +++ .../go/src/goca/api/group/group_grpc.pb.go | 422 ++ src/oca/go/src/goca/api/hook/hook.pb.go | 978 ++++ src/oca/go/src/goca/api/hook/hook_grpc.pb.go | 422 ++ src/oca/go/src/goca/api/host/host.pb.go | 884 +++ src/oca/go/src/goca/api/host/host_grpc.pb.go | 386 ++ src/oca/go/src/goca/api/image/image.pb.go | 1828 ++++++ .../go/src/goca/api/image/image_grpc.pb.go | 710 +++ .../goca/api/marketplace/marketplace.pb.go | 1129 ++++ .../api/marketplace/marketplace_grpc.pb.go | 458 ++ .../api/marketplaceapp/marketplaceapp.pb.go | 1422 +++++ .../marketplaceapp/marketplaceapp_grpc.pb.go | 566 ++ .../goca/api/response_id/response_id.pb.go | 94 + .../go/src/goca/api/secgroup/secgroup.pb.go | 1081 ++++ .../src/goca/api/secgroup/secgroup_grpc.pb.go | 422 ++ src/oca/go/src/goca/api/shared/shared.pb.go | 236 + src/oca/go/src/goca/api/system/system.pb.go | 419 ++ .../go/src/goca/api/system/system_grpc.pb.go | 206 + .../go/src/goca/api/template/template.pb.go | 1320 +++++ .../src/goca/api/template/template_grpc.pb.go | 494 ++ src/oca/go/src/goca/api/user/user.pb.go | 1367 +++++ src/oca/go/src/goca/api/user/user_grpc.pb.go | 602 ++ src/oca/go/src/goca/api/vdc/vdc.pb.go | 1562 +++++ src/oca/go/src/goca/api/vdc/vdc_grpc.pb.go | 638 +++ src/oca/go/src/goca/api/vm/vm.pb.go | 4739 +++++++++++++++ src/oca/go/src/goca/api/vm/vm_grpc.pb.go | 1826 ++++++ src/oca/go/src/goca/api/vmgroup/vmgroup.pb.go | 1351 +++++ .../src/goca/api/vmgroup/vmgroup_grpc.pb.go | 530 ++ src/oca/go/src/goca/api/vn/vn.pb.go | 1790 ++++++ src/oca/go/src/goca/api/vn/vn_grpc.pb.go | 710 +++ .../src/goca/api/vntemplate/vntemplate.pb.go | 1267 ++++ .../goca/api/vntemplate/vntemplate_grpc.pb.go | 494 ++ src/oca/go/src/goca/api/vrouter/vrouter.pb.go | 1381 +++++ .../src/goca/api/vrouter/vrouter_grpc.pb.go | 530 ++ src/oca/go/src/goca/api/zone/zone.pb.go | 1701 ++++++ src/oca/go/src/goca/api/zone/zone_grpc.pb.go | 602 ++ src/oca/go/src/goca/backupjob.go | 36 +- src/oca/go/src/goca/client.go | 1291 ++++- src/oca/go/src/goca/cluster.go | 34 +- src/oca/go/src/goca/cluster_test.go | 9 +- src/oca/go/src/goca/controller.go | 327 +- src/oca/go/src/goca/datastore.go | 25 +- src/oca/go/src/goca/datastore_test.go | 139 + src/oca/go/src/goca/document.go | 24 +- src/oca/go/src/goca/errors/errors.go | 26 + src/oca/go/src/goca/filter.go | 7 +- src/oca/go/src/goca/go.mod | 16 +- src/oca/go/src/goca/go.sum | 43 + src/oca/go/src/goca/group.go | 54 +- src/oca/go/src/goca/group_test.go | 144 + src/oca/go/src/goca/grpc_client.go | 3220 +++++++++++ src/oca/go/src/goca/helper_test.go | 19 +- src/oca/go/src/goca/hook.go | 26 +- src/oca/go/src/goca/hook_test.go | 66 +- src/oca/go/src/goca/hooklog.go | 2 +- src/oca/go/src/goca/host.go | 18 +- src/oca/go/src/goca/host_test.go | 106 + src/oca/go/src/goca/image.go | 56 +- src/oca/go/src/goca/image_test.go | 290 +- src/oca/go/src/goca/marketplace.go | 27 +- src/oca/go/src/goca/marketplace_test.go | 2 +- src/oca/go/src/goca/marketplaceapp.go | 24 +- src/oca/go/src/goca/schemas/vm/template.go | 12 + src/oca/go/src/goca/schemas/zone/zone.go | 44 + src/oca/go/src/goca/securitygroup.go | 21 +- src/oca/go/src/goca/securitygroup_test.go | 44 +- src/oca/go/src/goca/service_template_test.go | 26 + src/oca/go/src/goca/service_test.go | 2 +- src/oca/go/src/goca/system_test.go | 36 + src/oca/go/src/goca/template.go | 28 +- src/oca/go/src/goca/template_test.go | 213 +- src/oca/go/src/goca/user.go | 79 +- src/oca/go/src/goca/user_test.go | 166 + src/oca/go/src/goca/vdc.go | 35 +- src/oca/go/src/goca/vdc_test.go | 163 + src/oca/go/src/goca/virtualnetwork.go | 39 +- src/oca/go/src/goca/virtualnetwork_test.go | 274 +- src/oca/go/src/goca/virtualrouter.go | 29 +- src/oca/go/src/goca/virtualrouter_test.go | 294 +- src/oca/go/src/goca/vm.go | 162 +- src/oca/go/src/goca/vm_test.go | 408 +- src/oca/go/src/goca/vmgroup.go | 28 +- src/oca/go/src/goca/vmgroup_test.go | 12 +- src/oca/go/src/goca/vntemplate.go | 29 +- src/oca/go/src/goca/vntemplate_test.go | 151 + src/oca/go/src/goca/zone.go | 74 +- src/oca/go/src/goca/zone_test.go | 128 + .../opennebula/client/vm/VirtualMachine.java | 73 + src/oca/ruby/opennebula.rb | 15 +- src/oca/ruby/opennebula/acl.rb | 24 +- src/oca/ruby/opennebula/cluster_pool.rb | 2 + src/oca/ruby/opennebula/datastore_pool.rb | 2 + src/oca/ruby/opennebula/document.rb | 2 +- src/oca/ruby/opennebula/document_json.rb | 1 + src/oca/ruby/opennebula/document_pool_json.rb | 2 + src/oca/ruby/opennebula/error.rb | 10 +- src/oca/ruby/opennebula/flow/service_pool.rb | 2 + .../ruby/opennebula/flow/service_template.rb | 1 + src/oca/ruby/opennebula/group.rb | 3 + src/oca/ruby/opennebula/group_pool.rb | 2 + src/oca/ruby/opennebula/grpc/Makefile | 14 + src/oca/ruby/opennebula/grpc/lib/acl_map.rb | 50 + .../ruby/opennebula/grpc/lib/backupjob_map.rb | 164 + .../ruby/opennebula/grpc/lib/cluster_map.rb | 166 + .../ruby/opennebula/grpc/lib/datastore_map.rb | 102 + .../ruby/opennebula/grpc/lib/document_map.rb | 121 + src/oca/ruby/opennebula/grpc/lib/group_map.rb | 95 + .../opennebula/grpc/lib/grpc_map_loader.rb | 78 + src/oca/ruby/opennebula/grpc/lib/hook_map.rb | 101 + src/oca/ruby/opennebula/grpc/lib/host_map.rb | 111 + src/oca/ruby/opennebula/grpc/lib/image_map.rb | 181 + .../opennebula/grpc/lib/marketplace_map.rb | 116 + .../opennebula/grpc/lib/marketplaceapp_map.rb | 158 + .../opennebula/grpc/lib/securitygroup_map.rb | 120 + .../ruby/opennebula/grpc/lib/system_map.rb | 50 + .../ruby/opennebula/grpc/lib/template_map.rb | 135 + src/oca/ruby/opennebula/grpc/lib/user_map.rb | 141 + src/oca/ruby/opennebula/grpc/lib/vdc_map.rb | 155 + .../opennebula/grpc/lib/virtualmachine_map.rb | 467 ++ .../opennebula/grpc/lib/virtualnetwork_map.rb | 178 + .../opennebula/grpc/lib/virtualrouter_map.rb | 135 + .../ruby/opennebula/grpc/lib/vmgroup_map.rb | 132 + .../opennebula/grpc/lib/vntemplate_map.rb | 129 + src/oca/ruby/opennebula/grpc/lib/zone_map.rb | 145 + src/oca/ruby/opennebula/host_pool.rb | 2 + src/oca/ruby/opennebula/lib/client.rb | 133 + src/oca/ruby/opennebula/lib/grpc_client.rb | 105 + .../{client.rb => lib/xml_client.rb} | 140 +- src/oca/ruby/opennebula/lockable_ext.rb | 35 +- src/oca/ruby/opennebula/marketplaceapp_ext.rb | 3 + src/oca/ruby/opennebula/pool.rb | 3 +- src/oca/ruby/opennebula/pool_element.rb | 16 +- src/oca/ruby/opennebula/user_pool.rb | 1 + src/oca/ruby/opennebula/version.rb | 22 + .../ruby/opennebula/virtual_machine_ext.rb | 2 + .../ruby/opennebula/virtual_network_pool.rb | 2 + src/oca/ruby/opennebula/wait_ext.rb | 1 + src/oca/ruby/opennebula/xml_element.rb | 1 + src/oca/ruby/opennebula/xml_utils.rb | 4 +- src/oca/ruby/opennebula/zone.rb | 7 +- src/pool/PoolSQL.cc | 9 +- src/raft/FedReplicaManager.cc | 71 +- src/raft/RaftManager.cc | 164 +- src/raft/ReplicaThread.cc | 8 +- src/rm/Request.cc | 1092 +--- src/rm/RequestLogger.cc | 232 + src/rm/RequestManagerAllocate.cc | 1508 ----- src/rm/RequestManagerBackupJob.cc | 412 -- src/rm/RequestManagerChmod.cc | 333 -- src/rm/RequestManagerChown.cc | 618 -- src/rm/RequestManagerClone.cc | 258 - src/rm/RequestManagerCluster.cc | 467 -- src/rm/RequestManagerDelete.cc | 1093 ---- src/rm/RequestManagerGroup.cc | 182 - src/rm/RequestManagerImage.cc | 673 --- src/rm/RequestManagerInfo.cc | 295 - src/rm/RequestManagerLock.cc | 425 -- src/rm/RequestManagerMarketPlace.cc | 115 - src/rm/RequestManagerMarketPlaceApp.cc | 71 - src/rm/RequestManagerPoolInfoFilter.cc | 1168 ---- src/rm/RequestManagerRename.cc | 265 - src/rm/RequestManagerSchedAction.cc | 283 - src/rm/RequestManagerSystem.cc | 312 - src/rm/RequestManagerUpdateTemplate.cc | 281 - src/rm/RequestManagerUser.cc | 552 -- src/rm/RequestManagerVMTemplate.cc | 394 -- src/rm/RequestManagerVdc.cc | 296 - src/rm/SConstruct | 278 +- .../{RequestManagerAcl.cc => api/AclAPI.cc} | 106 +- src/rm/api/AclAPI.h | 57 + src/rm/api/BackupJobAPI.cc | 489 ++ src/rm/api/BackupJobAPI.h | 128 + .../rm/api/BackupJobPoolAPI.h | 28 +- src/rm/api/ClusterAPI.cc | 660 +++ src/rm/api/ClusterAPI.h | 167 + src/rm/api/ClusterPoolAPI.cc | 18 + src/rm/api/ClusterPoolAPI.h | 44 + src/rm/api/DatastoreAPI.cc | 174 + src/rm/api/DatastoreAPI.h | 134 + src/rm/api/DatastorePoolAPI.h | 44 + src/rm/api/DocumentAPI.cc | 69 + src/rm/api/DocumentAPI.h | 113 + src/rm/api/DocumentPoolAPI.h | 45 + src/rm/api/GroupAPI.cc | 291 + src/rm/api/GroupAPI.h | 137 + src/rm/api/GroupPoolAPI.h | 43 + src/rm/api/HookPoolAPI.cc | 110 + src/rm/api/HookPoolAPI.h | 49 + src/rm/api/HostAPI.cc | 223 + src/rm/api/HostAPI.h | 161 + src/rm/api/HostPoolAPI.cc | 40 + .../HostPoolAPI.h} | 50 +- src/rm/api/ImageAPI.cc | 936 +++ src/rm/api/ImageAPI.h | 129 + src/rm/api/ImagePoolAPI.h | 44 + src/rm/api/MarketPlaceAPI.cc | 243 + src/rm/api/MarketPlaceAPI.h | 132 + src/rm/api/MarketPlaceAppAPI.cc | 224 + src/rm/api/MarketPlaceAppAPI.h | 144 + src/rm/api/MarketPlaceAppPoolAPI.h | 44 + src/rm/api/MarketPlacePoolAPI.h | 44 + src/rm/api/PoolSharedAPI.cc | 182 + src/rm/api/PoolSharedAPI.h | 73 + .../RMHookAPI.cc} | 63 +- src/rm/api/RMHookAPI.h | 100 + .../SecurityGroupAPI.cc} | 78 +- src/rm/api/SecurityGroupAPI.h | 101 + src/rm/api/SecurityGroupPoolAPI.h | 43 + src/rm/api/SharedAPI.cc | 1704 ++++++ src/rm/api/SharedAPI.h | 473 ++ src/rm/api/SystemAPI.cc | 175 + .../SystemAPI.h} | 120 +- src/rm/api/TemplateAPI.cc | 774 +++ src/rm/api/TemplateAPI.h | 145 + src/rm/api/TemplatePoolAPI.h | 44 + src/rm/api/UserAPI.cc | 866 +++ src/rm/api/UserAPI.h | 258 + src/rm/api/UserPoolAPI.h | 43 + .../VMGroupAPI.cc} | 98 +- src/rm/api/VMGroupAPI.h | 97 + src/rm/api/VMGroupPoolAPI.h | 43 + .../VNTemplateAPI.cc} | 144 +- src/rm/api/VNTemplateAPI.h | 112 + src/rm/api/VNTemplatePoolAPI.h | 44 + src/rm/api/VdcAPI.cc | 364 ++ src/rm/api/VdcAPI.h | 191 + src/rm/api/VdcPoolAPI.h | 43 + .../VirtualMachineAPI.cc} | 5091 +++++++++-------- src/rm/api/VirtualMachineAPI.h | 352 ++ src/rm/api/VirtualMachinePoolAPI.cc | 288 + src/rm/api/VirtualMachinePoolAPI.h | 92 + .../VirtualNetworkAPI.cc} | 636 +- src/rm/api/VirtualNetworkAPI.h | 180 + src/rm/api/VirtualNetworkPoolAPI.h | 44 + .../VirtualRouterAPI.cc} | 313 +- src/rm/api/VirtualRouterAPI.h | 118 + src/rm/api/VirtualRouterPoolAPI.h | 43 + .../{RequestManagerZone.cc => api/ZoneAPI.cc} | 480 +- src/rm/api/ZoneAPI.h | 225 + src/rm/api/ZonePoolAPI.h | 43 + src/rm/grpc/AclServiceGRPC.cc | 95 + src/rm/grpc/AclServiceGRPC.h | 96 + src/rm/grpc/BackupJobServiceGRPC.cc | 435 ++ src/rm/grpc/BackupJobServiceGRPC.h | 357 ++ src/rm/grpc/ClusterServiceGRPC.cc | 374 ++ src/rm/grpc/ClusterServiceGRPC.h | 323 ++ src/rm/grpc/DatastoreServiceGRPC.cc | 246 + src/rm/grpc/DatastoreServiceGRPC.h | 208 + src/rm/grpc/DocumentServiceGRPC.cc | 307 + src/rm/grpc/DocumentServiceGRPC.h | 245 + src/rm/grpc/GroupServiceGRPC.cc | 254 + src/rm/grpc/GroupServiceGRPC.h | 233 + src/rm/grpc/HookServiceGRPC.cc | 262 + src/rm/grpc/HookServiceGRPC.h | 223 + src/rm/grpc/HostServiceGRPC.cc | 238 + src/rm/grpc/HostServiceGRPC.h | 207 + src/rm/grpc/ImageServiceGRPC.cc | 471 ++ src/rm/grpc/ImageServiceGRPC.h | 378 ++ src/rm/grpc/MarketPlaceAppServiceGRPC.cc | 367 ++ src/rm/grpc/MarketPlaceAppServiceGRPC.h | 316 + src/rm/grpc/MarketPlaceServiceGRPC.cc | 294 + src/rm/grpc/MarketPlaceServiceGRPC.h | 255 + src/rm/grpc/RequestAttributesGRPC.h | 132 + src/rm/grpc/RequestGRPC.cc | 383 ++ src/rm/grpc/RequestGRPC.h | 138 + src/rm/grpc/RequestLoggerGRPC.cc | 132 + src/rm/grpc/RequestLoggerGRPC.h | 50 + src/rm/grpc/RequestManagerGRPC.cc | 129 + src/rm/grpc/RequestManagerGRPC.h | 116 + src/rm/grpc/SecurityGroupServiceGRPC.cc | 278 + src/rm/grpc/SecurityGroupServiceGRPC.h | 226 + src/rm/grpc/SystemServiceGRPC.cc | 105 + src/rm/grpc/SystemServiceGRPC.h | 107 + src/rm/grpc/TemplateServiceGRPC.cc | 335 ++ src/rm/grpc/TemplateServiceGRPC.h | 264 + src/rm/grpc/UnknownServiceGRPC.h | 53 + src/rm/grpc/UserServiceGRPC.cc | 386 ++ src/rm/grpc/UserServiceGRPC.h | 340 ++ src/rm/grpc/VMGroupServiceGRPC.cc | 347 ++ src/rm/grpc/VMGroupServiceGRPC.h | 283 + src/rm/grpc/VNTemplateServiceGRPC.cc | 327 ++ src/rm/grpc/VNTemplateServiceGRPC.h | 264 + src/rm/grpc/VdcServiceGRPC.cc | 413 ++ src/rm/grpc/VdcServiceGRPC.h | 365 ++ src/rm/grpc/VirtualMachineServiceGRPC.cc | 1266 ++++ src/rm/grpc/VirtualMachineServiceGRPC.h | 967 ++++ src/rm/grpc/VirtualNetworkServiceGRPC.cc | 468 ++ src/rm/grpc/VirtualNetworkServiceGRPC.h | 378 ++ src/rm/grpc/VirtualRouterServiceGRPC.cc | 351 ++ src/rm/grpc/VirtualRouterServiceGRPC.h | 283 + src/rm/grpc/ZoneServiceGRPC.cc | 416 ++ src/rm/grpc/ZoneServiceGRPC.h | 326 ++ src/rm/grpc/proto/acl.proto | 51 + src/rm/grpc/proto/backupjob.proto | 184 + src/rm/grpc/proto/cluster.proto | 139 + src/rm/grpc/proto/datastore.proto | 113 + src/rm/grpc/proto/document.proto | 135 + src/rm/grpc/proto/group.proto | 104 + src/rm/grpc/proto/hook.proto | 114 + src/rm/grpc/proto/host.proto | 104 + src/rm/grpc/proto/image.proto | 201 + src/rm/grpc/proto/marketplace.proto | 128 + src/rm/grpc/proto/marketplaceapp.proto | 158 + src/rm/grpc/proto/secgroup.proto | 124 + .../rm/grpc/proto/shared.proto | 23 +- src/rm/grpc/proto/system.proto | 56 + src/rm/grpc/proto/template.proto | 149 + src/rm/grpc/proto/user.proto | 155 + src/rm/grpc/proto/vdc.proto | 174 + src/rm/grpc/proto/vm.proto | 501 ++ src/rm/grpc/proto/vmgroup.proto | 152 + src/rm/grpc/proto/vn.proto | 198 + src/rm/grpc/proto/vntemplate.proto | 143 + src/rm/grpc/proto/vrouter.proto | 155 + src/rm/grpc/proto/zone.proto | 182 + .../rm/xml-rpc/AclXRPC.cc | 55 +- .../rm/xml-rpc/AclXRPC.h | 80 +- src/rm/xml-rpc/BackupJobXRPC.cc | 285 + src/rm/xml-rpc/BackupJobXRPC.h | 313 + src/rm/xml-rpc/ClusterXRPC.cc | 226 + src/rm/xml-rpc/ClusterXRPC.h | 293 + src/rm/xml-rpc/DatastoreXRPC.cc | 164 + src/rm/xml-rpc/DatastoreXRPC.h | 177 + src/rm/xml-rpc/DocumentXRPC.cc | 206 + src/rm/xml-rpc/DocumentXRPC.h | 211 + src/rm/xml-rpc/GroupXRPC.cc | 167 + src/rm/xml-rpc/GroupXRPC.h | 194 + src/rm/xml-rpc/HookXRPC.cc | 174 + src/rm/xml-rpc/HookXRPC.h | 194 + src/rm/xml-rpc/HostXRPC.cc | 160 + src/rm/xml-rpc/HostXRPC.h | 177 + src/rm/xml-rpc/ImageXRPC.cc | 306 + src/rm/xml-rpc/ImageXRPC.h | 330 ++ src/rm/xml-rpc/MarketPlaceAppXRPC.cc | 241 + src/rm/xml-rpc/MarketPlaceAppXRPC.h | 262 + src/rm/xml-rpc/MarketPlaceXRPC.cc | 200 + src/rm/xml-rpc/MarketPlaceXRPC.h | 211 + src/rm/xml-rpc/RequestAttributesXRPC.h | 96 + src/rm/xml-rpc/RequestLoggerXRPC.cc | 160 + src/rm/xml-rpc/RequestLoggerXRPC.h | 52 + .../RequestManagerProxyXRPC.cc} | 30 +- .../rm/xml-rpc/RequestManagerProxyXRPC.h | 27 +- .../RequestManagerXRPC.cc} | 1400 +++-- .../rm/xml-rpc/RequestManagerXRPC.h | 103 +- src/rm/xml-rpc/RequestXRPC.cc | 247 + src/rm/xml-rpc/RequestXRPC.h | 87 + src/rm/xml-rpc/SecurityGroupXRPC.cc | 187 + src/rm/xml-rpc/SecurityGroupXRPC.h | 194 + .../rm/xml-rpc/SystemXRPC.cc | 74 +- .../rm/xml-rpc/SystemXRPC.h | 109 +- src/rm/xml-rpc/TemplateXRPC.cc | 223 + src/rm/xml-rpc/TemplateXRPC.h | 228 + src/rm/xml-rpc/UserXRPC.cc | 260 + src/rm/xml-rpc/UserXRPC.h | 279 + src/rm/xml-rpc/VMGroupXRPC.cc | 230 + src/rm/xml-rpc/VMGroupXRPC.h | 245 + src/rm/xml-rpc/VNTemplateXRPC.cc | 217 + src/rm/xml-rpc/VNTemplateXRPC.h | 228 + src/rm/xml-rpc/VdcXRPC.cc | 269 + src/rm/xml-rpc/VdcXRPC.h | 296 + src/rm/xml-rpc/VirtualMachineXRPC.cc | 761 +++ src/rm/xml-rpc/VirtualMachineXRPC.h | 857 +++ src/rm/xml-rpc/VirtualNetworkXRPC.cc | 305 + src/rm/xml-rpc/VirtualNetworkXRPC.h | 330 ++ src/rm/xml-rpc/VirtualRouterXRPC.cc | 234 + src/rm/xml-rpc/VirtualRouterXRPC.h | 245 + src/rm/xml-rpc/ZoneXRPC.cc | 251 + src/rm/xml-rpc/ZoneXRPC.h | 280 + src/sam/ScheduledActionManager.cc | 43 +- src/schedm/PlanManager.cc | 33 +- src/template/OpenNebulaTemplate.cc | 9 +- src/um/UserPool.cc | 84 +- src/vm/BackupJob.cc | 10 +- src/zone/Zone.cc | 5 +- src/zone/ZonePool.cc | 47 +- 493 files changed, 106493 insertions(+), 26561 deletions(-) create mode 100644 include/ClientGRPC.h create mode 100644 include/ClientXRPC.h create mode 100644 include/RequestAttributes.h create mode 100644 include/RequestLogger.h delete mode 100644 include/RequestManagerAcl.h delete mode 100644 include/RequestManagerAllocate.h delete mode 100644 include/RequestManagerAllocateDB.h delete mode 100644 include/RequestManagerBackupJob.h delete mode 100644 include/RequestManagerChmod.h delete mode 100644 include/RequestManagerChown.h delete mode 100644 include/RequestManagerClone.h delete mode 100644 include/RequestManagerCluster.h delete mode 100644 include/RequestManagerConnection.h delete mode 100644 include/RequestManagerDelete.h delete mode 100644 include/RequestManagerDropDB.h delete mode 100644 include/RequestManagerGroup.h delete mode 100644 include/RequestManagerImage.h delete mode 100644 include/RequestManagerInfo.h delete mode 100644 include/RequestManagerLock.h delete mode 100644 include/RequestManagerPoolInfoFilter.h delete mode 100644 include/RequestManagerRename.h delete mode 100644 include/RequestManagerSchedAction.h delete mode 100644 include/RequestManagerSystem.h delete mode 100644 include/RequestManagerUpdateDB.h delete mode 100644 include/RequestManagerUpdateTemplate.h delete mode 100644 include/RequestManagerUser.h delete mode 100644 include/RequestManagerVMGroup.h delete mode 100644 include/RequestManagerVMTemplate.h delete mode 100644 include/RequestManagerVNTemplate.h delete mode 100644 include/RequestManagerVdc.h delete mode 100644 include/RequestManagerVirtualMachine.h delete mode 100644 include/RequestManagerVirtualNetwork.h delete mode 100644 include/RequestManagerVirtualRouter.h delete mode 100644 include/RequestManagerZone.h create mode 100644 src/client/ClientGRPC.cc create mode 100644 src/client/ClientXRPC.cc create mode 100644 src/oca/go/src/goca/acl_test.go create mode 100644 src/oca/go/src/goca/api/acl/acl.pb.go create mode 100644 src/oca/go/src/goca/api/acl/acl_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/backupjob/backupjob.pb.go create mode 100644 src/oca/go/src/goca/api/backupjob/backupjob_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/cluster/cluster.pb.go create mode 100644 src/oca/go/src/goca/api/cluster/cluster_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/datastore/datastore.pb.go create mode 100644 src/oca/go/src/goca/api/datastore/datastore_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/document/document.pb.go create mode 100644 src/oca/go/src/goca/api/document/document_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/group/group.pb.go create mode 100644 src/oca/go/src/goca/api/group/group_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/hook/hook.pb.go create mode 100644 src/oca/go/src/goca/api/hook/hook_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/host/host.pb.go create mode 100644 src/oca/go/src/goca/api/host/host_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/image/image.pb.go create mode 100644 src/oca/go/src/goca/api/image/image_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/marketplace/marketplace.pb.go create mode 100644 src/oca/go/src/goca/api/marketplace/marketplace_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/marketplaceapp/marketplaceapp.pb.go create mode 100644 src/oca/go/src/goca/api/marketplaceapp/marketplaceapp_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/response_id/response_id.pb.go create mode 100644 src/oca/go/src/goca/api/secgroup/secgroup.pb.go create mode 100644 src/oca/go/src/goca/api/secgroup/secgroup_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/shared/shared.pb.go create mode 100644 src/oca/go/src/goca/api/system/system.pb.go create mode 100644 src/oca/go/src/goca/api/system/system_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/template/template.pb.go create mode 100644 src/oca/go/src/goca/api/template/template_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/user/user.pb.go create mode 100644 src/oca/go/src/goca/api/user/user_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/vdc/vdc.pb.go create mode 100644 src/oca/go/src/goca/api/vdc/vdc_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/vm/vm.pb.go create mode 100644 src/oca/go/src/goca/api/vm/vm_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/vmgroup/vmgroup.pb.go create mode 100644 src/oca/go/src/goca/api/vmgroup/vmgroup_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/vn/vn.pb.go create mode 100644 src/oca/go/src/goca/api/vn/vn_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/vntemplate/vntemplate.pb.go create mode 100644 src/oca/go/src/goca/api/vntemplate/vntemplate_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/vrouter/vrouter.pb.go create mode 100644 src/oca/go/src/goca/api/vrouter/vrouter_grpc.pb.go create mode 100644 src/oca/go/src/goca/api/zone/zone.pb.go create mode 100644 src/oca/go/src/goca/api/zone/zone_grpc.pb.go create mode 100644 src/oca/go/src/goca/datastore_test.go create mode 100644 src/oca/go/src/goca/group_test.go create mode 100644 src/oca/go/src/goca/grpc_client.go create mode 100644 src/oca/go/src/goca/host_test.go create mode 100644 src/oca/go/src/goca/system_test.go create mode 100644 src/oca/go/src/goca/user_test.go create mode 100644 src/oca/go/src/goca/vdc_test.go create mode 100644 src/oca/go/src/goca/vntemplate_test.go create mode 100644 src/oca/go/src/goca/zone_test.go create mode 100644 src/oca/ruby/opennebula/grpc/Makefile create mode 100644 src/oca/ruby/opennebula/grpc/lib/acl_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/backupjob_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/cluster_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/datastore_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/document_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/group_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/grpc_map_loader.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/hook_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/host_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/image_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/marketplace_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/marketplaceapp_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/securitygroup_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/system_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/template_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/user_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/vdc_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/virtualmachine_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/virtualnetwork_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/virtualrouter_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/vmgroup_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/vntemplate_map.rb create mode 100644 src/oca/ruby/opennebula/grpc/lib/zone_map.rb create mode 100644 src/oca/ruby/opennebula/lib/client.rb create mode 100644 src/oca/ruby/opennebula/lib/grpc_client.rb rename src/oca/ruby/opennebula/{client.rb => lib/xml_client.rb} (56%) create mode 100644 src/oca/ruby/opennebula/version.rb create mode 100644 src/rm/RequestLogger.cc delete mode 100644 src/rm/RequestManagerAllocate.cc delete mode 100644 src/rm/RequestManagerBackupJob.cc delete mode 100644 src/rm/RequestManagerChmod.cc delete mode 100644 src/rm/RequestManagerChown.cc delete mode 100644 src/rm/RequestManagerClone.cc delete mode 100644 src/rm/RequestManagerCluster.cc delete mode 100644 src/rm/RequestManagerDelete.cc delete mode 100644 src/rm/RequestManagerGroup.cc delete mode 100644 src/rm/RequestManagerImage.cc delete mode 100644 src/rm/RequestManagerInfo.cc delete mode 100644 src/rm/RequestManagerLock.cc delete mode 100644 src/rm/RequestManagerMarketPlace.cc delete mode 100644 src/rm/RequestManagerMarketPlaceApp.cc delete mode 100644 src/rm/RequestManagerPoolInfoFilter.cc delete mode 100644 src/rm/RequestManagerRename.cc delete mode 100644 src/rm/RequestManagerSchedAction.cc delete mode 100644 src/rm/RequestManagerSystem.cc delete mode 100644 src/rm/RequestManagerUpdateTemplate.cc delete mode 100644 src/rm/RequestManagerUser.cc delete mode 100644 src/rm/RequestManagerVMTemplate.cc delete mode 100644 src/rm/RequestManagerVdc.cc rename src/rm/{RequestManagerAcl.cc => api/AclAPI.cc} (52%) create mode 100644 src/rm/api/AclAPI.h create mode 100644 src/rm/api/BackupJobAPI.cc create mode 100644 src/rm/api/BackupJobAPI.h rename include/RequestManagerMarketPlace.h => src/rm/api/BackupJobPoolAPI.h (73%) create mode 100644 src/rm/api/ClusterAPI.cc create mode 100644 src/rm/api/ClusterAPI.h create mode 100644 src/rm/api/ClusterPoolAPI.cc create mode 100644 src/rm/api/ClusterPoolAPI.h create mode 100644 src/rm/api/DatastoreAPI.cc create mode 100644 src/rm/api/DatastoreAPI.h create mode 100644 src/rm/api/DatastorePoolAPI.h create mode 100644 src/rm/api/DocumentAPI.cc create mode 100644 src/rm/api/DocumentAPI.h create mode 100644 src/rm/api/DocumentPoolAPI.h create mode 100644 src/rm/api/GroupAPI.cc create mode 100644 src/rm/api/GroupAPI.h create mode 100644 src/rm/api/GroupPoolAPI.h create mode 100644 src/rm/api/HookPoolAPI.cc create mode 100644 src/rm/api/HookPoolAPI.h create mode 100644 src/rm/api/HostAPI.cc create mode 100644 src/rm/api/HostAPI.h create mode 100644 src/rm/api/HostPoolAPI.cc rename src/rm/{RequestManagerDatastore.cc => api/HostPoolAPI.h} (64%) create mode 100644 src/rm/api/ImageAPI.cc create mode 100644 src/rm/api/ImageAPI.h create mode 100644 src/rm/api/ImagePoolAPI.h create mode 100644 src/rm/api/MarketPlaceAPI.cc create mode 100644 src/rm/api/MarketPlaceAPI.h create mode 100644 src/rm/api/MarketPlaceAppAPI.cc create mode 100644 src/rm/api/MarketPlaceAppAPI.h create mode 100644 src/rm/api/MarketPlaceAppPoolAPI.h create mode 100644 src/rm/api/MarketPlacePoolAPI.h create mode 100644 src/rm/api/PoolSharedAPI.cc create mode 100644 src/rm/api/PoolSharedAPI.h rename src/rm/{RequestManagerHook.cc => api/RMHookAPI.cc} (66%) create mode 100644 src/rm/api/RMHookAPI.h rename src/rm/{RequestManagerSecurityGroup.cc => api/SecurityGroupAPI.cc} (50%) create mode 100644 src/rm/api/SecurityGroupAPI.h create mode 100644 src/rm/api/SecurityGroupPoolAPI.h create mode 100644 src/rm/api/SharedAPI.cc create mode 100644 src/rm/api/SharedAPI.h create mode 100644 src/rm/api/SystemAPI.cc rename src/rm/{RequestManagerHost.cc => api/SystemAPI.h} (53%) create mode 100644 src/rm/api/TemplateAPI.cc create mode 100644 src/rm/api/TemplateAPI.h create mode 100644 src/rm/api/TemplatePoolAPI.h create mode 100644 src/rm/api/UserAPI.cc create mode 100644 src/rm/api/UserAPI.h create mode 100644 src/rm/api/UserPoolAPI.h rename src/rm/{RequestManagerVMGroup.cc => api/VMGroupAPI.cc} (55%) create mode 100644 src/rm/api/VMGroupAPI.h create mode 100644 src/rm/api/VMGroupPoolAPI.h rename src/rm/{RequestManagerVNTemplate.cc => api/VNTemplateAPI.cc} (57%) create mode 100644 src/rm/api/VNTemplateAPI.h create mode 100644 src/rm/api/VNTemplatePoolAPI.h create mode 100644 src/rm/api/VdcAPI.cc create mode 100644 src/rm/api/VdcAPI.h create mode 100644 src/rm/api/VdcPoolAPI.h rename src/rm/{RequestManagerVirtualMachine.cc => api/VirtualMachineAPI.cc} (62%) create mode 100644 src/rm/api/VirtualMachineAPI.h create mode 100644 src/rm/api/VirtualMachinePoolAPI.cc create mode 100644 src/rm/api/VirtualMachinePoolAPI.h rename src/rm/{RequestManagerVirtualNetwork.cc => api/VirtualNetworkAPI.cc} (50%) create mode 100644 src/rm/api/VirtualNetworkAPI.h create mode 100644 src/rm/api/VirtualNetworkPoolAPI.h rename src/rm/{RequestManagerVirtualRouter.cc => api/VirtualRouterAPI.cc} (50%) create mode 100644 src/rm/api/VirtualRouterAPI.h create mode 100644 src/rm/api/VirtualRouterPoolAPI.h rename src/rm/{RequestManagerZone.cc => api/ZoneAPI.cc} (60%) create mode 100644 src/rm/api/ZoneAPI.h create mode 100644 src/rm/api/ZonePoolAPI.h create mode 100644 src/rm/grpc/AclServiceGRPC.cc create mode 100644 src/rm/grpc/AclServiceGRPC.h create mode 100644 src/rm/grpc/BackupJobServiceGRPC.cc create mode 100644 src/rm/grpc/BackupJobServiceGRPC.h create mode 100644 src/rm/grpc/ClusterServiceGRPC.cc create mode 100644 src/rm/grpc/ClusterServiceGRPC.h create mode 100644 src/rm/grpc/DatastoreServiceGRPC.cc create mode 100644 src/rm/grpc/DatastoreServiceGRPC.h create mode 100644 src/rm/grpc/DocumentServiceGRPC.cc create mode 100644 src/rm/grpc/DocumentServiceGRPC.h create mode 100644 src/rm/grpc/GroupServiceGRPC.cc create mode 100644 src/rm/grpc/GroupServiceGRPC.h create mode 100644 src/rm/grpc/HookServiceGRPC.cc create mode 100644 src/rm/grpc/HookServiceGRPC.h create mode 100644 src/rm/grpc/HostServiceGRPC.cc create mode 100644 src/rm/grpc/HostServiceGRPC.h create mode 100644 src/rm/grpc/ImageServiceGRPC.cc create mode 100644 src/rm/grpc/ImageServiceGRPC.h create mode 100644 src/rm/grpc/MarketPlaceAppServiceGRPC.cc create mode 100644 src/rm/grpc/MarketPlaceAppServiceGRPC.h create mode 100644 src/rm/grpc/MarketPlaceServiceGRPC.cc create mode 100644 src/rm/grpc/MarketPlaceServiceGRPC.h create mode 100644 src/rm/grpc/RequestAttributesGRPC.h create mode 100644 src/rm/grpc/RequestGRPC.cc create mode 100644 src/rm/grpc/RequestGRPC.h create mode 100644 src/rm/grpc/RequestLoggerGRPC.cc create mode 100644 src/rm/grpc/RequestLoggerGRPC.h create mode 100644 src/rm/grpc/RequestManagerGRPC.cc create mode 100644 src/rm/grpc/RequestManagerGRPC.h create mode 100644 src/rm/grpc/SecurityGroupServiceGRPC.cc create mode 100644 src/rm/grpc/SecurityGroupServiceGRPC.h create mode 100644 src/rm/grpc/SystemServiceGRPC.cc create mode 100644 src/rm/grpc/SystemServiceGRPC.h create mode 100644 src/rm/grpc/TemplateServiceGRPC.cc create mode 100644 src/rm/grpc/TemplateServiceGRPC.h create mode 100644 src/rm/grpc/UnknownServiceGRPC.h create mode 100644 src/rm/grpc/UserServiceGRPC.cc create mode 100644 src/rm/grpc/UserServiceGRPC.h create mode 100644 src/rm/grpc/VMGroupServiceGRPC.cc create mode 100644 src/rm/grpc/VMGroupServiceGRPC.h create mode 100644 src/rm/grpc/VNTemplateServiceGRPC.cc create mode 100644 src/rm/grpc/VNTemplateServiceGRPC.h create mode 100644 src/rm/grpc/VdcServiceGRPC.cc create mode 100644 src/rm/grpc/VdcServiceGRPC.h create mode 100644 src/rm/grpc/VirtualMachineServiceGRPC.cc create mode 100644 src/rm/grpc/VirtualMachineServiceGRPC.h create mode 100644 src/rm/grpc/VirtualNetworkServiceGRPC.cc create mode 100644 src/rm/grpc/VirtualNetworkServiceGRPC.h create mode 100644 src/rm/grpc/VirtualRouterServiceGRPC.cc create mode 100644 src/rm/grpc/VirtualRouterServiceGRPC.h create mode 100644 src/rm/grpc/ZoneServiceGRPC.cc create mode 100644 src/rm/grpc/ZoneServiceGRPC.h create mode 100644 src/rm/grpc/proto/acl.proto create mode 100644 src/rm/grpc/proto/backupjob.proto create mode 100644 src/rm/grpc/proto/cluster.proto create mode 100644 src/rm/grpc/proto/datastore.proto create mode 100644 src/rm/grpc/proto/document.proto create mode 100644 src/rm/grpc/proto/group.proto create mode 100644 src/rm/grpc/proto/hook.proto create mode 100644 src/rm/grpc/proto/host.proto create mode 100644 src/rm/grpc/proto/image.proto create mode 100644 src/rm/grpc/proto/marketplace.proto create mode 100644 src/rm/grpc/proto/marketplaceapp.proto create mode 100644 src/rm/grpc/proto/secgroup.proto rename include/RequestManagerSecurityGroup.h => src/rm/grpc/proto/shared.proto (79%) create mode 100644 src/rm/grpc/proto/system.proto create mode 100644 src/rm/grpc/proto/template.proto create mode 100644 src/rm/grpc/proto/user.proto create mode 100644 src/rm/grpc/proto/vdc.proto create mode 100644 src/rm/grpc/proto/vm.proto create mode 100644 src/rm/grpc/proto/vmgroup.proto create mode 100644 src/rm/grpc/proto/vn.proto create mode 100644 src/rm/grpc/proto/vntemplate.proto create mode 100644 src/rm/grpc/proto/vrouter.proto create mode 100644 src/rm/grpc/proto/zone.proto rename include/RequestManagerMarketPlaceApp.h => src/rm/xml-rpc/AclXRPC.cc (62%) rename include/RequestManagerDatastore.h => src/rm/xml-rpc/AclXRPC.h (62%) create mode 100644 src/rm/xml-rpc/BackupJobXRPC.cc create mode 100644 src/rm/xml-rpc/BackupJobXRPC.h create mode 100644 src/rm/xml-rpc/ClusterXRPC.cc create mode 100644 src/rm/xml-rpc/ClusterXRPC.h create mode 100644 src/rm/xml-rpc/DatastoreXRPC.cc create mode 100644 src/rm/xml-rpc/DatastoreXRPC.h create mode 100644 src/rm/xml-rpc/DocumentXRPC.cc create mode 100644 src/rm/xml-rpc/DocumentXRPC.h create mode 100644 src/rm/xml-rpc/GroupXRPC.cc create mode 100644 src/rm/xml-rpc/GroupXRPC.h create mode 100644 src/rm/xml-rpc/HookXRPC.cc create mode 100644 src/rm/xml-rpc/HookXRPC.h create mode 100644 src/rm/xml-rpc/HostXRPC.cc create mode 100644 src/rm/xml-rpc/HostXRPC.h create mode 100644 src/rm/xml-rpc/ImageXRPC.cc create mode 100644 src/rm/xml-rpc/ImageXRPC.h create mode 100644 src/rm/xml-rpc/MarketPlaceAppXRPC.cc create mode 100644 src/rm/xml-rpc/MarketPlaceAppXRPC.h create mode 100644 src/rm/xml-rpc/MarketPlaceXRPC.cc create mode 100644 src/rm/xml-rpc/MarketPlaceXRPC.h create mode 100644 src/rm/xml-rpc/RequestAttributesXRPC.h create mode 100644 src/rm/xml-rpc/RequestLoggerXRPC.cc create mode 100644 src/rm/xml-rpc/RequestLoggerXRPC.h rename src/rm/{RequestManagerProxy.cc => xml-rpc/RequestManagerProxyXRPC.cc} (70%) rename include/RequestManagerProxy.h => src/rm/xml-rpc/RequestManagerProxyXRPC.h (76%) rename src/rm/{RequestManager.cc => xml-rpc/RequestManagerXRPC.cc} (63%) rename include/RequestManager.h => src/rm/xml-rpc/RequestManagerXRPC.h (71%) create mode 100644 src/rm/xml-rpc/RequestXRPC.cc create mode 100644 src/rm/xml-rpc/RequestXRPC.h create mode 100644 src/rm/xml-rpc/SecurityGroupXRPC.cc create mode 100644 src/rm/xml-rpc/SecurityGroupXRPC.h rename include/RequestManagerHook.h => src/rm/xml-rpc/SystemXRPC.cc (60%) rename include/RequestManagerHost.h => src/rm/xml-rpc/SystemXRPC.h (55%) create mode 100644 src/rm/xml-rpc/TemplateXRPC.cc create mode 100644 src/rm/xml-rpc/TemplateXRPC.h create mode 100644 src/rm/xml-rpc/UserXRPC.cc create mode 100644 src/rm/xml-rpc/UserXRPC.h create mode 100644 src/rm/xml-rpc/VMGroupXRPC.cc create mode 100644 src/rm/xml-rpc/VMGroupXRPC.h create mode 100644 src/rm/xml-rpc/VNTemplateXRPC.cc create mode 100644 src/rm/xml-rpc/VNTemplateXRPC.h create mode 100644 src/rm/xml-rpc/VdcXRPC.cc create mode 100644 src/rm/xml-rpc/VdcXRPC.h create mode 100644 src/rm/xml-rpc/VirtualMachineXRPC.cc create mode 100644 src/rm/xml-rpc/VirtualMachineXRPC.h create mode 100644 src/rm/xml-rpc/VirtualNetworkXRPC.cc create mode 100644 src/rm/xml-rpc/VirtualNetworkXRPC.h create mode 100644 src/rm/xml-rpc/VirtualRouterXRPC.cc create mode 100644 src/rm/xml-rpc/VirtualRouterXRPC.h create mode 100644 src/rm/xml-rpc/ZoneXRPC.cc create mode 100644 src/rm/xml-rpc/ZoneXRPC.h diff --git a/.gitignore b/.gitignore index 75d890543e..c0f9167aa1 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,11 @@ share/context/* !share/context/download_context.sh !share/context/SConstruct +# grpc generated +src/rm/grpc/src/ +src/oca/ruby/opennebula/grpc/*_pb.rb +src/oca/ruby/opennebula/grpc/.proto_built + # editors temporary/swap files *.swp *.swo @@ -67,7 +72,7 @@ share/context/* # backups *.*- -# vendor +# vendor src/datastore_mad/remotes/restic/vendor/bin/ src/oneprometheus/vendor/alertmanager.arm64/ src/oneprometheus/vendor/alertmanager/ diff --git a/SConstruct b/SConstruct index 8bf8d8d42d..56577e6d46 100755 --- a/SConstruct +++ b/SConstruct @@ -66,6 +66,8 @@ add_bison(main_env) # Include dirs main_env.Append(CPPPATH=[ cwd+'/include', + cwd+'/src/rm/xml-rpc', + cwd+'/src/rm/api', cwd+'/src/monitor/include', cwd+'/src/parsers' ]) @@ -171,6 +173,45 @@ if mysql == 'yes': else: main_env.Append(mysql='no') +# grpc +grpc = ARGUMENTS.get('grpc', 'yes') + +if grpc == 'yes': + main_env.Append(grpc='yes') + + main_env.Append(CPPFLAGS=["-DGRPC", "-DGRPC_CALLBACK_API_NONEXPERIMENTAL"]) + + main_env.Append(CPPPATH=[ + cwd+'/src/rm/grpc', + cwd+'/src/rm/grpc/src', + ]) + + main_env.Append(LIBS=[ + 'grpc++', + 'grpc++_reflection', + 'grpc', + 'gpr', + 'absl_synchronization', + 'absl_cord', + # 'absl_cordz_info', + # 'absl_cordz_functions', + # 'absl_log_internal_check_op', + # 'absl_log_internal_message', + 'absl_spinlock_wait', + 'absl_raw_logging_internal', + 'protobuf' + ]) +else: + main_env.Append(grpc='no') + +# grpc +grpcproto = ARGUMENTS.get('grpcproto', 'no') + +if grpcproto == 'yes': + main_env.Append(proto='yes') +else: + main_env.Append(proto='no') + # systemd systemd = ARGUMENTS.get('systemd', 'no') if systemd == 'yes': diff --git a/include/Client.h b/include/Client.h index de0b4b6f56..f63bcb59f4 100644 --- a/include/Client.h +++ b/include/Client.h @@ -17,51 +17,55 @@ #ifndef ONE_CLIENT_H_ #define ONE_CLIENT_H_ -#include -#include -#include - #include +#include +#include -// ============================================================================= -// Doc: -// http://xmlrpc-c.sourceforge.net/doc/#clientexamplepp -// http://xmlrpc-c.sourceforge.net/doc/libxmlrpc_client++.html#simple_client -// ============================================================================= +class ClientXRPC; +class ClientGRPC; /** * This class represents the connection with the core and handles the - * xml-rpc calls. + * rpc calls. */ class Client { public: + struct replicate_params + { + int leader_id; + uint32_t leader_term; + uint64_t leader_commit; + uint64_t index; + uint64_t prev_index; + uint32_t term; + uint32_t prev_term; + uint64_t fed_index; + }; + /** * Singleton accessor */ - static Client * client() + static Client * client(); + + static ClientXRPC * client_xmlrpc() { - return _client; - }; + return _client_xmlrpc; + } + + static ClientGRPC * client_grpc() + { + return _client_grpc; + } /** * Singleton initializer */ - static Client * initialize(const std::string& secret, - const std::string& endpoint, size_t message_size, unsigned int tout) - { - if ( _client == 0 ) - { - _client = new Client(secret, endpoint, message_size, tout); - } - - return _client; - }; - - size_t get_message_size() const - { - return xmlrpc_limit_get(XMLRPC_XML_SIZE_LIMIT_ID); - }; + static void initialize(const std::string& secret, + const std::string& endpoint_xmlrpc, + const std::string& endpoint_grpc, + size_t message_size, + unsigned int tout); /** * Reads ONE_AUTH from environment or its default location at @@ -69,64 +73,62 @@ public: */ static int read_oneauth(std::string &secret, std::string& error); - /** - * Performs a xmlrpc call to the initialized server - * @param method name - * @param plist initialized param list - * @param result of the xmlrpc call - */ - void call(const std::string& method, const xmlrpc_c::paramList& plist, - xmlrpc_c::value * const result); + static bool is_grpc(const std::string& endpoint) + { + return endpoint.find("RPC2") == std::string::npos; + } - /** - * Performs a xmlrpc call - * @param endpoint of server - * @param method name - * @param plist initialized param list - * @param timeout (ms) for the request, set 0 for global xml_rpc timeout - * @param result of the xmlrpc call - * @param error string if any - * @return 0 - */ - static int call(const std::string& endpoint, const std::string& method, - const xmlrpc_c::paramList& plist, unsigned int _timeout, - xmlrpc_c::value * const result, std::string& error); + virtual int market_allocate(const std::string& xml, std::string& error) = 0; + virtual int market_update(int oid, const std::string& xml) = 0; - /** - * Performs an xmlrpc call to the initialized server and credentials. - * This method automatically adds the credential argument. - * @param method name - * @param format of the arguments, supported arguments are i:int, s:string - * and b:bool - * @param result to store the xmlrpc call result - * @param ... xmlrpc arguments - */ - void call(const std::string &method, const std::string &format, - xmlrpc_c::value * const result, ...); + virtual int market_app_allocate(const std::string& xml, std::string& error) = 0; + virtual int market_app_drop(int oid, std::string& error) = 0; + virtual int market_app_update(int oid, const std::string& xml) = 0; - void refresh_authentication(); + virtual int user_allocate(const std::string& uname, + const std::string& passwd, + const std::string& driver, + const std::set& gids, + std::string& error_str) = 0; + virtual int user_chgrp(int user_id, int group_id, std::string& error_str) = 0; -private: - /** - * Creates a new xml-rpc client with specified options. - * - * @param secret A string containing the ONE user:password tuple. - * If not set, the auth. file will be assumed to be at $ONE_AUTH - * @param endpoint Where the rpc server is listening, must be something - * like "http://localhost:2633/RPC2". If not set, the endpoint will be set - * to $ONE_XMLRPC. - * @param message_size for XML elements in the client library (in bytes) - * @throws Exception if the authorization options are invalid - */ - Client(const std::string& secret, const std::string& endpoint, size_t message_size, - unsigned int tout); + virtual int master_update_zone(int oid, const std::string& xml, std::string& error_str) = 0; - std::string one_auth; - std::string one_endpoint; + static int fed_replicate(const std::string& endpoint, + uint64_t index, + uint64_t prev_index, + const std::string& sql, + time_t timeout_ms, + bool& success, + uint64_t& last, + std::string& error_msg); - unsigned int timeout; + static int replicate(const std::string& endpoint, + const replicate_params& params, + const std::string& sql, + time_t timeout_ms, + bool& success, + uint32_t& follower_term, + std::string& error_msg); - static Client * _client; + static int vote_request(const std::string& endpoint, + uint32_t term, + int candidate_id, + uint32_t log_index, + uint32_t log_term, + time_t timeout_ms, + bool& success, + uint32_t& follower_term, + std::string& error_msg); + +protected: + std::string one_auth; + std::string one_endpoint; + + unsigned int timeout = 10000; // Timout for rpc calls + + static ClientXRPC * _client_xmlrpc; + static ClientGRPC * _client_grpc; }; #endif /*ONECLIENT_H_*/ diff --git a/include/ClientGRPC.h b/include/ClientGRPC.h new file mode 100644 index 0000000000..838d369a00 --- /dev/null +++ b/include/ClientGRPC.h @@ -0,0 +1,95 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2025, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +#ifndef ONE_CLIENT_GRPC_H_ +#define ONE_CLIENT_GRPC_H_ + +#include "Client.h" + +#include +#include + +/** + * This class handles gRPC calls. + */ +class ClientGRPC : public Client +{ +public: + /** + * Creates a new xml-rpc client with specified options. + * + * @param secret A string containing the ONE user:password tuple. + * If not set, the auth. file will be assumed to be at $ONE_AUTH + * @param endpoint Where the rpc server is listening, must be something + * like "http://localhost:2633/RPC2". If not set, the endpoint will be set + * to $ONE_XMLRPC. + * @throws Exception if the authorization options are invalid + */ + ClientGRPC(const std::string& secret, + const std::string& endpoint, + unsigned int tout); + + int market_allocate(const std::string& xml, std::string& error) override; + int market_update(int oid, const std::string& xml) override; + + int market_app_allocate(const std::string& xml, std::string& error) override; + int market_app_drop(int oid, std::string& error) override; + int market_app_update(int oid, const std::string& xml) override; + + int user_allocate(const std::string& uname, + const std::string& passwd, + const std::string& driver, + const std::set& gids, + std::string& error_str) override; + int user_chgrp(int user_id, int group_id, std::string& error_str) override; + + int master_update_zone(int oid, const std::string& xml, std::string& error_str) override; + + static int fed_replicate(const std::string& endpoint, + const std::string& secret, + uint64_t index, + uint64_t prev_index, + const std::string& sql, + time_t timeout_ms, + bool& success, + uint64_t& last, + std::string& error_msg); + + static int replicate(const std::string& endpoint, + const std::string& secret, + const replicate_params& params, + const std::string& sql, + time_t timeout_ms, + bool& success, + uint32_t& follower_term, + std::string& error_msg); + + static int vote_request(const std::string& endpoint, + const std::string& secret, + uint32_t term, + int candidate_id, + uint32_t log_index, + uint32_t log_term, + time_t timeout_ms, + bool& success, + uint32_t& follower_term, + std::string& error_msg); + +private: + std::shared_ptr channel; +}; + +#endif diff --git a/include/ClientXRPC.h b/include/ClientXRPC.h new file mode 100644 index 0000000000..08a9da908d --- /dev/null +++ b/include/ClientXRPC.h @@ -0,0 +1,146 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2025, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +#ifndef ONE_CLIENT_XRPC_H_ +#define ONE_CLIENT_XRPC_H_ + +#include "Client.h" + +#include +#include +#include + +#include + +// ============================================================================= +// Doc: +// http://xmlrpc-c.sourceforge.net/doc/#clientexamplepp +// http://xmlrpc-c.sourceforge.net/doc/libxmlrpc_client++.html#simple_client +// ============================================================================= + +/** + * This class handles xml-rpc calls. + */ +class ClientXRPC : public Client +{ +public: + /** + * Creates a new xml-rpc client with specified options. + * + * @param secret A string containing the ONE user:password tuple. + * If not set, the auth. file will be assumed to be at $ONE_AUTH + * @param endpoint Where the rpc server is listening, must be something + * like "http://localhost:2633/RPC2". If not set, the endpoint will be set + * to $ONE_XMLRPC. + * @param message_size for XML elements in the client library (in bytes) + * @throws Exception if the authorization options are invalid + */ + ClientXRPC(const std::string& secret, + const std::string& endpoint, + size_t message_size, + unsigned int tout); + + int market_allocate(const std::string& xml, std::string& error) override; + int market_update(int oid, const std::string& xml) override; + + int market_app_allocate(const std::string& xml, std::string& error) override; + int market_app_drop(int oid, std::string& error) override; + int market_app_update(int oid, const std::string& xml) override; + + int user_allocate(const std::string& uname, + const std::string& passwd, + const std::string& driver, + const std::set& gids, + std::string& error_str) override; + int user_chgrp(int user_id, int group_id, std::string& error_str) override; + + int master_update_zone(int oid, const std::string& xml, std::string& error_str) override; + + static int fed_replicate(const std::string& endpoint, + const std::string& secret, + uint64_t index, + uint64_t prev_index, + const std::string& sql, + time_t timeout_ms, + bool& success, + uint64_t& last, + std::string& error_msg); + + static int replicate(const std::string& endpoint, + const std::string& secret, + const replicate_params& params, + const std::string& sql, + time_t timeout_ms, + bool& success, + uint32_t& follower_term, + std::string& error_msg); + + static int vote_request(const std::string& endpoint, + const std::string& secret, + uint32_t term, + int candidate_id, + uint32_t log_index, + uint32_t log_term, + time_t timeout_ms, + bool& success, + uint32_t& follower_term, + std::string& error_msg); + + /** + * Performs a xmlrpc call to the initialized server + * @param method name + * @param plist initialized param list + * @param result of the xmlrpc call + */ + void call(const std::string& method, + const xmlrpc_c::paramList& plist, + xmlrpc_c::value * const result); + + /** + * Performs a xmlrpc call + * @param endpoint of server + * @param method name + * @param plist initialized param list + * @param timeout (ms) for the request, set 0 for global xml_rpc timeout + * @param result of the xmlrpc call + * @param error string if any + * @return 0 + */ + static int call(const std::string& endpoint, + const std::string& method, + const xmlrpc_c::paramList& plist, + unsigned int _timeout, + xmlrpc_c::value * const result, + std::string& error); + + /** + * Performs an xmlrpc call to the initialized server and credentials. + * This method automatically adds the credential argument. + * @param method name + * @param format of the arguments, supported arguments are i:int, s:string + * and b:bool + * @param result to store the xmlrpc call result + * @param ... xmlrpc arguments + */ + void call(const std::string &method, + const std::string &format, + xmlrpc_c::value * const result, + ...); + +private: +}; + +#endif diff --git a/include/DispatchManager.h b/include/DispatchManager.h index 607876c0e4..fe64dc2560 100644 --- a/include/DispatchManager.h +++ b/include/DispatchManager.h @@ -35,7 +35,7 @@ class SecurityGroupPool; class VirtualMachine; class VirtualMachineTemplate; -struct RequestAttributes; +class RequestAttributes; class DispatchManager : public Listener diff --git a/include/FedReplicaManager.h b/include/FedReplicaManager.h index 43443dcc1f..85e775a4a7 100644 --- a/include/FedReplicaManager.h +++ b/include/FedReplicaManager.h @@ -72,15 +72,14 @@ public: void replicate_failure(int zone_id, uint64_t zone_last); /** - * XML-RPC API call to replicate a log entry on slaves + * RPC API call to replicate a log entry on slaves * @param zone_id * @param success status of API call * @param last index replicate in zone slave * @param error description if any - * @return 0 on success -1 if a xml-rpc/network error occurred + * @return 0 on success -1 if a rpc/network error occurred */ - int xmlrpc_replicate_log(int zone_id, bool& success, uint64_t& last, - std::string& err); + int rpc_replicate_log(int zone_id, bool& success, uint64_t& last, std::string& err); /** * Start the replication threads, and updates the server list of the zone @@ -129,12 +128,12 @@ private: // ------------------------------------------------------------------------- // Synchronization variables - // - xmlrpc_timeout. To timeout xml-rpc api calls to replicate log + // - rpc_timeout_ms. To timeout api calls to replicate log // - zones list of zones in the federation with: - // - list of servers + // - list of servers // - next index to send to this zone // ------------------------------------------------------------------------- - static const time_t xmlrpc_timeout_ms; + static const time_t rpc_timeout_ms; struct ZoneServers { @@ -145,7 +144,7 @@ private: int zone_id; - std::string endpoint; + std::string endpoint; uint64_t next; diff --git a/include/HookAPI.h b/include/HookAPI.h index e4e855612d..c5d78b1884 100644 --- a/include/HookAPI.h +++ b/include/HookAPI.h @@ -97,8 +97,6 @@ private: * String representation of the API call */ std::string call; - - const static std::string unsupported_calls[]; }; #endif diff --git a/include/LifeCycleManager.h b/include/LifeCycleManager.h index 3e77ce87e1..eea655d58c 100644 --- a/include/LifeCycleManager.h +++ b/include/LifeCycleManager.h @@ -34,7 +34,7 @@ class SecurityGroupPool; class VirtualMachinePool; class VirtualMachine; class VirtualNetworkPool; -struct RequestAttributes; +class RequestAttributes; /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/include/Nebula.h b/include/Nebula.h index 61e6aa436d..93cd7b6306 100644 --- a/include/Nebula.h +++ b/include/Nebula.h @@ -64,7 +64,10 @@ class LifeCycleManager; class MarketPlaceManager; class PlanManager; class RaftManager; -class RequestManager; +class RequestManagerXRPC; +#ifdef GRPC +class RequestManagerGRPC; +#endif class ScheduledActionManager; class TransferManager; class VirtualMachineManager; @@ -276,11 +279,18 @@ public: return frm; }; - RequestManager * get_rm() const + RequestManagerXRPC * get_rm_xrpc() const { - return rm; + return rm_xrpc; }; +#ifdef GRPC + RequestManagerGRPC * get_rm_grpc() const + { + return rm_grpc; + }; +#endif + ScheduledActionManager * get_sam() const { return sam; @@ -373,10 +383,15 @@ public: return server_id; }; - const std::string& get_master_oned() const + const std::string& get_master_oned_xmlrpc() const { - return master_oned; - }; + return master_oned_xmlrpc; + } + + const std::string& get_master_oned_grpc() const + { + return master_oned_grpc; + } void set_zone_state(Zone::ZoneState state) { @@ -655,9 +670,12 @@ public: , dspool(0), clpool(0), docpool(0), zonepool(0), secgrouppool(0) , vdcpool(0), vrouterpool(0), marketpool(0), apppool(0), vmgrouppool(0) , vntpool(0), hkpool(0), bjpool(0), sapool(0), plpool(0) - , lcm(0), vmm(0), im(0), tm(0), dm(0), rm(0), hm(0) - , hl(0), authm(0), aclm(0), imagem(0), marketm(0), ipamm(0), raftm(0), frm(0) - , sam(0), sm(0), planm(0) + , lcm(0), vmm(0), im(0), tm(0), dm(0), rm_xrpc(0) +#ifdef GRPC + , rm_grpc(0) +#endif + , hm(0), hl(0), authm(0), aclm(0), imagem(0), marketm(0), ipamm(0) + , raftm(0), frm(0), sam(0), sm(0), planm(0) { }; @@ -687,7 +705,8 @@ private: bool cache; int zone_id; int server_id; - std::string master_oned; + std::string master_oned_xmlrpc; + std::string master_oned_grpc; Zone::ZoneState zone_state = Zone::ENABLED; // --------------------------------------------------------------- @@ -742,7 +761,10 @@ private: InformationManager * im; TransferManager * tm; DispatchManager * dm; - RequestManager * rm; + RequestManagerXRPC * rm_xrpc; +#ifdef GRPC + RequestManagerGRPC * rm_grpc; +#endif HookManager * hm; HookLog * hl; AuthManager * authm; diff --git a/include/PoolSQL.h b/include/PoolSQL.h index be18689715..b3c6fa6d9d 100644 --- a/include/PoolSQL.h +++ b/include/PoolSQL.h @@ -45,6 +45,17 @@ public: virtual ~PoolSQL() = default; + + /** + * Filter modes for pools. Constants are defined to match API defintion + */ + enum PoolFilter { + ALL = -2, + MINE = -3, + MINE_GROUP = -1, + GROUP = -4, + }; + /** * Allocates a new object, writting it in the pool database. No memory is * allocated for the object. diff --git a/include/RaftManager.h b/include/RaftManager.h index 9b0963dcab..c347c20e8a 100644 --- a/include/RaftManager.h +++ b/include/RaftManager.h @@ -50,11 +50,11 @@ public: * @param log_purge period to purge logDB records * @param bcast heartbeat broadcast timeout * @param election timeout - * @param xmlrpc timeout for RAFT related xmlrpc API calls + * @param rpc_timeout timeout for RAFT related rpc API calls **/ RaftManager(int server_id, const VectorAttribute * leader_hook_mad, const VectorAttribute * follower_hook_mad, time_t log_purge, - long long bcast, long long election, time_t xmlrpc, + long long bcast, long long election, time_t rpc_timeout, const std::string& remotes_location); ~RaftManager() = default; @@ -236,40 +236,40 @@ public: } /** - * Gets the endpoint for xml-rpc calls of the current leader + * Gets the endpoint for rpc calls of the current leader * @param endpoint * @return 0 on success, -1 if no leader found */ - int get_leader_endpoint(std::string& endpoint); + int get_leader_endpoint(std::string& endpoint, bool grpc = true); // ------------------------------------------------------------------------- - // XML-RPC Raft API calls + // RPC Raft API calls // ------------------------------------------------------------------------- /** - * Calls the follower xml-rpc method + * Calls the follower rpc method * @param follower_id to make the call * @param lr the record to replicate - * @param success of the xml-rpc method + * @param success of the rpc method * @param ft term in the follower as returned by the replicate call * @param error describing error if any - * @return -1 if a XMl-RPC (network) error occurs, 0 otherwise + * @return -1 if a RPC (network) error occurs, 0 otherwise */ - int xmlrpc_replicate_log(int follower_id, LogDBRecord * lr, bool& success, - unsigned int& ft, std::string& error); + int rpc_replicate_log(int follower_id, LogDBRecord * lr, bool& success, + unsigned int& ft, std::string& error); /** - * Calls the request vote xml-rpc method + * Calls the request vote rpc method * @param follower_id to make the call * @param lindex highest last log index * @param lterm highest last log term - * @param success of the xml-rpc method + * @param success of the rpc method * @param ft term in the follower as returned by the replicate call * @param error describing error if any - * @return -1 if a XMl-RPC (network) error occurs, 0 otherwise + * @return -1 if a RPC (network) error occurs, 0 otherwise */ - int xmlrpc_request_vote(int follower_id, uint64_t lindex, - unsigned int lterm, bool& success, unsigned int& fterm, - std::string& error); + int rpc_request_vote(int follower_id, uint64_t lindex, unsigned int lterm, + bool& success, unsigned int& fterm, + std::string& error); // ------------------------------------------------------------------------- // Server related interface @@ -278,9 +278,11 @@ public: * Adds a new server to the follower list and starts associated replica * thread. * @param follower_id id of new server - * @param xmlep xmlrpc endpoint for new server + * @param endpoint rpc endpoint for new server */ - void add_server(int follower_id, const std::string& xmlep); + void add_server(int follower_id, + const std::string& endpoint_xrpc, + const std::string& endpoint_grpc); /** * Deletes a new server to the follower list and stops associated replica @@ -362,7 +364,7 @@ private: // Timers // - timer_period_ms. Base timer to wake up the manager (10ms) // - purge_period_ms. How often the LogDB is purged (600s) - // - xmlrpc_timeout. To timeout xml-rpc api calls to replicate log + // - rpc_timeout_ms. To timeout api calls to replicate log // - election_timeout. Timeout leader heartbeats (followers) // - broadcast_timeout. To send heartbeat to followers (leader) //-------------------------------------------------------------------------- @@ -370,7 +372,7 @@ private: time_t purge_period_ms; - time_t xmlrpc_timeout_ms; + time_t rpc_timeout_ms; struct timespec election_timeout; @@ -392,7 +394,7 @@ private: // // - next, next log to send to each follower // - match, highest log replicated in this server - // - servers, list of servers in zone and xml-rpc edp + // - servers, list of servers in zone and rpc edp // ------------------------------------------------------------------------- RaftReplicaManager replica_manager; @@ -404,7 +406,7 @@ private: std::map match; - std::map servers; + std::map> servers; // ------------------------------------------------------------------------- // Hooks diff --git a/include/Request.h b/include/Request.h index 398504b779..c2d15bbc89 100644 --- a/include/Request.h +++ b/include/Request.h @@ -17,211 +17,22 @@ #ifndef REQUEST_H_ #define REQUEST_H_ -#include -#include - -#include "RequestManager.h" #include "AuthRequest.h" -#include "PoolObjectSQL.h" #include "Quotas.h" #include "UserPool.h" - -/** - * This class represents the dynamic attributes: specific for a request of the - * same method. - */ -struct RequestAttributes -{ -public: - int uid; /**< id of the user */ - int gid; /**< id of the user's group */ - - std::string uname; /**< name of the user */ - std::string gname; /**< name of the user's group */ - - std::string password; /**< password of the user */ - - std::set group_ids; /**< set of user's group ids */ - - std::string session; /**< Session from ONE XML-RPC API */ - int req_id; /**< Request ID for log messages */ - - int umask; /**< User umask for new objects */ - - xmlrpc_c::value * retval; /**< Return value from libxmlrpc-c */ - std::string retval_xml; /**< Return value in XML format */ - std::string extra_xml; /**< Extra information returned for API Hooks */ - - PoolObjectSQL::ObjectType resp_obj; /**< object type */ - int resp_id; /**< Id of the object */ - std::string resp_msg; /**< Additional response message */ - - uint64_t replication_idx; - - AuthRequest::Operation auth_op; /**< Auth operation for the request */ - - bool success; /**< True if the call was successfull false otherwise */ - - RequestAttributes(AuthRequest::Operation api_auth_op) - : uid(-1) - , gid(-1) - , req_id(-1) - , umask(0) - , retval(nullptr) - , resp_obj(PoolObjectSQL::NONE) - , resp_id(-1) - , replication_idx(UINT64_MAX) - , auth_op(api_auth_op) - , success(false) - {} - - RequestAttributes(AuthRequest::Operation api_auth_op, - int _uid, - int _gid, - PoolObjectSQL::ObjectType object_type) - : uid(_uid) - , gid(_gid) - , req_id(-1) - , umask(0) - , retval(nullptr) - , resp_obj(object_type) - , resp_id(-1) - , replication_idx(UINT64_MAX) - , auth_op(api_auth_op) - , success(false) - {} - - RequestAttributes(const RequestAttributes& ra) = default; - - RequestAttributes(int _uid, int _gid, const RequestAttributes& ra) - : uid(_uid) - , gid(_gid) - , uname() - , gname() - , password() - , group_ids(ra.group_ids) - , session(ra.session) - , req_id(ra.req_id) - , umask(ra.umask) - , retval(ra.retval) - , retval_xml(ra.retval_xml) - , extra_xml() - , resp_obj(PoolObjectSQL::NONE) - , resp_id(-1) - , resp_msg() - , replication_idx(UINT64_MAX) - , auth_op(ra.auth_op) - , success(ra.success) - {} - - bool is_admin() const - { - return uid == UserPool::ONEADMIN_ID || - group_ids.count(GroupPool::ONEADMIN_ID) == 1; - } - - bool is_oneadmin() const - { - return uid == UserPool::ONEADMIN_ID; - } - - bool is_oneadmin_group() const - { - return gid == GroupPool::ONEADMIN_ID; - } - - /** - * Set the operation level (admin, manage or use) associated to this - * request. Precedence is: user > group > system. - * - * @param action perfomed on the VM object - */ - void set_auth_op(VMActions::Action action); -}; - -class ParamList -{ -public: - - ParamList(const xmlrpc_c::paramList * paramList, - const std::set& hidden): - _paramList(paramList), _hidden(hidden) {}; - - std::string& to_string(std::string& str) const - { - std::ostringstream oss; - - oss << get_value_as_string(0); - - for (unsigned int i = 1; i < _paramList->size(); i++) - { - oss << " " << get_value_as_string(i); - } - - str = oss.str(); - - return str; - }; - - std::string get_value_as_string(int index) const - { - if (_hidden.count(index) == 1 ) - { - return "****"; - } - - std::ostringstream oss; - xmlrpc_c::value::type_t type((*_paramList)[index].type()); - - if( type == xmlrpc_c::value::TYPE_INT) - { - oss << _paramList->getInt(index); - return oss.str(); - } - else if( type == xmlrpc_c::value::TYPE_I8 ) - { - oss << _paramList->getI8(index); - return oss.str(); - } - else if( type == xmlrpc_c::value::TYPE_BOOLEAN ) - { - oss << _paramList->getBoolean(index); - return oss.str(); - } - else if( type == xmlrpc_c::value::TYPE_STRING ) - { - oss << _paramList->getString(index); - return oss.str(); - } - else if( type == xmlrpc_c::value::TYPE_DOUBLE ) - { - oss << _paramList->getDouble(index); - return oss.str(); - } - - return oss.str(); - }; - - int size() const - { - return _paramList->size(); - }; - -private: - const xmlrpc_c::paramList * _paramList; - - const std::set& _hidden; -}; +#include "PoolObjectSQL.h" +#include "RequestAttributes.h" +#include "HookAPI.h" /** * The Request Class represents the basic abstraction for the OpenNebula * XML-RPC API. This interface must be implemented by any XML-RPC API call */ -class Request: public xmlrpc_c::method2 +class Request { public: /** - * Error codes for the XML-RPC API + * Error codes for the OpenNebula API */ enum ErrorCode { @@ -230,332 +41,228 @@ public: AUTHORIZATION = 0x00200, NO_EXISTS = 0x00400, ACTION = 0x00800, - XML_RPC_API = 0x01000, + RPC_API = 0x01000, INTERNAL = 0x02000, ALLOCATE = 0x04000, LOCKED = 0x08000, REPLICATION = 0x10000 }; - /** - * Gets a string representation for the Auth object in the - * request. - * @param ob object for the auth operation - * @return string equivalent of the object - */ - static std::string object_name(PoolObjectSQL::ObjectType ob); - - /** - * Sets the format string to log xml-rpc method calls. The format string - * interprets the following sequences: - * %i -- request id - * %m -- method name - * %u -- user id - * %U -- user name - * %l -- param list - * %p -- user password - * %g -- group id - * %G -- group name - * %a -- auth token - * %A -- client IP address (only IPv4) - * %a -- client port (only IPv4) - * %% -- % - */ - static void set_call_log_format(const std::string& log_format) - { - format_str = log_format; - } - - /** - * Performs a basic quota check for this request using the uid/gid - * from the request. Usage counters are updated for the user/group. - * On case of error, the failure_response return values is not set, instead - * the error reason is returned in error_str - * - * @param tmpl describing the object - * @param object type of the object - * @param att the specific request attributes - * - * @param error_str Error reason, if any - * @return true if the user is authorized. - */ - static bool quota_authorization(Template * tmpl, Quotas::QuotaType qtype, - const RequestAttributes& att, std::string& error_str, - bool resize = false); - - /** - * Performs rollback on usage counters for a previous quota check operation - * for the request. - * @param tmpl describing the object - * @param att the specific request attributes - */ - static void quota_rollback(Template * tmpl, Quotas::QuotaType qtype, - const RequestAttributes& att); - - static std::string failure_message(ErrorCode ec, RequestAttributes& att, - const std::string& method_name, - PoolObjectSQL::ObjectType auth_object = PoolObjectSQL::NONE); - - /** - * Performs a basic authorization for this request using the uid/gid - * from the request. The function gets the object from the pool to get - * the public attribute and its owner. The authorization is based on - * object and type of operation for the request. - * @param pool object pool - * @param oid of the object, can be -1 for objects to be created, or - * pools. - * @param att the specific request attributes - * - * @return SUCCESS if the user is authorized. - */ - static ErrorCode basic_authorization( - PoolSQL* pool, - int oid, - PoolObjectSQL::ObjectType auth_object, - RequestAttributes& att); - -protected: - /* ---------------------------------------------------------------------- */ - /* Global configuration attributes por API calls */ - /* ---------------------------------------------------------------------- */ - static std::string format_str; - static const long long xmlrpc_timeout; //Timeout (ms) for request forwarding - - /* ---------------------------------------------------------------------- */ - /* Static Request Attributes: shared among request of the same method */ - /* ---------------------------------------------------------------------- */ - PoolSQL * pool; - std::string method_name; - - // Configuration for authentication level of the API call - PoolObjectSQL::ObjectType auth_object = PoolObjectSQL::ObjectType::NONE; - AuthRequest::Operation auth_op = AuthRequest::NONE; - - VMActions::Action vm_action; - - // Logging configuration fot the API call - std::set hidden_params; - bool log_method_call; - - // Method can be only execute by leaders or solo servers - bool leader_only; - - // Method can be executed in disabled state - bool zone_disabled; - /* ---------------------------------------------------------------------- */ /* Class Constructors */ /* ---------------------------------------------------------------------- */ - Request(const std::string& mn, - const std::string& signature, - const std::string& help) - : pool(nullptr) - , method_name(mn) - , vm_action(VMActions::NONE_ACTION) - , log_method_call(true) - , leader_only(true) - , zone_disabled(false) - { - _signature = signature; - _help = help; - - // Always hide parameter 0 (session token) for logs and API hooks - hidden_params.insert(0); - } + Request(const std::string& mn): + _method_name(mn), + _log_method_call(true), + _leader_only(true), + _zone_disabled(false) + {} virtual ~Request() = default; - /* ---------------------------------------------------------------------- */ - /* Methods to execute the request when received at the server */ - /* ---------------------------------------------------------------------- */ /** - * Wraps the actual execution function by authorizing the user - * and calling the request_execute virtual function - * @param _paramlist list of XML parameters - * @param _retval value to be returned to the client - */ - void execute(xmlrpc_c::paramList const& _paramList, - const xmlrpc_c::callInfo * _callInfoP, xmlrpc_c::value * const _retval) override; - - /** - * Actual Execution method for the request. Must be implemented by the - * XML-RPC requests - * @param _paramlist of the XML-RPC call (complete list) - * @param att the specific request attributes - */ - virtual void request_execute(xmlrpc_c::paramList const& _paramList, - RequestAttributes& att) = 0; - /** - * Locks the requested object, gets information, and unlocks it + * A descriptive error message is constructed using att.resp_obj, att.resp_id + * and/or att.resp_msg and the ErrorCode * - * @param pool object pool - * @param id of the object - * @param type of the object - * @param att the specific request attributes - * - * @param perms returns the object's permissions - * @param name returns the object's name - * @param throw_error send error response to client if object not found - * - * @return 0 on success, -1 otherwise + * @param ec error code for this call + * @param ra the specific request attributes */ - int get_info(PoolSQL * pool, - int id, - PoolObjectSQL::ObjectType type, - RequestAttributes& att, - PoolObjectAuth& perms, - std::string& name, - bool throw_error); + static std::string failure_message(ErrorCode ec, + RequestAttributes& att, + const std::string& method_name, + PoolObjectSQL::ObjectType auth_object = PoolObjectSQL::NONE); /* ---------------------------------------------------------------------- */ - /* Methods to send response to xml-rpc client */ + /* Request Attributes */ /* ---------------------------------------------------------------------- */ - /** - * Builds an XML-RPC response updating retval. After calling this function - * the xml-rpc excute method should return - * @param val to be returned to the client - * @param att the specific request attributes - */ - void success_response(int val, RequestAttributes& att); - /** - * Builds an XML-RPC response updating retval. After calling this function - * the xml-rpc excute method should return - * @param val string to be returned to the client - * @param att the specific request attributes - */ - void success_response(const std::string& val, RequestAttributes& att); + const std::string& method_name() const + { + return _method_name; + } - /** - * Builds an XML-RPC response updating retval. After calling this function - * the xml-rpc execute method should return - * @param val to be returned to the client - * @param att the specific request attributes - */ - void success_response(bool val, RequestAttributes& att); + void method_name(const std::string& mn) + { + _method_name = mn; + } - /** - * Builds an XML-RPC response updating retval. After calling this function - * the xml-rpc excute method should return - * @param val to be returned to the client - * @param att the specific request attributes - */ - void success_response(uint64_t val, RequestAttributes& att); + PoolObjectSQL::ObjectType auth_object() const + { + return _auth_object; + } - /** - * Builds an XML-RPC response updating retval. After calling this function - * the xml-rpc excute method should return. A descriptive error message - * is constructed using att.resp_obj, att.resp_id and/or att.resp_msg and - * the ErrorCode - * @param ec error code for this call - * @param ra the specific request attributes - */ - void failure_response(ErrorCode ec, RequestAttributes& ra); + void auth_object(PoolObjectSQL::ObjectType ao) + { + _auth_object = ao; + } - /** - * Builds an error response. A descriptive error message - * is constructed using att.resp_obj, att.resp_id and/or att.resp_msg and - * the ErrorCode - * @param ec error code for this call - * @param att the specific request attributes - */ - std::string failure_message(ErrorCode ec, RequestAttributes& att); + void auth_op(AuthRequest::Operation ao) + { + _auth_op = ao; + } + + void hidden_params(const std::set& hp) + { + _hidden_params = hp; + + _hidden_params.insert(0); // always hide the first parameter + } + + void leader_only(bool lo) + { + _leader_only = lo; + } + + void log_method_call(bool lm) + { + _log_method_call = lm; + } + + void zone_disabled(bool zd) + { + _zone_disabled = zd; + } + +protected: + /* ---------------------------------------------------------------------- */ + /* Global configuration attributes for API calls */ + /* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */ - /* Authorization methods for requests */ + /* Request Attributes: shared among request of the same method */ /* ---------------------------------------------------------------------- */ - /** - * Performs a basic authorization for this request using the uid/gid - * from the request. The function gets the object from the pool to get - * the public attribute and its owner. The authorization is based on - * object and type of operation for the request. - * @param oid of the object, can be -1 for objects to be created, or - * pools. - * @param att the specific request attributes - * - * @return true if the user is authorized. - */ - bool basic_authorization(int oid, RequestAttributes& att); + std::string _method_name; - /** - * Performs a basic quota check for this request using the uid/gid - * from the request. Usage counters are updated for the user/group. - * On case of error, the failure_response return values are set - * - * @param tmpl describing the object - * @param object type of the object - * @param att the specific request attributes - * - * @return true if the user is authorized. - */ - bool quota_authorization(Template * tmpl, Quotas::QuotaType qtype, - RequestAttributes& att); + // Configuration for authentication level of the API call + PoolObjectSQL::ObjectType _auth_object = PoolObjectSQL::ObjectType::NONE; - /** - * @param tmpl describing the object - * @param att the specific request attributes - */ - ErrorCode as_uid_gid(Template * tmpl, RequestAttributes& att); + AuthRequest::Operation _auth_op = AuthRequest::NONE; + + // Logging configuration fot the API call + std::set _hidden_params = { 0 }; // hide first parameter by default + bool _log_method_call; + + // Method can be only execute by leaders or solo servers + bool _leader_only; + + // Method can be executed in disabled state + bool _zone_disabled; -private: /* ---------------------------------------------------------------------- */ - /* Functions to manage user and group quotas */ + + template + void response(ErrorCode ec, const T& out, RequestAttributes& att) + { + if (ec == SUCCESS) + { + success_response(out, att); + } + else + { + failure_response(ec, att); + } + } + /* ---------------------------------------------------------------------- */ - static bool user_quota_authorization(Template * tmpl, Quotas::QuotaType qtype, bool resize, - const RequestAttributes& att, std::string& error_str); + /* Exit code functions for RPCs */ + /* Prepares request exit code. After calling these functions the excute */ + /* method should return */ + /* ---------------------------------------------------------------------- */ + void failure_response(ErrorCode ec, RequestAttributes& att); - static bool group_quota_authorization(Template * tmpl, Quotas::QuotaType qtype, bool resize, - const RequestAttributes& att, std::string& error_str); + void failure_response(ErrorCode ec, + const std::string& val, + RequestAttributes& att) + { + if (HookAPI::supported_call(_method_name)) + { + make_xml_response(ec, val, att); + } - static void user_quota_rollback(Template * tmpl, Quotas::QuotaType qtype, - const RequestAttributes& att); + att.success = false; - static void group_quota_rollback(Template * tmpl, Quotas::QuotaType qtype, - const RequestAttributes& att); + make_response(ec, val, att); + } /** - * Builds an XML-RPC response updating retval. After calling this function - * the xml-rpc excute method should return - * @param ec error code for this call - * @param va string representation of the error - * @param ra the specific request attributes + * @param val to be returned to the client + * @param att the specific request attributes */ - void failure_response(ErrorCode ec, const std::string& va, RequestAttributes& ra) const; + template + void success_response(const T& val, RequestAttributes& att) + { + if (HookAPI::supported_call(_method_name)) + { + make_xml_response(SUCCESS, val, att); + } - /** - * Logs the method invocation, including the arguments - * @param att the specific request attributes - * @param paramList list of XML parameters - * @param format_str for the log - * @param hidden_params params not to be shown - * @param callInfoP information of client - */ - static void log_method_invoked(const RequestAttributes& att, - const xmlrpc_c::paramList& paramList, const std::string& format_str, - const std::string& method_name, const std::set& hidden_params, - const xmlrpc_c::callInfo * callInfoP); + att.success = true; - /** - * Logs the method result, including the output data or error message - * - * @param att the specific request attributes - * @param method_name that produced the error - */ - static void log_result(const RequestAttributes& att, - const std::string& method_name); + make_response(SUCCESS, val, att); + } - /** - * Formats and adds a xmlrpc_c::value to oss. - * - * @param v value to format - * @param oss stream to write v - * @param limit of characters to wirte - */ - static void log_xmlrpc_value(const xmlrpc_c::value& v, - std::ostringstream& oss, const int limit); + /* Generate the protocol specific response message*/ + virtual void make_response(ErrorCode ec, + const std::string& value, + RequestAttributes& att) + {} - // Default number of character to show in the log. Option %l - const static int DEFAULT_LOG_LIMIT = 20; + virtual void make_response(ErrorCode ec, + int value, + RequestAttributes& att) + {} + + virtual void make_response(ErrorCode ec, + uint64_t value, + RequestAttributes& att) + {} + + /* ---------------------------------------------------------------------- */ + template + void make_parameter(std::ostringstream& oss, int pos, const T& val) + { + oss << "" + << "" << pos << "" + << "OUT" + << "" << val << "" + << ""; + } + + /* Compose xml output, used for hooks */ + template + void make_xml_response(ErrorCode ec, + const T& value, + RequestAttributes& att) + { + std::ostringstream oss; + + if ( ec == SUCCESS ) + { + make_parameter(oss, 1, "true"); + } + else + { + make_parameter(oss, 1, "false"); + } + + if constexpr (std::is_same_v) + { + make_parameter(oss, 2, value? "true": "false"); + } + else + { + make_parameter(oss, 2, value); + } + + make_parameter(oss, 3, ec); + + if ( ec != SUCCESS ) + { + make_parameter(oss, 4, att.resp_id); + } + + att.retval_xml = oss.str(); + } }; /* -------------------------------------------------------------------------- */ diff --git a/include/RequestAttributes.h b/include/RequestAttributes.h new file mode 100644 index 0000000000..77fa56ba65 --- /dev/null +++ b/include/RequestAttributes.h @@ -0,0 +1,281 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2025, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +#ifndef REQUEST_ATTRIBUTES_H_ +#define REQUEST_ATTRIBUTES_H_ + +#include "AuthRequest.h" +#include "PoolObjectSQL.h" +#include "UserPool.h" +#include "Nebula.h" + +/** + * Generic class to process the arguments of a request + */ +class ParamList +{ +public: + ParamList(const std::set& hidden):_hidden(hidden) {}; + + virtual ~ParamList() = default; + + std::string& to_string(std::string& str) const + { + std::ostringstream oss; + + str.clear(); + + unsigned int pl_size = size(); + + if (pl_size == 0) + { + return str; + } + + oss << param_value(0); + + for (unsigned int i = 1; i < pl_size; i++) + { + oss << " " << param_value(i); + } + + str = oss.str(); + + return str; + } + + void log(std::ostringstream& oss, unsigned int limit) const + { + std::ostringstream pl_oss; + + for (unsigned int i=1; i < size(); i++) + { + if (i != 1) + { + pl_oss << ", "; + } + pl_oss << param_value(i); + } + + std::string pl_s = pl_oss.str(); + + if ( pl_s.length() <= limit ) + { + oss << pl_s; + return; + } + + oss << pl_s.substr(0, limit - 3) << "..."; + } + + std::string param_value(int index) const + { + if ( _hidden.count(index) == 1 ) + { + return "****"; + } + + return api_value(index); + } + + std::string session() const + { + return api_value(0); + } + + virtual unsigned int size() const = 0; + +protected: + const std::set& _hidden; + + virtual std::string api_value(int index) const = 0; +}; + +/** + * This class represents the dynamic attributes: specific for a request of the + * same method. + */ +class RequestAttributes +{ +private: + static inline uint REQUEST_ID_LENGTH = 9999; + +public: + int uid; /**< id of the user */ + int gid; /**< id of the user's group */ + + std::string uname; /**< name of the user */ + std::string gname; /**< name of the user's group */ + + std::string password; /**< password of the user */ + + std::set group_ids; /**< set of user's group ids */ + + std::string session; /**< Session from ONE XML-RPC API */ + uint req_id; /**< Request ID for log messages */ + + int umask; /**< User umask for new objects */ + + PoolObjectSQL::ObjectType resp_obj; /**< object type */ + int resp_id; /**< Id of the object */ + std::string resp_msg; /**< Additional response message */ + + uint64_t replication_idx; + + AuthRequest::Operation auth_op; /**< Auth operation for the request */ + + bool success; /**< True if the call was successfull false otherwise */ + + std::string retval_xml; /**< Return value in XML format for API Hooks*/ + + std::string extra_xml; /**< Extra information returned for API Hooks */ + + RequestAttributes(AuthRequest::Operation api_auth_op, const ParamList& pl): + uid(-1), + gid(-1), + session(pl.session()), + req_id(one_util::random(0, REQUEST_ID_LENGTH)), + umask(0), + resp_obj(PoolObjectSQL::NONE), + resp_id(-1), + replication_idx(UINT64_MAX), + auth_op(api_auth_op), + success(false) + { + } + + RequestAttributes(AuthRequest::Operation api_auth_op): + uid(-1), + gid(-1), + req_id(one_util::random(0, REQUEST_ID_LENGTH)), + umask(0), + resp_obj(PoolObjectSQL::NONE), + resp_id(-1), + replication_idx(UINT64_MAX), + auth_op(api_auth_op), + success(false) + { + } + + RequestAttributes(AuthRequest::Operation api_auth_op, int _uid, int _gid, + PoolObjectSQL::ObjectType object_type): + uid(_uid), + gid(_gid), + req_id(one_util::random(0, REQUEST_ID_LENGTH)), + umask(0), + resp_obj(object_type), + resp_id(-1), + replication_idx(UINT64_MAX), + auth_op(api_auth_op), + success(false) + { + } + + RequestAttributes(int _uid, int _gid, const RequestAttributes& ra): + uid(_uid), + gid(_gid), + uname(), + gname(), + password(), + group_ids(ra.group_ids), + session(ra.session), + req_id(ra.req_id), + umask(ra.umask), + resp_obj(PoolObjectSQL::NONE), + resp_id(-1), + resp_msg(), + replication_idx(UINT64_MAX), + auth_op(ra.auth_op), + success(ra.success), + retval_xml(ra.retval_xml), + extra_xml(ra.extra_xml) + {} + + RequestAttributes(const RequestAttributes& ra) = default; + + virtual ~RequestAttributes() = default; + + bool is_admin() const + { + return uid == UserPool::ONEADMIN_ID || + group_ids.count(GroupPool::ONEADMIN_ID) == 1; + } + + bool is_oneadmin() const + { + return uid == UserPool::ONEADMIN_ID; + } + + bool is_oneadmin_group() const + { + return gid == GroupPool::ONEADMIN_ID; + } + + /** + * Set the operation level (admin, manage or use) associated to this + * request. Precedence is: user > group > system. + * + * @param action perfomed on the VM object + */ + void set_auth_op(VMActions::Action action) + { + if (action == VMActions::NONE_ACTION) + { + return; + } + + AuthRequest::Operation result = AuthRequest::NONE; + + auto& nd = Nebula::instance(); + + if (auto user = nd.get_upool()->get_ro(uid)) + { + result = user->get_vm_auth_op(action); + } + + if (result != AuthRequest::NONE) + { + auth_op = result; + return; + } + + if (auto group = nd.get_gpool()->get_ro(gid)) + { + result = group->get_vm_auth_op(action); + } + + if (result != AuthRequest::NONE) + { + auth_op = result; + return; + } + + result = nd.get_vm_auth_op(action); + + if (result != AuthRequest::NONE) + { + auth_op = result; + } + } +}; + + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +#endif //REQUEST_ATTRIBUTES_H_ + diff --git a/include/RequestLogger.h b/include/RequestLogger.h new file mode 100644 index 0000000000..6414c6c251 --- /dev/null +++ b/include/RequestLogger.h @@ -0,0 +1,105 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2025, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +#ifndef REQUEST_LOGGER_H_ +#define REQUEST_LOGGER_H_ + +#include +#include + +#include "PoolObjectSQL.h" + +class RequestAttributes; + +class ParamList; + +/** + * The Request Class represents the basic abstraction for the OpenNebula + * XML-RPC API. This interface must be implemented by any XML-RPC API call + */ +class RequestLogger +{ +public: + RequestLogger() = default; + + virtual ~RequestLogger() = default; + + /** + * Gets a string representation for the Auth object in the + * request. + * @param ob object for the auth operation + * @return string equivalent of the object + */ + static std::string object_name(PoolObjectSQL::ObjectType ob); + + /** + * Sets the format string to log xml-rpc method calls. The format string + * interprets the following sequences: + * %i -- request id + * %m -- method name + * %u -- user id + * %U -- user name + * %l -- param list + * %p -- user password + * %g -- group id + * %G -- group name + * %a -- auth token + * %A -- client IP address (only IPv4) + * %a -- client port (only IPv4) + * %% -- % + */ + static void set_call_log_format(const std::string& log_format) + { + format_str = log_format; + } + + /** + * Logs the method invocation, including the arguments + * @param att the specific request attributes + * @param paramList list of XML parameters + * @param hidden_params params not to be shown + * @param callInfoP information of client + */ + void log_method_invoked(const RequestAttributes& att, + const ParamList& pl, + const std::string& method_name); + + /** + * Logs the method result, including the output data or error message + * + * @param att the specific request attributes + * @param method_name that produced the error + */ + void log_result(const RequestAttributes& att, const std::string& method_name); + +protected: + // Default number of character to show in the log. Option %l + const static inline int DEFAULT_LOG_LIMIT = 20; + + static inline std::string format_str; + + virtual void client_ip(char * const ip, char * const port) = 0; + + virtual bool log_return_value(std::ostringstream& oss, + const RequestAttributes& att) = 0; +}; + +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ + +#endif //REQUEST_LOGGER_H_ + diff --git a/include/RequestManagerAcl.h b/include/RequestManagerAcl.h deleted file mode 100644 index 2dfcd40dab..0000000000 --- a/include/RequestManagerAcl.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* Copyright 2002-2025, OpenNebula Project, OpenNebula Systems */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ -/* not use this file except in compliance with the License. You may obtain */ -/* a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ -/* See the License for the specific language governing permissions and */ -/* limitations under the License. */ -/* -------------------------------------------------------------------------- */ - -#ifndef REQUEST_MANAGER_ACL_H -#define REQUEST_MANAGER_ACL_H - -#include "Request.h" -#include "Nebula.h" - -/* ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------- */ - -class RequestManagerAcl: public Request -{ -protected: - RequestManagerAcl( const std::string& method_name, - const std::string& help, - const std::string& params) - :Request(method_name, params, help) - { - auth_object = PoolObjectSQL::ACL; - auth_op = AuthRequest::MANAGE; - - Nebula& nd = Nebula::instance(); - aclm = nd.get_aclm(); - }; - - ~RequestManagerAcl() {}; - - /* -------------------------------------------------------------------- */ - - AclManager * aclm; -}; - -/* ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------- */ - -class AclAddRule : public RequestManagerAcl -{ -public: - AclAddRule(): - RequestManagerAcl("one.acl.addrule", - "Adds a new ACL rule", - "A:ssss") - {}; - - ~AclAddRule() {}; - - void request_execute(xmlrpc_c::paramList const& _paramList, - RequestAttributes& att) override; -}; - -/* ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------- */ - -class AclDelRule : public RequestManagerAcl -{ -public: - AclDelRule(): - RequestManagerAcl("one.acl.delrule", - "Deletes an existing ACL rule", - "A:si") - {}; - - ~AclDelRule() {}; - - void request_execute(xmlrpc_c::paramList const& _paramList, - RequestAttributes& att) override; -}; - -/* ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------- */ - -class AclInfo: public RequestManagerAcl -{ -public: - AclInfo(): - RequestManagerAcl("one.acl.info", - "Returns the ACL rule set", - "A:s") - {}; - - ~AclInfo() {}; - - void request_execute(xmlrpc_c::paramList const& _paramList, - RequestAttributes& att) override; -}; - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -#endif diff --git a/include/RequestManagerAllocate.h b/include/RequestManagerAllocate.h deleted file mode 100644 index f0cf1b1a76..0000000000 --- a/include/RequestManagerAllocate.h +++ /dev/null @@ -1,826 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* Copyright 2002-2025, OpenNebula Project, OpenNebula Systems */ -/* */ -/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ -/* not use this file except in compliance with the License. You may obtain */ -/* a copy of the License at */ -/* */ -/* http://www.apache.org/licenses/LICENSE-2.0 */ -/* */ -/* Unless required by applicable law or agreed to in writing, software */ -/* distributed under the License is distributed on an "AS IS" BASIS, */ -/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ -/* See the License for the specific language governing permissions and */ -/* limitations under the License. */ -/* -------------------------------------------------------------------------- */ - -#ifndef REQUEST_MANAGER_ALLOCATE_H_ -#define REQUEST_MANAGER_ALLOCATE_H_ - -#include "Request.h" -#include "Nebula.h" - -#include "VirtualNetworkTemplate.h" -#include "ImageTemplate.h" -#include "VirtualMachineTemplate.h" -#include "DatastoreTemplate.h" -#include "MarketPlaceTemplate.h" - -#include "BackupJobPool.h" -#include "ClusterPool.h" -#include "DatastorePool.h" -#include "DocumentPool.h" -#include "HookPool.h" -#include "HostPool.h" -#include "ImagePool.h" -#include "MarketPlacePool.h" -#include "MarketPlaceAppPool.h" -#include "SecurityGroupPool.h" -#include "VdcPool.h" -#include "VirtualMachinePool.h" -#include "VirtualNetworkPool.h" -#include "VirtualRouterPool.h" -#include "VMGroupPool.h" -#include "VMTemplatePool.h" -#include "VNTemplatePool.h" -#include "ZonePool.h" - - -/* ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------- */ -/* ------------------------------------------------------------------------- */ - -class RequestManagerAllocate: public Request -{ -protected: - RequestManagerAllocate(const std::string& method_name, - const std::string& help, - const std::string& xml_args, - bool _do_template) - :Request(method_name, xml_args, help), do_template(_do_template) - { - auth_op = AuthRequest::CREATE; - - Nebula& nd = Nebula::instance(); - clpool = nd.get_clpool(); - }; - - ~RequestManagerAllocate() {}; - - /* -------------------------------------------------------------------- */ - - void request_execute(xmlrpc_c::paramList const& _paramList, - RequestAttributes& att) override; - - virtual bool allocate_authorization(xmlrpc_c::paramList const& _paramList, - Template *obj_template, RequestAttributes& att, - PoolObjectAuth *cluster_perms); - - /* -------------------------------------------------------------------- */ - - virtual std::unique_ptr