How to create a VM on a specified host with openstack
2012-08-23 22:36
375 查看
如果用devstack安装的openstack cluster,那么所有的source code都在/opt/stack下面。
如果用户想创建一个VM在特定的机器上,openstack提供了一种hack的方法,具体可以这样做,在通过"nova boot"创建instance的时候,使用availability_zone来制定目标机器,格式为“xxx:targethost”,xxx可以是任意的字符串,和targethost使用冒号分开。
以上的命令可以保证用户新创建的instance会在devstack13上边。
从代码上也可以看出来,以下这段代码来自于:/opt/stack/nova/nova/compute/api.py:_create_instance()
如果用户想创建一个VM在特定的机器上,openstack提供了一种hack的方法,具体可以这样做,在通过"nova boot"创建instance的时候,使用availability_zone来制定目标机器,格式为“xxx:targethost”,xxx可以是任意的字符串,和targethost使用冒号分开。
root@devstack12:~# nova boot usage: nova boot [--flavor <flavor>] [--image <image>] [--meta <key=value>] [--file <dst-path=src-path>] [--key_name <key_name>] [--user_data <user-data>] [--availability_zone <availability-zone>] [--security_groups <security_groups>] [--block_device_mapping <dev_name=mapping>] [--hint <key=value>] [--nic <net-id=net-uuid,v4-fixed-ip=ip-addr>] [--config-drive <value>] [--poll] <name> error: too few arguments Try 'nova help boot' for more information. root@devstack12:~# nova image-list +--------------------------------------+---------------------------------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+---------------------------------+--------+--------+ | 4bca2cad-3d3e-4526-983c-0d4b0d1110e0 | cirros-0.3.0-x86_64-uec | ACTIVE | | | ab22c6d4-dba6-460d-afbe-7c4f62b138cb | cirros-0.3.0-x86_64-uec-kernel | ACTIVE | | | d014fd1f-549c-4732-931d-58f18b151b68 | cirros-0.3.0-x86_64-uec-ramdisk | ACTIVE | | +--------------------------------------+---------------------------------+--------+--------+ root@devstack12:~# root@devstack12:~# nova boot --image 4bca2cad-3d3e-4526-983c-0d4b0d1110e0 --flavor 1--availability_zone xx:devstack13 server1
以上的命令可以保证用户新创建的instance会在devstack13上边。
从代码上也可以看出来,以下这段代码来自于:/opt/stack/nova/nova/compute/api.py:_create_instance()
# NOTE(vish): We have a legacy hack to allow admins to specify hosts # via az using az:host. It might be nice to expose an # api to specify specific hosts to force onto, but for # now it just supports this legacy hack. host = None if availability_zone: availability_zone, _x, host = availability_zone.partition(':') if not availability_zone: availability_zone = FLAGS.default_schedule_zone if context.is_admin and host: filter_properties = {'force_hosts': [host]} else: filter_properties = {} filter_properties['scheduler_hints'] = scheduler_hints
相关文章推荐
- How to configure Red Hat Cluster using KVM fencing with two guest VM's running on a IBM PowerKVM
- How to Create a High Availability Setup with Pacemaker, Corosync and Floating IPs on CentOS 7
- how-to create a high-availability mysql setup with corosync pacemaker and drbd on ubuntu
- How to create id with AUTO_INCREMENT on Oracle?
- DOS cmd - how to ping a remote host with specified port
- How to Create Text Image on the fly with ASP.NET
- How to Install Linux KVM and Create Guest VM with Examples
- How to create openstack single node with devstack
- DOS cmd - how to ping a remote host with specified port
- Step by Step - How to create a c++ library with NDK on Android Studio 1.5 (not experimental way)
- How to create physical standby database with 11g RMAN DUPLICATE FROM ACTIVE DATABASE [ID 747250.1]
- how to create an ssl certificate on nginx for ubuntu14.04
- How to use OpenID to sign on with Google account
- How to create and apply a patch with Git
- Enemies and Combat: How to Create a Tile Based Game with Cocos2D Part 3
- How to Create Mixed Reality Videos for the Vive - with Two Controllers
- How to Register an ActiveX DLL on Vista with regsvr32
- How to develop applications with Qt Mobility based on Symbian device
- how to test observe with rspec in ruby on rails.
- How to install Microsoft Office 2010 on Linux with Wine