ironic workflow---debug and changing (1)

作为openstack的一个模块,ironic的不同之处在于它是使用pecan的框架,当然了这仅仅是形式上的,如何接受rest的call并响应而已,至于接收到rest 请求之后如何,记录一下心得:

有时候我们希望改变程序之后加入自己的log从而查看程序是否按照自己所想运行,记得在Ubuntu上面改了之后openstack的程序是会自动编译好,直接重启服务就可以了,重新编译改动的文件为pyc和pyo(pyo文件减小了容量)文件,只是提升了加载速度而已,因此不用刻意去编译。

然而在centos下面修改py文件后没有起作用,

生成pyc文件 :python -m py_compile file.py

生成pyo文件:python -O -m py_compile file.py

也可以使用compileall编译整个目录:

import compileall
compileall.compile_dir(dirpath)

发现还是没有起作用,觉得非常奇怪,为什么log里面就显示不出来呢,后来想明白了,我用的是log.debug,可能是log的level不对,我改成使用log.warning就可以了,同事编译和重启服务都是必须的,否则不起作用。。。

应该是可以设置的,使得自动编译,记得ubuntu下面是直接生效的,应该没有记错才对
写一个python脚本实现它

import os
import compileall
compileall.compile_dir(r'/usr/lib/python2.7/site-packages/ironic')

os.system('systemctl restart openstack-ironic-api.service')
os.system('systemctl restart openstack-ironic-conductor.service')
print 'end of restart ironic serice'

运行ironic node-set-provision-state 8cdc7750-9d66-4353-ab3e-99fe82e739e2 rebuild 或active时,总是failed,日志显示:

2015-03-22 14:22:05.436 6992 WARNING ironic.dhcp.neutron [-] No VIFs found for node 8cdc7750-9d66-4353-ab3e-99fe82e739e2 when attempting  to get port IP address.
2015-03-22 14:22:05.436 6992 WARNING ironic.dhcp.neutron [-] Some errors were encountered on node 8cdc7750-9d66-4353-ab3e-99fe82e739e2 while retrieving IP address on the following ports: [u'9f10c0b8-4400-4e04-8db0-e42c7f689425'].
2015-03-22 14:22:05.436 6992 WARNING ironic.conductor.manager [-] Error in deploy of node 8cdc7750-9d66-4353-ab3e-99fe82e739e2: Failed to get IP address for any port on node 8cdc7750-9d66-4353-ab3e-99fe82e739e2.

进入代码发现在common/network.py中拿不到vif_port_id,在dhcp/neutron.py的方法_get_fixed_ip_address中,调用了

neutron_port = client.show_port(port_uuid).get('port')

即通过neutron的port来获得新设备的ip,因此vif_port_id应该是neutron中某个port的uuid:


[root@xxx~(keystone_admin)]# neutron port-list
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
| id                                   | name | mac_address       | fixed_ips                                                                           |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
| ad16ca5b-b948-4176-b605-058e09261fb0 |      | fa:16:3e:22:fc:f6 | {"subnet_id": "7d1efba5-a637-42c0-b327-b4237715f6c8", "ip_address": "192.168.1.14"} |
| a1ecfc63-aa64-418e-ab69-81ec5cd1364a |      | fa:16:3e:1c:97:68 | {"subnet_id": "7d1efba5-a637-42c0-b327-b4237715f6c8", "ip_address": "192.168.1.11"} |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------------+
于是调用命令:

ironic port-update 9f10c0b8-4400-4e04-8db0-e42c7f689425 add extra/vif_port_id=ad16ca5b-b948-4176-b605-058e09261fb0

再次调用ironic node-set-provision-state 8cdc7750-9d66-4353-ab3e-99fe82e739e2 rebuild并 ironic node-show 8cdc7750-9d66-4353-ab3e-99fe82e739e2有

[root@xxx~(keystone_admin)]# ironic node-show 8cdc7750-9d66-4353-ab3e-99fe82e739e2
+------------------------+--------------------------------------------------------------------------+
| Property               | Value                                                                    |
+------------------------+--------------------------------------------------------------------------+
| instance_uuid          | None                                                                     |
| target_power_state     | None                                                                     |
| properties             | {u'cpu_arch': u'x86_64', u'local_gb': u'1200', u'cpus': u'2',            |
|                        | u'capabilities': u'boot_mode:uefi', u'memory': u'131072'}                |
| maintenance            | False                                                                    |
| driver_info            | {u'pxe_deploy_ramdisk': u'ffe9fc7c-1a0c-4de7-8d42-a81603fa1033',         |
|                        | u'pxe_deploy_kernel': u'cd59399d-5394-4ec1-8178-539c2a2a4833',           |
|                        | u'ipmi_address': u'10.240.212.85', u'ipmi_username': u'USERID',          |
|                        | u'ipmi_password': u'PASSW0RD'}                                           |
| extra                  | {}                                                                       |
| last_error             | None                                                                     |
| created_at             | 2015-03-19T04:14:33+00:00                                                |
| target_provision_state | deploy complete                                                          |
| driver                 | pxe_ipmitool                                                             |
| updated_at             | 2015-03-22T07:14:11+00:00                                                |
| instance_info          | {u'ramdisk': u'aa24e8be-d4ad-4d19-9520-d7293662a400', u'kernel':         |
|                        | u'ea63b1b1-1423-43d3-bf26-9ba93bd1e809', u'root_gb': u'10',              |
|                        | u'image_source': u'bee88655-cdc1-49f8-9dcb-8004d8b96582', u'deploy_key': |
|                        | u'JCUH18XD4X9KIX4I1S47VGXUWG66G0HW', u'image_checksum':                  |
|                        | u'870e8ce725224d8f8e63fcc76c8d074e'}                                     |
| chassis_uuid           | None                                                                     |
| provision_state        | wait call-back                                                           |
| reservation            | None                                                                     |
| power_state            | power on                                                                 |
| console_enabled        | False                                                                    |
| uuid                   | 8cdc7750-9d66-4353-ab3e-99fe82e739e2                                     |
+------------------------+--------------------------------------------------------------------------+

dnsmasq-dhcp no available address:

待续。。。









  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值