From 44981562f80fa4a8211db52c8c80ff0563f27b12 Mon Sep 17 00:00:00 2001 From: William Fitzgerald Date: Fri, 20 Dec 2019 16:03:05 -0500 Subject: [PATCH] Moving RedHat Automate domain content for Namespace "Integration" to ManageIQ. Namespace "Integration" which includes ServiceNow and VMware components NOT found currently in ManageIQ domain. --- .../ServiceNow/CMDB.class/__class__.yaml | 133 ++++++++++++++++++ .../CMDB.class/__methods__/create.rb | 86 +++++++++++ .../CMDB.class/__methods__/create.yaml | 12 ++ .../CMDB.class/__methods__/delete.rb | 48 +++++++ .../CMDB.class/__methods__/delete.yaml | 12 ++ .../ServiceNow/CMDB.class/__methods__/get.rb | 56 ++++++++ .../CMDB.class/__methods__/get.yaml | 12 ++ .../CMDB.class/__methods__/get_all.rb | 43 ++++++ .../CMDB.class/__methods__/get_all.yaml | 12 ++ .../CMDB.class/__methods__/update.rb | 82 +++++++++++ .../CMDB.class/__methods__/update.yaml | 12 ++ .../CMDB.class/__methods__/update_patch.rb | 79 +++++++++++ .../CMDB.class/__methods__/update_patch.yaml | 12 ++ .../ServiceNow/CMDB.class/create.yaml | 12 ++ .../ServiceNow/CMDB.class/delete.yaml | 12 ++ .../ServiceNow/CMDB.class/get.yaml | 12 ++ .../ServiceNow/CMDB.class/get_all.yaml | 12 ++ .../ServiceNow/CMDB.class/update.yaml | 12 ++ .../ServiceNow/CMDB.class/update_patch.yaml | 12 ++ .../Integration/ServiceNow/__namespace__.yaml | 10 ++ .../VMware/VimApi.class/__class__.yaml | 33 +++++ .../__methods__/vmware_hotadd_cpu.rb | 19 +++ .../__methods__/vmware_hotadd_cpu.yaml | 12 ++ .../__methods__/vmware_hotadd_disk.rb | 21 +++ .../__methods__/vmware_hotadd_disk.yaml | 12 ++ .../__methods__/vmware_hotadd_ram.rb | 18 +++ .../__methods__/vmware_hotadd_ram.yaml | 12 ++ .../VimApi.class/vmware_hotadd_cpu.yaml | 12 ++ .../VimApi.class/vmware_hotadd_disk.yaml | 12 ++ .../VimApi.class/vmware_hotadd_ram.yaml | 12 ++ .../Integration/VMware/__namespace__.yaml | 10 ++ .../ManageIQ/Integration/__namespace__.yaml | 10 ++ 32 files changed, 864 insertions(+) create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__class__.yaml create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/create.rb create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/create.yaml create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/delete.rb create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/delete.yaml create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get.rb create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get.yaml create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get_all.rb create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get_all.yaml create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update.rb create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update.yaml create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update_patch.rb create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update_patch.yaml create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/create.yaml create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/delete.yaml create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/get.yaml create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/get_all.yaml create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/update.yaml create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/update_patch.yaml create mode 100644 content/automate/ManageIQ/Integration/ServiceNow/__namespace__.yaml create mode 100644 content/automate/ManageIQ/Integration/VMware/VimApi.class/__class__.yaml create mode 100644 content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_cpu.rb create mode 100644 content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_cpu.yaml create mode 100644 content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_disk.rb create mode 100644 content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_disk.yaml create mode 100644 content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_ram.rb create mode 100644 content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_ram.yaml create mode 100644 content/automate/ManageIQ/Integration/VMware/VimApi.class/vmware_hotadd_cpu.yaml create mode 100644 content/automate/ManageIQ/Integration/VMware/VimApi.class/vmware_hotadd_disk.yaml create mode 100644 content/automate/ManageIQ/Integration/VMware/VimApi.class/vmware_hotadd_ram.yaml create mode 100644 content/automate/ManageIQ/Integration/VMware/__namespace__.yaml create mode 100644 content/automate/ManageIQ/Integration/__namespace__.yaml diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__class__.yaml b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__class__.yaml new file mode 100644 index 000000000..290f47a3f --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__class__.yaml @@ -0,0 +1,133 @@ +--- +object_type: class +version: 1.0 +object: + attributes: + description: + display_name: + name: CMDB + type: + inherits: + visibility: + owner: + schema: + - field: + aetype: attribute + name: snow_server + display_name: + datatype: string + priority: 1 + owner: + default_value: + substitute: true + message: create + visibility: + collect: + scope: + description: + condition: + on_entry: + on_exit: + on_error: + max_retries: + max_time: + - field: + aetype: attribute + name: snow_user + display_name: + datatype: string + priority: 2 + owner: + default_value: + substitute: true + message: create + visibility: + collect: + scope: + description: + condition: + on_entry: + on_exit: + on_error: + max_retries: + max_time: + - field: + aetype: attribute + name: snow_password + display_name: + datatype: password + priority: 3 + owner: + default_value: + substitute: true + message: create + visibility: + collect: + scope: + description: + condition: + on_entry: + on_exit: + on_error: + max_retries: + max_time: + - field: + aetype: attribute + name: sys_id + display_name: + datatype: string + priority: 4 + owner: + default_value: + substitute: true + message: create + visibility: + collect: + scope: + description: + condition: + on_entry: + on_exit: + on_error: + max_retries: + max_time: + - field: + aetype: attribute + name: table_name + display_name: + datatype: string + priority: 5 + owner: + default_value: cmdb_ci_server + substitute: true + message: create + visibility: + collect: + scope: + description: + condition: + on_entry: + on_exit: + on_error: + max_retries: + max_time: + - field: + aetype: method + name: execute + display_name: + datatype: string + priority: 6 + owner: + default_value: + substitute: true + message: create + visibility: + collect: + scope: + description: + condition: + on_entry: + on_exit: + on_error: + max_retries: + max_time: diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/create.rb b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/create.rb new file mode 100644 index 000000000..94d382855 --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/create.rb @@ -0,0 +1,86 @@ +# +# Description: Create ServiceNow CMDB Record +# + +require 'rest-client' +require 'json' +require 'base64' + +def log(level, message) + method = '----- Create ServiceNow CMDB Record -----' + $evm.log(level, "#{method} - #{message}") +end + +def get_virtual_column_value(vm, virtual_column_name) + virtual_column_value = vm.send(virtual_column_name) + return virtual_column_value unless virtual_column_value.nil? + nil +end + +def hostname(vm) + vm.hostnames.first.presence || vm.name +end + +snow_server = $evm.object['snow_server'] +snow_user = $evm.object['snow_user'] +snow_password = $evm.object.decrypt('snow_password') +table_name = $evm.object['table_name'] +uri = "https://#{snow_server}/api/now/table/#{table_name}" + +headers = { + :content_type => 'application/json', + :accept => 'application/json', + :authorization => "Basic #{Base64.strict_encode64("#{snow_user}:#{snow_password}")}" +} + +# Grab the VM object +log(:info, "vmdb_object_type => <#{$evm.root['vmdb_object_type']}>") +case $evm.root['vmdb_object_type'] +when 'miq_provision' + prov = $evm.root['miq_provision'] + vm = prov.vm unless prov.nil? +when 'service_template_provision_task' + # Added for generic catalogue item scenario + vm_host_name = $evm.root['service_template_provision_task'].options[:dialog][:dialog_option_0_vm_host_name] + vm = $evm.vmdb('vm').find_by_name(vm_host_name) +else + vm = $evm.root['vm'] +end +log(:warn, 'VM object is empty') if vm.nil? + +# Extend payload attributes as required +virtual = $evm.object['virtual'] || true +name = $evm.object['name'] || vm.name +description = $evm.object['description'] || "CloudForms GUID <#{vm.guid}>" +host_name = $evm.object['host_name'] || hostname(vm) +cpu_count = $evm.object['cpu_count'] || get_virtual_column_value(vm, :num_cpu) +memory = $evm.object['memory'] || get_virtual_column_value(vm, :mem_cpu) +vendor = $evm.object['vendor'] || vm.vendor + +payload = { + :virtual => virtual, + :name => name, + :short_description => description, + :host_name => host_name, + :cpu_count => cpu_count, + :ram => memory, + :vendor => vendor +} +log(:info, "uri => #{uri}") +log(:info, "payload => #{payload}") + +request = RestClient::Request.new( + :method => :post, + :url => uri, + :headers => headers, + :payload => payload.to_json +) +rest_result = request.execute +log(:info, "Return code <#{rest_result.code}>") + +json_parse = JSON.parse(rest_result) +result = json_parse['result'] +log(:info, "sys_id => <#{result['sys_id']}>") + +# Add sys_id to VM object +vm.custom_set(:servicenow_sys_id, result['sys_id']) diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/create.yaml b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/create.yaml new file mode 100644 index 000000000..836864dab --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/create.yaml @@ -0,0 +1,12 @@ +--- +object_type: method +version: 1.0 +object: + attributes: + name: create + display_name: + description: + scope: instance + language: ruby + location: inline + inputs: [] diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/delete.rb b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/delete.rb new file mode 100644 index 000000000..f416a12d7 --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/delete.rb @@ -0,0 +1,48 @@ +# +# Description: Delete ServiceNow CMDB Record +# + +require 'rest-client' +require 'base64' + +def log(level, message) + method = '----- Delete ServiceNow CMDB Record -----' + $evm.log(level, "#{method} - #{message}") +end + +snow_server = $evm.object['snow_server'] +snow_user = $evm.object['snow_user'] +snow_password = $evm.object.decrypt('snow_password') +table_name = $evm.object['table_name'] +uri = "https://#{snow_server}/api/now/table/#{table_name}" + +headers = { + :content_type => 'application/json', + :accept => 'application/json', + :authorization => "Basic #{Base64.strict_encode64("#{snow_user}:#{snow_password}")}" +} + +# Grab the VM object +log(:info, "vmdb_object_type => <#{$evm.root['vmdb_object_type']}>") +case $evm.root['vmdb_object_type'] +when 'miq_provision' + prov = $evm.root['miq_provision'] + vm = prov.vm unless prov.nil? +else + vm = $evm.root['vm'] +end +log(:warn, 'VM object is empty') if vm.nil? + +sys_id = $evm.object['sys_id'] || vm.custom_get(:servicenow_sys_id) +raise 'ServiceNow sys_id is empty' if sys_id.nil? + +uri = "#{uri}/#{sys_id}" +log(:info, "uri => #{uri}") + +request = RestClient::Request.new( + :method => :delete, + :url => uri, + :headers => headers, +) +rest_result = request.execute +log(:info, "Return code <#{rest_result.code}>") diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/delete.yaml b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/delete.yaml new file mode 100644 index 000000000..48a32775e --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/delete.yaml @@ -0,0 +1,12 @@ +--- +object_type: method +version: 1.0 +object: + attributes: + name: delete + display_name: + description: + scope: instance + language: ruby + location: inline + inputs: [] diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get.rb b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get.rb new file mode 100644 index 000000000..c7af0d1d2 --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get.rb @@ -0,0 +1,56 @@ +# +# Description: Get ServiceNow CMDB Record +# + +require 'rest-client' +require 'json' +require 'base64' + +def log(level, message) + method = '----- Get ServiceNow CMDB Record -----' + $evm.log(level, "#{method} - #{message}") +end + +snow_server = $evm.object['snow_server'] +snow_user = $evm.object['snow_user'] +snow_password = $evm.object.decrypt('snow_password') +table_name = $evm.object['table_name'] +uri = "https://#{snow_server}/api/now/table/#{table_name}" + +headers = { + :content_type => 'application/json', + :accept => 'application/json', + :authorization => "Basic #{Base64.strict_encode64("#{snow_user}:#{snow_password}")}" +} + +# Grab the VM object +log(:info, "vmdb_object_type => <#{$evm.root['vmdb_object_type']}>") +case $evm.root['vmdb_object_type'] +when 'miq_provision' + prov = $evm.root['miq_provision'] + vm = prov.vm unless prov.nil? +else + vm = $evm.root['vm'] +end +log(:warn, 'VM object is empty') if vm.nil? + +sys_id = $evm.object['sys_id'] || vm.custom_get(:servicenow_sys_id) +raise 'ServiceNow sys_id is empty' if sys_id.nil? + +uri = "#{uri}/#{sys_id}" +log(:info, "uri => #{uri}") + +request = RestClient::Request.new( + :method => :get, + :url => uri, + :headers => headers +) +rest_result = request.execute +log(:info, "Return code <#{rest_result.code}>") + +json_parse = JSON.parse(rest_result) +result = json_parse['result'] +log(:info, "Item <#{result['name']}> attributes:") +result.sort.each do | k, v | + log(:info, " #{k} => <#{v}>") +end diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get.yaml b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get.yaml new file mode 100644 index 000000000..3731f45ce --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get.yaml @@ -0,0 +1,12 @@ +--- +object_type: method +version: 1.0 +object: + attributes: + name: get + display_name: + description: + scope: instance + language: ruby + location: inline + inputs: [] diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get_all.rb b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get_all.rb new file mode 100644 index 000000000..1a4bfa89e --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get_all.rb @@ -0,0 +1,43 @@ +# +# Description: Get All ServiceNow CMDB Records +# + +require 'rest-client' +require 'json' +require 'base64' + +def log(level, message) + method = '----- Get All ServiceNow CMDB Records -----' + $evm.log(level, "#{method} - #{message}") +end + +snow_server = $evm.object['snow_server'] +snow_user = $evm.object['snow_user'] +snow_password = $evm.object.decrypt('snow_password') +table_name = $evm.object['table_name'] +uri = "https://#{snow_server}/api/now/table/#{table_name}" + +headers = { + :content_type => 'application/json', + :accept => 'application/json', + :authorization => "Basic #{Base64.strict_encode64("#{snow_user}:#{snow_password}")}" +} + +log(:info, "uri => #{uri}") + +request = RestClient::Request.new( + :method => :get, + :url => uri, + :headers => headers +) +rest_result = request.execute +log(:info, "Return code <#{rest_result.code}>") + +json_parse = JSON.parse(rest_result) +result = json_parse['result'] +result.each do | ci | + log(:info, "Item <#{ci['name']}> attributes:") + ci.sort.each do | k, v | + log(:info, " #{k} => <#{v}>") + end +end diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get_all.yaml b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get_all.yaml new file mode 100644 index 000000000..db6753b4b --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/get_all.yaml @@ -0,0 +1,12 @@ +--- +object_type: method +version: 1.0 +object: + attributes: + name: get_all + display_name: + description: + scope: instance + language: ruby + location: inline + inputs: [] diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update.rb b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update.rb new file mode 100644 index 000000000..b72f23277 --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update.rb @@ -0,0 +1,82 @@ +# +# Description: Update ServiceNow CMDB Record +# + +require 'rest-client' +require 'json' +require 'base64' + +def log(level, message) + method = '----- Update ServiceNow CMDB Record -----' + $evm.log(level, "#{method} - #{message}") +end + +def get_virtual_column_value(vm, virtual_column_name) + virtual_column_value = vm.send(virtual_column_name) + return virtual_column_value unless virtual_column_value.nil? + nil +end + +def hostname(vm) + vm.hostnames.first.presence || vm.name +end + +snow_server = $evm.object['snow_server'] +snow_user = $evm.object['snow_user'] +snow_password = $evm.object.decrypt('snow_password') +table_name = $evm.object['table_name'] +uri = "https://#{snow_server}/api/now/table/#{table_name}" + +headers = { + :content_type => 'application/json', + :accept => 'application/json', + :authorization => "Basic #{Base64.strict_encode64("#{snow_user}:#{snow_password}")}" +} + +# Grab the VM object +log(:info, "vmdb_object_type => <#{$evm.root['vmdb_object_type']}>") +case $evm.root['vmdb_object_type'] +when 'miq_provision' + prov = $evm.root['miq_provision'] + vm = prov.vm unless prov.nil? +else + vm = $evm.root['vm'] +end +log(:warn, 'VM object is empty') if vm.nil? + +sys_id = $evm.object['sys_id'] || vm.custom_get(:servicenow_sys_id) +raise 'ServiceNow sys_id is empty' if sys_id.nil? + +uri = "#{uri}/#{sys_id}" + +log(:info, 'Getting item details') +request = RestClient::Request.new( + :method => :get, + :url => uri, + :headers => headers +) +rest_result = request.execute +log(:info, "Return code <#{rest_result.code}>") + +json_parse = JSON.parse(rest_result) +result = json_parse['result'] + +# Extend payload attributes as required +result[:virtual] = $evm.object['virtual'] || true +result[:name] = $evm.object['name'] || vm.name +result[:short_description] = $evm.object['description'] || "CloudForms GUID <#{vm.guid}>" +result[:host_name] = $evm.object['host_name'] || hostname(vm) +result[:cpu_count] = $evm.object['cpu_count'] || get_virtual_column_value(vm, :num_cpu) +result[:ram] = $evm.object['memory'] || get_virtual_column_value(vm, :mem_cpu) +result[:vendor] = $evm.object['vendor'] || vm.vendor +log(:info, "payload => #{result}") + +log(:info, 'Updating record details') +request = RestClient::Request.new( + :method => :put, + :url => uri, + :headers => (headers.merge!(:cookies => request.cookies)), + :payload => result.to_json +) +rest_result = request.execute +log(:info, "Return code <#{rest_result.code}>") diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update.yaml b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update.yaml new file mode 100644 index 000000000..e24450bdc --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update.yaml @@ -0,0 +1,12 @@ +--- +object_type: method +version: 1.0 +object: + attributes: + name: update + display_name: + description: + scope: instance + language: ruby + location: inline + inputs: [] diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update_patch.rb b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update_patch.rb new file mode 100644 index 000000000..e25c40d5b --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update_patch.rb @@ -0,0 +1,79 @@ +# +# Description: Update(Patch) ServiceNow CMDB Record +# + +require 'rest-client' +require 'json' +require 'base64' + +def log(level, message) + method = '----- Update(Patch) ServiceNow CMDB Record -----' + $evm.log(level, "#{method} - #{message}") +end + +def get_virtual_column_value(vm, virtual_column_name) + virtual_column_value = vm.send(virtual_column_name) + return virtual_column_value unless virtual_column_value.nil? + nil +end + +def hostname(vm) + vm.hostnames.first.presence || vm.name +end + +snow_server = $evm.object['snow_server'] +snow_user = $evm.object['snow_user'] +snow_password = $evm.object.decrypt('snow_password') +table_name = $evm.object['table_name'] +uri = "https://#{snow_server}/api/now/table/#{table_name}" + +headers = { + :content_type => 'application/json', + :accept => 'application/json', + :authorization => "Basic #{Base64.strict_encode64("#{snow_user}:#{snow_password}")}" +} + +# Grab the VM object +log(:info, "vmdb_object_type => <#{$evm.root['vmdb_object_type']}>") +case $evm.root['vmdb_object_type'] +when 'miq_provision' + prov = $evm.root['miq_provision'] + vm = prov.vm unless prov.nil? +else + vm = $evm.root['vm'] +end +log(:warn, 'VM object is empty') if vm.nil? + +sys_id = $evm.object['sys_id'] || vm.custom_get(:servicenow_sys_id) +raise 'ServiceNow sys_id is empty' if sys_id.nil? +uri = "#{uri}/#{sys_id}" + +# Extend payload attributes as required +virtual = $evm.object['virtual'] || true +name = $evm.object['name'] || vm.name +description = $evm.object['description'] || "CloudForms GUID <#{vm.guid}>" +host_name = $evm.object['host_name'] || hostname(vm) +cpu_count = $evm.object['cpu_count'] || get_virtual_column_value(vm, :num_cpu) +memory = $evm.object['memory'] || get_virtual_column_value(vm, :mem_cpu) +vendor = $evm.object['vendor'] || vm.vendor + +payload = { + :virtual => virtual, + :name => name, + :short_description => description, + :host_name => host_name, + :cpu_count => cpu_count, + :ram => memory, + :vendor => vendor +} +log(:info, "uri => #{uri}") +log(:info, "payload => #{payload}") + +request = RestClient::Request.new( + :method => :patch, + :url => uri, + :headers => headers, + :payload => payload.to_json +) +rest_result = request.execute +log(:info, "Return code <#{rest_result.code}>") diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update_patch.yaml b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update_patch.yaml new file mode 100644 index 000000000..2f9d485f4 --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/__methods__/update_patch.yaml @@ -0,0 +1,12 @@ +--- +object_type: method +version: 1.0 +object: + attributes: + name: update_patch + display_name: + description: + scope: instance + language: ruby + location: inline + inputs: [] diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/create.yaml b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/create.yaml new file mode 100644 index 000000000..d2417703e --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/create.yaml @@ -0,0 +1,12 @@ +--- +object_type: instance +version: 1.0 +object: + attributes: + display_name: + name: create + inherits: + description: + fields: + - execute: + value: create diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/delete.yaml b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/delete.yaml new file mode 100644 index 000000000..0dc779355 --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/delete.yaml @@ -0,0 +1,12 @@ +--- +object_type: instance +version: 1.0 +object: + attributes: + display_name: + name: delete + inherits: + description: + fields: + - execute: + value: delete diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/get.yaml b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/get.yaml new file mode 100644 index 000000000..5f171ab83 --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/get.yaml @@ -0,0 +1,12 @@ +--- +object_type: instance +version: 1.0 +object: + attributes: + display_name: + name: get + inherits: + description: + fields: + - execute: + value: get diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/get_all.yaml b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/get_all.yaml new file mode 100644 index 000000000..9ae159cbc --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/get_all.yaml @@ -0,0 +1,12 @@ +--- +object_type: instance +version: 1.0 +object: + attributes: + display_name: + name: get_all + inherits: + description: + fields: + - execute: + value: get_all diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/update.yaml b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/update.yaml new file mode 100644 index 000000000..2bc0d02ce --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/update.yaml @@ -0,0 +1,12 @@ +--- +object_type: instance +version: 1.0 +object: + attributes: + display_name: + name: update + inherits: + description: + fields: + - execute: + value: update diff --git a/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/update_patch.yaml b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/update_patch.yaml new file mode 100644 index 000000000..abc45865b --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/CMDB.class/update_patch.yaml @@ -0,0 +1,12 @@ +--- +object_type: instance +version: 1.0 +object: + attributes: + display_name: + name: update_patch + inherits: + description: + fields: + - execute: + value: update_patch diff --git a/content/automate/ManageIQ/Integration/ServiceNow/__namespace__.yaml b/content/automate/ManageIQ/Integration/ServiceNow/__namespace__.yaml new file mode 100644 index 000000000..b369c83ec --- /dev/null +++ b/content/automate/ManageIQ/Integration/ServiceNow/__namespace__.yaml @@ -0,0 +1,10 @@ +--- +object_type: namespace +version: 1.0 +object: + attributes: + name: ServiceNow + description: + display_name: + priority: + enabled: diff --git a/content/automate/ManageIQ/Integration/VMware/VimApi.class/__class__.yaml b/content/automate/ManageIQ/Integration/VMware/VimApi.class/__class__.yaml new file mode 100644 index 000000000..2f1a01a24 --- /dev/null +++ b/content/automate/ManageIQ/Integration/VMware/VimApi.class/__class__.yaml @@ -0,0 +1,33 @@ +--- +object_type: class +version: 1.0 +object: + attributes: + description: + display_name: + name: VimApi + type: + inherits: + visibility: + owner: + schema: + - field: + aetype: method + name: execute + display_name: + datatype: string + priority: 1 + owner: + default_value: + substitute: true + message: create + visibility: + collect: + scope: + description: + condition: + on_entry: + on_exit: + on_error: + max_retries: + max_time: diff --git a/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_cpu.rb b/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_cpu.rb new file mode 100644 index 000000000..b91b806fc --- /dev/null +++ b/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_cpu.rb @@ -0,0 +1,19 @@ +# +# Description: This method is used to modify vCPUs to an existing VM running on VMware +# +# Inputs: $evm.root['vm'], cpus +# + +# Get vm object from root +vm = $evm.root['vm'] +raise "Missing $evm.root['vm'] object" unless vm + +# Get the number of cpus from root +cpus = $evm.root['cpus'].to_i +$evm.log("info", "Detected cpus:<#{cpus}>") + +# Add disk to a VM +unless cpus.zero? + $evm.log("info", "Setting number of vCPUs to #{cpus} on VM:<#{vm.name}>") + vm.set_number_of_cpus(cpus.to_i, :sync => true) +end diff --git a/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_cpu.yaml b/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_cpu.yaml new file mode 100644 index 000000000..1a547c57a --- /dev/null +++ b/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_cpu.yaml @@ -0,0 +1,12 @@ +--- +object_type: method +version: 1.0 +object: + attributes: + name: VMware_HotAdd_CPU + display_name: + description: + scope: instance + language: ruby + location: inline + inputs: [] diff --git a/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_disk.rb b/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_disk.rb new file mode 100644 index 000000000..86b8e710c --- /dev/null +++ b/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_disk.rb @@ -0,0 +1,21 @@ +# +# Description: This method is used to add a new disk to an existing VM running on VMware +# +# Inputs: $evm.root['vm'], size +# + +# Get vm object +vm = $evm.root['vm'] +raise "Missing $evm.root['vm'] object" unless vm + +# Get the size for the new disk from the root object +size = $evm.root['size'].to_i +$evm.log("info", "Detected size:<#{size}>") + +# Add disk to a VM +if size.zero? + $evm.log("error", "Size:<#{size}> invalid") +else + $evm.log("info", "Creating a new #{size}GB disk on Storage:<#{vm.storage_name}>") + vm.add_disk("[#{vm.storage_name}]", size * 1024, :sync => true) +end diff --git a/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_disk.yaml b/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_disk.yaml new file mode 100644 index 000000000..571e025f7 --- /dev/null +++ b/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_disk.yaml @@ -0,0 +1,12 @@ +--- +object_type: method +version: 1.0 +object: + attributes: + name: VMware_HotAdd_Disk + display_name: + description: + scope: instance + language: ruby + location: inline + inputs: [] diff --git a/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_ram.rb b/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_ram.rb new file mode 100644 index 000000000..a894111d3 --- /dev/null +++ b/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_ram.rb @@ -0,0 +1,18 @@ +# +# Description: This method is used to modify vRAM to an existing VM running on VMware +# +# Inputs: $evm.root['vm'], ram +# + +# Get vm object from root +vm = $evm.root['vm'] +raise "Missing $evm.root['vm'] object" unless vm + +# Get amount of ram from root +ram = $evm.root['ram'].to_i +$evm.log("info", "Detected ram:<#{ram}>") + +unless ram.zero? + $evm.log("info", "Setting amount of vRAM to #{ram} on VM:<#{vm.name}>") + vm.set_memory(ram, :sync => true) +end diff --git a/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_ram.yaml b/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_ram.yaml new file mode 100644 index 000000000..f23f70a02 --- /dev/null +++ b/content/automate/ManageIQ/Integration/VMware/VimApi.class/__methods__/vmware_hotadd_ram.yaml @@ -0,0 +1,12 @@ +--- +object_type: method +version: 1.0 +object: + attributes: + name: VMware_HotAdd_RAM + display_name: + description: + scope: instance + language: ruby + location: inline + inputs: [] diff --git a/content/automate/ManageIQ/Integration/VMware/VimApi.class/vmware_hotadd_cpu.yaml b/content/automate/ManageIQ/Integration/VMware/VimApi.class/vmware_hotadd_cpu.yaml new file mode 100644 index 000000000..7d4c892e2 --- /dev/null +++ b/content/automate/ManageIQ/Integration/VMware/VimApi.class/vmware_hotadd_cpu.yaml @@ -0,0 +1,12 @@ +--- +object_type: instance +version: 1.0 +object: + attributes: + display_name: + name: VMware_HotAdd_CPU + inherits: + description: + fields: + - execute: + value: VMware_HotAdd_CPU diff --git a/content/automate/ManageIQ/Integration/VMware/VimApi.class/vmware_hotadd_disk.yaml b/content/automate/ManageIQ/Integration/VMware/VimApi.class/vmware_hotadd_disk.yaml new file mode 100644 index 000000000..5607c1ccf --- /dev/null +++ b/content/automate/ManageIQ/Integration/VMware/VimApi.class/vmware_hotadd_disk.yaml @@ -0,0 +1,12 @@ +--- +object_type: instance +version: 1.0 +object: + attributes: + display_name: + name: VMware_HotAdd_Disk + inherits: + description: + fields: + - execute: + value: VMware_HotAdd_Disk diff --git a/content/automate/ManageIQ/Integration/VMware/VimApi.class/vmware_hotadd_ram.yaml b/content/automate/ManageIQ/Integration/VMware/VimApi.class/vmware_hotadd_ram.yaml new file mode 100644 index 000000000..3db881728 --- /dev/null +++ b/content/automate/ManageIQ/Integration/VMware/VimApi.class/vmware_hotadd_ram.yaml @@ -0,0 +1,12 @@ +--- +object_type: instance +version: 1.0 +object: + attributes: + display_name: + name: VMware_HotAdd_RAM + inherits: + description: + fields: + - execute: + value: VMware_HotAdd_RAM diff --git a/content/automate/ManageIQ/Integration/VMware/__namespace__.yaml b/content/automate/ManageIQ/Integration/VMware/__namespace__.yaml new file mode 100644 index 000000000..e1d60c166 --- /dev/null +++ b/content/automate/ManageIQ/Integration/VMware/__namespace__.yaml @@ -0,0 +1,10 @@ +--- +object_type: namespace +version: 1.0 +object: + attributes: + name: VMware + description: + display_name: + priority: + enabled: diff --git a/content/automate/ManageIQ/Integration/__namespace__.yaml b/content/automate/ManageIQ/Integration/__namespace__.yaml new file mode 100644 index 000000000..d8aab7cbb --- /dev/null +++ b/content/automate/ManageIQ/Integration/__namespace__.yaml @@ -0,0 +1,10 @@ +--- +object_type: namespace +version: 1.0 +object: + attributes: + name: Integration + description: + display_name: + priority: + enabled: