Class: Fog::Baremetal::OpenStack::Real
- Inherits:
-
Object
- Object
- Fog::Baremetal::OpenStack::Real
- Includes:
- OpenStack::Core
- Defined in:
- lib/fog/baremetal/openstack.rb,
lib/fog/baremetal/openstack/requests/get_node.rb,
lib/fog/baremetal/openstack/requests/get_port.rb,
lib/fog/baremetal/openstack/requests/get_driver.rb,
lib/fog/baremetal/openstack/requests/list_nodes.rb,
lib/fog/baremetal/openstack/requests/list_ports.rb,
lib/fog/baremetal/openstack/requests/patch_node.rb,
lib/fog/baremetal/openstack/requests/patch_port.rb,
lib/fog/baremetal/openstack/requests/create_node.rb,
lib/fog/baremetal/openstack/requests/create_port.rb,
lib/fog/baremetal/openstack/requests/delete_node.rb,
lib/fog/baremetal/openstack/requests/delete_port.rb,
lib/fog/baremetal/openstack/requests/get_chassis.rb,
lib/fog/baremetal/openstack/requests/list_chassis.rb,
lib/fog/baremetal/openstack/requests/list_drivers.rb,
lib/fog/baremetal/openstack/requests/patch_chassis.rb,
lib/fog/baremetal/openstack/requests/create_chassis.rb,
lib/fog/baremetal/openstack/requests/delete_chassis.rb,
lib/fog/baremetal/openstack/requests/list_nodes_detailed.rb,
lib/fog/baremetal/openstack/requests/list_ports_detailed.rb,
lib/fog/baremetal/openstack/requests/set_node_maintenance.rb,
lib/fog/baremetal/openstack/requests/set_node_power_state.rb,
lib/fog/baremetal/openstack/requests/get_driver_properties.rb,
lib/fog/baremetal/openstack/requests/list_chassis_detailed.rb,
lib/fog/baremetal/openstack/requests/unset_node_maintenance.rb,
lib/fog/baremetal/openstack/requests/set_node_provision_state.rb
Instance Attribute Summary
Attributes included from OpenStack::Core
#auth_token, #auth_token_expiration, #current_tenant, #current_user, #current_user_id, #openstack_cache_ttl, #openstack_domain_id, #openstack_domain_name, #openstack_identity_prefix, #openstack_project_domain, #openstack_project_domain_id, #openstack_project_id, #openstack_user_domain, #openstack_user_domain_id, #unscoped_token
Instance Method Summary collapse
-
#create_chassis(attributes) ⇒ Object
Create a new chassis.
-
#create_node(attributes) ⇒ Object
Create a new node.
-
#create_port(attributes) ⇒ Object
Create a new port.
- #delete_chassis(chassis_uuid) ⇒ Object
- #delete_node(node_uuid) ⇒ Object
- #delete_port(port_uuid) ⇒ Object
- #get_chassis(chassis_uuid) ⇒ Object
- #get_driver(driver_name) ⇒ Object
- #get_driver_properties(driver_name) ⇒ Object
- #get_node(node_id) ⇒ Object
- #get_port(port_id) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
NOTE: uncommenting this should be treated as api-change! def self.not_found_class Fog::Baremetal::OpenStack::NotFound end.
- #list_chassis(options = {}) ⇒ Object
- #list_chassis_detailed(options = {}) ⇒ Object
- #list_drivers(options = {}) ⇒ Object
- #list_nodes(options = {}) ⇒ Object
- #list_nodes_detailed(options = {}) ⇒ Object
- #list_ports(options = {}) ⇒ Object
- #list_ports_detailed(options = {}) ⇒ Object
-
#patch_chassis(chassis_uuid, patch) ⇒ Object
Patch a chassis.
-
#patch_node(node_uuid, patch) ⇒ Object
Patch a node.
-
#patch_port(port_uuid, patch) ⇒ Object
Patch a port.
- #set_node_maintenance(node_uuid, parameters = nil) ⇒ Object
- #set_node_power_state(node_id, power_state) ⇒ Object
- #set_node_provision_state(node_id, provision_state) ⇒ Object
- #unset_node_maintenance(node_uuid, parameters = nil) ⇒ Object
Methods included from OpenStack::Core
#credentials, #initialize_identity, not_found_class, #reload
Constructor Details
#initialize(options = {}) ⇒ Real
256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/fog/baremetal/openstack.rb', line 256 def initialize( = {}) initialize_identity @openstack_service_type = [:openstack_service_type] || ['baremetal'] @openstack_service_name = [:openstack_service_name] @connection_options = [:connection_options] || {} authenticate set_api_path @persistent = [:persistent] || false @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end |
Instance Method Details
#create_chassis(attributes) ⇒ Object
Create a new chassis
Attributes ===
description = Free text description of the chassis extra = Record arbitrary key/value metadata. Can be specified multiple times
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fog/baremetal/openstack/requests/create_chassis.rb', line 10 def create_chassis(attributes) = [ :description, :extra ] # Filter only allowed creation attributes data = attributes.select { |key, _value| .include?(key.to_sym) } request( :body => Fog::JSON.encode(data), :expects => [200, 201], :method => 'POST', :path => 'chassis' ) end |
#create_node(attributes) ⇒ Object
Create a new node
Attributes ===
chassis_uuid = UUID of the chassis that this node belongs to driver = Driver used to control the node [REQUIRED] driver_info = Key/value pairs used by the driver, such as out-of-band management credentials. Can be
specified multiple times
extra = Record arbitrary key/value metadata. Can be specified multiple times uuid = Unique UUID for the node properties = Key/value pairs describing the physical characteristics of the node. This is exported to
Nova and used by the scheduler. Can be specified multiple times
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fog/baremetal/openstack/requests/create_node.rb', line 16 def create_node(attributes) = [ :chassis_uuid, :driver, :driver_info, :extra, :uuid, :properties ] # Filter only allowed creation attributes data = attributes.select { |key, _value| .include?(key.to_sym) } request( :body => Fog::JSON.encode(data), :expects => [200, 201], :method => 'POST', :path => 'nodes' ) end |
#create_port(attributes) ⇒ Object
Create a new port
Attributes ===
address = MAC Address for this port extra = Record arbitrary key/value metadata. Can be specified multiple times node_uuid = UUID of the node that this port belongs to
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fog/baremetal/openstack/requests/create_port.rb', line 11 def create_port(attributes) = [ :address, :extra, :node_uuid ] # Filter only allowed creation attributes data = attributes.select { |key, _value| .include?(key.to_sym) } request( :body => Fog::JSON.encode(data), :expects => [200, 201], :method => 'POST', :path => 'ports' ) end |
#delete_chassis(chassis_uuid) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/fog/baremetal/openstack/requests/delete_chassis.rb', line 5 def delete_chassis(chassis_uuid) data = {:chassis_uuid => chassis_uuid} request( :body => Fog::JSON.encode(data), :expects => [200, 204], :method => 'DELETE', :path => 'chassis' ) end |
#delete_node(node_uuid) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/fog/baremetal/openstack/requests/delete_node.rb', line 5 def delete_node(node_uuid) data = {:node_ident => node_uuid} request( :body => Fog::JSON.encode(data), :expects => [200, 204], :method => 'DELETE', :path => 'nodes' ) end |
#delete_port(port_uuid) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/fog/baremetal/openstack/requests/delete_port.rb', line 5 def delete_port(port_uuid) data = {:port_uuid => port_uuid} request( :body => Fog::JSON.encode(data), :expects => [200, 204], :method => 'DELETE', :path => 'ports' ) end |
#get_chassis(chassis_uuid) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/baremetal/openstack/requests/get_chassis.rb', line 5 def get_chassis(chassis_uuid) request( :expects => [200, 204], :method => 'GET', :path => "chassis/#{chassis_uuid}" ) end |
#get_driver(driver_name) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/baremetal/openstack/requests/get_driver.rb', line 5 def get_driver(driver_name) request( :expects => [200, 204], :method => 'GET', :path => "drivers/#{driver_name}" ) end |
#get_driver_properties(driver_name) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/fog/baremetal/openstack/requests/get_driver_properties.rb', line 5 def get_driver_properties(driver_name) data = {:driver_name => driver_name} request( :body => Fog::JSON.encode(data), :expects => [200, 204], :method => 'GET', :path => "drivers/properties" ) end |
#get_node(node_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/baremetal/openstack/requests/get_node.rb', line 5 def get_node(node_id) request( :expects => [200, 204], :method => 'GET', :path => "nodes/#{node_id}" ) end |
#get_port(port_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fog/baremetal/openstack/requests/get_port.rb', line 5 def get_port(port_id) request( :expects => [200, 204], :method => 'GET', :path => "ports/#{port_id}" ) end |
#list_chassis(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/baremetal/openstack/requests/list_chassis.rb', line 5 def list_chassis( = {}) request( :expects => [200, 204], :method => 'GET', :path => 'chassis', :query => ) end |
#list_chassis_detailed(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/baremetal/openstack/requests/list_chassis_detailed.rb', line 5 def list_chassis_detailed( = {}) request( :expects => [200, 204], :method => 'GET', :path => 'chassis/detail', :query => ) end |
#list_drivers(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/baremetal/openstack/requests/list_drivers.rb', line 5 def list_drivers( = {}) request( :expects => [200, 204], :method => 'GET', :path => 'drivers', :query => ) end |
#list_nodes(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/baremetal/openstack/requests/list_nodes.rb', line 5 def list_nodes( = {}) request( :expects => [200, 204], :method => 'GET', :path => 'nodes', :query => ) end |
#list_nodes_detailed(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/baremetal/openstack/requests/list_nodes_detailed.rb', line 5 def list_nodes_detailed( = {}) request( :expects => [200, 204], :method => 'GET', :path => 'nodes/detail', :query => ) end |
#list_ports(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/baremetal/openstack/requests/list_ports.rb', line 5 def list_ports( = {}) request( :expects => [200, 204], :method => 'GET', :path => 'ports', :query => ) end |
#list_ports_detailed(options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/baremetal/openstack/requests/list_ports_detailed.rb', line 5 def list_ports_detailed( = {}) request( :expects => [200, 204], :method => 'GET', :path => 'ports/detail', :query => ) end |
#patch_chassis(chassis_uuid, patch) ⇒ Object
Patch a chassis
parameter example:
- ‘replace’, :path => “/extra/placement”, :value => “somewhere”
-
Patch parameter, list of jsonpatch ===
op = Operations: ‘add’, ‘replace’ or ‘remove’ path = Attributes to add/replace or remove (only PATH is necessary on remove),
e.g. /extra/placement
value = Value to set
15 16 17 18 19 20 21 22 |
# File 'lib/fog/baremetal/openstack/requests/patch_chassis.rb', line 15 def patch_chassis(chassis_uuid, patch) request( :body => Fog::JSON.encode(patch), :expects => 200, :method => 'PATCH', :path => "chassis/#{chassis_uuid}" ) end |
#patch_node(node_uuid, patch) ⇒ Object
Patch a node
parameter example:
- ‘replace’, :path => “/driver”, :value => “pxe_ssh”
-
Patch parameter, list of jsonpatch ===
op = Operations: ‘add’, ‘replace’ or ‘remove’ path = Attributes to add/replace or remove (only PATH is necessary on remove),
e.g. /driver_info/ipmi_address
value = Value to set
15 16 17 18 19 20 21 22 |
# File 'lib/fog/baremetal/openstack/requests/patch_node.rb', line 15 def patch_node(node_uuid, patch) request( :body => Fog::JSON.encode(patch), :expects => 200, :method => 'PATCH', :path => "nodes/#{node_uuid}" ) end |
#patch_port(port_uuid, patch) ⇒ Object
Patch a port
parameter example:
- ‘replace’, :path => “/driver_info/ipmi_address”, :value => “192.0.2.1”
-
Patch parameter, list of jsonpatch ===
op = Operations: ‘add’, ‘replace’ or ‘remove’ path = Attributes to add/replace or remove (only PATH is necessary on remove),
e.g. /driver_info/ipmi_address
value = Value to set
15 16 17 18 19 20 21 22 |
# File 'lib/fog/baremetal/openstack/requests/patch_port.rb', line 15 def patch_port(port_uuid, patch) request( :body => Fog::JSON.encode(patch), :expects => 200, :method => 'PATCH', :path => "ports/#{port_uuid}" ) end |
#set_node_maintenance(node_uuid, parameters = nil) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/baremetal/openstack/requests/set_node_maintenance.rb', line 5 def set_node_maintenance(node_uuid, parameters = nil) request( :expects => [200, 202, 204], :method => 'PUT', :path => "nodes/#{node_uuid}/maintenance", :query => parameters ) end |
#set_node_power_state(node_id, power_state) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/fog/baremetal/openstack/requests/set_node_power_state.rb', line 5 def set_node_power_state(node_id, power_state) data = { 'target' => power_state } request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'PUT', :path => "nodes/#{node_id}/states/power" ) end |
#set_node_provision_state(node_id, provision_state) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fog/baremetal/openstack/requests/set_node_provision_state.rb', line 5 def set_node_provision_state(node_id, provision_state) data = { 'target' => provision_state } request( :body => Fog::JSON.encode(data), :expects => 202, :method => 'PUT', :path => "nodes/#{node_id}/states/provision", :headers => { :'X-OpenStack-Ironic-API-Version' => 'latest' } ) end |
#unset_node_maintenance(node_uuid, parameters = nil) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/fog/baremetal/openstack/requests/unset_node_maintenance.rb', line 5 def unset_node_maintenance(node_uuid, parameters = nil) request( :expects => [200, 202, 204], :method => 'DELETE', :path => "nodes/#{node_uuid}/maintenance", :query => parameters ) end |