_id
stringlengths 2
6
| title
stringlengths 9
130
| partition
stringclasses 3
values | text
stringlengths 30
4.3k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q1200
|
Lex.Linter.validate_tokens
|
train
|
def validate_tokens(lexer)
if lexer.lex_tokens.empty?
complain("No token list defined")
end
if !lexer.lex_tokens.respond_to?(:to_ary)
complain("Tokens must be a list or enumerable")
end
terminals = []
lexer.lex_tokens.each do |token|
if !identifier?(token)
|
ruby
|
{
"resource": ""
}
|
q1201
|
Lex.Linter.validate_states
|
train
|
def validate_states(lexer)
if !lexer.state_info.respond_to?(:each_pair)
complain("States must be defined as a hash")
end
lexer.state_info.each do |state_name, state_type|
if ![:inclusive, :exclusive].include?(state_type)
complain("State type for state #{state_name}" \
" must be :inclusive or :exclusive")
end
if state_type == :exclusive
if !lexer.state_error.key?(state_name)
lexer.logger.warn("No error rule is defined " \
|
ruby
|
{
"resource": ""
}
|
q1202
|
Scorched.Response.body=
|
train
|
def body=(value)
value = [] if !value || value
|
ruby
|
{
"resource": ""
}
|
q1203
|
Scorched.Response.finish
|
train
|
def finish(*args, &block)
self['Content-Type'] ||= 'text/html;charset=utf-8'
@block = block if block
if [204, 205, 304].include?(status.to_i)
header.delete "Content-Type"
|
ruby
|
{
"resource": ""
}
|
q1204
|
Scorched.Controller.try_matches
|
train
|
def try_matches
eligable_matches.each do |match,idx|
request.breadcrumb << match
catch(:pass) {
dispatch(match)
|
ruby
|
{
"resource": ""
}
|
q1205
|
Scorched.Controller.dispatch
|
train
|
def dispatch(match)
@_dispatched = true
target = match.mapping[:target]
response.merge! begin
if Proc === target
instance_exec(&target)
else
target.call(env.merge(
'SCRIPT_NAME' => request.matched_path.chomp('/'),
|
ruby
|
{
"resource": ""
}
|
q1206
|
Scorched.Controller.matches
|
train
|
def matches
@_matches ||= begin
to_match = request.unmatched_path
to_match = to_match.chomp('/') if config[:strip_trailing_slash] == :ignore && to_match =~ %r{./$}
mappings.map { |mapping|
mapping[:pattern].match(to_match) do |match_data|
if match_data.pre_match == ''
if match_data.names.empty?
captures = match_data.captures
else
captures = Hash[match_data.names.map {|v| v.to_sym}.zip(match_data.captures)]
captures.each do
|
ruby
|
{
"resource": ""
}
|
q1207
|
Scorched.Controller.eligable_matches
|
train
|
def eligable_matches
@_eligable_matches ||= begin
matches.select { |m| m.failed_condition.nil? }.each_with_index.sort_by do |m,idx|
priority = m.mapping[:priority] || 0
media_type_rank = [*m.mapping[:conditions][:media_type]].map { |type|
|
ruby
|
{
"resource": ""
}
|
q1208
|
Scorched.Controller.check_for_failed_condition
|
train
|
def check_for_failed_condition(conds)
failed = (conds || []).find { |c, v| !check_condition?(c, v) }
if failed
|
ruby
|
{
"resource": ""
}
|
q1209
|
Scorched.Controller.check_condition?
|
train
|
def check_condition?(c, v)
c = c[0..-2].to_sym if invert = (c[-1] == '!')
raise Error, "The condition `#{c}` either does
|
ruby
|
{
"resource": ""
}
|
q1210
|
Scorched.Controller.redirect
|
train
|
def redirect(url, status: (env['HTTP_VERSION'] == 'HTTP/1.1') ? 303 : 302, halt: true)
|
ruby
|
{
"resource": ""
}
|
q1211
|
Scorched.Controller.flash
|
train
|
def flash(key = :flash)
raise Error, "Flash session data cannot be used without a valid Rack session" unless session
flash_hash = env['scorched.flash'] ||= {}
|
ruby
|
{
"resource": ""
}
|
q1212
|
Scorched.Controller.run_filters
|
train
|
def run_filters(type)
halted = false
tracker = env['scorched.executed_filters'] ||= {before: Set.new, after: Set.new}
filters[type].reject { |f| tracker[type].include?(f)
|
ruby
|
{
"resource": ""
}
|
q1213
|
Scorched.Request.unescaped_path
|
train
|
def unescaped_path
path_info.split(/(%25|%2F)/i).each_slice(2).map
|
ruby
|
{
"resource": ""
}
|
q1214
|
SoftLayer.Server.reboot!
|
train
|
def reboot!(reboot_technique = :default_reboot)
case reboot_technique
when :default_reboot
self.service.rebootDefault
when :os_reboot
|
ruby
|
{
"resource": ""
}
|
q1215
|
SoftLayer.Server.notes=
|
train
|
def notes=(new_notes)
raise ArgumentError, "The new notes cannot be nil" unless new_notes
|
ruby
|
{
"resource": ""
}
|
q1216
|
SoftLayer.Server.set_hostname!
|
train
|
def set_hostname!(new_hostname)
raise ArgumentError, "The new hostname cannot be nil" unless new_hostname
raise ArgumentError, "The new hostname cannot be empty" if new_hostname.empty?
edit_template = {
|
ruby
|
{
"resource": ""
}
|
q1217
|
SoftLayer.Server.set_domain!
|
train
|
def set_domain!(new_domain)
raise ArgumentError, "The new hostname cannot be nil" unless new_domain
raise ArgumentError, "The new hostname cannot be empty" if new_domain.empty?
edit_template = {
|
ruby
|
{
"resource": ""
}
|
q1218
|
SoftLayer.Server.change_port_speed
|
train
|
def change_port_speed(new_speed, public = true)
if public
self.service.setPublicNetworkInterfaceSpeed(new_speed)
|
ruby
|
{
"resource": ""
}
|
q1219
|
SoftLayer.Server.reload_os!
|
train
|
def reload_os!(token = '', provisioning_script_uri = nil, ssh_keys = nil)
configuration = {}
configuration['customProvisionScriptUri'] = provisioning_script_uri if provisioning_script_uri
|
ruby
|
{
"resource": ""
}
|
q1220
|
Drone.Plugin.parse
|
train
|
def parse
self.result ||= Payload.new.tap do |payload|
PayloadRepresenter.new(
payload
).from_json(
input
|
ruby
|
{
"resource": ""
}
|
q1221
|
SoftLayer.APIParameterFilter.object_filter
|
train
|
def object_filter(filter)
raise ArgumentError, "object_filter expects an instance of SoftLayer::ObjectFilter" if filter.nil? || !filter.kind_of?(SoftLayer::ObjectFilter)
# we create a new object in case the user wants to store
|
ruby
|
{
"resource": ""
}
|
q1222
|
SoftLayer.VirtualServerUpgradeOrder.verify
|
train
|
def verify()
if has_order_items?
order_template = order_object
order_template = yield order_object if block_given?
|
ruby
|
{
"resource": ""
}
|
q1223
|
SoftLayer.VirtualServerUpgradeOrder.place_order!
|
train
|
def place_order!()
if has_order_items?
order_template = order_object
order_template = yield order_object if block_given?
|
ruby
|
{
"resource": ""
}
|
q1224
|
SoftLayer.VirtualServerUpgradeOrder._item_prices_in_category
|
train
|
def _item_prices_in_category(which_category)
@virtual_server.upgrade_options.select { |item_price| item_price['categories'].find {
|
ruby
|
{
"resource": ""
}
|
q1225
|
SoftLayer.VirtualServerUpgradeOrder._item_price_with_capacity
|
train
|
def _item_price_with_capacity(which_category, capacity)
_item_prices_in_category(which_category).find { |item_price|
|
ruby
|
{
"resource": ""
}
|
q1226
|
SoftLayer.VirtualServerUpgradeOrder.order_object
|
train
|
def order_object
prices = []
cores_price_item = @cores ? _item_price_with_capacity("guest_core", @cores) : nil
ram_price_item = @ram ? _item_price_with_capacity("ram", @ram) : nil
max_port_speed_price_item = @max_port_speed ? _item_price_with_capacity("port_speed", @max_port_speed) : nil
prices << { "id" => cores_price_item['id'] } if cores_price_item
|
ruby
|
{
"resource": ""
}
|
q1227
|
SoftLayer.NetworkStorage.assign_credential
|
train
|
def assign_credential(username)
raise ArgumentError, "The username cannot be nil" unless username
raise ArgumentError, "The username cannot be empty" if username.empty?
|
ruby
|
{
"resource": ""
}
|
q1228
|
SoftLayer.NetworkStorage.password=
|
train
|
def password=(password)
raise ArgumentError, "The new password cannot be nil" unless password
raise ArgumentError,
|
ruby
|
{
"resource": ""
}
|
q1229
|
SoftLayer.NetworkStorage.remove_credential
|
train
|
def remove_credential(username)
raise ArgumentError, "The username cannot be nil" unless username
raise ArgumentError, "The username cannot be empty" if username.empty?
|
ruby
|
{
"resource": ""
}
|
q1230
|
SoftLayer.NetworkStorage.softlayer_properties
|
train
|
def softlayer_properties(object_mask = nil)
my_service = self.service
if(object_mask)
my_service = my_service.object_mask(object_mask)
else
my_service
|
ruby
|
{
"resource": ""
}
|
q1231
|
SoftLayer.NetworkStorage.update_credential_password
|
train
|
def update_credential_password(username, password)
raise ArgumentError, "The new password cannot be nil" unless password
raise ArgumentError, "The new username cannot be nil" unless username
raise ArgumentError, "The new password cannot be empty"
|
ruby
|
{
"resource": ""
}
|
q1232
|
SoftLayer.ProductPackage.items_with_description
|
train
|
def items_with_description(expected_description)
filter = ObjectFilter.new { |filter| filter.accept("items.description").when_it is(expected_description) }
items_data = self.service.object_filter(filter).getItems()
items_data.collect
|
ruby
|
{
"resource": ""
}
|
q1233
|
SoftLayer.ImageTemplate.available_datacenters
|
train
|
def available_datacenters
datacenters_data = self.service.getStorageLocations()
datacenters_data.collect { |datacenter_data|
|
ruby
|
{
"resource": ""
}
|
q1234
|
SoftLayer.ImageTemplate.shared_with_accounts=
|
train
|
def shared_with_accounts= (account_id_list)
already_sharing_with = self.shared_with_accounts
accounts_to_add = account_id_list.select { |account_id| !already_sharing_with.include?(account_id) }
# Note, using the network API, it is possible to "unshare" an image template
# with the account that owns it, however, this leads to a rather odd state
# where the image has allocated resources (that the account may be charged for)
# but no
|
ruby
|
{
"resource": ""
}
|
q1235
|
SoftLayer.ImageTemplate.wait_until_ready
|
train
|
def wait_until_ready(max_trials, seconds_between_tries = 2)
# pessimistically assume the server is not ready
num_trials = 0
begin
self.refresh_details()
parent_ready = !(has_sl_property? :transactionId) || (self[:transactionId] == "")
children_ready = (nil == self['children'].find { |child| child['transactionId'] != "" })
ready = parent_ready && children_ready
|
ruby
|
{
"resource": ""
}
|
q1236
|
SoftLayer.ServerFirewallOrder.verify
|
train
|
def verify()
order_template = firewall_order_template
order_template = yield order_template if block_given?
|
ruby
|
{
"resource": ""
}
|
q1237
|
SoftLayer.VLANFirewall.cancel!
|
train
|
def cancel!(notes = nil)
user = self.softlayer_client[:Account].object_mask("mask[id,account.id]").getCurrentUser
notes = "Cancelled by a call to #{__method__} in the softlayer_api gem" if notes == nil || notes == ""
cancellation_request = {
'accountId' => user['account']['id'],
'userId' => user['id'],
'items' =>
|
ruby
|
{
"resource": ""
}
|
q1238
|
SoftLayer.VLANFirewall.change_rules_bypass!
|
train
|
def change_rules_bypass!(bypass_symbol)
change_object = {
"firewallContextAccessControlListId" => rules_ACL_id(),
"rules" => self.rules
}
case bypass_symbol
when :apply_firewall_rules
change_object['bypassFlag'] = false
self.softlayer_client[:Network_Firewall_Update_Request].createObject(change_object)
when :bypass_firewall_rules
change_object['bypassFlag'] =
|
ruby
|
{
"resource": ""
}
|
q1239
|
SoftLayer.VLANFirewall.change_routing_bypass!
|
train
|
def change_routing_bypass!(routing_symbol)
vlan_firewall_id = self['networkVlanFirewall']['id']
raise "Could not identify the device for a VLAN firewall" if !vlan_firewall_id
case routing_symbol
when :route_through_firewall
self.softlayer_client[:Network_Vlan_Firewall].object_with_id(vlan_firewall_id).updateRouteBypass(false)
|
ruby
|
{
"resource": ""
}
|
q1240
|
SoftLayer.VLANFirewall.rules_ACL_id
|
train
|
def rules_ACL_id
outside_interface_data = self['firewallInterfaces'].find { |interface_data| interface_data['name'] == 'outside' }
incoming_ACL = outside_interface_data['firewallContextAccessControlLists'].find
|
ruby
|
{
"resource": ""
}
|
q1241
|
SoftLayer.VirtualServerOrder.place_order!
|
train
|
def place_order!()
order_template = virtual_guest_template
order_template = yield order_template if block_given?
virtual_server_hash
|
ruby
|
{
"resource": ""
}
|
q1242
|
SoftLayer.Software.delete_user_password!
|
train
|
def delete_user_password!(username)
user_password = self.passwords.select { |sw_pw| sw_pw.username == username.to_s }
|
ruby
|
{
"resource": ""
}
|
q1243
|
Danger.DangerTodoist.print_todos_table
|
train
|
def print_todos_table
find_todos if @todos.nil?
return if @todos.empty?
markdown("#### Todos left in files")
@todos
|
ruby
|
{
"resource": ""
}
|
q1244
|
SoftLayer.VirtualServerOrder_Package.virtual_server_order
|
train
|
def virtual_server_order
product_order = {
'packageId' => @package.id,
'useHourlyPricing' => !!@hourly,
'virtualGuests' => [{
'domain' => @domain,
'hostname' => @hostname
}]
}
#Note that the use of image_template and SoftLayer::ProductPackage os/guest_diskX configuration category
#item prices is mutually exclusive.
product_order['imageTemplateGlobalIdentifier'] = @image_template.global_id if @image_template
product_order['location'] = @datacenter.id if @datacenter
|
ruby
|
{
"resource": ""
}
|
q1245
|
SoftLayer.VirtualServer.capture_image
|
train
|
def capture_image(image_name, include_attached_storage = false, image_notes = '')
image_notes = '' if !image_notes
image_name = 'Captured Image' if !image_name
disk_filter = lambda { |disk| disk['device'] == '0' }
disk_filter = lambda { |disk| disk['device'] != '1' } if include_attached_storage
disks =
|
ruby
|
{
"resource": ""
}
|
q1246
|
SoftLayer.VirtualServer.wait_until_ready
|
train
|
def wait_until_ready(max_trials, wait_for_transactions = false, seconds_between_tries = 2)
# pessimistically assume the server is not ready
num_trials = 0
begin
self.refresh_details()
has_os_reload = has_sl_property? :lastOperatingSystemReload
has_active_transaction = has_sl_property? :activeTransaction
reloading_os = has_active_transaction && has_os_reload && (self.last_operating_system_reload['id'] == self.active_transaction['id'])
|
ruby
|
{
"resource": ""
}
|
q1247
|
SoftLayer.Account.find_vlan_with_number
|
train
|
def find_vlan_with_number(vlan_number)
filter = SoftLayer::ObjectFilter.new() { |filter|
filter.accept('networkVlans.vlanNumber').when_it is vlan_number
}
vlan_data =
|
ruby
|
{
"resource": ""
}
|
q1248
|
SoftLayer.Client.service_named
|
train
|
def service_named(service_name, service_options = {})
raise ArgumentError,"Please provide a service name" if service_name.nil? || service_name.empty?
# Strip whitespace from service_name and ensure that it starts with "SoftLayer_".
# If it does not, then add the prefix.
full_name = service_name.to_s.strip
|
ruby
|
{
"resource": ""
}
|
q1249
|
SoftLayer.Service.call_softlayer_api_with_params
|
train
|
def call_softlayer_api_with_params(method_name, parameters, args)
additional_headers = {};
# The client knows about authentication, so ask him for the auth headers
authentication_headers = self.client.authentication_headers
additional_headers.merge!(authentication_headers)
if parameters && parameters.server_object_filter
additional_headers.merge!("#{@service_name}ObjectFilter" => parameters.server_object_filter)
end
# Object masks go into the headers too.
if parameters && parameters.server_object_mask
object_mask = parameters.server_object_mask
additional_headers.merge!("SoftLayer_ObjectMask" => { "mask" => object_mask }) unless object_mask.empty?
end
# Result limits go into the headers
if (parameters && parameters.server_result_limit)
additional_headers.merge!("resultLimit" => { "limit" => parameters.server_result_limit, "offset" => (parameters.server_result_offset || 0) })
end
# Add an object id to the headers.
if parameters && parameters.server_object_id
additional_headers.merge!("#{@service_name}InitParameters" => { "id" => parameters.server_object_id })
end
# This is a workaround for a potential problem that arises from mis-using the
# API. If you call SoftLayer_Virtual_Guest and you call the getObject method
# but pass a virtual guest as a parameter, what happens is the getObject method
# is called through an HTTP POST verb and the API creates a new VirtualServer that
# is a copy of the one you passed in.
#
|
ruby
|
{
"resource": ""
}
|
q1250
|
ILO_SDK.BiosHelper.set_bios_settings
|
train
|
def set_bios_settings(options, system_id = 1)
r = response_handler(rest_patch("/redfish/v1/Systems/#{system_id}/bios/Settings/",
|
ruby
|
{
"resource": ""
}
|
q1251
|
ILO_SDK.BiosHelper.set_uefi_shell_startup
|
train
|
def set_uefi_shell_startup(uefi_shell_startup, uefi_shell_startup_location, uefi_shell_startup_url)
new_action = {
'UefiShellStartup' => uefi_shell_startup,
'UefiShellStartupLocation' => uefi_shell_startup_location,
'UefiShellStartupUrl' => uefi_shell_startup_url
|
ruby
|
{
"resource": ""
}
|
q1252
|
ILO_SDK.BiosHelper.get_bios_dhcp
|
train
|
def get_bios_dhcp
response = rest_get('/redfish/v1/Systems/1/bios/Settings/')
bios = response_handler(response)
{
'Dhcpv4' => bios['Dhcpv4'],
'Ipv4Address' => bios['Ipv4Address'],
'Ipv4Gateway' => bios['Ipv4Gateway'],
|
ruby
|
{
"resource": ""
}
|
q1253
|
ILO_SDK.BiosHelper.set_bios_dhcp
|
train
|
def set_bios_dhcp(dhcpv4, ipv4_address = '', ipv4_gateway = '', ipv4_primary_dns = '', ipv4_secondary_dns = '', ipv4_subnet_mask = '')
new_action = {
'Dhcpv4' => dhcpv4,
'Ipv4Address' => ipv4_address,
'Ipv4Gateway' => ipv4_gateway,
'Ipv4PrimaryDNS' => ipv4_primary_dns,
'Ipv4SecondaryDNS' => ipv4_secondary_dns,
|
ruby
|
{
"resource": ""
}
|
q1254
|
ILO_SDK.BiosHelper.set_url_boot_file
|
train
|
def set_url_boot_file(url_boot_file)
new_action = { 'UrlBootFile' => url_boot_file }
|
ruby
|
{
"resource": ""
}
|
q1255
|
ILO_SDK.BiosHelper.set_bios_service
|
train
|
def set_bios_service(name, email)
new_action = {
'ServiceName' => name,
'ServiceEmail' =>
|
ruby
|
{
"resource": ""
}
|
q1256
|
ILO_SDK.LogEntryHelper.clear_logs
|
train
|
def clear_logs(log_type)
new_action = { 'Action' => 'ClearLog' }
response
|
ruby
|
{
"resource": ""
}
|
q1257
|
ILO_SDK.LogEntryHelper.get_logs
|
train
|
def get_logs(severity_level, duration, log_type)
response = rest_get("#{uri_for_log_type(log_type)}Entries/")
entries = response_handler(response)['Items']
start_time = Time.now.utc -
|
ruby
|
{
"resource": ""
}
|
q1258
|
ILO_SDK.ComputerDetailsHelper.get_computer_details
|
train
|
def get_computer_details
general_computer_details = get_general_computer_details
computer_network_details = get_computer_network_details
|
ruby
|
{
"resource": ""
}
|
q1259
|
ILO_SDK.ComputerDetailsHelper.get_general_computer_details
|
train
|
def get_general_computer_details
response = rest_get('/redfish/v1/Systems/1/')
details = response_handler(response)
{
'GeneralDetails' => {
'manufacturer' => details['Manufacturer'],
'model' => details['Model'],
'AssetTag' => details['AssetTag'],
'bios_version' => details['Bios']['Current']['VersionString'],
|
ruby
|
{
"resource": ""
}
|
q1260
|
ILO_SDK.ComputerDetailsHelper.get_computer_network_details
|
train
|
def get_computer_network_details
network_adapters = []
response = rest_get('/redfish/v1/Systems/1/NetworkAdapters/')
networks = response_handler(response)['links']['Member']
networks.each do |network|
response = rest_get(network['href'])
detail = response_handler(response)
physical_ports = []
detail['PhysicalPorts'].each do |port|
n = {
'Name' => port['Name'],
'StructuredName' => port['Oem']['Hp']['StructuredName'],
'MacAddress' => port['MacAddress'],
'State' => port['Status']['State']
}
physical_ports.push(n)
|
ruby
|
{
"resource": ""
}
|
q1261
|
ILO_SDK.FirmwareUpdateHelper.set_fw_upgrade
|
train
|
def set_fw_upgrade(uri, tpm_override_flag = true)
new_action = { 'Action' => 'InstallFromURI', 'FirmwareURI' => uri, 'TPMOverrideFlag' => tpm_override_flag }
|
ruby
|
{
"resource": ""
}
|
q1262
|
Sprockets.Helpers.asset_path
|
train
|
def asset_path(source, options = {})
uri = URI.parse(source)
return source if uri.absolute?
options[:prefix] = Sprockets::Helpers.prefix unless options[:prefix]
if Helpers.debug || options[:debug]
options[:manifest] = false
options[:digest] = false
options[:asset_host] = false
end
source_ext = File.extname(source)
|
ruby
|
{
"resource": ""
}
|
q1263
|
ILO_SDK.ChassisHelper.get_power_metrics
|
train
|
def get_power_metrics
chassis = rest_get('/redfish/v1/Chassis/')
chassis_uri = response_handler(chassis)['links']['Member'][0]['href']
power_metrics_uri = response_handler(rest_get(chassis_uri))['links']['PowerMetrics']['href']
response = rest_get(power_metrics_uri)
metrics = response_handler(response)
power_supplies = []
metrics['PowerSupplies'].each do |ps|
power_supply = {
'LineInputVoltage' => ps['LineInputVoltage'],
'LineInputVoltageType' => ps['LineInputVoltageType'],
'PowerCapacityWatts' => ps['PowerCapacityWatts'],
'PowerSupplyType' => ps['PowerSupplyType'],
'Health' => ps['Status']['Health'],
|
ruby
|
{
"resource": ""
}
|
q1264
|
ILO_SDK.ChassisHelper.get_thermal_metrics
|
train
|
def get_thermal_metrics
chassis = rest_get('/redfish/v1/Chassis/')
chassis_uri = response_handler(chassis)['links']['Member'][0]['href']
thermal_metrics_uri = response_handler(rest_get(chassis_uri))['links']['ThermalMetrics']['href']
response = rest_get(thermal_metrics_uri)
temperatures = response_handler(response)['Temperatures']
|
ruby
|
{
"resource": ""
}
|
q1265
|
ILO_SDK.DateTimeHelper.set_time_zone
|
train
|
def set_time_zone(time_zone)
time_response = rest_get('/redfish/v1/Managers/1/DateTime/')
new_time_zone = response_handler(time_response)['TimeZoneList'].select { |timezone| timezone['Name'] == time_zone }
new_action = { 'TimeZone' => {
|
ruby
|
{
"resource": ""
}
|
q1266
|
ILO_SDK.DateTimeHelper.set_ntp
|
train
|
def set_ntp(use_ntp)
new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'UseNTPServers' => use_ntp } } } }
|
ruby
|
{
"resource": ""
}
|
q1267
|
ILO_SDK.DateTimeHelper.set_ntp_servers
|
train
|
def set_ntp_servers(ntp_servers)
new_action = { 'StaticNTPServers' => ntp_servers }
response = rest_patch('/redfish/v1/Managers/1/DateTime/',
|
ruby
|
{
"resource": ""
}
|
q1268
|
ILO_SDK.Cli.output
|
train
|
def output(data = {}, indent = 0)
case @options['format']
when 'json'
puts JSON.pretty_generate(data)
when 'yaml'
puts data.to_yaml
else
# rubocop:disable Metrics/BlockNesting
if data.class == Hash
data.each do |k, v|
if v.class == Hash || v.class == Array
puts "#{' ' * indent}#{k.nil? ? 'nil' : k}:"
output(v, indent + 2)
|
ruby
|
{
"resource": ""
}
|
q1269
|
ILO_SDK.BootSettingsHelper.set_boot_order
|
train
|
def set_boot_order(boot_order)
new_action = { 'PersistentBootConfigOrder' => boot_order }
|
ruby
|
{
"resource": ""
}
|
q1270
|
ILO_SDK.BootSettingsHelper.set_temporary_boot_order
|
train
|
def set_temporary_boot_order(boot_target)
response = rest_get('/redfish/v1/Systems/1/')
boottargets = response_handler(response)['Boot']['BootSourceOverrideSupported']
unless boottargets.include? boot_target
raise "BootSourceOverrideTarget value - #{boot_target} is not supported. Valid values are: #{boottargets}"
end
new_action = {
|
ruby
|
{
"resource": ""
}
|
q1271
|
ILO_SDK.ServiceRootHelper.get_schema
|
train
|
def get_schema(schema_prefix)
response = rest_get('/redfish/v1/Schemas/')
schemas = response_handler(response)['Items']
schema = schemas.select { |s| s['Schema'].start_with?(schema_prefix) }
raise "NO schema found with this schema prefix : #{schema_prefix}" if schema.empty?
info = []
schema.each do
|
ruby
|
{
"resource": ""
}
|
q1272
|
ILO_SDK.ServiceRootHelper.get_registry
|
train
|
def get_registry(registry_prefix)
response = rest_get('/redfish/v1/Registries/')
registries = response_handler(response)['Items']
registry = registries.select { |reg| reg['Schema'].start_with?(registry_prefix) }
info = []
registry.each
|
ruby
|
{
"resource": ""
}
|
q1273
|
ILO_SDK.ManagerNetworkProtocolHelper.set_timeout
|
train
|
def set_timeout(timeout)
new_action = { 'SessionTimeoutMinutes' => timeout }
|
ruby
|
{
"resource": ""
}
|
q1274
|
ILO_SDK.EthernetInterfaceHelper.set_ilo_ipv4_dhcp
|
train
|
def set_ilo_ipv4_dhcp(manager_id: 1, ethernet_interface: 1)
new_action = {
'Oem' => {
'Hp' => {
'DHCPv4' => {
'Enabled' => true,
'UseDNSServers' => true,
'UseDomainName' => true,
'UseGateway' => true,
'UseNTPServers' => true,
'UseStaticRoutes' => true,
'UseWINSServers' => true
|
ruby
|
{
"resource": ""
}
|
q1275
|
ILO_SDK.EthernetInterfaceHelper.set_ilo_ipv4_static
|
train
|
def set_ilo_ipv4_static(ip:, netmask:, gateway: '0.0.0.0', manager_id: 1, ethernet_interface: 1)
new_action = {
'Oem' => { 'Hp' => { 'DHCPv4' => { 'Enabled' => false } } },
'IPv4Addresses' => [
'Address' => ip, 'SubnetMask' => netmask, 'Gateway' => gateway
]
|
ruby
|
{
"resource": ""
}
|
q1276
|
ILO_SDK.EthernetInterfaceHelper.set_ilo_ipv4_dns_servers
|
train
|
def set_ilo_ipv4_dns_servers(dns_servers:, manager_id: 1, ethernet_interface: 1)
new_action = {
'Oem' => {
'Hp' => {
'DHCPv4' => { 'UseDNSServers' => false },
'IPv4' => { 'DNSServers' => dns_servers }
}
|
ruby
|
{
"resource": ""
}
|
q1277
|
ILO_SDK.EthernetInterfaceHelper.set_ilo_hostname
|
train
|
def set_ilo_hostname(hostname:, domain_name: nil, manager_id: 1, ethernet_interface: 1)
new_action = { 'Oem' => { 'Hp' => { 'HostName' => hostname } } }
new_action['Oem']['Hp'].merge!('DHCPv4' => {}, 'DHCPv6' => {}) if domain_name
new_action['Oem']['Hp']['DHCPv4']['UseDomainName'] = false if domain_name
new_action['Oem']['Hp']['DHCPv6']['UseDomainName'] = false if domain_name
|
ruby
|
{
"resource": ""
}
|
q1278
|
ILO_SDK.Rest.rest_api
|
train
|
def rest_api(type, path, options = {})
raise InvalidRequest, 'Must specify path' unless path
raise InvalidRequest, 'Must specify type' unless type
@logger.debug "Making :#{type} rest call to #{@host}#{path}"
uri = URI.parse(URI.escape("#{@host}#{path}"))
http = @disable_proxy ? Net::HTTP.new(uri.host, uri.port, nil, nil) : Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri.scheme == 'https'
http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @ssl_enabled
request = build_request(type, uri, options)
response = http.request(request)
@logger.debug " Response: Code=#{response.code}. Headers=#{response.to_hash}\n Body=#{response.body}"
response
rescue OpenSSL::SSL::SSLError => e
msg = 'SSL verification failed for the request. Please either:'
msg
|
ruby
|
{
"resource": ""
}
|
q1279
|
ILO_SDK.Rest.response_handler
|
train
|
def response_handler(response)
case response.code.to_i
when RESPONSE_CODE_OK # Synchronous read/query
begin
return JSON.parse(response.body)
rescue JSON::ParserError => e
@logger.warn "Failed to parse JSON response. #{e}"
return response.body
end
when RESPONSE_CODE_CREATED # Synchronous add
return JSON.parse(response.body)
when RESPONSE_CODE_ACCEPTED # Asynchronous add, update or delete
return JSON.parse(response.body) # TODO: Remove when tested
# TODO: Make this actually wait for the task
# @logger.debug "Waiting for task: #{response.header['location']}"
# task = wait_for(response.header['location'])
# return true unless task['associatedResource'] && task['associatedResource']['resourceUri']
# resource_data = rest_get(task['associatedResource']['resourceUri'])
# return JSON.parse(resource_data.body)
|
ruby
|
{
"resource": ""
}
|
q1280
|
ILO_SDK.ManagerAccountHelper.get_account_privileges
|
train
|
def get_account_privileges(username)
response = rest_get('/redfish/v1/AccountService/Accounts/')
accounts = response_handler(response)['Items']
accounts.each do |account|
if
|
ruby
|
{
"resource": ""
}
|
q1281
|
ILO_SDK.ManagerAccountHelper.set_account_privileges
|
train
|
def set_account_privileges(username, privileges)
response = rest_get('/redfish/v1/AccountService/Accounts/')
accounts = response_handler(response)['Items']
id = '0'
accounts.each do |account|
if account['Oem']['Hp']['LoginName'] == username
id = account['Id']
break
end
end
new_action = {
'Oem' => {
'Hp'
|
ruby
|
{
"resource": ""
}
|
q1282
|
ILO_SDK.HttpsCertHelper.get_certificate
|
train
|
def get_certificate
uri = URI.parse(URI.escape(@host))
options = { use_ssl: true, verify_mode:
|
ruby
|
{
"resource": ""
}
|
q1283
|
ILO_SDK.HttpsCertHelper.generate_csr
|
train
|
def generate_csr(country, state, city, org_name, org_unit, common_name)
new_action = {
'Action' => 'GenerateCSR',
'Country' => country,
'State' => state,
'City' => city,
'OrgName' => org_name,
'OrgUnit' => org_unit,
|
ruby
|
{
"resource": ""
}
|
q1284
|
ILO_SDK.SecureBootHelper.set_uefi_secure_boot
|
train
|
def set_uefi_secure_boot(secure_boot_enable)
new_action = { 'SecureBootEnable' => secure_boot_enable }
response =
|
ruby
|
{
"resource": ""
}
|
q1285
|
ILO_SDK.PowerHelper.set_power_state
|
train
|
def set_power_state(state)
new_action = { 'Action' => 'Reset', 'ResetType' => state }
response =
|
ruby
|
{
"resource": ""
}
|
q1286
|
ILO_SDK.SNMPServiceHelper.set_snmp
|
train
|
def set_snmp(snmp_mode, snmp_alerts)
new_action = { 'Mode' => snmp_mode, 'AlertsEnabled' => snmp_alerts }
response =
|
ruby
|
{
"resource": ""
}
|
q1287
|
ILO_SDK.VirtualMediaHelper.get_virtual_media
|
train
|
def get_virtual_media
response = rest_get('/redfish/v1/Managers/1/VirtualMedia/')
media = {}
response_handler(response)['links']['Member'].each do |vm|
|
ruby
|
{
"resource": ""
}
|
q1288
|
ILO_SDK.VirtualMediaHelper.insert_virtual_media
|
train
|
def insert_virtual_media(id, image)
new_action = {
'Action' => 'InsertVirtualMedia',
'Target' => '/Oem/Hp',
'Image' => image
}
|
ruby
|
{
"resource": ""
}
|
q1289
|
ILO_SDK.VirtualMediaHelper.eject_virtual_media
|
train
|
def eject_virtual_media(id)
new_action = {
'Action' => 'EjectVirtualMedia',
'Target' => '/Oem/Hp'
|
ruby
|
{
"resource": ""
}
|
q1290
|
ILO_SDK.ComputerSystemHelper.set_asset_tag
|
train
|
def set_asset_tag(asset_tag)
@logger.warn '[Deprecated] `set_asset_tag` is deprecated. Please use `set_system_settings(AssetTag: <tag>)` instead.'
new_action = { 'AssetTag' => asset_tag }
|
ruby
|
{
"resource": ""
}
|
q1291
|
ILO_SDK.ComputerSystemHelper.set_indicator_led
|
train
|
def set_indicator_led(state)
@logger.warn '[Deprecated] `set_indicator_led` is deprecated. Please use `set_system_settings(IndicatorLED: <state>)` instead.'
new_action = { 'IndicatorLED' => state }
|
ruby
|
{
"resource": ""
}
|
q1292
|
ILO_SDK.AccountServiceHelper.userhref
|
train
|
def userhref(uri, username)
response = rest_get(uri)
items = response_handler(response)['Items']
items.each do |it|
return
|
ruby
|
{
"resource": ""
}
|
q1293
|
ILO_SDK.AccountServiceHelper.create_user
|
train
|
def create_user(username, password)
new_action = { 'UserName' => username, 'Password' => password, 'Oem' => { 'Hp' =>
|
ruby
|
{
"resource": ""
}
|
q1294
|
ILO_SDK.AccountServiceHelper.change_password
|
train
|
def change_password(username, password)
new_action = { 'Password' => password }
userhref = userhref('/redfish/v1/AccountService/Accounts/', username)
response =
|
ruby
|
{
"resource": ""
}
|
q1295
|
ILO_SDK.AccountServiceHelper.delete_user
|
train
|
def delete_user(username)
userhref = userhref('/redfish/v1/AccountService/Accounts/', username)
response =
|
ruby
|
{
"resource": ""
}
|
q1296
|
Proxmox.Proxmox.templates
|
train
|
def templates
data = http_action_get "nodes/#{@node}/storage/local/content"
template_list = {}
|
ruby
|
{
"resource": ""
}
|
q1297
|
Proxmox.Proxmox.openvz_get
|
train
|
def openvz_get
data = http_action_get "nodes/#{@node}/openvz"
ve_list = {}
data.each do |ve|
|
ruby
|
{
"resource": ""
}
|
q1298
|
Proxmox.Proxmox.openvz_post
|
train
|
def openvz_post(ostemplate, vmid, config = {})
config['vmid'] = vmid
config['ostemplate'] = "local%3Avztmpl%2F#{ostemplate}.tar.gz"
vm_definition = config.to_a.map
|
ruby
|
{
"resource": ""
}
|
q1299
|
Proxmox.Proxmox.create_ticket
|
train
|
def create_ticket
post_param = { username: @username, realm: @realm, password: @password }
@site['access/ticket'].post post_param do |response, _request, _result, &_block|
if response.code == 200
|
ruby
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.