Skip to content

Instantly share code, notes, and snippets.

@rbirnie
Created December 10, 2013 01:20
Show Gist options
  • Save rbirnie/7884276 to your computer and use it in GitHub Desktop.
Save rbirnie/7884276 to your computer and use it in GitHub Desktop.
cd /usr/share/foreman
rails c
1.9.3-p484 :001 > a = Host.find_by_name 'hostname'
1.9.3-p484 :002 > a.interfaces
Nic::Base Load (1.2ms) SELECT `nics`.* FROM `nics` WHERE `nics`.`host_id` = 237
+----+-------------------+-------------+----------+------+---------+-----------+-----------+-------------------------+-------------------------+-------------------------+
| id | mac | ip | type | name | host_id | subnet_id | domain_id | attrs | created_at | updated_at |
+----+-------------------+-------------+----------+------+---------+-----------+-----------+-------------------------+-------------------------+-------------------------+
| 6 | 5c:f9:dd:f0:a7:50 | 10.199.11.8 | Nic::BMC | | 237 | | | {:username=>"root", ... | 2013-11-27 01:00:37 UTC | 2013-11-27 01:00:37 UTC |
+----+-------------------+-------------+----------+------+---------+-----------+-----------+-------------------------+-------------------------+-------------------------+
1.9.3-p484 :008 > b = a.interfaces.new(:mac => '5c:f9:dd:f0:a7:51', :ip => '10.199.11.19', :type => 'Nic::Managed', :host_id => '237')
+----+-------------------+--------------+--------------+------+---------+-----------+-----------+-------+------------+------------+
| id | mac | ip | type | name | host_id | subnet_id | domain_id | attrs | created_at | updated_at |
+----+-------------------+--------------+--------------+------+---------+-----------+-----------+-------+------------+------------+
| | 5c:f9:dd:f0:a7:51 | 10.199.11.19 | Nic::Managed | | 237 | | | {} | | |
+----+-------------------+--------------+--------------+------+---------+-----------+-----------+-------+------------+------------+
1 row in set
1.9.3-p484 :009 > b.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment