OpenStack

OpenStack

基于OpenStack构建企业私有云(1)实验环境准备

OpenStack赵班长 发表了文章 • 4 个评论 • 2599 次浏览 • 2018-04-04 19:47 • 来自相关话题

一.基础软件包安装 1.安装EPEL仓库# rpm -ivh [url]http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm[/url] ...查看全部
一.基础软件包安装

1.安装EPEL仓库
# rpm -ivh [url]http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm[/url]


2.安装OpenStack仓库
# yum install -y centos-release-openstack-queens

3.安装OpenStack客户端
# yum install -y python-openstackclient

 4.安装openstack SELinux管理包
# yum install -y openstack-selinux


二.MySQL数据库部署

1.MySQL安装
[root@linux-node1 ~]# yum install -y mariadb mariadb-server python2-PyMySQL

2.修改MySQL配置文件
[root@linux-node1 ~]# vim /etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 192.168.56.11 #设置监听的IP地址
default-storage-engine = innodb #设置默认的存储引擎
innodb_file_per_table = on#使用独享表空间
collation-server = utf8_general_ci #服务器的默认校对规则
character-set-server = utf8 #服务器安装时指定的默认字符集设定
max_connections = 4096 #设置MySQL的最大连接数,生产请根据实际情况设置。



3.启动MySQL Server并设置开机启动
[root@linux-node1 ~]# systemctl enable mariadb.service
[root@linux-node1 ~]# systemctl start mariadb.service


4.进行数据库安全设置
[root@linux-node1 ~]# mysql_secure_installation


5.数据库创建

[root@linux-node1 ~]# mysql -u root -p
Enter password:

MariaDB [(none)]>

Keystone数据库
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'keystone';

Glance数据库
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'glance';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance';

Nova数据库
CREATE DATABASE nova;
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'nova';
CREATE DATABASE nova_api;
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'nova';
CREATE DATABASE nova_cell0;
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'nova';

Neutron 数据库
CREATE DATABASE neutron;
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'neutron';
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'neutron';

Cinder数据库
CREATE DATABASE cinder;
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'cinder';
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'cinder';

三:消息代理RabbitMQ
1.安装RabbitMQ
[root@linux-node1 ~]# yum install -y rabbitmq-server

2.设置开启启动,并启动RabbitMQ
[root@linux-node1 ~]# systemctl enable rabbitmq-server.service
[root@linux-node1 ~]# systemctl start rabbitmq-server.service

3.添加openstack用户。
[root@linux-node1 ~]# rabbitmqctl add_user openstack openstack
Creating user "openstack" ...



4.给刚才创建的openstack用户,创建权限。
[root@linux-node1 ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Setting permissions for user "openstack" in vhost "/" ...

5.启用Web监控插件
[root@linux-node1 ~]# rabbitmq-plugins list
[root@linux-node1 ~]# rabbitmq-plugins enable rabbitmq_management


 

OpenStack Icehouse novncproxy无法启动解决

OpenStack赵班长 发表了文章 • 3 个评论 • 3624 次浏览 • 2015-11-19 14:53 • 来自相关话题

将OpenStack Icehouse版升级完毕后,发现novncproxy无法启动。 第一步:使用命令启动看看报错。[root@test-node1 ~]# nova-novncproxy --config-file /etc/no ...查看全部
将OpenStack Icehouse版升级完毕后,发现novncproxy无法启动。

第一步:使用命令启动看看报错。
[root@test-node1 ~]# nova-novncproxy --config-file /etc/nova/nova.conf
Traceback (most recent call last):
File "/usr/bin/nova-novncproxy", line 10, in <module>
sys.exit(main())
File "/usr/lib/python2.6/site-packages/nova/cmd/novncproxy.py", line 87, in main
wrap_cmd=None)
File "/usr/lib/python2.6/site-packages/nova/console/websocketproxy.py", line 47, in __init__
ssl_target=None, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/websockify/websocketproxy.py", line 231, in __init__
websocket.WebSocketServer.__init__(self, RequestHandlerClass, *args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'no_parent'

第二步:Google。发现这个是由于websockify版本过高的问题。

第三步:安装一个低版本的。
[root@test-node1 ~]# /usr/bin/pip2.6 install websockify==0.5.1

OK,搞定。
 

OpenStack如何修改Cinder后端存储的卷信息

OpenStack赵班长 发表了文章 • 0 个评论 • 2670 次浏览 • 2015-11-18 09:47 • 来自相关话题

    公司面临着Glusterfs的迁移工作,原OpenStack都是连接的192.168.0.3上面的Glusterfs的volume。现在需要更换IP,发现硬重启云主机,并不会自动进行volume的变动,于是查看源码,确认生成libvirtxml的时候从 ...查看全部
    公司面临着Glusterfs的迁移工作,原OpenStack都是连接的192.168.0.3上面的Glusterfs的volume。现在需要更换IP,发现硬重启云主机,并不会自动进行volume的变动,于是查看源码,确认生成libvirtxml的时候从哪里取的卷。vim /usr/lib/python2.6/site-packages/nova/virt/libvirt/volume.py
发现会从nova数据库的block_device_mapping表中取connection_info,好吧,继续暴力一次,直接update一下。
update nova.block_device_mapping set connection_info='{"driver_volume_type": "glusterfs", "mount_point_base": "/var/lib/cinder/mnt", "serial": "484c287a-0e1b-46cb-a7e0-5a626e2c632e", "data": {"device_path": "/var/lib/nova/mnt/b6c2ec525d0123967968d0b115df02fd/volume-484c287a-0e1b-46cb-a7e0-5a626e2c632e", "name": "volume-484c287a-0e1b-46cb-a7e0-5a626e2c632e", "format": "raw", "qos_specs": null, "export": "192.168.0.1:/cinder-volume", "access_mode": "rw", "options": null}}' where instance_uuid='d897bf7e-e95a-4d73-a6f3-8b1c8a794d3e' and volume_id='484c287a-0e1b-46cb-a7e0-5a626e2c632e';


update nova.block_device_mapping set connection_info='{"driver_volume_type": "glusterfs", "mount_point_base": "/var/lib/cinder/mnt", "serial": "6caf9478-365d-41b1-9997-f92ccf47c0ff", "data": {"device_path": "/var/lib/nova/mnt/b6c2ec525d0123967968d0b115df02fd/volume-6caf9478-365d-41b1-9997-f92ccf47c0ff", "name": "volume-6caf9478-365d-41b1-9997-f92ccf47c0ff", "format": "raw", "qos_specs": null, "export": "192.168.0.1:/cinder-volume", "access_mode": "rw", "options": null}}' where instance_uuid='d897bf7e-e95a-4d73-a6f3-8b1c8a794d3e' and volume_id='6caf9478-365d-41b1-9997-f92ccf47c0ff';

      把每台云主机的每个卷都update一下,然后硬重启,nova会重新生成新的libvrit.xml。然后你发现,变成了你想要的样子了,不说了,继续搬砖。有机会好好研究研究源码,现在事情太多。

OpenStack桌面虚拟化支持USB重定向和声卡

OpenStack赵班长 发表了文章 • 8 个评论 • 3826 次浏览 • 2015-11-17 18:04 • 来自相关话题

公司测试OpenStack的桌面虚拟化,默认情况下生成的libvirt的xml是不支持USB重定向和声卡,最快捷的方法就是,Hack下源码,硬加进去: vim /usr/lib/python2.6/site-packages/nova ...查看全部
公司测试OpenStack的桌面虚拟化,默认情况下生成的libvirt的xml是不支持USB重定向和声卡,最快捷的方法就是,Hack下源码,硬加进去:

vim /usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py
    def to_xml(self, context, instance, network_info, disk_info,
image_meta=None, rescue=None,
block_device_info=None, write_to_disk=False):
# We should get image metadata every time for generating xml
if image_meta is None:
(image_service, image_id) = glance.get_remote_image_service(
context, instance['image_ref'])
image_meta = compute_utils.get_image_metadata(
context, image_service, image_id, instance)
# NOTE(danms): Stringifying a NetworkInfo will take a lock. Do
# this ahead of time so that we don't acquire it while also
# holding the logging lock.
network_info_str = str(network_info)
LOG.debug(_('Start to_xml '
'network_info=%(network_info)s '
'disk_info=%(disk_info)s '
'image_meta=%(image_meta)s rescue=%(rescue)s'
'block_device_info=%(block_device_info)s'),
{'network_info': network_info_str, 'disk_info': disk_info,
'image_meta': image_meta, 'rescue': rescue,
'block_device_info': block_device_info},
instance=instance)
conf = self.get_guest_config(instance, network_info, image_meta,
disk_info, rescue, block_device_info)
pre_xml = conf.to_xml()
hack_xml = """
<append>
<controller type='usb' index='0' model='ich9-ehci1'/>
<controller type='usb' index='0' model='ich9-uhci1'>
<master startport='0'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci2'>
<master startport='2'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci3'>
<master startport='4'/>
</controller>
<redirdev bus='usb' type='spicevmc'/>
<redirdev bus='usb' type='spicevmc'/>
<redirdev bus='usb' type='spicevmc'/>
<redirdev bus='usb' type='spicevmc'/>
<sound model='ich6'>
<alias name='sound0'/>
</sound>
</append>
"""
tar_obj = ''
libvit_obj = minidom.parseString(pre_xml)
hack_obj = minidom.parseString(hack_xml)
for c_lib_obj in libvit_obj.childNodes[0].childNodes:
if (isinstance(c_lib_obj, minidom.Element) and c_lib_obj.tagName == 'devices'):
c_lib_obj.childNodes.extend(hack_obj.childNodes[0].childNodes)

xml = libvit_obj.toxml()
if write_to_disk:
instance_dir = libvirt_utils.get_instance_path(instance)
xml_path = os.path.join(instance_dir, 'libvirt.xml')
libvirt_utils.write_to_file(xml_path, xml)

LOG.debug(_('End to_xml xml=%(xml)s'),
{'xml': xml}, instance=instance)
return xml

简单的说,就是让Nova生成libvirt xml的时候,硬编码进去相关的xml标签,好暴力,但是高效好用!

OpenStack 无法连接到Neutron 问题解决

OpenStack赵班长 发表了文章 • 2 个评论 • 8031 次浏览 • 2015-11-11 10:19 • 来自相关话题

    我们在Icehouse版本创建虚拟机会遇到错误:无法连接到Neutron.的报错,但是虚拟机还可以创建成功,这个是一个已知的bug,可以通过修改源码解决。     注意:还有一种情况,就是你的Neutron真的无法连接,要查看 ...查看全部
    我们在Icehouse版本创建虚拟机会遇到错误:无法连接到Neutron.的报错,但是虚拟机还可以创建成功,这个是一个已知的bug,可以通过修改源码解决。

    注意:还有一种情况,就是你的Neutron真的无法连接,要查看服务和监听端口是否正常!

Yum安装的文件在这里:
[root@test-node1 ~]# vim /usr/share/openstack-dashboard/openstack_dashboard/api/neutron.py
源码安装的在这里:
vim /usr/lib/python2.6/site-packages/openstack_dashboard/api/neutron.py
在class FloatingIpManager类里少了is_supported的方法,这个是一个bug,可以通过手动修改解决。
def is_simple_associate_supported(self):
        # NOTE: There are two reason that simple association support
        # needs more considerations. (1) Neutron does not support the
        # default floating IP pool at the moment. It can be avoided
        # in case where only one floating IP pool exists.
        # (2) Neutron floating IP is associated with each VIF and
        # we need to check whether such VIF is only one for an instance
        # to enable simple association support.
        return False
#在这个类的最下面,增加下面的方法,注意缩进。
    def is_supported(self):
        network_config = getattr(settings, 'OPENSTACK_NEUTRON_NETWORK', {})
        return network_config.get('enable_router', True)
修改完毕后,需要重启apache才可以生效:
[root@test-node1 ~]# /etc/init.d/httpd restart

OpenStack如何实现key注入和密码注入?

OpenStack赵班长 发表了文章 • 2 个评论 • 2941 次浏览 • 2015-09-22 10:59 • 来自相关话题

有朋友问,OpenStack是否支持Key注入和在Horizon的Dashboard上面修改密码,nova是支持的,不过默认可能没有打开。操作也比较简单,需要两个步骤。 1.修改nova.conf,修改以下配置: ...查看全部
有朋友问,OpenStack是否支持Key注入和在Horizon的Dashboard上面修改密码,nova是支持的,不过默认可能没有打开。操作也比较简单,需要两个步骤。

1.修改nova.conf,修改以下配置:

inject_password=true
inject_key=true
inject_partition=-1
重启nova-api。

2.修改horizon配置文件,local_settings
#启用Web界面上修改密码
OPENSTACK_HYPERVISOR_FEATURES = {
    'can_set_mount_point': True,
    'can_set_password': True,
}

好的,现在就可以创建虚拟机了,并且可以在dashboard上给虚拟机设置密码!

基于OpenStack构建企业私有云(1)实验环境准备

OpenStack赵班长 发表了文章 • 4 个评论 • 2599 次浏览 • 2018-04-04 19:47 • 来自相关话题

一.基础软件包安装 1.安装EPEL仓库# rpm -ivh [url]http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm[/url] ...查看全部
一.基础软件包安装

1.安装EPEL仓库
# rpm -ivh [url]http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm[/url]


2.安装OpenStack仓库
# yum install -y centos-release-openstack-queens

3.安装OpenStack客户端
# yum install -y python-openstackclient

 4.安装openstack SELinux管理包
# yum install -y openstack-selinux


二.MySQL数据库部署

1.MySQL安装
[root@linux-node1 ~]# yum install -y mariadb mariadb-server python2-PyMySQL

2.修改MySQL配置文件
[root@linux-node1 ~]# vim /etc/my.cnf.d/openstack.cnf
[mysqld]
bind-address = 192.168.56.11 #设置监听的IP地址
default-storage-engine = innodb #设置默认的存储引擎
innodb_file_per_table = on#使用独享表空间
collation-server = utf8_general_ci #服务器的默认校对规则
character-set-server = utf8 #服务器安装时指定的默认字符集设定
max_connections = 4096 #设置MySQL的最大连接数,生产请根据实际情况设置。



3.启动MySQL Server并设置开机启动
[root@linux-node1 ~]# systemctl enable mariadb.service
[root@linux-node1 ~]# systemctl start mariadb.service


4.进行数据库安全设置
[root@linux-node1 ~]# mysql_secure_installation


5.数据库创建

[root@linux-node1 ~]# mysql -u root -p
Enter password:

MariaDB [(none)]>

Keystone数据库
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'keystone';

Glance数据库
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'glance';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance';

Nova数据库
CREATE DATABASE nova;
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'nova';
CREATE DATABASE nova_api;
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'nova';
CREATE DATABASE nova_cell0;
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'nova';
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'nova';

Neutron 数据库
CREATE DATABASE neutron;
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'neutron';
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'neutron';

Cinder数据库
CREATE DATABASE cinder;
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'cinder';
GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'cinder';

三:消息代理RabbitMQ
1.安装RabbitMQ
[root@linux-node1 ~]# yum install -y rabbitmq-server

2.设置开启启动,并启动RabbitMQ
[root@linux-node1 ~]# systemctl enable rabbitmq-server.service
[root@linux-node1 ~]# systemctl start rabbitmq-server.service

3.添加openstack用户。
[root@linux-node1 ~]# rabbitmqctl add_user openstack openstack
Creating user "openstack" ...



4.给刚才创建的openstack用户,创建权限。
[root@linux-node1 ~]# rabbitmqctl set_permissions openstack ".*" ".*" ".*"
Setting permissions for user "openstack" in vhost "/" ...

5.启用Web监控插件
[root@linux-node1 ~]# rabbitmq-plugins list
[root@linux-node1 ~]# rabbitmq-plugins enable rabbitmq_management


 

OpenStack Icehouse novncproxy无法启动解决

OpenStack赵班长 发表了文章 • 3 个评论 • 3624 次浏览 • 2015-11-19 14:53 • 来自相关话题

将OpenStack Icehouse版升级完毕后,发现novncproxy无法启动。 第一步:使用命令启动看看报错。[root@test-node1 ~]# nova-novncproxy --config-file /etc/no ...查看全部
将OpenStack Icehouse版升级完毕后,发现novncproxy无法启动。

第一步:使用命令启动看看报错。
[root@test-node1 ~]# nova-novncproxy --config-file /etc/nova/nova.conf
Traceback (most recent call last):
File "/usr/bin/nova-novncproxy", line 10, in <module>
sys.exit(main())
File "/usr/lib/python2.6/site-packages/nova/cmd/novncproxy.py", line 87, in main
wrap_cmd=None)
File "/usr/lib/python2.6/site-packages/nova/console/websocketproxy.py", line 47, in __init__
ssl_target=None, *args, **kwargs)
File "/usr/lib/python2.6/site-packages/websockify/websocketproxy.py", line 231, in __init__
websocket.WebSocketServer.__init__(self, RequestHandlerClass, *args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'no_parent'

第二步:Google。发现这个是由于websockify版本过高的问题。

第三步:安装一个低版本的。
[root@test-node1 ~]# /usr/bin/pip2.6 install websockify==0.5.1

OK,搞定。
 

OpenStack如何修改Cinder后端存储的卷信息

OpenStack赵班长 发表了文章 • 0 个评论 • 2670 次浏览 • 2015-11-18 09:47 • 来自相关话题

    公司面临着Glusterfs的迁移工作,原OpenStack都是连接的192.168.0.3上面的Glusterfs的volume。现在需要更换IP,发现硬重启云主机,并不会自动进行volume的变动,于是查看源码,确认生成libvirtxml的时候从 ...查看全部
    公司面临着Glusterfs的迁移工作,原OpenStack都是连接的192.168.0.3上面的Glusterfs的volume。现在需要更换IP,发现硬重启云主机,并不会自动进行volume的变动,于是查看源码,确认生成libvirtxml的时候从哪里取的卷。vim /usr/lib/python2.6/site-packages/nova/virt/libvirt/volume.py
发现会从nova数据库的block_device_mapping表中取connection_info,好吧,继续暴力一次,直接update一下。
update nova.block_device_mapping set connection_info='{"driver_volume_type": "glusterfs", "mount_point_base": "/var/lib/cinder/mnt", "serial": "484c287a-0e1b-46cb-a7e0-5a626e2c632e", "data": {"device_path": "/var/lib/nova/mnt/b6c2ec525d0123967968d0b115df02fd/volume-484c287a-0e1b-46cb-a7e0-5a626e2c632e", "name": "volume-484c287a-0e1b-46cb-a7e0-5a626e2c632e", "format": "raw", "qos_specs": null, "export": "192.168.0.1:/cinder-volume", "access_mode": "rw", "options": null}}' where instance_uuid='d897bf7e-e95a-4d73-a6f3-8b1c8a794d3e' and volume_id='484c287a-0e1b-46cb-a7e0-5a626e2c632e';


update nova.block_device_mapping set connection_info='{"driver_volume_type": "glusterfs", "mount_point_base": "/var/lib/cinder/mnt", "serial": "6caf9478-365d-41b1-9997-f92ccf47c0ff", "data": {"device_path": "/var/lib/nova/mnt/b6c2ec525d0123967968d0b115df02fd/volume-6caf9478-365d-41b1-9997-f92ccf47c0ff", "name": "volume-6caf9478-365d-41b1-9997-f92ccf47c0ff", "format": "raw", "qos_specs": null, "export": "192.168.0.1:/cinder-volume", "access_mode": "rw", "options": null}}' where instance_uuid='d897bf7e-e95a-4d73-a6f3-8b1c8a794d3e' and volume_id='6caf9478-365d-41b1-9997-f92ccf47c0ff';

      把每台云主机的每个卷都update一下,然后硬重启,nova会重新生成新的libvrit.xml。然后你发现,变成了你想要的样子了,不说了,继续搬砖。有机会好好研究研究源码,现在事情太多。

OpenStack桌面虚拟化支持USB重定向和声卡

OpenStack赵班长 发表了文章 • 8 个评论 • 3826 次浏览 • 2015-11-17 18:04 • 来自相关话题

公司测试OpenStack的桌面虚拟化,默认情况下生成的libvirt的xml是不支持USB重定向和声卡,最快捷的方法就是,Hack下源码,硬加进去: vim /usr/lib/python2.6/site-packages/nova ...查看全部
公司测试OpenStack的桌面虚拟化,默认情况下生成的libvirt的xml是不支持USB重定向和声卡,最快捷的方法就是,Hack下源码,硬加进去:

vim /usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py
    def to_xml(self, context, instance, network_info, disk_info,
image_meta=None, rescue=None,
block_device_info=None, write_to_disk=False):
# We should get image metadata every time for generating xml
if image_meta is None:
(image_service, image_id) = glance.get_remote_image_service(
context, instance['image_ref'])
image_meta = compute_utils.get_image_metadata(
context, image_service, image_id, instance)
# NOTE(danms): Stringifying a NetworkInfo will take a lock. Do
# this ahead of time so that we don't acquire it while also
# holding the logging lock.
network_info_str = str(network_info)
LOG.debug(_('Start to_xml '
'network_info=%(network_info)s '
'disk_info=%(disk_info)s '
'image_meta=%(image_meta)s rescue=%(rescue)s'
'block_device_info=%(block_device_info)s'),
{'network_info': network_info_str, 'disk_info': disk_info,
'image_meta': image_meta, 'rescue': rescue,
'block_device_info': block_device_info},
instance=instance)
conf = self.get_guest_config(instance, network_info, image_meta,
disk_info, rescue, block_device_info)
pre_xml = conf.to_xml()
hack_xml = """
<append>
<controller type='usb' index='0' model='ich9-ehci1'/>
<controller type='usb' index='0' model='ich9-uhci1'>
<master startport='0'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci2'>
<master startport='2'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci3'>
<master startport='4'/>
</controller>
<redirdev bus='usb' type='spicevmc'/>
<redirdev bus='usb' type='spicevmc'/>
<redirdev bus='usb' type='spicevmc'/>
<redirdev bus='usb' type='spicevmc'/>
<sound model='ich6'>
<alias name='sound0'/>
</sound>
</append>
"""
tar_obj = ''
libvit_obj = minidom.parseString(pre_xml)
hack_obj = minidom.parseString(hack_xml)
for c_lib_obj in libvit_obj.childNodes[0].childNodes:
if (isinstance(c_lib_obj, minidom.Element) and c_lib_obj.tagName == 'devices'):
c_lib_obj.childNodes.extend(hack_obj.childNodes[0].childNodes)

xml = libvit_obj.toxml()
if write_to_disk:
instance_dir = libvirt_utils.get_instance_path(instance)
xml_path = os.path.join(instance_dir, 'libvirt.xml')
libvirt_utils.write_to_file(xml_path, xml)

LOG.debug(_('End to_xml xml=%(xml)s'),
{'xml': xml}, instance=instance)
return xml

简单的说,就是让Nova生成libvirt xml的时候,硬编码进去相关的xml标签,好暴力,但是高效好用!

OpenStack 无法连接到Neutron 问题解决

OpenStack赵班长 发表了文章 • 2 个评论 • 8031 次浏览 • 2015-11-11 10:19 • 来自相关话题

    我们在Icehouse版本创建虚拟机会遇到错误:无法连接到Neutron.的报错,但是虚拟机还可以创建成功,这个是一个已知的bug,可以通过修改源码解决。     注意:还有一种情况,就是你的Neutron真的无法连接,要查看 ...查看全部
    我们在Icehouse版本创建虚拟机会遇到错误:无法连接到Neutron.的报错,但是虚拟机还可以创建成功,这个是一个已知的bug,可以通过修改源码解决。

    注意:还有一种情况,就是你的Neutron真的无法连接,要查看服务和监听端口是否正常!

Yum安装的文件在这里:
[root@test-node1 ~]# vim /usr/share/openstack-dashboard/openstack_dashboard/api/neutron.py
源码安装的在这里:
vim /usr/lib/python2.6/site-packages/openstack_dashboard/api/neutron.py
在class FloatingIpManager类里少了is_supported的方法,这个是一个bug,可以通过手动修改解决。
def is_simple_associate_supported(self):
        # NOTE: There are two reason that simple association support
        # needs more considerations. (1) Neutron does not support the
        # default floating IP pool at the moment. It can be avoided
        # in case where only one floating IP pool exists.
        # (2) Neutron floating IP is associated with each VIF and
        # we need to check whether such VIF is only one for an instance
        # to enable simple association support.
        return False
#在这个类的最下面,增加下面的方法,注意缩进。
    def is_supported(self):
        network_config = getattr(settings, 'OPENSTACK_NEUTRON_NETWORK', {})
        return network_config.get('enable_router', True)
修改完毕后,需要重启apache才可以生效:
[root@test-node1 ~]# /etc/init.d/httpd restart

OpenStack如何实现key注入和密码注入?

OpenStack赵班长 发表了文章 • 2 个评论 • 2941 次浏览 • 2015-09-22 10:59 • 来自相关话题

有朋友问,OpenStack是否支持Key注入和在Horizon的Dashboard上面修改密码,nova是支持的,不过默认可能没有打开。操作也比较简单,需要两个步骤。 1.修改nova.conf,修改以下配置: ...查看全部
有朋友问,OpenStack是否支持Key注入和在Horizon的Dashboard上面修改密码,nova是支持的,不过默认可能没有打开。操作也比较简单,需要两个步骤。

1.修改nova.conf,修改以下配置:

inject_password=true
inject_key=true
inject_partition=-1
重启nova-api。

2.修改horizon配置文件,local_settings
#启用Web界面上修改密码
OPENSTACK_HYPERVISOR_FEATURES = {
    'can_set_mount_point': True,
    'can_set_password': True,
}

好的,现在就可以创建虚拟机了,并且可以在dashboard上给虚拟机设置密码!
OpenStack