F #3859: Adapt azure+ec2 driver to new monitoring system(#4481)

This commit is contained in:
Jan Orel authored and GitHub committed 2020-04-05 19:50:45 +02:00
1 parent 94cb0cbb1b
commit e658320cb5
37 files changed
+1577 -1016

No files matched your search

+56 -9
View File
@@ -305,7 +305,15 @@ VAR_DIRS="$VAR_LOCATION/remotes \
$VAR_LOCATION/remotes/im/firecracker-probes.d/vm/status \
$VAR_LOCATION/remotes/im/vcenter.d \
$VAR_LOCATION/remotes/im/ec2.d \
$VAR_LOCATION/remotes/im/ec2-probes.d/host/monitor \
$VAR_LOCATION/remotes/im/ec2-probes.d/host/system \
$VAR_LOCATION/remotes/im/ec2-probes.d/vm/monitor \
$VAR_LOCATION/remotes/im/ec2-probes.d/vm/status \
$VAR_LOCATION/remotes/im/az.d \
$VAR_LOCATION/remotes/im/az-probes.d/host/monitor \
$VAR_LOCATION/remotes/im/az-probes.d/host/system \
$VAR_LOCATION/remotes/im/az-probes.d/vm/monitor \
$VAR_LOCATION/remotes/im/az-probes.d/vm/status \
$VAR_LOCATION/remotes/im/one.d \
$VAR_LOCATION/remotes/im/packet.d \
$VAR_LOCATION/remotes/pm \
@@ -486,6 +494,11 @@ INSTALL_FILES=(
IM_PROBES_FIRECRACKER_FILES:$VAR_LOCATION/remotes/im/firecracker.d
IM_PROBES_DUMMY_FILES:$VAR_LOCATION/remotes/im/dummy.d
IM_PROBES_LXD_FILES:$VAR_LOCATION/remotes/im/lxd.d
IM_PROBES_VCENTER_FILES:$VAR_LOCATION/remotes/im/vcenter.d
IM_PROBES_EC2_FILES:$VAR_LOCATION/remotes/im/ec2.d
IM_PROBES_AZ_FILES:$VAR_LOCATION/remotes/im/az.d
IM_PROBES_ONE_FILES:$VAR_LOCATION/remotes/im/one.d
IM_PROBES_PACKET_FILES:$VAR_LOCATION/remotes/im/packet.d
IM_PROBES_KVM_HOST_BEACON_FILES:$VAR_LOCATION/remotes/im/kvm-probes.d/host/beacon
IM_PROBES_KVM_HOST_MONITOR_FILES:$VAR_LOCATION/remotes/im/kvm-probes.d/host/monitor
IM_PROBES_KVM_HOST_SYSTEM_FILES:$VAR_LOCATION/remotes/im/kvm-probes.d/host/system
@@ -504,11 +517,14 @@ INSTALL_FILES=(
IM_PROBES_LXD_VM_STATUS_FILES:$VAR_LOCATION/remotes/im/lxd-probes.d/vm/status
IM_PROBES_LXD_PROBES_FILES:$VAR_LOCATION/remotes/im/lxd-probes.d
IM_PROBES_ETC_LXD_PROBES_FILES:$VAR_LOCATION/remotes/etc/im/lxd-probes.d
IM_PROBES_VCENTER_FILES:$VAR_LOCATION/remotes/im/vcenter.d
IM_PROBES_EC2_FILES:$VAR_LOCATION/remotes/im/ec2.d
IM_PROBES_AZ_FILES:$VAR_LOCATION/remotes/im/az.d
IM_PROBES_ONE_FILES:$VAR_LOCATION/remotes/im/one.d
IM_PROBES_PACKET_FILES:$VAR_LOCATION/remotes/im/packet.d
IM_PROBES_AZ_HOST_MONITOR_FILES:$VAR_LOCATION/remotes/im/az-probes.d/host/monitor
IM_PROBES_AZ_HOST_SYSTEM_FILES:$VAR_LOCATION/remotes/im/az-probes.d/host/system
IM_PROBES_AZ_VM_MONITOR_FILES:$VAR_LOCATION/remotes/im/az-probes.d/vm/monitor
IM_PROBES_AZ_VM_STATUS_FILES:$VAR_LOCATION/remotes/im/az-probes.d/vm/status
IM_PROBES_EC2_HOST_MONITOR_FILES:$VAR_LOCATION/remotes/im/ec2-probes.d/host/monitor
IM_PROBES_EC2_HOST_SYSTEM_FILES:$VAR_LOCATION/remotes/im/ec2-probes.d/host/system
IM_PROBES_EC2_VM_MONITOR_FILES:$VAR_LOCATION/remotes/im/ec2-probes.d/vm/monitor
IM_PROBES_EC2_VM_STATUS_FILES:$VAR_LOCATION/remotes/im/ec2-probes.d/vm/status
IM_PROBES_VERSION:$VAR_LOCATION/remotes
IM_PROBES_FIRECRACKER_HOST_BEACON_FILES:$VAR_LOCATION/remotes/im/firecracker-probes.d/host/beacon
IM_PROBES_FIRECRACKER_HOST_MONITOR_FILES:$VAR_LOCATION/remotes/im/firecracker-probes.d/host/monitor
@@ -789,6 +805,7 @@ RUBY_LIB_FILES="src/mad/ruby/ActionManager.rb \
src/mad/ruby/CommandManager.rb \
src/mad/ruby/OpenNebulaDriver.rb \
src/mad/ruby/VirtualMachineDriver.rb \
src/mad/ruby/PublicCloudDriver.rb \
src/mad/ruby/DriverExecHelper.rb \
src/mad/ruby/ssh_stream.rb \
src/vnm_mad/one_vnm.rb \
@@ -1067,7 +1084,6 @@ VMM_EXEC_EC2_SCRIPTS="src/vmm_mad/remotes/ec2/cancel \
src/vmm_mad/remotes/ec2/reboot \
src/vmm_mad/remotes/ec2/reset \
src/vmm_mad/remotes/ec2/save \
src/vmm_mad/remotes/ec2/poll \
src/vmm_mad/remotes/ec2/shutdown \
src/vmm_mad/remotes/ec2/reconfigure \
src/vmm_mad/remotes/ec2/prereconfigure \
@@ -1091,7 +1107,6 @@ VMM_EXEC_AZ_SCRIPTS="src/vmm_mad/remotes/az/cancel \
src/vmm_mad/remotes/az/reboot \
src/vmm_mad/remotes/az/reset \
src/vmm_mad/remotes/az/save \
src/vmm_mad/remotes/az/poll \
src/vmm_mad/remotes/az/shutdown \
src/vmm_mad/remotes/az/reconfigure \
src/vmm_mad/remotes/az/prereconfigure \
@@ -1273,9 +1288,41 @@ IM_PROBES_ETC_FIRECRACKER_PROBES_FILES="src/im_mad/remotes/lib/probe_db.conf"
IM_PROBES_VCENTER_FILES="src/im_mad/remotes/vcenter.d/poll"
IM_PROBES_EC2_FILES="src/im_mad/remotes/ec2.d/poll"
# EC2 monitord-client
IM_PROBES_EC2_FILES="\
src/im_mad/remotes/ec2.d/monitord-client_control.sh \
src/im_mad/remotes/ec2.d/monitord-client.rb"
IM_PROBES_AZ_FILES="src/im_mad/remotes/az.d/poll"
# EC2 probes
IM_PROBES_EC2_HOST_MONITOR_FILES="\
src/im_mad/remotes/ec2-probes.d/host/monitor/probe_host_monitor.rb"
IM_PROBES_EC2_HOST_SYSTEM_FILES="\
src/im_mad/remotes/ec2-probes.d/host/system/probe_host_system.rb"
IM_PROBES_EC2_VM_MONITOR_FILES="\
src/im_mad/remotes/ec2-probes.d/vm/monitor/probe_vm_monitor.rb"
IM_PROBES_EC2_VM_STATUS_FILES="\
src/im_mad/remotes/ec2-probes.d/vm/status/probe_vm_status.rb"
# AZ monitord-client
IM_PROBES_AZ_FILES="\
src/im_mad/remotes/az.d/monitord-client_control.sh \
src/im_mad/remotes/az.d/monitord-client.rb"
# AZ probes
IM_PROBES_AZ_HOST_MONITOR_FILES="\
src/im_mad/remotes/az-probes.d/host/monitor/probe_host_monitor.rb"
IM_PROBES_AZ_HOST_SYSTEM_FILES="\
src/im_mad/remotes/az-probes.d/host/system/probe_host_system.rb"
IM_PROBES_AZ_VM_MONITOR_FILES="\
src/im_mad/remotes/az-probes.d/vm/monitor/probe_vm_monitor.rb"
IM_PROBES_AZ_VM_STATUS_FILES="\
src/im_mad/remotes/az-probes.d/vm/status/probe_vm_status.rb"
IM_PROBES_ONE_FILES="src/im_mad/remotes/one.d/poll"
+20 -18
View File
@@ -12,24 +12,26 @@ GEM
xml-simple (>= 1.0.12)
augeas (0.6.4)
aws-eventstream (1.0.3)
aws-sdk (2.11.446)
aws-sdk-resources (= 2.11.446)
aws-sdk-core (2.11.446)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.11.446)
aws-sdk-core (= 2.11.446)
aws-sigv4 (1.1.0)
aws-partitions (1.289.0)
aws-sdk-core (3.92.0)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.0)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-ec2 (1.151.0)
aws-sdk-core (~> 3, >= 3.71.0)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.1.1)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_monitor (0.17.5)
ms_rest_azure (~> 0.11.1)
azure_mgmt_network (0.23.0)
azure_mgmt_network (0.23.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_resources (0.17.8)
ms_rest_azure (~> 0.11.1)
azure_mgmt_storage (0.19.2)
azure_mgmt_storage (0.19.3)
ms_rest_azure (~> 0.11.1)
builder (3.2.4)
chunky_png (1.3.11)
@@ -69,15 +71,15 @@ GEM
mime-types-data (3.2019.1009)
mini_portile2 (2.1.0)
minitest (5.11.3)
ms_rest (0.7.5)
ms_rest (0.7.6)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
timeliness (~> 0.3.10)
ms_rest_azure (0.11.1)
ms_rest_azure (0.11.2)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
faraday-cookie_jar (~> 0.0.6)
ms_rest (~> 0.7.4)
ms_rest (~> 0.7.6)
unf_ext (= 0.0.7.2)
multipart-post (2.1.1)
mysql2 (0.5.3)
@@ -102,7 +104,7 @@ GEM
rqrcode (0.10.1)
chunky_png (~> 1.0)
scrub_rb (1.0.1)
sequel (5.29.0)
sequel (5.30.0)
sinatra (1.4.8)
rack (~> 1.5)
rack-protection (~> 1.4)
@@ -138,7 +140,7 @@ DEPENDENCIES
activesupport (~> 4.2)
amazon-ec2
augeas (~> 0.6)
aws-sdk (~> 2.5)
aws-sdk-ec2 (>= 1.151)
azure_mgmt_compute
azure_mgmt_monitor
azure_mgmt_network
+22 -20
View File
@@ -12,24 +12,26 @@ GEM
xml-simple (>= 1.0.12)
augeas (0.6.4)
aws-eventstream (1.0.3)
aws-sdk (2.11.446)
aws-sdk-resources (= 2.11.446)
aws-sdk-core (2.11.446)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.11.446)
aws-sdk-core (= 2.11.446)
aws-sigv4 (1.1.0)
aws-partitions (1.290.0)
aws-sdk-core (3.92.0)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.0)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-ec2 (1.151.0)
aws-sdk-core (~> 3, >= 3.71.0)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.1.1)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_monitor (0.17.5)
ms_rest_azure (~> 0.11.1)
azure_mgmt_network (0.23.0)
azure_mgmt_network (0.23.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_resources (0.17.8)
ms_rest_azure (~> 0.11.1)
azure_mgmt_storage (0.19.2)
azure_mgmt_storage (0.19.3)
ms_rest_azure (~> 0.11.1)
builder (3.2.4)
chunky_png (1.3.11)
@@ -69,22 +71,22 @@ GEM
mime-types-data (3.2019.1009)
mini_portile2 (2.4.0)
minitest (5.14.0)
ms_rest (0.7.5)
ms_rest (0.7.6)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
timeliness (~> 0.3.10)
ms_rest_azure (0.11.1)
ms_rest_azure (0.11.2)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
faraday-cookie_jar (~> 0.0.6)
ms_rest (~> 0.7.4)
ms_rest (~> 0.7.6)
unf_ext (= 0.0.7.2)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
mysql2 (0.5.3)
net-ldap (0.16.2)
nokogiri (1.10.8)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
optimist (3.0.0)
ox (2.13.2)
@@ -104,9 +106,9 @@ GEM
rqrcode (1.1.2)
chunky_png (~> 1.0)
rqrcode_core (~> 0.1)
rqrcode_core (0.1.1)
rqrcode_core (0.1.2)
ruby2_keywords (0.0.2)
sequel (5.29.0)
sequel (5.30.0)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
@@ -144,7 +146,7 @@ DEPENDENCIES
activesupport (~> 4.2)
amazon-ec2
augeas (~> 0.6)
aws-sdk (~> 2.5)
aws-sdk-ec2 (>= 1.151)
azure_mgmt_compute
azure_mgmt_monitor
azure_mgmt_network
+22 -20
View File
@@ -12,24 +12,26 @@ GEM
xml-simple (>= 1.0.12)
augeas (0.6.4)
aws-eventstream (1.0.3)
aws-sdk (2.11.446)
aws-sdk-resources (= 2.11.446)
aws-sdk-core (2.11.446)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.11.446)
aws-sdk-core (= 2.11.446)
aws-sigv4 (1.1.0)
aws-partitions (1.290.0)
aws-sdk-core (3.92.0)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.0)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-ec2 (1.151.0)
aws-sdk-core (~> 3, >= 3.71.0)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.1.1)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_monitor (0.17.5)
ms_rest_azure (~> 0.11.1)
azure_mgmt_network (0.23.0)
azure_mgmt_network (0.23.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_resources (0.17.8)
ms_rest_azure (~> 0.11.1)
azure_mgmt_storage (0.19.2)
azure_mgmt_storage (0.19.3)
ms_rest_azure (~> 0.11.1)
builder (3.2.4)
chunky_png (1.3.11)
@@ -69,22 +71,22 @@ GEM
mime-types-data (3.2019.1009)
mini_portile2 (2.4.0)
minitest (5.14.0)
ms_rest (0.7.5)
ms_rest (0.7.6)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
timeliness (~> 0.3.10)
ms_rest_azure (0.11.1)
ms_rest_azure (0.11.2)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
faraday-cookie_jar (~> 0.0.6)
ms_rest (~> 0.7.4)
ms_rest (~> 0.7.6)
unf_ext (= 0.0.7.2)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
mysql2 (0.5.3)
net-ldap (0.16.2)
nokogiri (1.10.8)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
optimist (3.0.0)
ox (2.13.2)
@@ -104,9 +106,9 @@ GEM
rqrcode (1.1.2)
chunky_png (~> 1.0)
rqrcode_core (~> 0.1)
rqrcode_core (0.1.1)
rqrcode_core (0.1.2)
ruby2_keywords (0.0.2)
sequel (5.29.0)
sequel (5.30.0)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
@@ -144,7 +146,7 @@ DEPENDENCIES
activesupport (~> 4.2)
amazon-ec2
augeas (~> 0.6)
aws-sdk (~> 2.5)
aws-sdk-ec2 (>= 1.151)
azure_mgmt_compute
azure_mgmt_monitor
azure_mgmt_network
+22 -20
View File
@@ -12,24 +12,26 @@ GEM
xml-simple (>= 1.0.12)
augeas (0.6.4)
aws-eventstream (1.0.3)
aws-sdk (2.11.446)
aws-sdk-resources (= 2.11.446)
aws-sdk-core (2.11.446)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.11.446)
aws-sdk-core (= 2.11.446)
aws-sigv4 (1.1.0)
aws-partitions (1.290.0)
aws-sdk-core (3.92.0)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.0)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-ec2 (1.151.0)
aws-sdk-core (~> 3, >= 3.71.0)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.1.1)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_monitor (0.17.5)
ms_rest_azure (~> 0.11.1)
azure_mgmt_network (0.23.0)
azure_mgmt_network (0.23.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_resources (0.17.8)
ms_rest_azure (~> 0.11.1)
azure_mgmt_storage (0.19.2)
azure_mgmt_storage (0.19.3)
ms_rest_azure (~> 0.11.1)
builder (3.2.4)
chunky_png (1.3.11)
@@ -69,22 +71,22 @@ GEM
mime-types-data (3.2019.1009)
mini_portile2 (2.4.0)
minitest (5.14.0)
ms_rest (0.7.5)
ms_rest (0.7.6)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
timeliness (~> 0.3.10)
ms_rest_azure (0.11.1)
ms_rest_azure (0.11.2)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
faraday-cookie_jar (~> 0.0.6)
ms_rest (~> 0.7.4)
ms_rest (~> 0.7.6)
unf_ext (= 0.0.7.2)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
mysql2 (0.5.3)
net-ldap (0.16.2)
nokogiri (1.10.8)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
optimist (3.0.0)
ox (2.13.2)
@@ -104,9 +106,9 @@ GEM
rqrcode (1.1.2)
chunky_png (~> 1.0)
rqrcode_core (~> 0.1)
rqrcode_core (0.1.1)
rqrcode_core (0.1.2)
ruby2_keywords (0.0.2)
sequel (5.29.0)
sequel (5.30.0)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
@@ -143,7 +145,7 @@ DEPENDENCIES
activesupport (~> 4.2)
amazon-ec2
augeas (~> 0.6)
aws-sdk (~> 2.5)
aws-sdk-ec2 (>= 1.151)
azure_mgmt_compute
azure_mgmt_monitor
azure_mgmt_network
+1 -1
View File
@@ -68,7 +68,7 @@ gem 'azure_mgmt_resources' # hybrid
gem 'azure_mgmt_storage' # hybrid
gem 'rbvmomi', '~> 2.2.0' # vmware
gem 'parse-cron' # oneflow
gem 'aws-sdk', '~> 2.5' # ec2_hybrid
gem 'aws-sdk-ec2', '>=1.151' # ec2_hybrid
gem 'ox' # oca
gem 'highline', '~> 1.7' # oneprovision
gem 'faraday', '~> 0.15' # packethost
+22 -20
View File
@@ -12,24 +12,26 @@ GEM
xml-simple (>= 1.0.12)
augeas (0.6.4)
aws-eventstream (1.0.3)
aws-sdk (2.11.446)
aws-sdk-resources (= 2.11.446)
aws-sdk-core (2.11.446)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.11.446)
aws-sdk-core (= 2.11.446)
aws-sigv4 (1.1.0)
aws-partitions (1.290.0)
aws-sdk-core (3.92.0)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.0)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-ec2 (1.151.0)
aws-sdk-core (~> 3, >= 3.71.0)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.1.1)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_monitor (0.17.5)
ms_rest_azure (~> 0.11.1)
azure_mgmt_network (0.23.0)
azure_mgmt_network (0.23.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_resources (0.17.8)
ms_rest_azure (~> 0.11.1)
azure_mgmt_storage (0.19.2)
azure_mgmt_storage (0.19.3)
ms_rest_azure (~> 0.11.1)
builder (3.2.4)
chunky_png (1.3.11)
@@ -69,22 +71,22 @@ GEM
mime-types-data (3.2019.1009)
mini_portile2 (2.4.0)
minitest (5.14.0)
ms_rest (0.7.5)
ms_rest (0.7.6)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
timeliness (~> 0.3.10)
ms_rest_azure (0.11.1)
ms_rest_azure (0.11.2)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
faraday-cookie_jar (~> 0.0.6)
ms_rest (~> 0.7.4)
ms_rest (~> 0.7.6)
unf_ext (= 0.0.7.2)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
mysql2 (0.5.3)
net-ldap (0.16.2)
nokogiri (1.10.8)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
optimist (3.0.0)
ox (2.13.2)
@@ -104,9 +106,9 @@ GEM
rqrcode (1.1.2)
chunky_png (~> 1.0)
rqrcode_core (~> 0.1)
rqrcode_core (0.1.1)
rqrcode_core (0.1.2)
ruby2_keywords (0.0.2)
sequel (5.29.0)
sequel (5.30.0)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
@@ -143,7 +145,7 @@ DEPENDENCIES
activesupport (~> 4.2)
amazon-ec2
augeas (~> 0.6)
aws-sdk (~> 2.5)
aws-sdk-ec2 (>= 1.151)
azure_mgmt_compute
azure_mgmt_monitor
azure_mgmt_network
+22 -20
View File
@@ -12,24 +12,26 @@ GEM
xml-simple (>= 1.0.12)
augeas (0.6.4)
aws-eventstream (1.0.3)
aws-sdk (2.11.446)
aws-sdk-resources (= 2.11.446)
aws-sdk-core (2.11.446)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.11.446)
aws-sdk-core (= 2.11.446)
aws-sigv4 (1.1.0)
aws-partitions (1.290.0)
aws-sdk-core (3.92.0)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.0)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-ec2 (1.151.0)
aws-sdk-core (~> 3, >= 3.71.0)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.1.1)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_monitor (0.17.5)
ms_rest_azure (~> 0.11.1)
azure_mgmt_network (0.23.0)
azure_mgmt_network (0.23.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_resources (0.17.8)
ms_rest_azure (~> 0.11.1)
azure_mgmt_storage (0.19.2)
azure_mgmt_storage (0.19.3)
ms_rest_azure (~> 0.11.1)
builder (3.2.4)
chunky_png (1.3.11)
@@ -69,22 +71,22 @@ GEM
mime-types-data (3.2019.1009)
mini_portile2 (2.4.0)
minitest (5.14.0)
ms_rest (0.7.5)
ms_rest (0.7.6)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
timeliness (~> 0.3.10)
ms_rest_azure (0.11.1)
ms_rest_azure (0.11.2)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
faraday-cookie_jar (~> 0.0.6)
ms_rest (~> 0.7.4)
ms_rest (~> 0.7.6)
unf_ext (= 0.0.7.2)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
mysql2 (0.5.3)
net-ldap (0.16.2)
nokogiri (1.10.8)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
optimist (3.0.0)
ox (2.13.2)
@@ -104,9 +106,9 @@ GEM
rqrcode (1.1.2)
chunky_png (~> 1.0)
rqrcode_core (~> 0.1)
rqrcode_core (0.1.1)
rqrcode_core (0.1.2)
ruby2_keywords (0.0.2)
sequel (5.29.0)
sequel (5.30.0)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
@@ -144,7 +146,7 @@ DEPENDENCIES
activesupport (~> 4.2)
amazon-ec2
augeas (~> 0.6)
aws-sdk (~> 2.5)
aws-sdk-ec2 (>= 1.151)
azure_mgmt_compute
azure_mgmt_monitor
azure_mgmt_network
+22 -20
View File
@@ -12,24 +12,26 @@ GEM
xml-simple (>= 1.0.12)
augeas (0.6.4)
aws-eventstream (1.0.3)
aws-sdk (2.11.446)
aws-sdk-resources (= 2.11.446)
aws-sdk-core (2.11.446)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.11.446)
aws-sdk-core (= 2.11.446)
aws-sigv4 (1.1.0)
aws-partitions (1.290.0)
aws-sdk-core (3.92.0)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.0)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-ec2 (1.151.0)
aws-sdk-core (~> 3, >= 3.71.0)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.1.1)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_monitor (0.17.5)
ms_rest_azure (~> 0.11.1)
azure_mgmt_network (0.23.0)
azure_mgmt_network (0.23.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_resources (0.17.8)
ms_rest_azure (~> 0.11.1)
azure_mgmt_storage (0.19.2)
azure_mgmt_storage (0.19.3)
ms_rest_azure (~> 0.11.1)
builder (3.2.4)
chunky_png (1.3.11)
@@ -69,22 +71,22 @@ GEM
mime-types-data (3.2019.1009)
mini_portile2 (2.4.0)
minitest (5.14.0)
ms_rest (0.7.5)
ms_rest (0.7.6)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
timeliness (~> 0.3.10)
ms_rest_azure (0.11.1)
ms_rest_azure (0.11.2)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
faraday-cookie_jar (~> 0.0.6)
ms_rest (~> 0.7.4)
ms_rest (~> 0.7.6)
unf_ext (= 0.0.7.2)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
mysql2 (0.5.3)
net-ldap (0.16.2)
nokogiri (1.10.8)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
optimist (3.0.0)
ox (2.13.2)
@@ -104,9 +106,9 @@ GEM
rqrcode (1.1.2)
chunky_png (~> 1.0)
rqrcode_core (~> 0.1)
rqrcode_core (0.1.1)
rqrcode_core (0.1.2)
ruby2_keywords (0.0.2)
sequel (5.29.0)
sequel (5.30.0)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
@@ -144,7 +146,7 @@ DEPENDENCIES
activesupport (~> 4.2)
amazon-ec2
augeas (~> 0.6)
aws-sdk (~> 2.5)
aws-sdk-ec2 (>= 1.151)
azure_mgmt_compute
azure_mgmt_monitor
azure_mgmt_network
+22 -20
View File
@@ -12,24 +12,26 @@ GEM
xml-simple (>= 1.0.12)
augeas (0.6.4)
aws-eventstream (1.0.3)
aws-sdk (2.11.446)
aws-sdk-resources (= 2.11.446)
aws-sdk-core (2.11.446)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-resources (2.11.446)
aws-sdk-core (= 2.11.446)
aws-sigv4 (1.1.0)
aws-partitions (1.290.0)
aws-sdk-core (3.92.0)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.0)
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-ec2 (1.151.0)
aws-sdk-core (~> 3, >= 3.71.0)
aws-sigv4 (~> 1.1)
aws-sigv4 (1.1.1)
aws-eventstream (~> 1.0, >= 1.0.2)
azure_mgmt_compute (0.19.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_monitor (0.17.5)
ms_rest_azure (~> 0.11.1)
azure_mgmt_network (0.23.0)
azure_mgmt_network (0.23.1)
ms_rest_azure (~> 0.11.1)
azure_mgmt_resources (0.17.8)
ms_rest_azure (~> 0.11.1)
azure_mgmt_storage (0.19.2)
azure_mgmt_storage (0.19.3)
ms_rest_azure (~> 0.11.1)
builder (3.2.4)
chunky_png (1.3.11)
@@ -69,22 +71,22 @@ GEM
mime-types-data (3.2019.1009)
mini_portile2 (2.4.0)
minitest (5.14.0)
ms_rest (0.7.5)
ms_rest (0.7.6)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
timeliness (~> 0.3.10)
ms_rest_azure (0.11.1)
ms_rest_azure (0.11.2)
concurrent-ruby (~> 1.0)
faraday (~> 0.9)
faraday (>= 0.9, < 2.0.0)
faraday-cookie_jar (~> 0.0.6)
ms_rest (~> 0.7.4)
ms_rest (~> 0.7.6)
unf_ext (= 0.0.7.2)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
mysql2 (0.5.3)
net-ldap (0.16.2)
nokogiri (1.10.8)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
optimist (3.0.0)
ox (2.13.2)
@@ -104,9 +106,9 @@ GEM
rqrcode (1.1.2)
chunky_png (~> 1.0)
rqrcode_core (~> 0.1)
rqrcode_core (0.1.1)
rqrcode_core (0.1.2)
ruby2_keywords (0.0.2)
sequel (5.29.0)
sequel (5.30.0)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
@@ -144,7 +146,7 @@ DEPENDENCIES
activesupport (~> 4.2)
amazon-ec2
augeas (~> 0.6)
aws-sdk (~> 2.5)
aws-sdk-ec2 (>= 1.151)
azure_mgmt_compute
azure_mgmt_monitor
azure_mgmt_network
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
# Copyright 2002-2020, 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 #
@@ -16,14 +16,14 @@
# limitations under the License. #
# -------------------------------------------------------------------------- #
ONE_LOCATION = ENV['ONE_LOCATION'] if !defined?(ONE_LOCATION)
ONE_LOCATION ||= ENV['ONE_LOCATION'] if !defined? ONE_LOCATION
if !ONE_LOCATION
RUBY_LIB_LOCATION = '/usr/lib/one/ruby' if !defined?(RUBY_LIB_LOCATION)
GEMS_LOCATION = '/usr/share/one/gems' if !defined?(GEMS_LOCATION)
RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby'
GEMS_LOCATION ||= '/usr/share/one/gems'
else
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby' if !defined?(RUBY_LIB_LOCATION)
GEMS_LOCATION = ONE_LOCATION + '/share/gems' if !defined?(GEMS_LOCATION)
RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby'
GEMS_LOCATION ||= ONE_LOCATION + '/share/gems'
end
if File.directory?(GEMS_LOCATION)
@@ -34,11 +34,12 @@ $LOAD_PATH << RUBY_LIB_LOCATION
require 'az_driver'
host = ARGV[-1]
az_drv = AzureDriver.new(host)
host = ARGV[-1]
host_id = ARGV[-2]
az_drv = AzureDriver.new(host, host_id)
begin
az_drv.monitor_all_vms
puts az_drv.probe_host_monitor
rescue => e
OpenNebula.handle_driver_exception("im poll", e, host)
OpenNebula.handle_driver_exception("im probe_host_monitor", e, host)
end
@@ -0,0 +1,45 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2020, 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. #
# -------------------------------------------------------------------------- #
ONE_LOCATION = ENV['ONE_LOCATION'] if !defined? ONE_LOCATION
if !ONE_LOCATION
RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby'
GEMS_LOCATION ||= '/usr/share/one/gems'
else
RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby'
GEMS_LOCATION ||= ONE_LOCATION + '/share/gems'
end
if File.directory?(GEMS_LOCATION)
Gem.use_paths(GEMS_LOCATION)
end
$LOAD_PATH << RUBY_LIB_LOCATION
require 'az_driver'
host = ARGV[-1]
host_id = ARGV[-2]
az_drv = AzureDriver.new(host, host_id)
begin
puts az_drv.probe_host_system
rescue => e
OpenNebula.handle_driver_exception("im probe_host_system", e, host)
end
@@ -0,0 +1,45 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2020, 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. #
# -------------------------------------------------------------------------- #
ONE_LOCATION ||= ENV['ONE_LOCATION'] if !defined? ONE_LOCATION
if !ONE_LOCATION
RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby'
GEMS_LOCATION ||= '/usr/share/one/gems'
else
RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby'
GEMS_LOCATION ||= ONE_LOCATION + '/share/gems'
end
if File.directory?(GEMS_LOCATION)
Gem.use_paths(GEMS_LOCATION)
end
$LOAD_PATH << RUBY_LIB_LOCATION
require 'az_driver'
host = ARGV[-1]
host_id = ARGV[-2]
az_drv = AzureDriver.new(host, host_id)
begin
puts az_drv.probe_vm_monitor
rescue => e
OpenNebula.handle_driver_exception("im probe_vm_monitor", e, host)
end
@@ -0,0 +1,49 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2020, 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. #
# -------------------------------------------------------------------------- #
ONE_LOCATION ||= ENV['ONE_LOCATION'] if !defined? ONE_LOCATION
if !ONE_LOCATION
RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby'
GEMS_LOCATION ||= '/usr/share/one/gems'
else
RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby'
GEMS_LOCATION ||= ONE_LOCATION + '/share/gems'
end
if File.directory?(GEMS_LOCATION)
Gem.use_paths(GEMS_LOCATION)
end
$LOAD_PATH << RUBY_LIB_LOCATION
require 'az_driver'
require_relative '../../../lib/probe_db'
host = ARGV[-1]
host_id = ARGV[-2]
begin
vmdb = VirtualMachineDB.new('az',
:missing_state => 'UNKNOWN',
:sync => 180)
vmdb.purge
puts vmdb.to_status(host, host_id)
rescue => e
OpenNebula.handle_driver_exception("im probe_vm_status", e, host)
end
+1
View File
@@ -0,0 +1 @@
../common.d/monitord-client.rb
+1
View File
@@ -0,0 +1 @@
../common.d/monitord-client_control.sh
+23 -10
View File
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
# Copyright 2002-2020, 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 #
@@ -29,9 +29,10 @@ require 'rexml/document'
require_relative '../lib/probe_db'
#-------------------------------------------------------------------------------
# This class represents a monitord client. It handles udp and tcp connections
# and send update messages to monitord
#
#-------------------------------------------------------------------------------
class MonitorClient
# Defined in src/monitor/include/MonitorDriverMessages.h
@@ -110,9 +111,10 @@ class MonitorClient
end
#-------------------------------------------------------------------------------
# This class wraps the execution of a probe directory and sends data to
# monitord (optionally)
#
#-------------------------------------------------------------------------------
class ProbeRunner
def initialize(hyperv, path, stdin)
@@ -212,26 +214,32 @@ class ProbeRunner
end
#-------------------------------------------------------------------------------
# Script helper functions and gLobals
#-------------------------------------------------------------------------------
LOCAL_HYPERVISOR = %w[az ec2 packet].freeze
def local?(hypervisor)
LOCAL_HYPERVISOR.include?(hypervisor)
end
#-------------------------------------------------------------------------------
# Configuration (from monitord)
#-------------------------------------------------------------------------------
xml_txt = STDIN.read
begin
config = REXML::Document.new(xml_txt).root
hyperv = ARGV[0].split(' ')[0]
xml_txt = Base64.decode64(xml_txt) if local? hyperv
config = REXML::Document.new(xml_txt).root
host = config.elements['UDP_LISTENER/MONITOR_ADDRESS'].text.to_s
port = config.elements['UDP_LISTENER/PORT'].text.to_s
pubkey = config.elements['UDP_LISTENER/PUBKEY'].text.to_s
hostid = config.elements['HOST_ID'].text.to_s
hyperv = ARGV[0].split(' ')[0]
probes = {
:beacon_host_udp => {
:period => config.elements['PROBES_PERIOD/BEACON_HOST'].text.to_s,
:path => 'host/beacon'
},
:system_host_udp => {
:period => config.elements['PROBES_PERIOD/SYSTEM_HOST'].text.to_s,
:path => 'host/system'
@@ -253,6 +261,11 @@ begin
}
}
probes[:beacon_host_udp] = {
:period => config.elements['PROBES_PERIOD/BEACON_HOST'].text.to_s,
:path => 'host/beacon'
} unless local? hyperv
if !pubkey.empty?
exp = /(-+BEGIN RSA PUBLIC KEY-+)([^-]*)(-+END RSA PUBLIC KEY-+)/
m = pubkey.match(exp)
@@ -1,7 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
# Copyright 2002-2020, 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 #
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
# Copyright 2002-2020, 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 #
@@ -16,14 +16,14 @@
# limitations under the License. #
# -------------------------------------------------------------------------- #
ONE_LOCATION = ENV['ONE_LOCATION'] if !defined?(ONE_LOCATION)
ONE_LOCATION ||= ENV['ONE_LOCATION'] if !defined? ONE_LOCATION
if !ONE_LOCATION
RUBY_LIB_LOCATION = '/usr/lib/one/ruby' if !defined?(RUBY_LIB_LOCATION)
GEMS_LOCATION = '/usr/share/one/gems' if !defined?(GEMS_LOCATION)
RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby'
GEMS_LOCATION ||= '/usr/share/one/gems'
else
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby' if !defined?(RUBY_LIB_LOCATION)
GEMS_LOCATION = ONE_LOCATION + '/share/gems' if !defined?(GEMS_LOCATION)
RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby'
GEMS_LOCATION ||= ONE_LOCATION + '/share/gems'
end
if File.directory?(GEMS_LOCATION)
@@ -39,8 +39,8 @@ host_id = ARGV[-2]
ec2_drv = EC2Driver.new(host, host_id)
begin
ec2_drv.monitor_all_vms
puts ec2_drv.probe_host_monitor
rescue Exception => e
OpenNebula.handle_driver_exception("im poll", e, host)
OpenNebula.handle_driver_exception("im probe_host_monitor", e, host)
end
@@ -0,0 +1,47 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2020, 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. #
# -------------------------------------------------------------------------- #
ONE_LOCATION = ENV['ONE_LOCATION'] if !defined? ONE_LOCATION
if !ONE_LOCATION
RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby'
GEMS_LOCATION ||= '/usr/share/one/gems'
else
RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby'
GEMS_LOCATION ||= ONE_LOCATION + '/share/gems'
end
if File.directory?(GEMS_LOCATION)
Gem.use_paths(GEMS_LOCATION)
end
$LOAD_PATH << RUBY_LIB_LOCATION
require 'ec2_driver'
host = ARGV[-1]
host_id = ARGV[-2]
ec2_drv = EC2Driver.new(host, host_id)
begin
puts ec2_drv.probe_host_system
rescue Exception => e
OpenNebula.handle_driver_exception("im probe_host_system", e, host)
end
@@ -0,0 +1,46 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2020, 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. #
# -------------------------------------------------------------------------- #
ONE_LOCATION ||= ENV['ONE_LOCATION'] if !defined? ONE_LOCATION
if !ONE_LOCATION
RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby'
GEMS_LOCATION ||= '/usr/share/one/gems'
else
RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby'
GEMS_LOCATION ||= ONE_LOCATION + '/share/gems'
end
if File.directory?(GEMS_LOCATION)
Gem.use_paths(GEMS_LOCATION)
end
$LOAD_PATH << RUBY_LIB_LOCATION
require 'ec2_driver'
host = ARGV[-1]
host_id = ARGV[-2]
ec2_drv = EC2Driver.new(host, host_id)
begin
puts ec2_drv.probe_vm_monitor
rescue Exception => e
OpenNebula.handle_driver_exception("im probe_vm_monitor", e, host)
end
@@ -0,0 +1,49 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2020, 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. #
# -------------------------------------------------------------------------- #
ONE_LOCATION ||= ENV['ONE_LOCATION'] if !defined? ONE_LOCATION
if !ONE_LOCATION
RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby'
GEMS_LOCATION ||= '/usr/share/one/gems'
else
RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby'
GEMS_LOCATION ||= ONE_LOCATION + '/share/gems'
end
if File.directory?(GEMS_LOCATION)
Gem.use_paths(GEMS_LOCATION)
end
$LOAD_PATH << RUBY_LIB_LOCATION
require 'ec2_driver'
require_relative '../../../lib/probe_db'
host = ARGV[-1]
host_id = ARGV[-2]
begin
vmdb = VirtualMachineDB.new('ec2',
:missing_state => 'UNKNOWN',
:sync => 180)
vmdb.purge
puts vmdb.to_status(host, host_id)
rescue => e
OpenNebula.handle_driver_exception("im probe_vm_status", e, host)
end
+1
View File
@@ -0,0 +1 @@
../common.d/monitord-client.rb
+1
View File
@@ -0,0 +1 @@
../common.d/monitord-client_control.sh
@@ -4,6 +4,8 @@ require_relative '../../../lib/probe_db'
require_relative '../../../lib/firecracker'
xml_txt = STDIN.read
host = ARGV[-1]
host_id = ARGV[-2]
begin
config = REXML::Document.new(xml_txt).root
@@ -18,7 +20,7 @@ begin
:sync => sync)
vmdb.purge
puts vmdb.to_status
puts vmdb.to_status(host, host_id)
rescue StandardError => e
puts e
end
@@ -4,6 +4,8 @@ require_relative '../../../lib/kvm'
require_relative '../../../lib/probe_db'
xml_txt = STDIN.read
host = ARGV[-1]
host_id = ARGV[-2]
begin
config = REXML::Document.new(xml_txt).root
@@ -20,7 +22,7 @@ begin
:sync => sync)
vmdb.purge
puts vmdb.to_status
puts vmdb.to_status(host, host_id)
rescue StandardError => e
puts e
end
+1 -1
View File
@@ -385,7 +385,7 @@ module DomainList
domains.to_monitor
end
def self.state_info
def self.state_info(host, host_id)
domains = FirecrackerDomains.new
domains.state_info
+1 -5
View File
@@ -449,7 +449,7 @@ module DomainList
domains.wilds_to_monitor
end
def self.state_info
def self.state_info(host, host_id)
domains = KVMDomains.new
domains.state_info
@@ -501,10 +501,6 @@ module DomainList
end
end
# Get the list of VMs (known and not known to OpenNebula) and their info
# not including process usage.
#
# @return [Hash] with KVM Domain classes indexed by their uuid
def state_info
info_each(false) do |name|
vm = Domain.new name
+13 -12
View File
@@ -1,7 +1,7 @@
#!/usr/bin/ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
# Copyright 2002-2020, 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 #
@@ -16,14 +16,14 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
ONE_LOCATION = ENV['ONE_LOCATION']
ONE_LOCATION = ENV['ONE_LOCATION'] if !defined? ONE_LOCATION
if !ONE_LOCATION
RUBY_LIB_LOCATION = '/usr/lib/one/ruby'
GEMS_LOCATION = '/usr/share/one/gems'
RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby'
GEMS_LOCATION ||= '/usr/share/one/gems'
else
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby'
GEMS_LOCATION = ONE_LOCATION + '/share/gems'
RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby'
GEMS_LOCATION ||= ONE_LOCATION + '/share/gems'
end
if File.directory?(GEMS_LOCATION)
@@ -89,17 +89,17 @@ class VirtualMachineDB
# Returns the VM status that changed compared to the DB info as well
# as VMs that have been reported as missing more than missing_times
def to_status
def to_status(host, host_id)
time = Time.now.to_i
last = @db.execute("SELECT MAX(timestamp) from #{@dataset}").flatten![0]
last ||= 0
return sync_status if time > (last + @conf[:sync]) && last != 0
return sync_status(host, host_id) if time > (last + @conf[:sync]) && last != 0
status_str = ''
monitor_ids = []
vms = DomainList.state_info
vms = DomainList.state_info(host, host_id)
# ----------------------------------------------------------------------
# report state changes in vms
@@ -108,7 +108,8 @@ class VirtualMachineDB
if vm[:id] == -1
filter = "WHERE uuid = '#{uuid}'"
else
filter = "WHERE id = '#{vm[:id]}'"
# in ec2 id could first be -1 but later added, check also uuid
filter = "WHERE id = '#{vm[:id]}' OR uuid = '#{uuid}'"
end
vm_db = @db.execute("SELECT * FROM #{@dataset} #{filter}").first
@@ -191,14 +192,14 @@ class VirtualMachineDB
private
def sync_status
def sync_status(host, host_id)
time = Time.now.to_i
@db.execute("DELETE FROM #{@dataset}")
status_str = "SYNC_STATE=yes\nMISSING_STATE=#{@conf[:missing_state]}\n"
DomainList.state_info.each do |uuid, vm|
DomainList.state_info(host, host_id).each do |uuid, vm|
@db.execute(
"INSERT INTO #{@dataset} VALUES (?, ?, ?, ?, ?, ?, ?)",
[uuid,
@@ -20,7 +20,11 @@ module DomainList
}
# Returns a vm hash with the containers running in LXD
def self.state_info
# @param host [String] name of the host (not used here)
# @param host_id [Integer] ID of the host (not used here)
#
# @return [Hash] with KVM Domain classes indexed by their name
def self.state_info(host, host_id)
containers = Container.get_all(LXD::CLIENT)
return unless containers
@@ -62,6 +66,8 @@ module DomainList
end
xml_txt = STDIN.read
host = ARGV[-1]
host_id = ARGV[-2]
begin
config = REXML::Document.new(xml_txt).root
@@ -76,7 +82,7 @@ begin
:sync => sync)
vmdb.purge
puts vmdb.to_status
puts vmdb.to_status(host, host_id)
rescue StandardError => e
puts e
end
+264
View File
@@ -0,0 +1,264 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2020, 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. #
#--------------------------------------------------------------------------- #
require 'sqlite3'
# ------------------------------------------------------------------------------
# Class for public drivers (AZ, EC2) It provides common interface to interact
# wiht the abstract host that representats a public cloud in OpenNebula
# ------------------------------------------------------------------------------
module PublicCloudDriver
#---------------------------------------------------------------------------
# MODULE Main Interface
# --------------------------------------------------------------------------
# Returns host monitoring data
#
# @return [String]
def probe_host_monitor(db, limit, xmlhost)
total_cpu, total_mem = host_capacity(xmlhost)
used_cpu, used_mem = used_capacity(db, limit)
data = "HYPERVISOR=#{@hypervisor}\n"
data << "PUBLIC_CLOUD=YES\n"
data << "USEDCPU=#{used_cpu}\n"
data << "USEDMEMORY=#{used_mem}\n"
data << "FREECPU=#{total_cpu - used_cpu}\n"
data << "FREEMEMORY=#{total_mem - used_mem}"
data
end
# Returns host information including wild VMs
#
# @return [String]
def probe_host_system(db, limit, xmlhost)
total_cpu, total_mem = host_capacity(xmlhost)
data = "HYPERVISOR=#{@hypervisor}\n"
data << "PUBLIC_CLOUD=YES\n"
data << "TOTALCPU=#{total_cpu}\n"
data << "TOTALMEMORY=#{total_mem}\n"
# include wild instances
vms = vms_data(db, limit)
vms.each do |vm|
next unless vm[:id] == -1
vm[:import_template] = vm_to_one(vm)
vm[:vm_name] = vm[:name]
vm.delete(:name)
data << hash_to_template(vm, 'VM = [ ', " ]\n")
end
data
end
# Returns VM monitor information
#
# @return [String]
def probe_vm_monitor
vms = fetch_vms_data(true)
data = ''
vms.each do |vm|
data << hash_to_template(vm, 'VM = [ ', " ]\n")
end
data
end
#---------------------------------------------------------------------------
# MODULE Helper functions
# --------------------------------------------------------------------------
# Either return VMs info from cache db or from public_cloud
def vms_data(db, time_limit)
return fetch_vms_data(false) if db.expired?(time_limit)
db.select_vms
end
# Return the information of a host in xml format
# @param host_id [Integer] ID of the host
#
# @return [Host, nil]
def host_info(host, host_id)
client = OpenNebula::Client.new
if host_id.nil?
pool = OpenNebula::HostPool.new(client)
pool.info
objects = pool.select {|object| object.name==host }
host_id = objects.first.id
end
xmlhost = OpenNebula::Host.new_with_id(host_id, client)
rc = xmlhost.info(true)
raise rc.to_str() if OpenNebula.is_error?(rc)
xmlhost
end
# Return count total cpu and memory based on instance type numbers in host
# template
# @param xmlhost [OpenNebula::XMLElement] xml host object
#
# @return [Array] total cpu, total memory
def host_capacity(xmlhost)
capacity = xmlhost.retrieve_xmlelements('/HOST/TEMPLATE/CAPACITY/*')
raise 'Missing CAPACITY section in Host template' if capacity.nil?
total_memory = total_cpu = 0
capacity.each do |element|
name = element.name
value = element.text
name = parse_inst_type(name) if self.respond_to? :parse_inst_type
cpu, mem = instance_type_capacity(name)
total_memory += mem * value.to_i
total_cpu += cpu * value.to_i
end
[total_cpu, total_memory]
end
# Count cpu + mem of running instances
#
# @return [Array] used cpu, used memory
def used_capacity(db, limit)
vms = vms_data(db, limit)
used_memory = used_cpu = 0
vms.each do |vm|
cpu, mem = instance_type_capacity(vm[:type])
used_memory += mem
used_cpu += cpu
end
[used_cpu, used_memory]
end
# Build template for importation
def vm_to_one(vm)
cpu, mem = instance_type_capacity(vm[:type])
mem = mem.to_i / 1024 # Memory for templates expressed in MB
cpu = cpu.to_f / 100 # CPU expressed in units
str = "NAME = \"Instance from #{vm[:name]}\"\n"\
"CPU = \"#{cpu}\"\n"\
"vCPU = 1\n"\
"MEMORY = \"#{mem}\"\n"\
"PUBLIC_CLOUD = [\n"\
" TYPE =\"#{@hypervisor}\"\n"\
"]\n"\
"IMPORT_VM_ID = \"#{vm[:uuid]}\"\n"\
"SCHED_REQUIREMENTS = \"NAME=\\\"#{@host}\\\"\"\n"\
"DESCRIPTION = \"Imported from #{@hypervisor} from #{vm[:name]}\"\n"
Base64.strict_encode64(str)
end
# Hash to ONE template format
def hash_to_template(h, pref = '', post = '')
tmpl = h.to_a.map {|e| "#{e[0].to_s.upcase}=\"#{e[1]}\"" }.join(', ')
pref + tmpl + post
end
end
# ------------------------------------------------------------------------------
# This class implements a simple local cache to store VM information
# ------------------------------------------------------------------------------
class InstanceCache
def initialize(path)
@db = SQLite3::Database.new(path)
bootstrap
end
def execute_retry(query, tries=5, tsleep=0.5)
i=0
while i < tries
begin
return @db.execute(query)
rescue SQLite3::BusyException
i += 1
sleep 0.5
end
end
end
#TODO document DB schema
def bootstrap
sql = 'CREATE TABLE IF NOT EXISTS vms(uuid VARCHAR(128) PRIMARY KEY,'
sql << ' id INTEGER, name VARCHAR(128), state VARCHAR(128),'
sql << ' type VARCHAR(128))'
execute_retry(sql)
sql = 'CREATE TABLE IF NOT EXISTS timestamp(ts INTEGER PRIMARY KEY)'
execute_retry(sql)
end
def insert(instances)
execute_retry('DELETE from vms')
instances.each do |i|
sql = 'INSERT INTO vms VALUES ('
sql << "\"#{i[:uuid]}\", "
sql << "\"#{i[:id]}\", "
sql << "\"#{i[:name]}\", "
sql << "\"#{i[:state]}\", "
sql << "\"#{i[:type]}\")"
execute_retry(sql)
end
execute_retry('DELETE from timestamp')
execute_retry("INSERT INTO timestamp VALUES (#{Time.now.to_i})")
end
def select_vms()
vms = []
execute_retry('SELECT * from vms').each do |vm|
vms << Hash[[:uuid, :id, :name, :state, :type].zip(vm)]
end
vms
end
# return true if the cache data expired
#
# @param[Integer] time_limit time to expire cache data
#
# @return[Boolean]
def expired?(time_limit)
ts = execute_retry('SELECT * from timestamp')
ts.empty? || (Time.now.to_i - time_limit > ts.first.first)
end
end
+3 -3
View File
@@ -1,6 +1,6 @@
proxy_uri:
rgroup_name_format: one-%<NAME>s-%<ID>s
instance_types:
:proxy_uri:
:rgroup_name_format: one-%<NAME>s-%<ID>s
:instance_types:
Standard_B1ls:
memory: 0.5
cpu: 1
+255 -244
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
# Copyright 2002-2020, 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 #
@@ -15,20 +15,23 @@
# limitations under the License. #
# -------------------------------------------------------------------------- #
ONE_LOCATION ||= ENV['ONE_LOCATION']
ONE_LOCATION ||= ENV['ONE_LOCATION'] if !defined? ONE_LOCATION
if !ONE_LOCATION
RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby'
GEMS_LOCATION ||= '/usr/share/one/gems'
ETC_LOCATION ||= '/etc/one/'
VAR_LOCATION ||= '/var/lib/one/'
else
RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby'
GEMS_LOCATION ||= ONE_LOCATION + '/share/gems'
ETC_LOCATION ||= ONE_LOCATION + '/etc/'
RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby' if !defined?(RUBY_LIB_LOCATION)
GEMS_LOCATION ||= ONE_LOCATION + '/share/gems' if !defined?(GEMS_LOCATION)
ETC_LOCATION ||= ONE_LOCATION + '/etc/' if !defined?(ETC_LOCATION)
VAR_LOCATION ||= ONE_LOCATION + '/var/' if !defined?(VAR_LOCATION)
end
AZ_DRIVER_CONF = "#{ETC_LOCATION}/az_driver.conf"
AZ_DRIVER_CONF = "#{ETC_LOCATION}/az_driver.conf"
AZ_DRIVER_DEFAULT = "#{ETC_LOCATION}/az_driver.default"
AZ_DATABASE_PATH = "#{VAR_LOCATION}/remotes/im/az.d/az-cache.db"
if File.directory?(GEMS_LOCATION)
Gem.use_paths(GEMS_LOCATION)
@@ -45,31 +48,20 @@ require 'tempfile'
require 'CommandManager'
require 'scripts_common'
require 'VirtualMachineDriver'
require 'PublicCloudDriver'
require 'opennebula'
require 'azure_mgmt_compute'
require 'azure_mgmt_monitor'
require 'azure_mgmt_network'
require 'azure_mgmt_resources'
require 'azure_mgmt_storage'
#-------------------------------------------------------------------------------
# The main class for the Azure driver
#-------------------------------------------------------------------------------
class AzureDriver
ACTION = VirtualMachineDriver::ACTION
include PublicCloudDriver
# --------------------------------------------------------------------------
# Constants
# --------------------------------------------------------------------------
POLL_ATTRIBUTE = VirtualMachineDriver::POLL_ATTRIBUTE
VM_STATE = VirtualMachineDriver::VM_STATE
Compute = Azure::Compute::Profiles::Latest::Mgmt
Monitor = Azure::Monitor::Profiles::Latest::Mgmt
Network = Azure::Network::Profiles::Latest::Mgmt
Resources = Azure::Resources::Profiles::Latest::Mgmt
Storage = Azure::Storage::Profiles::Latest::Mgmt
ComputeModels = Compute::Models
NetworkModels = Network::Models
ResourceModels = Resources::Models
StorageModels = Storage::Models
MONITOR_METRICS = [
'Percentage CPU',
@@ -87,45 +79,126 @@ class AzureDriver
IMAGE_PUBLISHER IMAGE_OFFER IMAGE_SKU IMAGE_VERSION
]
DEFAULTS = {
:rgroup_name_format => 'one-%<NAME>s-%<ID>s',
:cache_expire => 120
}
# --------------------------------------------------------------------------
# Azure constructor, loads credentials, create azure clients
def initialize(host)
@host = host
@to_inst ={}
# @param [String] name of host in OpenNebula
# @param [String] ID of host in OpenNebula
# --------------------------------------------------------------------------
def initialize(host, id=nil)
@hypervisor = 'azure'
@host = host
@public_cloud_az_conf = YAML.safe_load(File.read(AZ_DRIVER_CONF))
@to_inst = {}
if @public_cloud_az_conf['proxy_uri']
ENV['HTTP_PROXY'] = @public_cloud_az_conf['proxy_uri']
end
load_conf = YAML.safe_load(File.read(AZ_DRIVER_CONF), [Symbol])
@az_conf = DEFAULTS
@az_conf.merge!(load_conf)
ENV['HTTP_PROXY'] = @az_conf[:proxy_uri] if @az_conf[:proxy_uri]
# ----------------------------------------------------------------------
# Init instance types
# ----------------------------------------------------------------------
@instance_types = @az_conf[:instance_types]
@instance_types = @public_cloud_az_conf['instance_types']
@instance_types.keys.each do |key|
@to_inst[key.upcase] = key
end
@xmlhost = host_info
@rgroup_name, @rgroup_keep_empty = rgroup_info
# ----------------------------------------------------------------------
# Init OpenNebula host information & AZ_RGROUP
# ----------------------------------------------------------------------
@xmlhost = host_info(host, id)
az_conn_opts = connect_info
@region = az_conn_opts[:region]
@rgroup_name = @xmlhost['TEMPLATE/AZ_RGROUP']
keep_empty = @xmlhost['TEMPLATE/AZ_RGROUP_KEEP_EMPTY']
provider = MsRestAzure::ApplicationTokenProvider.new(
az_conn_opts[:tenant_id],
az_conn_opts[:client_id],
az_conn_opts[:client_secret]
)
@rgroup_keep_empty = !keep_empty.nil? && keep_empty.upcase == 'YES'
az_conn_opts[:credentials] = MsRest::TokenCredentials.new(provider)
if !@rgroup_name
rgroup_format = @az_conf[:rgroup_name_format]
@compute_client = Compute::Client.new(az_conn_opts)
@monitor_client = Monitor::Client.new(az_conn_opts)
@network_client = Network::Client.new(az_conn_opts)
@resource_client = Resources::Client.new(az_conn_opts)
@storage_client = Storage::Client.new(az_conn_opts)
@rgroup_name = format(rgroup_format,
:NAME => @xmlhost['NAME'],
:CLUSTER => @xmlhost['CLUSTER'],
:ID => @xmlhost['ID'])
end
# ----------------------------------------------------------------------
# Init AZ connection options
# ----------------------------------------------------------------------
@az_conn_opts = {}
{
'AZ_SUB' => :subscription_id,
'AZ_CLIENT' => :client_id,
'AZ_SECRET' => :client_secret,
'AZ_TENANT' => :tenant_id,
'AZ_REGION' => :region
}.each do |attr, opt|
@az_conn_opts[opt] = @xmlhost["TEMPLATE/#{attr}"]
raise "Missing #{attr} in azure host" if @az_conn_opts[opt].nil?
end
@region = @az_conn_opts[:region]
# ----------------------------------------------------------------------
# create or open cache db
# ----------------------------------------------------------------------
@db = InstanceCache.new(AZ_DATABASE_PATH)
end
#---------------------------------------------------------------------------
#
#---------------------------------------------------------------------------
def az_connect
require 'azure_mgmt_compute'
require 'azure_mgmt_monitor'
require 'azure_mgmt_network'
require 'azure_mgmt_resources'
require 'azure_mgmt_storage'
@compute_models = Azure::Compute::Profiles::Latest::Mgmt::Models
@network_models = Azure::Network::Profiles::Latest::Mgmt::Models
provider = MsRestAzure::ApplicationTokenProvider.new(
@az_conn_opts[:tenant_id],
@az_conn_opts[:client_id],
@az_conn_opts[:client_secret]
)
@az_conn_opts[:credentials] = MsRest::TokenCredentials.new(provider)
# rubocop:disable Layout/LineLength
@compute_client =
Azure::Compute::Profiles::Latest::Mgmt::Client.new(@az_conn_opts)
@monitor_client =
Azure::Monitor::Profiles::Latest::Mgmt::Client.new(@az_conn_opts)
@network_client =
Azure::Network::Profiles::Latest::Mgmt::Client.new(@az_conn_opts)
@resource_client =
Azure::Resources::Profiles::Latest::Mgmt::Client.new(@az_conn_opts)
@storage_client =
Azure::Storage::Profiles::Latest::Mgmt::Client.new(@az_conn_opts)
# rubocop:enable Layout/LineLength
end
# --------------------------------------------------------------------------
# DEPLOY action
# --------------------------------------------------------------------------
def deploy(id, host, xml_text, lcm_state, deploy_id)
az_connect
@rgroup = create_rgroup(@rgroup_name, @region) \
unless @resource_client.resource_groups
.check_existence(@rgroup_name)
@@ -154,118 +227,122 @@ class AzureDriver
end
end
# --------------------------------------------------------------------------
# Shutdown an Azure instance
# --------------------------------------------------------------------------
def shutdown(deploy_id, lcm_state)
az_connect
case lcm_state
when 'SHUTDOWN'
@compute_client.virtual_machines.power_off(@rgroup_name, deploy_id)
@compute_client.virtual_machines.delete(@rgroup_name, deploy_id)
delete_vm_resources(deploy_id)
when 'SHUTDOWN_POWEROFF', 'SHUTDOWN_UNDEPLOY'
@compute_client.virtual_machines.delete(@rgroup_name, deploy_id)
@compute_client.virtual_machines.power_off(@rgroup_name, deploy_id)
end
delete_vm_resources(deploy_id)
end
# --------------------------------------------------------------------------
# Reboot an Azure instance
# --------------------------------------------------------------------------
def reboot(deploy_id)
az_connect
i = get_instance(deploy_id)
@compute_client.virtual_machines.restart(@rgroup_name, i.name)
end
# --------------------------------------------------------------------------
# Cancel an Azure instance
# --------------------------------------------------------------------------
def cancel(deploy_id)
az_connect
@compute_client.virtual_machines.delete(@rgroup_name, deploy_id)
delete_vm_resources(deploy_id)
end
# Stop an Azure instance
def save(deploy_id)
i = get_instance(deploy_id)
@compute_client.virtual_machines.power_off(@rgroup_name, i.name)
end
# --------------------------------------------------------------------------
# Resume an Azure instance
# --------------------------------------------------------------------------
def restore(deploy_id)
az_connect
i = get_instance(deploy_id)
return if vm_state(i) == 'running'
return if vm_state(i) == 'RUNNING'
@compute_client.virtual_machines.start(@rgroup_name, i.name)
end
# Get info (IP, and state) for an Azure instance
def poll(_id, deploy_id)
i = get_instance(deploy_id)
puts parse_poll(i)
#---------------------------------------------------------------------------
# Monitor Interface
#---------------------------------------------------------------------------
def probe_host_system
# call probe_host_system from PublicCloudDriver module
super(@db, @az_conf[:cache_expire], @xmlhost)
end
# Get the info of all Aure instances. An Azure instance must have
# a name compliant with the "one-####" format, where #### are integers
def monitor_all_vms
totalmemory = 0
totalcpu = 0
def probe_host_monitor
# call probe_host_monitor from PublicCloudDriver module
super(@db, @az_conf[:cache_expire], @xmlhost)
end
capacity = @xmlhost.to_hash['HOST']['TEMPLATE']['CAPACITY']
def retreive_vms_data
# call vms_data from PublicCloudDriver module
vms_data(@db, @az_conf[:cache_expire])
end
if capacity.nil? || !capacity.is_a?(Hash)
raise 'You must define CAPACITY section properly! '\
'Check the VM template'
#---------------------------------------------------------------------------
#
#
#---------------------------------------------------------------------------
private
# Verify az_info contains all required params
def validate_az_info(az_info)
AZ_REQUIRED_PARAMS.each do |param|
if !az_info.key? param
raise "Missing #{param} in VM template azure setting " \
"or in #{AZ_DRIVER_DEFAULT}"
end
end
end
capacity.each do |name, value|
cpu, mem = instance_type_capacity(name)
totalmemory += mem * value.to_i
totalcpu += cpu * value.to_i
end
host_info = "HYPERVISOR=AZURE\n"
host_info << "PUBLIC_CLOUD=YES\n"
host_info << "PRIORITY=-1\n"
host_info << "TOTALMEMORY=#{totalmemory.round}\n"
host_info << "TOTALCPU=#{totalcpu}\n"
host_info << "HOSTNAME=\"#{@host}\"\n"
vms_info = "VM_POLL=YES\n"
usedcpu = 0
usedmemory = 0
# Get VMs details from azure, include monitoring if needed
def fetch_vms_data(with_monitoring = false)
az_connect
work_q = Queue.new
vms = []
if @resource_client.resource_groups.check_existence(@rgroup_name)
@compute_client.virtual_machines
.list(@rgroup_name).each {|i| work_q.push i }
workers = (0...20).map do
az_instances = @compute_client.virtual_machines.list(@rgroup_name)
az_instances.each {|i| work_q.push i }
workers = (0...[az_instances.length, 20].min).map do
Thread.new do
begin
while (i = work_q.pop(true))
vm_state = vm_state(i)
next if vm_state !~ /running|pending/
next if vm_state != 'RUNNING'
one_id = i.tags['ONE_ID'] if i.tags
poll_data = parse_poll(i, vm_state)
vm = { :uuid => i.vm_id,
:id => one_id || -1,
:name => i.name,
:type => i.hardware_profile.vm_size,
:state => vm_state(i) }
vm_template_to_one = vm_to_one(i)
vm_template_to_one = Base64
.encode64(vm_template_to_one)
.gsub("\n", '')
if with_monitoring
vm[:monitor] = get_vm_monitor_data(i)
end
vms_info << "VM=[\n"
vms_info << " ID=#{one_id || -1},\n"
vms_info << " DEPLOY_ID=#{i.name},\n"
vms_info << " VM_NAME=#{i.name},\n"
vms_info << ' IMPORT_TEMPLATE='\
"\"#{vm_template_to_one}\",\n"
vms_info << " POLL=\"#{poll_data}\" ]\n"
vms << vm
next unless one_id
name = i.hardware_profile.vm_size
cpu, mem = instance_type_capacity(name)
usedcpu += cpu
usedmemory += mem
# next unless one_id
end
rescue ThreadError
nil
@@ -277,77 +354,10 @@ class AzureDriver
workers.map(&:join)
end
host_info << "USEDMEMORY=#{usedmemory.round}\n"
host_info << "USEDCPU=#{usedcpu.round}\n"
host_info << "FREEMEMORY=#{(totalmemory - usedmemory).round}\n"
host_info << "FREECPU=#{(totalcpu - usedcpu).round}\n"
# store to db
@db.insert(vms)
puts host_info
puts vms_info
end
private
def host_info
client = OpenNebula::Client.new
pool = OpenNebula::HostPool.new(client)
pool.info
objects=pool.select {|object| object.name==@host }
host_id = objects.first.id
xmlhost = OpenNebula::Host.new_with_id(host_id, client)
xmlhost.info(true)
xmlhost
end
# Check the host template to retrieve
# conection info needed for Azure
def connect_info
ret = {}
{ 'AZ_SUB' => :subscription_id,
'AZ_CLIENT' => :client_id,
'AZ_SECRET' => :client_secret,
'AZ_TENANT' => :tenant_id,
'AZ_REGION' => :region }.each do |attr_name, conn_opt|
ret[conn_opt] = @xmlhost["TEMPLATE/#{attr_name}"]
if ret[conn_opt].nil?
raise "Missing #{attr_name} in azure host template"
end
end
ret
end
# AZ resource group is either specified in host template attr AZ_GROUP
# or it is derived from the rgroup_name_format and host attributes
def rgroup_info
rgroup = @xmlhost['TEMPLATE/AZ_RGROUP']
keep_empty = @xmlhost['TEMPLATE/AZ_RGROUP_KEEP_EMPTY']
keep_empty = !keep_empty.nil? && keep_empty.upcase == 'YES'
return rgroup, keep_empty if rgroup
rgroup_name_format = @public_cloud_az_conf['rgroup_name_format'] || \
'one-%<NAME>s-%<ID>s'
rgroup = format(rgroup_name_format,
:NAME => @xmlhost['NAME'],
:CLUSTER => @xmlhost['CLUSTER'],
:ID => @xmlhost['ID'])
[rgroup, keep_empty]
end
# Verify az_info contains all required params
def validate_az_info(az_info)
AZ_REQUIRED_PARAMS.each do |param|
if !az_info.key? param
raise "Missing #{param} in VM template azure setting " \
"or in #{AZ_DRIVER_DEFAULT}"
end
end
vms
end
# Create azure resource group
@@ -413,10 +423,10 @@ class AzureDriver
end
def create_public_ip(id, ip_name)
public_ip_params = NetworkModels::PublicIPAddress.new.tap do |ip|
public_ip_params = @network_models::PublicIPAddress.new.tap do |ip|
ip.location = @region
ip.public_ipallocation_method =
NetworkModels::IPAllocationMethod::Dynamic
@network_models::IPAllocationMethod::Dynamic
ip.tags = { 'ONE_ID' => id }
end
@network_client.public_ipaddresses.create_or_update(
@@ -428,25 +438,28 @@ class AzureDriver
# rubocop:disable Layout/LineLength
def create_vm(id, subnet, public_ip, az_info, ssh_public_key)
vm_name = "one-#{id}"
net_ip_conf = NetworkModels::NetworkInterfaceIPConfiguration
ip_method = NetworkModels::IPAllocationMethod::Dynamic
net_ip_conf = @network_models::NetworkInterfaceIPConfiguration
ip_method = @network_models::IPAllocationMethod::Dynamic
if az_info['SECURITY_GROUP']
security_group = @network_client.network_security_groups.get(@rgroup_name, az_info['SECURITY_GROUP'])
security_group = @network_client.network_security_groups.get(
@rgroup_name, az_info['SECURITY_GROUP'])
end
if az_info['PROXIMITY_GROUP']
proximity_group = @compute_client.proximity_placement_groups.get(@rgroup_name, az_info['PROXIMITY_GROUP'])
proximity_group = @compute_client.proximity_placement_groups.get(
@rgroup_name, az_info['PROXIMITY_GROUP'])
end
if az_info['AVAILABILITY_SET']
availability_set = @compute_client.availability_sets.get(@rgroup_name, az_info['AVAILABILITY_SET'])
availability_set = @compute_client.availability_sets.get(
@rgroup_name, az_info['AVAILABILITY_SET'])
end
nic = @network_client.network_interfaces.create_or_update(
@rgroup_name,
"#{vm_name}-nic",
NetworkModels::NetworkInterface.new.tap do |interface|
@network_models::NetworkInterface.new.tap do |interface|
interface.location = @region
interface.network_security_group = security_group if security_group
interface.ip_configurations = [
@@ -462,9 +475,9 @@ class AzureDriver
end
)
vm_create_params = ComputeModels::VirtualMachine.new.tap do |vm|
vm_create_params = @compute_models::VirtualMachine.new.tap do |vm|
vm.location = @region
vm.os_profile = ComputeModels::OSProfile.new.tap do |os_profile|
vm.os_profile = @compute_models::OSProfile.new.tap do |os_profile|
os_profile.computer_name = vm_name
os_profile.admin_username = az_info['VM_USER']
os_profile.admin_password = az_info['VM_PASSWORD']
@@ -473,8 +486,8 @@ class AzureDriver
vm.proximity_placement_groups = proximity_group if proximity_group
vm.availability_set = availability_set if availability_set
vm.storage_profile = ComputeModels::StorageProfile.new.tap do |store_profile|
store_profile.image_reference = ComputeModels::ImageReference.new.tap do |ref|
vm.storage_profile = @compute_models::StorageProfile.new.tap do |store_profile|
store_profile.image_reference = @compute_models::ImageReference.new.tap do |ref|
ref.publisher = az_info['IMAGE_PUBLISHER']
ref.offer = az_info['IMAGE_OFFER']
ref.sku = az_info['IMAGE_SKU']
@@ -482,14 +495,14 @@ class AzureDriver
end
end
vm.hardware_profile = ComputeModels::HardwareProfile.new.tap do |hardware|
# hardware.vm_size = ComputeModels::VirtualMachineSizeTypes::StandardDS2V2
vm.hardware_profile = @compute_models::HardwareProfile.new.tap do |hardware|
# hardware.vm_size = @compute_models::VirtualMachineSizeTypes::StandardDS2V2
hardware.vm_size = az_info['INSTANCE_TYPE']
end
vm.network_profile = ComputeModels::NetworkProfile.new.tap do |net_profile|
vm.network_profile = @compute_models::NetworkProfile.new.tap do |net_profile|
net_profile.network_interfaces = [
ComputeModels::NetworkInterfaceReference.new.tap do |ref|
@compute_models::NetworkInterfaceReference.new.tap do |ref|
ref.id = nic.id
ref.primary = true
end
@@ -498,11 +511,11 @@ class AzureDriver
end
if ssh_public_key
vm_create_params.os_profile.linux_configuration = ComputeModels::LinuxConfiguration.new.tap do |linux|
vm_create_params.os_profile.linux_configuration = @compute_models::LinuxConfiguration.new.tap do |linux|
linux.disable_password_authentication = true
linux.ssh = ComputeModels::SshConfiguration.new.tap do |ssh_config|
linux.ssh = @compute_models::SshConfiguration.new.tap do |ssh_config|
ssh_config.public_keys = [
ComputeModels::SshPublicKey.new.tap do |pub_key|
@compute_models::SshPublicKey.new.tap do |pub_key|
pub_key.key_data = ssh_public_key
pub_key.path = "/home/#{az_info['VM_USER']}/.ssh/authorized_keys"
end
@@ -567,7 +580,7 @@ class AzureDriver
(resource['memory'].to_f * 1024 * 1024).to_i]
end
# Get the Azure section of the template. If more than one Azure section
# Get the Azure section of the template.
def get_deployment_info(host, xml_text)
xml = OpenNebula::XMLElement.new
xml.initialize_xml(xml_text, 'VM')
@@ -611,11 +624,23 @@ class AzureDriver
[az, context.first.to_hash['CONTEXT']]
end
# Return state of the instance (ONE state)
def vm_state(i)
az_inst_view = @compute_client.virtual_machines.instance_view(
@rgroup_name, i.name
)
az_inst_view.statuses[-1].code.split('/').last
az_state = az_inst_view.statuses[-1].code.split('/').last
case az_state
when 'running', 'starting'
# return VM_STATE[:active]
'RUNNING'
when 'suspended', 'stopping'
# return VM_STATE[:paused]
'SHUTDOWN'
else
# return VM_STATE[:unknown]
'UNKNOWN'
end
end
def get_cpu_num(instance)
@@ -628,32 +653,16 @@ class AzureDriver
end
# Retrive the vm information from the Azure instance view
def parse_poll(instance, vm_state)
info = state = ''
if !instance
state = VM_STATE[:deleted]
else
case vm_state
when 'running', 'starting'
state = VM_STATE[:active]
when 'suspended', 'stopping'
state = VM_STATE[:paused]
else
state = VM_STATE[:unknown]
end
end
info << "#{POLL_ATTRIBUTE[:state]}=#{state} "
def get_vm_monitor_data(instance)
# include metrics data (azure doesn't give any info about VM memory)
data = @monitor_client.metrics.list(
instance.id,
:metricnames => MONITOR_METRICS.join(','),
:timespan => 'PT1M', # Period time 1m
:timespan => 'PT1M', # Period time 1m
:result_type => 'Data'
)
info = ''
data.value.each do |e|
value = e.timeseries.first.data.first.average || 0
@@ -690,7 +699,7 @@ class AzureDriver
info << "\\\"#{v}\\\" "
end
info
Base64.encode64(info).gsub("\n", '')
end
def get_instance_public_ip(vm_name)
@@ -738,29 +747,6 @@ class AzureDriver
instance
end
# Build template for importation
def vm_to_one(vm)
cpu, mem = instance_type_capacity(vm.hardware_profile.vm_size)
mem = mem.to_i / 1024 # Memory for templates expressed in MB
cpu = cpu.to_f / 100 # CPU expressed in units
str = "NAME = \"Instance from #{vm.name}\"\n"\
"CPU = \"#{cpu}\"\n"\
"vCPU = \"#{cpu.ceil}\"\n"\
"MEMORY = \"#{mem}\"\n"\
"HYPERVISOR = \"AZURE\"\n"\
"PUBLIC_CLOUD = [\n"\
" TYPE =\"azure\"\n"\
"]\n"\
"IMPORT_VM_ID = \"#{vm.vm_id}\"\n"\
"SCHED_REQUIREMENTS=\"NAME=\\\"#{@host}\\\"\"\n"\
'DESCRIPTION = "Instance imported from Azure, from instance'\
" #{vm.name}\"\n"
str
end
# Transform object to hash
def examine(obj)
ret = {}
@@ -790,3 +776,28 @@ class AzureDriver
end
end
############################################################################
# Module Interface
# Interface for probe_db - VirtualMachineDB
############################################################################
module DomainList
def self.state_info(id, name)
az = AzureDriver.new(id, name)
vms = az.retreive_vms_data
info = {}
vms.each do |vm|
info[vm[:uuid]] = { :id => vm[:id],
:uuid => vm[:uuid],
:name => vm[:name],
:state => vm[:state],
:hyperv => 'az' }
end
info
end
end
+4 -31
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
@@ -14,34 +14,7 @@
# 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. #
# -------------------------------------------------------------------------- #
#--------------------------------------------------------------------------- #
ONE_LOCATION = ENV['ONE_LOCATION'] if !defined?(ONE_LOCATION)
if !ONE_LOCATION
RUBY_LIB_LOCATION = '/usr/lib/one/ruby' if !defined?(RUBY_LIB_LOCATION)
GEMS_LOCATION = '/usr/share/one/gems' if !defined?(GEMS_LOCATION)
else
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby' if !defined?(RUBY_LIB_LOCATION)
GEMS_LOCATION = ONE_LOCATION + '/share/gems' if !defined?(GEMS_LOCATION)
end
if File.directory?(GEMS_LOCATION)
Gem.use_paths(GEMS_LOCATION)
end
$LOAD_PATH << RUBY_LIB_LOCATION
$LOAD_PATH << File.dirname(__FILE__)
require 'az_driver'
deploy_id = ARGV[0]
file = ARGV[1]
host = ARGV[2]
begin
az_drv = AzureDriver.new(host)
az_drv.save(deploy_id)
rescue => e
OpenNebula.handle_driver_exception("Save", e, host, deploy_id, nil, file)
end
SCRIPT_NAME=$(basename $0)
echo "Action $SCRIPT_NAME not supported" 1>&2
+3 -3
View File
@@ -1,6 +1,6 @@
proxy_uri:
state_wait_timeout_seconds: 1500
instance_types:
:proxy_uri:
:state_wait_timeout_seconds: 1500
:instance_types:
a1.2xlarge:
cpu: 8
memory: 16.0
File diff suppressed because it is too large. Load diff
+4 -33
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env ruby
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
@@ -14,36 +14,7 @@
# 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. #
# -------------------------------------------------------------------------- #
ONE_LOCATION = ENV['ONE_LOCATION'] if !defined?(ONE_LOCATION)
if !ONE_LOCATION
RUBY_LIB_LOCATION = '/usr/lib/one/ruby' if !defined?(RUBY_LIB_LOCATION)
GEMS_LOCATION = '/usr/share/one/gems' if !defined?(GEMS_LOCATION)
else
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby' if !defined?(RUBY_LIB_LOCATION)
GEMS_LOCATION = ONE_LOCATION + '/share/gems' if !defined?(GEMS_LOCATION)
end
if File.directory?(GEMS_LOCATION)
Gem.use_paths(GEMS_LOCATION)
end
$LOAD_PATH << RUBY_LIB_LOCATION
$LOAD_PATH << File.dirname(__FILE__)
require 'ec2_driver'
deploy_id = ARGV[0]
file = ARGV[1]
host = ARGV[2]
begin
ec2_drv = EC2Driver.new(host)
ec2_drv.save(deploy_id)
rescue Exception => e
OpenNebula.handle_driver_exception("Save", e, host, deploy_id, nil, file)
end
#--------------------------------------------------------------------------- #
SCRIPT_NAME=$(basename $0)
echo "Action $SCRIPT_NAME not supported" 1>&2