Jump to: navigation, search

Difference between revisions of "Main Page/cobbler"

 
(32 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
其他功能
 +
1、使用远程桌面软件直接连接虚拟机
 +
(1)设置虚拟机远程连接协议
 +
模板页面->选择模板编辑->图像下拉框选择连接方式,vnc协议或者spice协议
 +
(2)登录服务器,使用virsh dumpxml 虚拟机id查看远程连接的ip地址和端口
 +
(3)使用远程桌面软件,输入虚拟机的远程协议ip地址和端口,即可远程连接虚拟机
 +
远程桌面软件地址请参见xxx
  
sqlalchemy和sqlalchemy-migrate在openstack的应用介绍
 
  
sqlalchemy
+
D:\git\kimchi-openstack\kimchi-openstack\src\kimchi\osinfo.py:43
简介:
+
'modern_update': dict(common_spec, disk_bus='scsi',
提供ORM(对象关系映射)能力的python库,类似hibernate技术,支持postgresql、mysql等主流关系数据;用户只需定义DB对应的类,通过操作类实例,即可通过sqlalchemy引擎转换成标准sql语句,对DB进行操作
+
                                        nic_model='virtio',
 +
                              sound_model='ich6')
  
Openstack中的应用:
+
if distro in modern_version_bases[arch]:
openstack各项目涉及关系数据库的DB driver,基本都是使用sqlalchemy库。
+
        if LooseVersion(version) >= LooseVersion(
table对应class定义:\nova\db\sqlalchemy\models.py中,例如class Instance(BASE, NovaBase)
+
                modern_version_bases[arch][distro]):
db操作API:\nova\db\sqlalchemy\api.py,调用sqlalchemy相关库函数操作DB,数据实体使用models.py定义的class
+
            if arch == 'x86':
 +
                params.update(template_specs[arch]['modern_update'])
 +
            else:
 +
                params.update(template_specs[arch]['modern'])
 +
        else:
 +
            params.update(template_specs[arch]['old'])
  
sqlalchemy-migrate
+
                                'window': '0'},
简介:
 
基于sqlalchemy库,提供数据库版本管控能力的python库。
 
 
 
Openstack中的应用:
 
版本升级能力是openstack当前能力较缺失的一块,但是从DB升级的角度看,由于引入了sqlalchemy-migrate框架,openstack各项目比较容易管理DB的变化,例如新增加一张table,新增加一个字段等。
 
sqlalchemy-migrate在2011年发布了0.7.2版本后,就已经停止更新了,也不接受bugfix。因此openstack考虑引入Alembic(同样由sqlalchemy-migrate的开发者)替代sqlalchemy-migrate
 
sqlalchemy-migrate提供upgrade(升级)、downgrade(降级)、db_version(查看最新版本)等接口
 
 
 
应用举例:
 
在H版本代码基础上nova项目提供USB设备管理能力,故在DB Layper需增加一张table存放USB设备信息。
 
 
 
1. 在/nova/db/sqlalchemy/migrate_repo/versions增加一个217_add_usb_devices.py(H版本version号到216,故新增文件命令以217开头)
 
#定义升级函数,本例升级即创建一张新table
 
def upgrade(migrate_engine):
 
    meta = MetaData(bind=migrate_engine)
 
 
 
    usb_devices_uc_name = 'uniq_usb_devices0compute_node_id0address0deleted'
 
    usb_devices = Table('usb_devices', meta,
 
                        Column('created_at', DateTime(timezone=False)),
 
                        ...
 
#定义升级回退函数,本例回退即删除创建的table
 
def downgrade(migrate_engine):
 
    meta = MetaData(bind=migrate_engine)
 
 
 
    try:
 
        usb_device = Table('usb_devices', meta, autoload=True)
 
        usb_device.drop()
 
        ...
 
2. 执行nova-manage db sync命令,对nova DB进行升级。结果是在数据库中即可见到产生的usb_devices表
 
3. 执行nova-manage db sync 216命令,对nova DB进行升级。结果是usb_devices表被删除
 
 
 
系统内部流程简介:
 
(1)在DB的migrate_version中存放了nova的DB版本信息,如下所示:
 
mysql> select * from migrate_version;
 
+---------------+------------------------------------------------------------------+---------+
 
| repository_id | repository_path                                                  | version |
 
+---------------+------------------------------------------------------------------+---------+
 
| nova          | /usr/lib/python2.6/site-packages/nova/db/sqlalchemy/migrate_repo |    216 |
 
+---------------+------------------------------------------------------------------+---------+
 
1 row in set (0.00 sec)
 
(2)执行nova-manage db sync命令,调用/nova/db/sqlalchemy/migration.py的db_sync函数
 
        此函数检查当前版本号和API传入的版本号,如果API不指定版本号(见上面例子)、或者指定的版本号大于当前版本号,则进入升级流程,否则进入降级流程
 
(3)最终进入migrate/versioning/api.py的_migrate函数
 
        此函数检查是否有变更点,如果没有变更点则结束流程,如果有变更点(例如上例新增加了217_xx),则执行变更(即执行217_add_usb_devices.py中的upgrade函数),产生新DB
 
 
 
相关参考:
 
http://blog.csdn.net/tpiperatgod/article/details/17560005
 
http://www.sqlalchemy.org/
 
http://www.cnblogs.com/willier/archive/2013/05/16/3081475.html
 
http://www.ustack.com/blog/sqlalchemy-migrate-and-alembic/
 
 
 
 
 
We provide VDI(Virtual Desktop) and server virtualization solutions for customers, our customers have strong requirements for using USB devices.
 
 
 
The typical use cases and our solutions are described as below:
 
1.In VDI solution, customers want to use local USB printers or USB scanners with TC(Thin-Client), because remote desktop protocol like ICA have already support USB-redirection,
 
so customers only need to attach USB device to TC, the protocol can map USB device to VM.
 
 
 
2. In virtualization solution, when starting or restarting some business-critical applications, a connected USB-KEY is needed for authentication,
 
some applications even need a daily authentication by USB-KEY. we suggest the following solutions:
 
(1) Using physical 'USB-HUB' box and technology of USB-redirection over TCP/IP.Customers need to buy USB-HUB and install software in guest os, the software helps 
 
redirecting USB device to VM.
 
 
 
(2) Using USB-Passthrough and USB hot-plug functions provided by our virtualization software.
 
The end users(normally application or system administrators)  insert USB devices to host that containing the VM, then  can see USB device list in portal and choose USB device to attach.
 
This solution has advantages that
 
1. It dosen’t need additional physical devices
 
2. It dosen't need a special server to run spice client for USB-Redirection
 
3. Business-critical applications commonly need stable and long-standing USB-KEY to attach, USB-Passthrough maybe more stable than USB-Redirection over TCP/IP or remote desktop protocol.
 
 
 
As described above, I think USB-Passthrough/USB hot-plug is valuable in Openstack.
 
This BP is focus on how to provide USB-Passthrough/USB hot-plug function in Openstack.
 
 
 
Use cases:
 
In private cloud, a end user wants to run a ERP software in VM which needs a USB-KEY for authentication, he proposes request to system administor, they perform the following steps:
 
1. The administrator finds the host which runs the VM with ERP software by portal or API.
 
2. The administrator goes to the machine room and insert USB-KEY to host.
 
3. The administrator adds some configuration(like white-list with USB-KEY's product and vendor informations) to nova-compute, restart nova-compute to trigger to discovery USB-KEY and save to DB.
 
4. The end user queries USB-KEY by host id.
 
5. The end user attaches USB-KEY to VM.
 
 
 
In private cloud, a end user wants to create a VM to run ERP software which needs a USB-KEY for authentication, he proposes request to system administor, they perform the following steps:
 
1. The administrator goes to the machine room and chooses a host to insert USB-KEY to.
 
2. The administrator adds some configuration(like white-list with USB-KEY's product and vendor informations) to nova-compute, restart nova-compute to trigger to discovery new devices and save to DB.
 
3. The administrator queries USB-KEY information(the information should be able to  distinguish USB-KEY,  for example using uuid genereated by system)  from system, and then creates a flavor with USB-KEY information.
 
4. The end user creates a VM with above flavor, the system chooses the host which contains the USB-KEY to create VM and attach USB-KEY to it.
 
 
 
Data model impact:
 
The new function has some impactions on other functions and the operations of user which I can identify by now.
 
1. When migrate a VM with USB device, it may be failed, so it is necessary to make some restriction on migration procedure.
 
2. It may be unsafe to suspend a VM with USB device, so it is necessary to add procedure of detach/re-attach USB device  to procedure of suspending VM.
 
3. For user it is more safe to pop-up USB device in guest os before detach USB device from VM.
 
4. After reboot host and restart VM, the VM may can't find the USB device because the physical information like device id have been change(which is the linux system's mechanism), so we need to find appropriate physical identifier to distinguish USB devices.
 
5. When rebuild a VM with USB device, it is necessary to re-attach USB device to the VM.
 
 
 
Developer impact
 
 
 
 
 
 
 
Work Items
 
Step 1: Add function to discover usb device.
 
Step 2: Add function to store USB device information.
 
Step 3: Add function to create VM with USB device.
 
Step 4: Add function to hot-plug/unplug usb device to/from VM.
 
Step 5: Add changes to other exist functions which have been affected by the new function.
 
Step 6: Add function to specify USB controller.
 
 
 
 
 
Testing
 
Add test cases to test the related functions.
 
 
 
 
 
 
 
Documentation Impact
 
Add doc about how to use this function.
 

Latest revision as of 11:18, 21 October 2014

其他功能 1、使用远程桌面软件直接连接虚拟机 (1)设置虚拟机远程连接协议 模板页面->选择模板编辑->图像下拉框选择连接方式,vnc协议或者spice协议 (2)登录服务器,使用virsh dumpxml 虚拟机id查看远程连接的ip地址和端口 (3)使用远程桌面软件,输入虚拟机的远程协议ip地址和端口,即可远程连接虚拟机 远程桌面软件地址请参见xxx


D:\git\kimchi-openstack\kimchi-openstack\src\kimchi\osinfo.py:43 'modern_update': dict(common_spec, disk_bus='scsi',

                                        nic_model='virtio',
                             sound_model='ich6')

if distro in modern_version_bases[arch]:

       if LooseVersion(version) >= LooseVersion(
               modern_version_bases[arch][distro]):
           if arch == 'x86':
               params.update(template_specs[arch]['modern_update'])
           else:
               params.update(template_specs[arch]['modern'])
       else:
           params.update(template_specs[arch]['old'])
                               'window': '0'},