vop-plugins 0.3.1 → 0.3.5
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/Rakefile +2 -2
- data/extended/hetzner/commands/add_ssh_key.rb +22 -0
- data/extended/hetzner/commands/disable_linux_install.rb +26 -0
- data/extended/hetzner/commands/enable_linux_install.rb +41 -0
- data/extended/hetzner/commands/hetzner_http.rb +24 -0
- data/extended/hetzner/commands/hetzner_machines.rb +11 -0
- data/extended/hetzner/commands/hetzner_server_list.rb +26 -0
- data/extended/hetzner/commands/linux_install_options.rb +29 -0
- data/extended/hetzner/commands/list_ssh_keys.rb +16 -0
- data/extended/hetzner/entities/hetzner_account.rb +9 -0
- data/extended/hetzner/hetzner.plugin +3 -0
- data/extended/hetzner_vop_0_2_x/commands/list_old_v2_vms.rb +46 -0
- data/extended/hetzner_vop_0_2_x/commands/old_libvirt_machines.rb +16 -0
- data/extended/hetzner_vop_0_2_x/commands/vop_0_2_x_ssh_options.rb +20 -0
- data/extended/hetzner_vop_0_2_x/hetzner_vop_0_2_x.plugin +5 -0
- data/extended/libvirt/commands/delete_vm.rb +32 -0
- data/extended/libvirt/commands/libvirt_config_file.rb +5 -0
- data/extended/libvirt/commands/libvirt_machines.rb +17 -0
- data/extended/libvirt/commands/libvirt_ssh_options.rb +29 -0
- data/extended/libvirt/commands/list_networks.rb +21 -0
- data/extended/libvirt/commands/list_pools.rb +20 -0
- data/extended/libvirt/commands/list_vms.rb +28 -0
- data/extended/libvirt/commands/list_vms_for_scan.rb +12 -0
- data/extended/libvirt/commands/list_vms_with_addresses.rb +20 -0
- data/extended/libvirt/commands/new_vm.rb +110 -0
- data/extended/libvirt/commands/parent.rb +10 -0
- data/extended/libvirt/commands/rename_vm.rb +34 -0
- data/extended/libvirt/commands/start_vm.rb +7 -0
- data/extended/libvirt/commands/stop_vm.rb +8 -0
- data/extended/libvirt/commands/vm_address.rb +7 -0
- data/extended/libvirt/commands/vm_addresses.rb +32 -0
- data/extended/libvirt/commands/vnc_ports.rb +32 -0
- data/extended/libvirt/helpers/helper.rb +3 -0
- data/extended/libvirt/libvirt.plugin +5 -0
- data/extended/libvirt/services/libvirt.rb +19 -0
- data/extended/libvirt_with_proxy/commands/reverse_proxy.rb +13 -0
- data/extended/libvirt_with_proxy/commands/vms_with_domains.rb +18 -0
- data/extended/libvirt_with_proxy/entities/_vms_with_domains.rbx +24 -0
- data/extended/libvirt_with_proxy/libvirt_with_proxy.plugin +1 -0
- data/extended/rails_machines/commands/rails_machines.rb +6 -0
- data/extended/rails_machines/commands/update_status.rb +38 -0
- data/extended/rails_machines/commands/write_found_machines_into_rails_db.rb.not +30 -0
- data/extended/rails_machines/rails_machines.plugin +1 -0
- data/extended/redis_cache/commands/flush_cache.rb +5 -0
- data/extended/redis_cache/commands/invalidate_cache.rb +26 -0
- data/extended/redis_cache/filters/cache_filter.rb +78 -0
- data/extended/redis_cache/helpers/cache_wrapper.rb +35 -0
- data/extended/redis_cache/redis_cache.plugin +8 -0
- data/extended/spares/commands/convert_spare.rb +93 -0
- data/extended/spares/commands/list_spares.rb +9 -0
- data/extended/spares/commands/new_vm_from_spare.rb +24 -0
- data/extended/spares/commands/post_convert_spare.rb +13 -0
- data/extended/spares/commands/prepare_spares.rb +17 -0
- data/extended/spares/commands/wait.rb +29 -0
- data/extended/spares/commands/wtf.rb +9 -0
- data/extended/spares/spares.plugin +1 -0
- data/standard/apt/apt.plugin +0 -0
- data/standard/apt/commands/add_apt_repo.rb +14 -0
- data/standard/git/commands/deploy.rb +19 -0
- data/standard/git/commands/deploy_from_git.rb +34 -0
- data/standard/git/commands/deploy_from_github.rb +12 -0
- data/standard/git/commands/git_clone.rb +7 -0
- data/standard/git/commands/git_clone_web.rb +22 -0
- data/standard/git/git.plugin +0 -0
- data/standard/linux/commands/append_to_file.rb +14 -0
- data/standard/linux/commands/chmod.rb +7 -0
- data/standard/linux/commands/curl.rb +15 -0
- data/standard/linux/commands/current_user.rb +5 -0
- data/standard/linux/commands/distro.rb +2 -1
- data/standard/linux/commands/download_file.rb +6 -6
- data/standard/linux/commands/external_ip.rb +15 -0
- data/standard/linux/commands/file_exists.rb +7 -0
- data/standard/linux/commands/home.rb +7 -0
- data/standard/linux/commands/hostname.rb +5 -0
- data/standard/linux/commands/internal_ip.rb +14 -0
- data/standard/linux/commands/ipaddress.rb +10 -0
- data/standard/linux/commands/list_files.rb +8 -6
- data/standard/linux/commands/list_ip_addresses.rb +22 -0
- data/standard/linux/commands/listen_ports.rb +3 -2
- data/standard/linux/commands/maybe_sudo.rb +8 -0
- data/standard/linux/commands/mkdirs.rb +12 -0
- data/standard/linux/commands/processes.rb +8 -6
- data/standard/linux/commands/processes_like.rb +7 -7
- data/standard/linux/commands/processes_top.rb +23 -0
- data/standard/linux/commands/processes_top_cpu.rb +8 -0
- data/standard/linux/commands/processes_top_mem.rb +8 -0
- data/standard/linux/commands/read_file.rb +7 -2
- data/standard/linux/commands/replace_in_file.rb +22 -0
- data/standard/linux/commands/set_hostname.rb +36 -0
- data/standard/linux/commands/update_hosts_file.rb +27 -0
- data/standard/linux/commands/write_file.rb +8 -21
- data/standard/linux/linux.plugin +1 -2
- data/standard/machines/commands/delete_old_machines.rb +17 -0
- data/standard/machines/commands/localhost.rb +7 -2
- data/standard/machines/commands/localhost_ssh_options.rb +9 -0
- data/standard/machines/commands/new_machine.rb +24 -0
- data/standard/machines/commands/new_vm_from_scratch.rb +25 -0
- data/standard/machines/commands/old_machines.rb +6 -0
- data/standard/machines/commands/select_machine.rb +4 -5
- data/standard/machines/entities/machine.rb +12 -0
- data/standard/machines/machines.plugin +1 -1
- data/standard/redis_machines/commands/installation_status.rb +10 -0
- data/standard/redis_machines/commands/track_installation_status.rb +13 -0
- data/standard/redis_machines/redis_machines.plugin +3 -0
- data/standard/rpm/commands/list_rpm_packages.rb +24 -0
- data/standard/rpm/rpm.plugin +1 -0
- data/standard/scanner/commands/clean_metadata.rb +8 -0
- data/standard/scanner/commands/fresh_ssh_test.rb +6 -0
- data/standard/scanner/commands/inspect_async.rb +6 -0
- data/standard/scanner/commands/inspect_machine.rb +42 -0
- data/standard/scanner/commands/machines_found.rb +35 -0
- data/standard/scanner/commands/metadata.rb +9 -0
- data/standard/scanner/commands/redis_machines.rb +11 -0
- data/standard/scanner/commands/scan.rb +5 -0
- data/standard/scanner/commands/scan_host.rb +7 -0
- data/standard/scanner/commands/scan_machines.rb +11 -0
- data/standard/scanner/commands/trigger_ssh_test.rb +8 -0
- data/standard/scanner/scanner.plugin +5 -0
- data/standard/services/commands/describe_service.rb +7 -0
- data/standard/services/commands/describe_service_installation.rb +13 -0
- data/standard/services/commands/detect_services.rb +34 -0
- data/standard/services/commands/install_service.rb +134 -0
- data/standard/services/commands/list_known_services.rb +14 -0
- data/standard/services/commands/load_plugin_services.rb +17 -0
- data/standard/services/entities/service.rb +3 -0
- data/standard/services/helpers/service.rb +31 -0
- data/standard/services/helpers/service_loader.rb +50 -0
- data/standard/services/helpers/service_syntax.rb +126 -0
- data/standard/services/services.plugin +9 -0
- data/standard/ssh/commands/clean_known_host.rb +11 -0
- data/standard/ssh/commands/clear_ssh_cache.rb +9 -0
- data/standard/ssh/commands/get_ssh_connection.rb +36 -0
- data/standard/ssh/commands/scp_down.rb +9 -0
- data/standard/ssh/commands/scp_up.rb +9 -0
- data/standard/ssh/commands/ssh.rb +20 -0
- data/standard/ssh/commands/ssh_call.rb +98 -0
- data/standard/ssh/commands/ssh_connection.rb +55 -0
- data/standard/ssh/commands/ssh_extended.rb +6 -0
- data/standard/ssh/commands/ssh_options.rb +12 -0
- data/standard/ssh/commands/sudo.rb +12 -0
- data/standard/ssh/commands/test_ssh.rb +43 -0
- data/standard/{linux → ssh}/helpers/regex.rb +0 -0
- data/standard/ssh/ssh.plugin +10 -0
- data/standard/ssh_keys/commands/add_authorized_key.rb +14 -0
- data/standard/ssh_keys/commands/disable_ssh_key_check.rb +11 -0
- data/standard/ssh_keys/commands/generate_keypair.rb +17 -0
- data/standard/ssh_keys/ssh_keys.plugin +0 -0
- data/standard/systemd/commands/disable_systemd_service.rb +8 -0
- data/standard/systemd/commands/enable_systemd_service.rb +8 -0
- data/standard/systemd/commands/list_systemd_services.rb +23 -0
- data/standard/systemd/commands/start_systemd_service.rb +6 -0
- data/standard/systemd/commands/stop_systemd_service.rb +6 -0
- data/standard/systemd/commands/systemd_service_status.rb +6 -0
- data/standard/systemd/commands/write_systemd_config.rb +16 -0
- data/standard/systemd/helpers/param_service.rb +7 -0
- data/standard/systemd/systemd.plugin +0 -0
- data/standard/systemd/templates/systemd_service.erb +11 -0
- data/standard/templates/commands/read_template.rb +8 -0
- data/standard/templates/commands/write_template.rb +37 -0
- data/standard/templates/templates.plugin +3 -0
- data/vop-plugins.gemspec +6 -7
- metadata +156 -55
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -68
- data/standard/debian-iso/commands/fetch_debian_iso.rb +0 -3
- data/standard/debian-iso/commands/fetch_ubuntu_iso.rb +0 -22
- data/standard/debian-iso/commands/list_isos.rb +0 -6
- data/standard/debian-iso/commands/rebuild_debian_iso.rb +0 -40
- data/standard/debian-iso/debian-iso.plugin +0 -2
- data/standard/debian-iso/files/rebuild-debian-iso +0 -74
- data/standard/debian-iso/templates/preseed.cfg +0 -45
- data/standard/libvirt/commands/delete_vm.rb +0 -16
- data/standard/libvirt/commands/list_local_vms.rb +0 -4
- data/standard/libvirt/commands/list_vms.rb +0 -15
- data/standard/libvirt/commands/new_vm.rb +0 -61
- data/standard/libvirt/commands/start_vm.rb +0 -6
- data/standard/libvirt/commands/stop_vm.rb +0 -6
- data/standard/libvirt/libvirt.plugin +0 -2
- data/standard/linux/commands/disk_free.rb +0 -26
- data/standard/linux/commands/disk_used.rb +0 -4
- data/standard/linux/commands/find.rb +0 -15
- data/standard/linux/commands/mkdir.rb +0 -6
- data/standard/linux/todo +0 -2
- data/standard/machines/commands/list_machines_old.rb +0 -7
- data/standard/machines/commands/machine.rb +0 -3
- data/standard/machines/commands/run_command.rb +0 -10
- data/standard/plugin.vop +0 -1
- data/standard/services/loader/service.rb +0 -3
- data/standard/vagrant/commands/vagrant_global_status.rb +0 -32
- data/standard/vagrant/vagrant.plugin +0 -1
- data/standard/working_copies/commands/git_working_copies.rb +0 -11
- data/standard/working_copies/commands/list_project_folders.rb +0 -8
- data/standard/working_copies/commands/working_copy.rb +0 -3
- data/standard/working_copies/working_copies.plugin +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 348e4c815e0899ea2dc4ea10a19dba4ee23e9532
|
4
|
+
data.tar.gz: 9744e4e14adf969a96f65bbac84ac95c17b4a039
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53344be71a72fff56fc76a4b3a8eb1164a3ade7554bf1c70301a6cca01037d0f120ae1f134178f23c426a3ade8f81b70a082729636a5db0a5622e37ac2895913
|
7
|
+
data.tar.gz: f1a33c003519847b6e56d784b79ead3a94f1ac2447c4e3dba39d79971ffdf2c844939da7bc81c542893ab839c7f616dcce9fa2c740c0f170d4cdcfb9be393cad
|
data/Rakefile
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
param! :hetzner_account
|
2
|
+
param! "name"
|
3
|
+
param! "key"
|
4
|
+
|
5
|
+
|
6
|
+
run do |hetzner_account, name, key|
|
7
|
+
request = Net::HTTP::Post.new("/key")
|
8
|
+
post_data = {
|
9
|
+
name: name,
|
10
|
+
data: key
|
11
|
+
}
|
12
|
+
request.set_form_data(post_data)
|
13
|
+
|
14
|
+
data = []
|
15
|
+
begin
|
16
|
+
data = hetzner_account.hetzner_http("http_request" => request)
|
17
|
+
rescue => e
|
18
|
+
$logger.warn("problem adding SSH key: #{e.message}")
|
19
|
+
end
|
20
|
+
|
21
|
+
data
|
22
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
param! :machine
|
2
|
+
|
3
|
+
run do |machine|
|
4
|
+
server_ip = machine.metadata["server_ip"]
|
5
|
+
unless server_ip
|
6
|
+
raise "no server IP found for #{machine.name}"
|
7
|
+
end
|
8
|
+
|
9
|
+
account_alias = machine.metadata["account"]
|
10
|
+
unless account_alias
|
11
|
+
raise "no hetzner account found in metadata"
|
12
|
+
end
|
13
|
+
$logger.info "activating hetzner reinstall configuration for #{server_ip} [#{account_alias}]"
|
14
|
+
|
15
|
+
account = @op.hetzner_accounts[account_alias]
|
16
|
+
raise "no account named '#{account_alias}'" unless account
|
17
|
+
|
18
|
+
url = "/boot/#{server_ip}/linux"
|
19
|
+
request = Net::HTTP::Delete.new(url)
|
20
|
+
data = account.hetzner_http("http_request" => request)
|
21
|
+
|
22
|
+
unless data.has_key?("linux")
|
23
|
+
raise "unexpected response - no key 'linux' found"
|
24
|
+
end
|
25
|
+
data["linux"]
|
26
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
param! :machine
|
2
|
+
|
3
|
+
param "dist", default: "Ubuntu 17.10 minimal"
|
4
|
+
param "arch", default: 64
|
5
|
+
|
6
|
+
param "lang", default: "en"
|
7
|
+
|
8
|
+
param "ssh_key", description: "fingerprints of SSH keys that should be authorized to login",
|
9
|
+
multi: true, default: []
|
10
|
+
|
11
|
+
run do |machine, dist, arch, lang, ssh_key|
|
12
|
+
server_ip = machine.metadata["server_ip"]
|
13
|
+
unless server_ip
|
14
|
+
raise "no server IP found for #{machine.name}"
|
15
|
+
end
|
16
|
+
|
17
|
+
account_alias = machine.metadata["account"]
|
18
|
+
unless account_alias
|
19
|
+
raise "no hetzner account found in metadata"
|
20
|
+
end
|
21
|
+
$logger.info "activating hetzner reinstall configuration for #{server_ip} [#{account_alias}]"
|
22
|
+
|
23
|
+
account = @op.hetzner_accounts[account_alias]
|
24
|
+
raise "no account named '#{account_alias}'" unless account
|
25
|
+
|
26
|
+
url = "/boot/#{server_ip}/linux"
|
27
|
+
request = Net::HTTP::Post.new(url)
|
28
|
+
post_data = {
|
29
|
+
dist: dist,
|
30
|
+
arch: arch,
|
31
|
+
lang: lang,
|
32
|
+
authorized_key: ssh_key
|
33
|
+
}
|
34
|
+
request.set_form_data(post_data)
|
35
|
+
|
36
|
+
data = account.hetzner_http("http_request" => request)
|
37
|
+
unless data.has_key?("linux")
|
38
|
+
raise "unexpected response - no key 'linux' found"
|
39
|
+
end
|
40
|
+
data["linux"]
|
41
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
param! :hetzner_account
|
2
|
+
param! "http_request"
|
3
|
+
|
4
|
+
run do |hetzner_account, params|
|
5
|
+
endpoint = "https://robot-ws.your-server.de"
|
6
|
+
uri = URI.parse(endpoint)
|
7
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
8
|
+
http.use_ssl = true
|
9
|
+
|
10
|
+
$logger.debug "hosts for account #{hetzner_account["alias"]}"
|
11
|
+
|
12
|
+
request = params["http_request"]
|
13
|
+
request.basic_auth(hetzner_account["username"], hetzner_account["password"])
|
14
|
+
|
15
|
+
$logger.info "authenticating with user #{hetzner_account["username"]}"
|
16
|
+
|
17
|
+
response = http.request(request)
|
18
|
+
unless response.is_a? Net::HTTPOK
|
19
|
+
raise "received HTTP code #{response.code} from #{uri} : #{response.message}"
|
20
|
+
end
|
21
|
+
|
22
|
+
json_response = response.body.strip
|
23
|
+
JSON.parse(json_response)
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "net/http"
|
2
|
+
|
3
|
+
param! :hetzner_account
|
4
|
+
|
5
|
+
run do |hetzner_account|
|
6
|
+
request = Net::HTTP::Get.new("/server")
|
7
|
+
|
8
|
+
data = []
|
9
|
+
begin
|
10
|
+
data = hetzner_account.hetzner_http("http_request" => request)
|
11
|
+
rescue => e
|
12
|
+
$logger.warn("problem fetching hetzner server list: #{e.message}")
|
13
|
+
end
|
14
|
+
|
15
|
+
result = []
|
16
|
+
data.each do |row|
|
17
|
+
if row.has_key? "server"
|
18
|
+
result << row["server"].tap do |x|
|
19
|
+
x["type"] = "host"
|
20
|
+
x["name"] = "#{x["server_name"]}.#{hetzner_account["alias"]}"
|
21
|
+
x["account"] = hetzner_account["alias"]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
result
|
26
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
param! :machine
|
2
|
+
|
3
|
+
run do |machine|
|
4
|
+
server_ip = machine.metadata["server_ip"]
|
5
|
+
unless server_ip
|
6
|
+
raise "no server IP found for #{machine.name}"
|
7
|
+
end
|
8
|
+
|
9
|
+
account_alias = machine.metadata["account"]
|
10
|
+
unless account_alias
|
11
|
+
raise "no hetzner account found in metadata"
|
12
|
+
end
|
13
|
+
|
14
|
+
account = @op.hetzner_accounts[account_alias]
|
15
|
+
raise "no account named '#{account_alias}'" unless account
|
16
|
+
|
17
|
+
request = Net::HTTP::Get.new("/boot/#{server_ip}/linux")
|
18
|
+
data = []
|
19
|
+
begin
|
20
|
+
data = account.hetzner_http("http_request" => request)
|
21
|
+
rescue => e
|
22
|
+
$logger.warn("problem fetching boot options for server #{machine.name} : #{e.message}")
|
23
|
+
end
|
24
|
+
|
25
|
+
unless data.has_key?("linux")
|
26
|
+
raise "unexpected response - no key 'linux' found"
|
27
|
+
end
|
28
|
+
data["linux"]
|
29
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
param! :hetzner_account
|
2
|
+
|
3
|
+
show display_type: :raw
|
4
|
+
|
5
|
+
run do |hetzner_account|
|
6
|
+
request = Net::HTTP::Get.new("/key")
|
7
|
+
|
8
|
+
data = []
|
9
|
+
begin
|
10
|
+
data = hetzner_account.hetzner_http("http_request" => request)
|
11
|
+
rescue => e
|
12
|
+
$logger.warn("problem listing SSH keys: #{e.message}")
|
13
|
+
end
|
14
|
+
|
15
|
+
data
|
16
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
param! :machine
|
2
|
+
|
3
|
+
run do |machine|
|
4
|
+
dir_name = "/var/lib/virtualop/machines/"
|
5
|
+
$logger.info "searching old vop 0.2.x style VMs on #{machine.id} in #{dir_name}"
|
6
|
+
|
7
|
+
result = []
|
8
|
+
|
9
|
+
if machine.test_ssh
|
10
|
+
if machine.file_exists("path" => dir_name)
|
11
|
+
$logger.info "dir #{dir_name} exists on #{machine.name} ? #{machine.file_exists(dir_name)}"
|
12
|
+
|
13
|
+
files = machine.list_files("dir" => dir_name)
|
14
|
+
files.each do |file|
|
15
|
+
full_name = File.join(dir_name, file["name"])
|
16
|
+
yaml = machine.read_file("file" => full_name)
|
17
|
+
data = ::YAML.load(yaml)
|
18
|
+
|
19
|
+
hash = {
|
20
|
+
"type" => "vm",
|
21
|
+
"source" => "list_old_v2_vms",
|
22
|
+
"name" => "#{data["vm_name"]}.#{machine.id}",
|
23
|
+
}
|
24
|
+
|
25
|
+
%w|memory_size vcpu_count disk_size bridge|.each do |key|
|
26
|
+
hash[key] = data[key] unless data[key].nil?
|
27
|
+
end
|
28
|
+
|
29
|
+
if data["extra_arg"]
|
30
|
+
data["extra_arg"].each do |line|
|
31
|
+
(key, value) = line.split("=")
|
32
|
+
hash[key] = value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
result << hash
|
37
|
+
end
|
38
|
+
else
|
39
|
+
$logger.debug "dir #{dir_name} does not exist on #{machine.name}"
|
40
|
+
end
|
41
|
+
else
|
42
|
+
$logger.warn "machine #{machine.id} not reachable by SSH"
|
43
|
+
end
|
44
|
+
|
45
|
+
result
|
46
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
contribute to: "scan_machines" do
|
2
|
+
result = []
|
3
|
+
|
4
|
+
@op.machines.each do |machine|
|
5
|
+
# we're interested in VMs installed on physical hosts (that have an IP)
|
6
|
+
begin
|
7
|
+
if machine.metadata.has_key?("server_ip") && machine.distro =~ /^centos/
|
8
|
+
result += machine.list_old_v2_vms
|
9
|
+
end
|
10
|
+
rescue => e
|
11
|
+
$logger.error("could not list old 0.2.x-style VMs on #{machine.name} : #{e.message}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
result
|
16
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
param! :machine
|
2
|
+
|
3
|
+
contribute to: "ssh_options" do |machine, params, plugin|
|
4
|
+
result = {}
|
5
|
+
|
6
|
+
# connect as root to the physical hosts
|
7
|
+
if machine.metadata.has_key? "server_ip"
|
8
|
+
result["host_or_ip"] = machine.metadata["server_ip"]
|
9
|
+
result["user"] = "root"
|
10
|
+
elsif machine.metadata.has_key?("vcpu_count") && machine.metadata.has_key?("ip")
|
11
|
+
host_name = machine.id.split(".")[1..-1].join(".")
|
12
|
+
# connect to the VM through the host's IP
|
13
|
+
result["host_or_ip"] = @op.ssh_options(machine: host_name)["host_or_ip"]
|
14
|
+
result["user"] = "root"
|
15
|
+
result["password"] = plugin.config["hetzner_root_password"]
|
16
|
+
result["port"] = machine.metadata["ip"].split(".").last.to_i + 2200
|
17
|
+
end
|
18
|
+
|
19
|
+
result
|
20
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
param! :machine
|
2
|
+
param! "name", lookup: lambda { |params| @op.list_vms("machine" => params["machine"]).map { |x| x["name"] } }
|
3
|
+
|
4
|
+
run do |machine, name|
|
5
|
+
vm_row = machine.list_vms.select { |x| x["name"] == name }.first
|
6
|
+
raise "VM not found in list_vms" unless vm_row
|
7
|
+
|
8
|
+
if vm_row["state"] == 'running'
|
9
|
+
machine.stop_vm("name" => name)
|
10
|
+
end
|
11
|
+
|
12
|
+
#machine.maybe_sudo cmd: ". /etc/profile && virsh undefine #{name}"
|
13
|
+
|
14
|
+
# see https://bugzilla.redhat.com/show_bug.cgi?id=697742
|
15
|
+
buggy_flag = "--managed-save"
|
16
|
+
machine.ssh "command" => "sudo virsh undefine #{name} #{buggy_flag}",
|
17
|
+
"request_pty" => true, "show_output" => true
|
18
|
+
|
19
|
+
@op.invalidate_cache(
|
20
|
+
"command" => "list_vms",
|
21
|
+
"raw_params" => machine.name
|
22
|
+
)
|
23
|
+
|
24
|
+
machine.list_vms
|
25
|
+
|
26
|
+
pools = machine.list_pools.map { |x| x["name"] }
|
27
|
+
pool = pools.include?("images") ? "images" : "default"
|
28
|
+
|
29
|
+
# TODO maybe check first if the volume exists?
|
30
|
+
machine.ssh "command" => "sudo virsh vol-delete --pool #{pool} #{name}.img",
|
31
|
+
"request_pty" => true, "show_output" => true
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
contribute to: "scan_machines" do
|
2
|
+
result = []
|
3
|
+
|
4
|
+
@op.machines.each do |machine|
|
5
|
+
# we're interested in VMs installed on physical hosts
|
6
|
+
# TODO the server_ip is hetzner-specific => extract into xop-libvirt ?
|
7
|
+
if machine.metadata.has_key?("server_ip") # TODO && machine.distro =~ /^ubuntu/
|
8
|
+
begin
|
9
|
+
result += machine.list_vms_for_scan
|
10
|
+
rescue => e
|
11
|
+
$logger.error("could not list VMs on #{machine.name} : #{e.message}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
result
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# TODO extract into xop-libvirt
|
2
|
+
|
3
|
+
param! :machine
|
4
|
+
|
5
|
+
contribute to: "ssh_options" do |machine, params, plugin|
|
6
|
+
result = {}
|
7
|
+
|
8
|
+
# connect to new-style libvirt VMs through the parent host as ProxyJump host
|
9
|
+
if machine.metadata.has_key?("source") &&
|
10
|
+
machine.metadata["source"] == "libvirt"
|
11
|
+
|
12
|
+
# extract the parent host from the VM name
|
13
|
+
parent_name = machine.name.split(".")[1..-1].join(".")
|
14
|
+
result["jump_host"] = parent_name
|
15
|
+
|
16
|
+
# from the jump host, we connect to the VM's internal IP
|
17
|
+
vm_short_name = machine.name.split(".").first
|
18
|
+
vm_ip = @op.vm_address("machine" => parent_name, "name" => vm_short_name)
|
19
|
+
result["host_or_ip"] = vm_ip
|
20
|
+
|
21
|
+
if plugin.config["ssh_user"].nil? || plugin.config["ssh_password"].nil?
|
22
|
+
raise "missing configuration - expected 'ssh_user' and 'ssh_password' in config for #{plugin.name}"
|
23
|
+
end
|
24
|
+
result["user"] = plugin.config["ssh_user"]
|
25
|
+
result["password"] = plugin.config["ssh_password"]
|
26
|
+
end
|
27
|
+
|
28
|
+
result
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
param! :machine
|
2
|
+
|
3
|
+
run do |machine|
|
4
|
+
result = []
|
5
|
+
|
6
|
+
input = machine.sudo "virsh net-list"
|
7
|
+
input.lines[2..-1].each do |line|
|
8
|
+
line.strip!
|
9
|
+
next if line.empty?
|
10
|
+
|
11
|
+
(name, state, autostart, persistent) = line.strip.split
|
12
|
+
result << {
|
13
|
+
"name" => name,
|
14
|
+
"state" => state,
|
15
|
+
"autostart" => autostart,
|
16
|
+
"persistent" => persistent
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
result
|
21
|
+
end
|