Using Ironic client with agent_ipmitool driver
作者:互联网
Lets see how to deploy a server using ironic. To do that we are going to define those variables: # Ironic client variables export IRONIC_URL=http://IRONIC-API-SERVER:6385/ export OS_AUTH_TOKEN=" " # Baremetal server variables NAME=test1 # PXE NIC address MAC=00:25:90:8f:51:a0 # IPMI address, we asume ADMIN/ADMIN as user/password IPMI=10.0.1.100 # UUID of the chassis (optinal, remove the references in the commands) CHASSIS=0cdaf66c-3d51-40fa-ba00-57dfdc9e5666 Now is possible to define the new host in Ironic. In this case we are going to deploy Ubuntu on a server using Config-Drive to pass the host configuration. # Define the new baremetal host ironic node-create -c $CHASSIS -n $NAME -d agent_ipmitool \ -i ipmi_address=$IPMI \ -i ipmi_username=ADMIN \ -i ipmi_password=ADMIN \ -i deploy_kernel=file:///var/lib/ironic/http/deploy/coreos_production_pxe.vmlinuz \ -i deploy_ramdisk=file:///var/lib/ironic/http/deploy/coreos_production_pxe_image-oem.cpio.gz +--------------+-----------------------------------------------------------------+ | Property | Value | +--------------+-----------------------------------------------------------------+ | uuid | 8898d0d0-5561-4fee-954b-7f22e6e3a0f7 | | driver_info | {u'deploy_kernel': | | | u'file:///var/lib/ironic/images/coreos_production_pxe.vmlinuz', | | | u'ipmi_address': u'10.0.1.100', u'ipmi_username': u'ADMIN', | | | u'ipmi_password': u'******', u'deploy_ramdisk': | | | u'file:///var/lib/ironic/images/coreos_production_pxe_image- | | | oem.cpio.gz'} | | extra | {} | | driver | agent_ipmitool | | chassis_uuid | 0cdaf66c-3d51-40fa-ba00-57dfdc9e5666 | | properties | {} | | name | test1 | +--------------+-----------------------------------------------------------------+ # Get the UUID of the new node UUID=$(ironic node-list | awk "/$NAME/ { print \$2 }") # Define the a port: a link between the MAC and the baremetal node for PXE booting ironic port-create -n $UUID -a $MAC +-----------+--------------------------------------+ | Property | Value | +-----------+--------------------------------------+ | node_uuid | 8898d0d0-5561-4fee-954b-7f22e6e3a0f7 | | extra | {} | | uuid | a81c60d1-dee8-472b-8d2f-549309547112 | | address | 00:25:90:8f:51:a0 | +-----------+--------------------------------------+ Note that the file references are on the Ironic server, not on the client, because those images are going to be used for PXE. To see all available images, go to: http://IRONIC-API-SERVER:80/ # Ironic needs the MD5 checksum of the image to check that it is not corrupted during the copy process MD5=45e1ecce11c3c7d6e40baba8e91eadef # Define the final image to deploy on the server ironic node-update $UUID add instance_info/image_source=http://xx.xxx.xx.xxx/images/trusty.qcow2 instance_info/image_checksum=$MD5 +------------------------+------------------------------------------------------------------+ | Property | Value | +------------------------+------------------------------------------------------------------+ | target_power_state | None | | extra | {} | | last_error | None | | updated_at | 2015-06-05T12:04:38+00:00 | | maintenance_reason | None | | provision_state | available | | uuid | 8898d0d0-5561-4fee-954b-7f22e6e3a0f7 | | console_enabled | False | | target_provision_state | None | | maintenance | False | | inspection_started_at | None | | inspection_finished_at | None | | power_state | power off | | driver | agent_ipmitool | | reservation | None | | properties | {} | | instance_uuid | None | | name | test1 | | driver_info | {u'ipmi_password': u'******', u'ipmi_address': u'10.0.1.100', | | | u'ipmi_username': u'ADMIN', u'deploy_kernel': | | | u'file:///var/lib/ironic/images/coreos_production_pxe.vmlinuz', | | | u'deploy_ramdisk': u'file:///var/lib/ironic/images | | | /coreos_production_pxe_image-oem.cpio.gz'} | | created_at | 2015-06-05T11:54:14+00:00 | | driver_internal_info | {} | | chassis_uuid | 0cdaf66c-3d51-40fa-ba00-57dfdc9e5666 | | instance_info | {u'image_source': u'http://xx.xxx.xx.xxx/trusty.qcow2', | | | u'image_checksum': u'45e1ecce11c3c7d6e40baba8e91eadef'} | +------------------------+------------------------------------------------------------------+ Now is time to validate the node: # Validate the node ironic node-validate $UUID +------------+--------+---------------------------------------------------------------+ | Interface | Result | Reason | +------------+--------+---------------------------------------------------------------+ | console | False | Missing 'ipmi_terminal_port' parameter in node's driver_info. | | deploy | True | | | inspect | None | not supported | | management | True | | | power | True | | +------------+--------+---------------------------------------------------------------+ Node validation is just a process to check that the node has defined all the variables for all the steps (and also if the images are available). In this case it complains about a missing parameter for the console, but unfortunately our hardware does not support console over UDP (ipmi_terminal_port). Also, the IPA deploy image has no inspect support, so hardware inspection is not available (for the moment). To deploy the node using Config-Drive folder (see here how to create it): ironic node-set-provision-state --config-drive /tmp/$NAME $NAME active ironic node-list +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ | UUID | Name | Instance UUID | Power State | Provisioning State | Maintenance | +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ | 8898d0d0-5561-4fee-954b-7f22e6e3a0f7 | test1 | None | power off | deploying | False | +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ # After a while, the node will be on and Ironic will be waiting for the IPA ironic node-list +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ | UUID | Name | Instance UUID | Power State | Provisioning State | Maintenance | +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ | 8898d0d0-5561-4fee-954b-7f22e6e3a0f7 | test1 | None | power on | wait call-back | False | +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ After a couple of minutes the baremetal host is going to be available and active: ironic node-list +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ | UUID | Name | Instance UUID | Power State | Provisioning State | Maintenance | +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ | 8898d0d0-5561-4fee-954b-7f22e6e3a0f7 | test1 | None | power on | active | False | +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ # To see all the details: ironic node-show test1 +------------------------+--------------------------------------------------------------------------+ | Property | Value | +------------------------+--------------------------------------------------------------------------+ | target_power_state | None | | extra | {} | | last_error | None | | updated_at | 2015-06-05T12:19:15+00:00 | | maintenance_reason | None | | provision_state | wait call-back | | uuid | 8898d0d0-5561-4fee-954b-7f22e6e3a0f7 | | console_enabled | False | | target_provision_state | active | | maintenance | False | | inspection_started_at | None | | inspection_finished_at | None | | power_state | power on | | driver | agent_ipmitool | | reservation | None | | properties | {} | | instance_uuid | None | | name | test1 | | driver_info | {u'ipmi_password': u'******', u'ipmi_address': u'10.0.1.100', | | | u'ipmi_username': u'ADMIN', u'deploy_kernel': | | | u'file:///var/lib/ironic/images/coreos_production_pxe.vmlinuz', | | | u'deploy_ramdisk': u'file:///var/lib/ironic/images | | | /coreos_production_pxe_image-oem.cpio.gz'} | | created_at | 2015-06-05T11:54:14+00:00 | | driver_internal_info | {u'is_whole_disk_image': True} | | chassis_uuid | 0cdaf66c-3d51-40fa-ba00-57dfdc9e5666 | | instance_info | {u'image_checksum': u'45e1ecce11c3c7d6e40baba8e91eadef', u'image_url': | | | u'http://xx.xxx.xx.xxx/images/trusty.qcow2', u'configdrive': u'H4sICJqTc | ... | | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwl+n/AK6TUGsA | | | AAYA', u'image_source': u'http://xx.xxx.xx.xxx/images/trusty.qcow2'} | +------------------------+--------------------------------------------------------------------------+ So, now the node has been deployed, by using the ip address you have specified on the Config-Drive configuration and the ssh-key you should also have provided, be able to login in the server! Time to do more interesting things: # Asking ironic for the boot devices supported on the baremetal host ironic node-get-supported-boot-devices test1 +------------------------+------------------------------+ | Property | Value | +------------------------+------------------------------+ | supported_boot_devices | pxe, disk, cdrom, bios, safe | +------------------------+------------------------------+ # Seeing which ports are linked to the server ironic node-port-list test1 +--------------------------------------+-------------------+ | UUID | Address | +--------------------------------------+-------------------+ | 324a4602-8cec-47d7-b496-241c081cbcee | 00:25:90:8f:51:a0 | +--------------------------------------+-------------------+ # Power off the server ironic node-set-power-state test1 off ironic node-list +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ | UUID | Name | Instance UUID | Power State | Provisioning State | Maintenance | +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ | 8898d0d0-5561-4fee-954b-7f22e6e3a0f7 | test1 | None | power off | active | False | +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ # Getting the current boot device ironic node-get-boot-device test1 +-------------+-------+ | Property | Value | +-------------+-------+ | boot_device | pxe | | persistent | True | +-------------+-------+ # Change the boot device in order to not depend on the Ironic PXE host ironic node-set-boot-device test1 disk --persistent ironic node-get-boot-device test1 +-------------+-------+ | Property | Value | +-------------+-------+ | boot_device | disk | | persistent | True | +-------------+-------+ # And with the setting boot_device == disk, tell ironic to rebuild the # baremetal host ... ironic node-set-provision-state test1 rebuild # When the node becomes active again (after finished the re-deployment), # ironic will put again the previous boot device (in between it changed # to PXE to redeploy the node) ironic node-get-boot-device test1 +-------------+-------+ | Property | Value | +-------------+-------+ | boot_device | disk | | persistent | True | +-------------+-------+ # Putting the server on maintenance mode ironic node-set-maintenance test1 on --reason "changing disk" ironic node-list +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ | UUID | Name | Instance UUID | Power State | Provisioning State | Maintenance | +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ | 8898d0d0-5561-4fee-954b-7f22e6e3a0f7 | test1 | None | power on | active | True | +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ ironic node-show test1 | grep maintenance | maintenance_reason | changing disk | | maintenance | True | # With a host in maintenance mode, ironic is going to refuse changing the # provisioning state and it is not going to sync the power state of # the server!!!!!! ironic node-set-provision-state test1 rebuild The provisioning operation can't be performed on node 7cefe9c2-031e-4160-b42e-6a7035a7873b because it's in maintenance mode. (HTTP 400) # Be carerul going to DELETE provisining state!!!! It is going # to wipe the entire disk and it can take ages!!! ironic node-set-provision-state test1 deleted ironic node-list +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ | UUID | Name | Instance UUID | Power State | Provisioning State | Maintenance | +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ | 8898d0d0-5561-4fee-954b-7f22e6e3a0f7 | test1 | None | power on | cleaning | True | +--------------------------------------+-------+---------------+-------------+--------------------+-------------+ # And finally, delete the node ironic node-delete test1 Node 8898d0d0-5561-4fee-954b-7f22e6e3a0f7 can't be deleted because it's not powered off (HTTP 409) # It is not possible to delete a node which is power on!!! ironic node-set-power-state test1 off ironic node-delete test1 Deleted node test1
标签:node,test1,None,ipmitool,UUID,driver,agent,state,ironic 来源: https://www.cnblogs.com/dream397/p/12713446.html