opennebula 7.0.2 → 7.1.80.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cloud/CloudClient.rb +1 -1
- data/lib/opennebula/acl.rb +11 -13
- data/lib/opennebula/cluster_pool.rb +2 -0
- data/lib/opennebula/datastore_pool.rb +2 -0
- data/lib/opennebula/document.rb +1 -1
- data/lib/opennebula/document_json.rb +1 -0
- data/lib/opennebula/document_pool_json.rb +2 -0
- data/lib/opennebula/error.rb +8 -2
- data/lib/opennebula/flow/service_pool.rb +2 -0
- data/lib/opennebula/flow/service_template.rb +1 -0
- data/lib/opennebula/group.rb +3 -0
- data/lib/opennebula/group_pool.rb +2 -0
- data/lib/opennebula/grpc/acl_pb.rb +21 -0
- data/lib/opennebula/grpc/acl_services_pb.rb +56 -0
- data/lib/opennebula/grpc/backupjob_pb.rb +35 -0
- data/lib/opennebula/grpc/backupjob_services_pb.rb +70 -0
- data/lib/opennebula/grpc/cluster_pb.rb +33 -0
- data/lib/opennebula/grpc/cluster_services_pb.rb +38 -0
- data/lib/opennebula/grpc/datastore_pb.rb +27 -0
- data/lib/opennebula/grpc/datastore_services_pb.rb +62 -0
- data/lib/opennebula/grpc/document_pb.rb +29 -0
- data/lib/opennebula/grpc/document_services_pb.rb +64 -0
- data/lib/opennebula/grpc/group_pb.rb +27 -0
- data/lib/opennebula/grpc/group_services_pb.rb +63 -0
- data/lib/opennebula/grpc/hook_pb.rb +28 -0
- data/lib/opennebula/grpc/hook_services_pb.rb +63 -0
- data/lib/opennebula/grpc/host_pb.rb +27 -0
- data/lib/opennebula/grpc/host_services_pb.rb +62 -0
- data/lib/opennebula/grpc/image_pb.rb +36 -0
- data/lib/opennebula/grpc/image_services_pb.rb +71 -0
- data/lib/opennebula/grpc/marketplace_pb.rb +29 -0
- data/lib/opennebula/grpc/marketplace_services_pb.rb +64 -0
- data/lib/opennebula/grpc/marketplaceapp_pb.rb +32 -0
- data/lib/opennebula/grpc/marketplaceapp_services_pb.rb +67 -0
- data/lib/opennebula/grpc/secgroup_pb.rb +28 -0
- data/lib/opennebula/grpc/secgroup_services_pb.rb +63 -0
- data/lib/opennebula/grpc/shared_pb.rb +16 -0
- data/lib/opennebula/grpc/system_pb.rb +22 -0
- data/lib/opennebula/grpc/system_services_pb.rb +57 -0
- data/lib/opennebula/grpc/template_pb.rb +30 -0
- data/lib/opennebula/grpc/template_services_pb.rb +65 -0
- data/lib/opennebula/grpc/user_pb.rb +32 -0
- data/lib/opennebula/grpc/user_services_pb.rb +68 -0
- data/lib/opennebula/grpc/vdc_pb.rb +34 -0
- data/lib/opennebula/grpc/vdc_services_pb.rb +69 -0
- data/lib/opennebula/grpc/vm_pb.rb +66 -0
- data/lib/opennebula/grpc/vm_services_pb.rb +102 -0
- data/lib/opennebula/grpc/vmgroup_pb.rb +31 -0
- data/lib/opennebula/grpc/vmgroup_services_pb.rb +66 -0
- data/lib/opennebula/grpc/vn_pb.rb +36 -0
- data/lib/opennebula/grpc/vn_services_pb.rb +71 -0
- data/lib/opennebula/grpc/vntemplate_pb.rb +30 -0
- data/lib/opennebula/grpc/vntemplate_services_pb.rb +65 -0
- data/lib/opennebula/grpc/vrouter_pb.rb +31 -0
- data/lib/opennebula/grpc/vrouter_services_pb.rb +66 -0
- data/lib/opennebula/grpc/zone_pb.rb +36 -0
- data/lib/opennebula/grpc/zone_services_pb.rb +68 -0
- data/lib/opennebula/host.rb +2 -0
- data/lib/opennebula/host_pool.rb +2 -0
- data/lib/opennebula/ldap_auth.rb +1 -1
- data/lib/opennebula/lockable_ext.rb +12 -23
- data/lib/opennebula/marketplaceapp_ext.rb +3 -0
- data/lib/opennebula/oneform_client.rb +320 -0
- data/lib/opennebula/pool.rb +2 -1
- data/lib/opennebula/pool_element.rb +8 -8
- data/lib/opennebula/saml_auth.rb +1 -1
- data/lib/opennebula/user_pool.rb +1 -0
- data/lib/opennebula/version.rb +22 -0
- data/lib/opennebula/virtual_machine.rb +34 -2
- data/lib/opennebula/virtual_machine_ext.rb +2 -0
- data/lib/opennebula/virtual_network_pool.rb +2 -0
- data/lib/opennebula/wait_ext.rb +1 -0
- data/lib/opennebula/xml_element.rb +1 -0
- data/lib/opennebula/xml_utils.rb +2 -2
- data/lib/opennebula/zone.rb +4 -3
- data/lib/opennebula.rb +2 -13
- metadata +51 -5
- data/lib/opennebula/client.rb +0 -228
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
3
|
+
# source: zone.proto
|
|
4
|
+
|
|
5
|
+
require 'google/protobuf'
|
|
6
|
+
|
|
7
|
+
require 'shared_pb'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
descriptor_data = "\n\nzone.proto\x12\x08one.zone\x1a\x0cshared.proto\"7\n\x0f\x41llocateRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t\x12\x10\n\x08template\x18\x02 \x01(\t\"0\n\rDeleteRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t\x12\x0b\n\x03oid\x18\x02 \x01(\x05\"?\n\x0bInfoRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t\x12\x0b\n\x03oid\x18\x02 \x01(\x05\x12\x0f\n\x07\x64\x65\x63rypt\x18\x03 \x01(\x08\"R\n\rUpdateRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t\x12\x0b\n\x03oid\x18\x02 \x01(\x05\x12\x10\n\x08template\x18\x03 \x01(\t\x12\x0e\n\x06\x61ppend\x18\x04 \x01(\x05\">\n\rRenameRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t\x12\x0b\n\x03oid\x18\x02 \x01(\x05\x12\x0c\n\x04name\x18\x03 \x01(\t\"C\n\x10\x41\x64\x64ServerRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t\x12\x0b\n\x03oid\x18\x02 \x01(\x05\x12\x0e\n\x06zs_str\x18\x03 \x01(\t\"B\n\x10\x44\x65lServerRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t\x12\x0b\n\x03oid\x18\x02 \x01(\x05\x12\r\n\x05zs_id\x18\x03 \x01(\x05\"D\n\x12ResetServerRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t\x12\x0b\n\x03oid\x18\x02 \x01(\x05\x12\r\n\x05zs_id\x18\x03 \x01(\x05\"@\n\rEnableRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t\x12\x0b\n\x03oid\x18\x02 \x01(\x05\x12\x0e\n\x06\x65nable\x18\x03 \x01(\x08\"\xcc\x01\n\x13ReplicateLogRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t\x12\x11\n\tleader_id\x18\x02 \x01(\x05\x12\x15\n\rleader_commit\x18\x03 \x01(\x04\x12\x13\n\x0bleader_term\x18\x04 \x01(\r\x12\r\n\x05index\x18\x05 \x01(\x04\x12\x0c\n\x04term\x18\x06 \x01(\r\x12\x12\n\nprev_index\x18\x07 \x01(\x04\x12\x11\n\tprev_term\x18\x08 \x01(\r\x12\x11\n\tfed_index\x18\t \x01(\x04\x12\x0b\n\x03sql\x18\n \x01(\t\"5\n\x14ResponseReplicateLog\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\x0c\n\x04term\x18\x02 \x01(\r\"\x88\x01\n\x0bVoteRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t\x12\x16\n\x0e\x63\x61ndidate_term\x18\x02 \x01(\r\x12\x14\n\x0c\x63\x61ndidate_id\x18\x03 \x01(\x05\x12\x1b\n\x13\x63\x61ndidate_log_index\x18\x04 \x01(\x04\x12\x1a\n\x12\x63\x61ndidate_log_term\x18\x05 \x01(\r\"-\n\x0cResponseVote\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\x0c\n\x04term\x18\x02 \x01(\r\"\'\n\x11RaftStatusRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t\"V\n\x16ReplicateFedLogRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t\x12\r\n\x05index\x18\x02 \x01(\x04\x12\x0c\n\x04prev\x18\x03 \x01(\x04\x12\x0b\n\x03sql\x18\x04 \x01(\t\"9\n\x17ResponseReplicateFedLog\x12\x0f\n\x07success\x18\x01 \x01(\x08\x12\r\n\x05index\x18\x02 \x01(\x04\"?\n\x0fUpdateDBRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t\x12\x0b\n\x03oid\x18\x02 \x01(\x05\x12\x0b\n\x03xml\x18\x03 \x01(\t\"%\n\x0fPoolInfoRequest\x12\x12\n\nsession_id\x18\x01 \x01(\t2\x84\x07\n\x0bZoneService\x12\x36\n\x08\x41llocate\x12\x19.one.zone.AllocateRequest\x1a\x0f.one.ResponseID\x12\x32\n\x06\x44\x65lete\x12\x17.one.zone.DeleteRequest\x1a\x0f.one.ResponseID\x12/\n\x04Info\x12\x15.one.zone.InfoRequest\x1a\x10.one.ResponseXML\x12\x32\n\x06Update\x12\x17.one.zone.UpdateRequest\x1a\x0f.one.ResponseID\x12\x32\n\x06Rename\x12\x17.one.zone.RenameRequest\x1a\x0f.one.ResponseID\x12\x38\n\tAddServer\x12\x1a.one.zone.AddServerRequest\x1a\x0f.one.ResponseID\x12\x38\n\tDelServer\x12\x1a.one.zone.DelServerRequest\x1a\x0f.one.ResponseID\x12<\n\x0bResetServer\x12\x1c.one.zone.ResetServerRequest\x1a\x0f.one.ResponseID\x12\x32\n\x06\x45nable\x12\x17.one.zone.EnableRequest\x1a\x0f.one.ResponseID\x12M\n\x0cReplicateLog\x12\x1d.one.zone.ReplicateLogRequest\x1a\x1e.one.zone.ResponseReplicateLog\x12\x35\n\x04Vote\x12\x15.one.zone.VoteRequest\x1a\x16.one.zone.ResponseVote\x12;\n\nRaftStatus\x12\x1b.one.zone.RaftStatusRequest\x1a\x10.one.ResponseXML\x12V\n\x0fReplicateFedLog\x12 .one.zone.ReplicateFedLogRequest\x1a!.one.zone.ResponseReplicateFedLog\x12\x36\n\x08UpdateDB\x12\x19.one.zone.UpdateDBRequest\x1a\x0f.one.ResponseID\x12\x37\n\x08PoolInfo\x12\x19.one.zone.PoolInfoRequest\x1a\x10.one.ResponseXMLB8Z6github.com/OpenNebula/one/src/oca/go/src/goca/api/zoneb\x06proto3"
|
|
11
|
+
|
|
12
|
+
pool = ::Google::Protobuf::DescriptorPool.generated_pool
|
|
13
|
+
pool.add_serialized_file(descriptor_data)
|
|
14
|
+
|
|
15
|
+
module One
|
|
16
|
+
module Zone
|
|
17
|
+
AllocateRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.AllocateRequest").msgclass
|
|
18
|
+
DeleteRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.DeleteRequest").msgclass
|
|
19
|
+
InfoRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.InfoRequest").msgclass
|
|
20
|
+
UpdateRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.UpdateRequest").msgclass
|
|
21
|
+
RenameRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.RenameRequest").msgclass
|
|
22
|
+
AddServerRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.AddServerRequest").msgclass
|
|
23
|
+
DelServerRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.DelServerRequest").msgclass
|
|
24
|
+
ResetServerRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.ResetServerRequest").msgclass
|
|
25
|
+
EnableRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.EnableRequest").msgclass
|
|
26
|
+
ReplicateLogRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.ReplicateLogRequest").msgclass
|
|
27
|
+
ResponseReplicateLog = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.ResponseReplicateLog").msgclass
|
|
28
|
+
VoteRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.VoteRequest").msgclass
|
|
29
|
+
ResponseVote = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.ResponseVote").msgclass
|
|
30
|
+
RaftStatusRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.RaftStatusRequest").msgclass
|
|
31
|
+
ReplicateFedLogRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.ReplicateFedLogRequest").msgclass
|
|
32
|
+
ResponseReplicateFedLog = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.ResponseReplicateFedLog").msgclass
|
|
33
|
+
UpdateDBRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.UpdateDBRequest").msgclass
|
|
34
|
+
PoolInfoRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("one.zone.PoolInfoRequest").msgclass
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
2
|
+
# Source: zone.proto for package 'one.zone'
|
|
3
|
+
# Original file comments:
|
|
4
|
+
# --------------------------------------------------------------------------
|
|
5
|
+
#
|
|
6
|
+
# Copyright 2002-2025, OpenNebula Project, OpenNebula Systems
|
|
7
|
+
#
|
|
8
|
+
#
|
|
9
|
+
#
|
|
10
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
11
|
+
#
|
|
12
|
+
# not use this file except in compliance with the License. You may obtain
|
|
13
|
+
#
|
|
14
|
+
# a copy of the License at
|
|
15
|
+
#
|
|
16
|
+
#
|
|
17
|
+
#
|
|
18
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
+
#
|
|
20
|
+
#
|
|
21
|
+
#
|
|
22
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
23
|
+
#
|
|
24
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
25
|
+
#
|
|
26
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27
|
+
#
|
|
28
|
+
# See the License for the specific language governing permissions and
|
|
29
|
+
#
|
|
30
|
+
# limitations under the License.
|
|
31
|
+
#
|
|
32
|
+
# --------------------------------------------------------------------------
|
|
33
|
+
|
|
34
|
+
require 'grpc'
|
|
35
|
+
require 'zone_pb'
|
|
36
|
+
|
|
37
|
+
module One
|
|
38
|
+
module Zone
|
|
39
|
+
module ZoneService
|
|
40
|
+
class Service
|
|
41
|
+
|
|
42
|
+
include ::GRPC::GenericService
|
|
43
|
+
|
|
44
|
+
self.marshal_class_method = :encode
|
|
45
|
+
self.unmarshal_class_method = :decode
|
|
46
|
+
self.service_name = 'one.zone.ZoneService'
|
|
47
|
+
|
|
48
|
+
rpc :Allocate, ::One::Zone::AllocateRequest, ::One::ResponseID
|
|
49
|
+
rpc :Delete, ::One::Zone::DeleteRequest, ::One::ResponseID
|
|
50
|
+
rpc :Info, ::One::Zone::InfoRequest, ::One::ResponseXML
|
|
51
|
+
rpc :Update, ::One::Zone::UpdateRequest, ::One::ResponseID
|
|
52
|
+
rpc :Rename, ::One::Zone::RenameRequest, ::One::ResponseID
|
|
53
|
+
rpc :AddServer, ::One::Zone::AddServerRequest, ::One::ResponseID
|
|
54
|
+
rpc :DelServer, ::One::Zone::DelServerRequest, ::One::ResponseID
|
|
55
|
+
rpc :ResetServer, ::One::Zone::ResetServerRequest, ::One::ResponseID
|
|
56
|
+
rpc :Enable, ::One::Zone::EnableRequest, ::One::ResponseID
|
|
57
|
+
rpc :ReplicateLog, ::One::Zone::ReplicateLogRequest, ::One::Zone::ResponseReplicateLog
|
|
58
|
+
rpc :Vote, ::One::Zone::VoteRequest, ::One::Zone::ResponseVote
|
|
59
|
+
rpc :RaftStatus, ::One::Zone::RaftStatusRequest, ::One::ResponseXML
|
|
60
|
+
rpc :ReplicateFedLog, ::One::Zone::ReplicateFedLogRequest, ::One::Zone::ResponseReplicateFedLog
|
|
61
|
+
rpc :UpdateDB, ::One::Zone::UpdateDBRequest, ::One::ResponseID
|
|
62
|
+
rpc :PoolInfo, ::One::Zone::PoolInfoRequest, ::One::ResponseXML
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
Stub = Service.rpc_stub_class
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
data/lib/opennebula/host.rb
CHANGED
data/lib/opennebula/host_pool.rb
CHANGED
data/lib/opennebula/ldap_auth.rb
CHANGED
|
@@ -16,17 +16,6 @@
|
|
|
16
16
|
|
|
17
17
|
require 'date'
|
|
18
18
|
|
|
19
|
-
require 'opennebula/document'
|
|
20
|
-
require 'opennebula/hook'
|
|
21
|
-
require 'opennebula/image'
|
|
22
|
-
require 'opennebula/marketplaceapp'
|
|
23
|
-
require 'opennebula/template'
|
|
24
|
-
require 'opennebula/virtual_machine'
|
|
25
|
-
require 'opennebula/virtual_network'
|
|
26
|
-
require 'opennebula/virtual_router'
|
|
27
|
-
require 'opennebula/vm_group'
|
|
28
|
-
require 'opennebula/vntemplate'
|
|
29
|
-
|
|
30
19
|
# Module to decorate Lockable classes with the following methods:
|
|
31
20
|
# - Lock
|
|
32
21
|
# - Unlock
|
|
@@ -125,17 +114,17 @@ module OpenNebula::LockableExt
|
|
|
125
114
|
def self.lockable?(obj)
|
|
126
115
|
# Lockable classes
|
|
127
116
|
lockable = [
|
|
128
|
-
OpenNebula::BackupJob,
|
|
129
|
-
OpenNebula::Document,
|
|
130
|
-
OpenNebula::Hook,
|
|
131
|
-
OpenNebula::Image,
|
|
132
|
-
OpenNebula::MarketPlaceApp,
|
|
133
|
-
OpenNebula::Template,
|
|
134
|
-
OpenNebula::VirtualMachine,
|
|
135
|
-
OpenNebula::VirtualNetwork,
|
|
136
|
-
OpenNebula::VirtualRouter,
|
|
137
|
-
OpenNebula::VMGroup,
|
|
138
|
-
OpenNebula::VNTemplate
|
|
117
|
+
'OpenNebula::BackupJob',
|
|
118
|
+
'OpenNebula::Document',
|
|
119
|
+
'OpenNebula::Hook',
|
|
120
|
+
'OpenNebula::Image',
|
|
121
|
+
'OpenNebula::MarketPlaceApp',
|
|
122
|
+
'OpenNebula::Template',
|
|
123
|
+
'OpenNebula::VirtualMachine',
|
|
124
|
+
'OpenNebula::VirtualNetwork',
|
|
125
|
+
'OpenNebula::VirtualRouter',
|
|
126
|
+
'OpenNebula::VMGroup',
|
|
127
|
+
'OpenNebula::VNTemplate'
|
|
139
128
|
]
|
|
140
129
|
|
|
141
130
|
# Get obj class to find parents in lockable class
|
|
@@ -147,7 +136,7 @@ module OpenNebula::LockableExt
|
|
|
147
136
|
i_class = o_class
|
|
148
137
|
|
|
149
138
|
while i_class
|
|
150
|
-
if lockable.include?(i_class)
|
|
139
|
+
if lockable.include?(i_class.name)
|
|
151
140
|
found = true
|
|
152
141
|
break
|
|
153
142
|
end
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
# limitations under the License. #
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
|
16
16
|
|
|
17
|
+
require 'opennebula/template'
|
|
18
|
+
require 'opennebula/image_pool'
|
|
19
|
+
|
|
17
20
|
# Module to decorate MarketApp class with additional helpers not directly
|
|
18
21
|
# exposed through the OpenNebula XMLRPC API. The extensions include
|
|
19
22
|
# - export helper that creates OpenNebula related objects from a given app.
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
|
2
|
+
# Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
|
|
3
|
+
# #
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
|
+
# not use this file except in compliance with the License. You may obtain #
|
|
6
|
+
# a copy of the License at #
|
|
7
|
+
# #
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
|
9
|
+
# #
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
|
13
|
+
# See the License for the specific language governing permissions and #
|
|
14
|
+
# limitations under the License. #
|
|
15
|
+
#--------------------------------------------------------------------------- #
|
|
16
|
+
|
|
17
|
+
require 'uri'
|
|
18
|
+
require 'base64'
|
|
19
|
+
require 'json'
|
|
20
|
+
|
|
21
|
+
require 'opennebula/form/helpers'
|
|
22
|
+
require 'opennebula/form/drivers'
|
|
23
|
+
require 'opennebula/form/providers'
|
|
24
|
+
require 'opennebula/form/provisions'
|
|
25
|
+
require 'cloud/CloudClient'
|
|
26
|
+
|
|
27
|
+
include CloudCLI
|
|
28
|
+
|
|
29
|
+
module OneForm
|
|
30
|
+
|
|
31
|
+
# OneForm API client
|
|
32
|
+
class Client
|
|
33
|
+
|
|
34
|
+
DEFAULT_OPTIONS = [
|
|
35
|
+
ENDPOINT = {
|
|
36
|
+
:name => 'server',
|
|
37
|
+
:short => '-s url',
|
|
38
|
+
:large => '--server url',
|
|
39
|
+
:format => String,
|
|
40
|
+
:description => 'OneForm endpoint'
|
|
41
|
+
},
|
|
42
|
+
USERNAME={
|
|
43
|
+
:name => 'username',
|
|
44
|
+
:short => '-u name',
|
|
45
|
+
:large => '--username name',
|
|
46
|
+
:format => String,
|
|
47
|
+
:description => 'User name'
|
|
48
|
+
},
|
|
49
|
+
PASSWORD={
|
|
50
|
+
:name => 'password',
|
|
51
|
+
:short => '-p pass',
|
|
52
|
+
:large => '--password pass',
|
|
53
|
+
:format => String,
|
|
54
|
+
:description => 'User password'
|
|
55
|
+
},
|
|
56
|
+
API_VERSION={
|
|
57
|
+
:name => 'api_version',
|
|
58
|
+
:large => '--api-version version',
|
|
59
|
+
:format => String,
|
|
60
|
+
:description => 'OneForm API Version to use'
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
include OneForm::Drivers
|
|
65
|
+
include OneForm::Providers
|
|
66
|
+
include OneForm::Provisions
|
|
67
|
+
|
|
68
|
+
def initialize(opts = {})
|
|
69
|
+
endpoint = '/.one/oneform_endpoint'
|
|
70
|
+
@username = opts[:username] || ENV['ONEFORM_USER']
|
|
71
|
+
@password = opts[:password] || ENV['ONEFORM_PASSWORD']
|
|
72
|
+
|
|
73
|
+
# By default oneform uses JSON as content type
|
|
74
|
+
@content_type = opts[:content_type] || 'application/json'
|
|
75
|
+
|
|
76
|
+
# Set API version
|
|
77
|
+
@version = opts[:api_version] || ENV['ONEFORM_VERSION'] || 'v1'
|
|
78
|
+
|
|
79
|
+
if opts[:url]
|
|
80
|
+
url = opts[:url]
|
|
81
|
+
elsif ENV['ONEFORM_URL']
|
|
82
|
+
url = ENV['ONEFORM_URL']
|
|
83
|
+
elsif Dir.home && File.exist?(Dir.home + endpoint)
|
|
84
|
+
url = File.read(Dir.home + endpoint).strip
|
|
85
|
+
elsif File.exist?('/var/lib/one/.one/oneform_endpoint')
|
|
86
|
+
url = File.read('/var/lib/one/.one/oneform_endpoint').strip
|
|
87
|
+
else
|
|
88
|
+
url = 'http://localhost:13013'
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
url = url.chomp('/') + "/api/#{@version}"
|
|
92
|
+
|
|
93
|
+
if @username.nil? && @password.nil?
|
|
94
|
+
if Dir.home && !Dir.home.empty? && ENV['ONE_AUTH'] && File.file?(ENV['ONE_AUTH'])
|
|
95
|
+
one_auth = File.read(ENV['ONE_AUTH'])
|
|
96
|
+
elsif Dir.home && File.file?(Dir.home + '/.one/one_auth')
|
|
97
|
+
one_auth = File.read(Dir.home + '/.one/one_auth')
|
|
98
|
+
elsif File.file?('/var/lib/one/.one/one_auth')
|
|
99
|
+
one_auth = File.read('/var/lib/one/.one/one_auth')
|
|
100
|
+
else
|
|
101
|
+
raise 'ONE_AUTH file not present'
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
one_auth = one_auth.rstrip
|
|
105
|
+
@username, @password = one_auth.split(':')
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
@uri = URI.parse(url)
|
|
109
|
+
|
|
110
|
+
@user_agent = "OpenNebula #{CloudClient::VERSION} " <<
|
|
111
|
+
"(#{opts[:user_agent]||'Ruby'})"
|
|
112
|
+
|
|
113
|
+
@host = nil
|
|
114
|
+
@port = nil
|
|
115
|
+
|
|
116
|
+
return unless ENV['http_proxy']
|
|
117
|
+
|
|
118
|
+
uri_proxy = URI.parse(ENV['http_proxy'])
|
|
119
|
+
flag = false
|
|
120
|
+
|
|
121
|
+
# Check if we need to bypass the proxy
|
|
122
|
+
if ENV['no_proxy']
|
|
123
|
+
ENV['no_proxy'].split(',').each do |item|
|
|
124
|
+
item = item.strip
|
|
125
|
+
|
|
126
|
+
if (IPAddress @uri.host rescue nil).nil?
|
|
127
|
+
if (IPAddress(item) rescue nil).nil?
|
|
128
|
+
flag |= (item == @uri.host)
|
|
129
|
+
end
|
|
130
|
+
else
|
|
131
|
+
unless (IPAddress item rescue nil).nil?
|
|
132
|
+
flag |= IPAddress(item).include? IPAddress(@uri.host)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
return if flag
|
|
139
|
+
|
|
140
|
+
@host = uri_proxy.host
|
|
141
|
+
@port = uri_proxy.port
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
private
|
|
145
|
+
|
|
146
|
+
def get(path, params = {})
|
|
147
|
+
uri = build_uri(path, params)
|
|
148
|
+
request = Net::HTTP::Proxy(@host, @port)::Get.new(uri, default_headers)
|
|
149
|
+
perform_request(uri, request)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def post(path, body = {})
|
|
153
|
+
uri = build_uri(path)
|
|
154
|
+
request = Net::HTTP::Proxy(@host, @port)::Post.new(uri, default_headers)
|
|
155
|
+
request.body = body.is_a?(String) ? body : body.to_json
|
|
156
|
+
perform_request(uri, request)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def put(path, body = {})
|
|
160
|
+
uri = build_uri(path)
|
|
161
|
+
request = Net::HTTP::Proxy(@host, @port)::Put.new(uri, default_headers)
|
|
162
|
+
request.body = body.is_a?(String) ? body : body.to_json
|
|
163
|
+
perform_request(uri, request)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def patch(path, body = {})
|
|
167
|
+
uri = build_uri(path)
|
|
168
|
+
request = Net::HTTP::Proxy(@host, @port)::Patch.new(uri, default_headers)
|
|
169
|
+
request.body = body.is_a?(String) ? body : body.to_json
|
|
170
|
+
perform_request(uri, request)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def delete(path, params = {})
|
|
174
|
+
uri = build_uri(path, params)
|
|
175
|
+
request = Net::HTTP::Proxy(@host, @port)::Delete.new(uri, default_headers)
|
|
176
|
+
perform_request(uri, request)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def poll_logs(path, params = {})
|
|
180
|
+
uri = build_uri(path, params)
|
|
181
|
+
request = Net::HTTP::Proxy(@host, @port)::Get.new(uri, default_headers)
|
|
182
|
+
|
|
183
|
+
raw_body = nil
|
|
184
|
+
|
|
185
|
+
Net::HTTP.start(
|
|
186
|
+
uri.host,
|
|
187
|
+
uri.port,
|
|
188
|
+
:use_ssl => (uri.scheme == 'https')
|
|
189
|
+
) do |http|
|
|
190
|
+
response = http.request(request)
|
|
191
|
+
|
|
192
|
+
raise "Request failed: #{response.code} #{response.message}" \
|
|
193
|
+
unless response.is_a?(Net::HTTPSuccess)
|
|
194
|
+
|
|
195
|
+
raw_body = response.body
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
json =
|
|
199
|
+
begin
|
|
200
|
+
JSON.parse(raw_body)
|
|
201
|
+
rescue JSON::ParserError => e
|
|
202
|
+
raise "Invalid JSON response: #{e.message}"
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
{
|
|
206
|
+
:pos => json['pos'],
|
|
207
|
+
:meta => json['meta'],
|
|
208
|
+
:lines => json['lines'] || []
|
|
209
|
+
}
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def follow_logs(path, params = {})
|
|
213
|
+
pos = params[:all] ? 0 : nil
|
|
214
|
+
interval = params[:interval] || 1.0
|
|
215
|
+
|
|
216
|
+
loop do
|
|
217
|
+
begin
|
|
218
|
+
response = poll_logs(path, { :pos => pos })
|
|
219
|
+
|
|
220
|
+
response[:lines].each do |entry|
|
|
221
|
+
level = entry['level'] || 'info'
|
|
222
|
+
text = entry['text'] || ''
|
|
223
|
+
puts "[#{level}] #{text}"
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
pos = response[:pos] || pos
|
|
227
|
+
sleep interval
|
|
228
|
+
rescue Interrupt
|
|
229
|
+
break
|
|
230
|
+
rescue StandardError => e
|
|
231
|
+
warn "Polling error: #{e.class}: #{e.message}"
|
|
232
|
+
sleep interval
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
def build_uri(path, params = {})
|
|
238
|
+
uri = @uri.dup
|
|
239
|
+
path = path.sub(%r{^/}, '')
|
|
240
|
+
uri.path = [@uri.path, path].join('/').gsub(%r{/{2,}}, '/')
|
|
241
|
+
uri.query = URI.encode_www_form(params) unless params.empty?
|
|
242
|
+
uri
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
def default_headers
|
|
246
|
+
auth = Base64.strict_encode64("#{@username}:#{@password}")
|
|
247
|
+
{
|
|
248
|
+
'Authorization' => "Basic #{auth}",
|
|
249
|
+
'Content-Type' => @content_type,
|
|
250
|
+
'Accept' => @content_type,
|
|
251
|
+
'User-Agent' => @user_agent
|
|
252
|
+
}
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
def perform_request(uri, request)
|
|
256
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
|
257
|
+
response = http.request(request)
|
|
258
|
+
handle_response(response)
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
def handle_response(response)
|
|
263
|
+
json = nil
|
|
264
|
+
|
|
265
|
+
begin
|
|
266
|
+
body = response.body && !response.body.strip.empty? ? response.body : '{}'
|
|
267
|
+
json = JSON.parse(body, :symbolize_names => true)
|
|
268
|
+
rescue JSON::ParserError
|
|
269
|
+
raise "OneForm Error: #{body.inspect}"
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
case response
|
|
273
|
+
when Net::HTTPSuccess
|
|
274
|
+
if json.is_a?(Array)
|
|
275
|
+
json.map do |item|
|
|
276
|
+
item.is_a?(Hash) && item.key?(:DOCUMENT) ? item[:DOCUMENT] : item
|
|
277
|
+
end
|
|
278
|
+
elsif json.is_a?(Hash) && json.key?(:DOCUMENT)
|
|
279
|
+
json[:DOCUMENT]
|
|
280
|
+
else
|
|
281
|
+
json
|
|
282
|
+
end
|
|
283
|
+
else
|
|
284
|
+
err_code = json[:err_code] || 'UNKNOWN'
|
|
285
|
+
error_message = json[:message] || 'No message provided'
|
|
286
|
+
err_ctx = json[:context] || {}
|
|
287
|
+
|
|
288
|
+
if err_ctx && !err_ctx.empty?
|
|
289
|
+
context_str = format_context(err_ctx)
|
|
290
|
+
|
|
291
|
+
msg = <<~MSG
|
|
292
|
+
OneForm Error (#{err_code}): #{error_message}
|
|
293
|
+
#{context_str}
|
|
294
|
+
MSG
|
|
295
|
+
else
|
|
296
|
+
msg = "OneForm Error (#{err_code}): #{error_message}"
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
raise msg
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
def format_context(hash, indent = 0, top_level = true)
|
|
304
|
+
prefix = ' ' * indent
|
|
305
|
+
|
|
306
|
+
hash.map do |key, value|
|
|
307
|
+
line_prefix = top_level ? "#{prefix}- " : "#{prefix} "
|
|
308
|
+
|
|
309
|
+
if value.is_a?(Hash)
|
|
310
|
+
nested = format_context(value, indent + 2, false)
|
|
311
|
+
"#{line_prefix}#{key}:\n#{nested}"
|
|
312
|
+
else
|
|
313
|
+
"#{line_prefix}#{key}: #{value}"
|
|
314
|
+
end
|
|
315
|
+
end.join("\n")
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
end
|
data/lib/opennebula/pool.rb
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
#--------------------------------------------------------------------------- #
|
|
16
16
|
|
|
17
17
|
require 'opennebula/xml_utils'
|
|
18
|
+
require 'opennebula/error'
|
|
18
19
|
|
|
19
20
|
module OpenNebula
|
|
20
21
|
|
|
@@ -259,7 +260,7 @@ module OpenNebula
|
|
|
259
260
|
end
|
|
260
261
|
|
|
261
262
|
size = OpenNebula.pool_page_size if (!size || size == 0)
|
|
262
|
-
rc = @client.call(method, @user_id, current, -size, state)
|
|
263
|
+
rc = @client.call(method, @user_id, current, -size, state, "")
|
|
263
264
|
|
|
264
265
|
return rc if OpenNebula.is_error?(rc)
|
|
265
266
|
|
|
@@ -39,21 +39,21 @@ module OpenNebula
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
#######################################################################
|
|
42
|
-
# Common
|
|
42
|
+
# Common RPC Methods for all the Pool Element Types
|
|
43
43
|
#######################################################################
|
|
44
44
|
|
|
45
45
|
# Common client call wrapper. Checks that @pe_id is defined, and
|
|
46
46
|
# returns nil instead of the response if it is successful
|
|
47
47
|
#
|
|
48
|
-
# @param [String]
|
|
48
|
+
# @param [String] rpc_method the name of the RPC method
|
|
49
49
|
# @param [Array] args any arguments for the xml-rpc method
|
|
50
50
|
#
|
|
51
51
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
|
52
52
|
# otherwise
|
|
53
|
-
def call(
|
|
53
|
+
def call(rpc_method, *args)
|
|
54
54
|
return Error.new('ID not defined') unless @pe_id
|
|
55
55
|
|
|
56
|
-
rc = @client.call(
|
|
56
|
+
rc = @client.call(rpc_method, *args)
|
|
57
57
|
rc = nil unless OpenNebula.is_error?(rc)
|
|
58
58
|
|
|
59
59
|
rc
|
|
@@ -86,13 +86,13 @@ module OpenNebula
|
|
|
86
86
|
# Calls to the corresponding allocate method to create a new element
|
|
87
87
|
# in the OpenNebula core
|
|
88
88
|
#
|
|
89
|
-
# @param [String]
|
|
90
|
-
# @param [Array] args any extra arguments for the
|
|
89
|
+
# @param [String] rpc_method the name of the RPC method
|
|
90
|
+
# @param [Array] args any extra arguments for the RPC method
|
|
91
91
|
#
|
|
92
92
|
# @return [nil, OpenNebula::Error] nil in case of success, Error
|
|
93
93
|
# otherwise
|
|
94
|
-
def allocate(
|
|
95
|
-
rc = @client.call(
|
|
94
|
+
def allocate(rpc_method, *args)
|
|
95
|
+
rc = @client.call(rpc_method, *args)
|
|
96
96
|
|
|
97
97
|
if !OpenNebula.is_error?(rc)
|
|
98
98
|
@pe_id = rc
|
data/lib/opennebula/saml_auth.rb
CHANGED
data/lib/opennebula/user_pool.rb
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# -------------------------------------------------------------------------- #
|
|
2
|
+
# Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
|
|
3
|
+
# #
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
|
5
|
+
# not use this file except in compliance with the License. You may obtain #
|
|
6
|
+
# a copy of the License at #
|
|
7
|
+
# #
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0 #
|
|
9
|
+
# #
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software #
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, #
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
|
13
|
+
# See the License for the specific language governing permissions and #
|
|
14
|
+
# limitations under the License. #
|
|
15
|
+
#--------------------------------------------------------------------------- #
|
|
16
|
+
|
|
17
|
+
module OpenNebula
|
|
18
|
+
|
|
19
|
+
# OpenNebula version
|
|
20
|
+
VERSION = '7.1.80'
|
|
21
|
+
|
|
22
|
+
end
|