当前位置:首页>开发>正文

如何在openstack启动instan 如何安装openstack tempest

2023-04-25 04:42:50 互联网 未知 开发

 如何在openstack启动instan 如何安装openstack tempest

如何在openstack启动instan

启动一个新的instance涉及到很多openstack nova里面的组件
API server:处理客户端的请求,并且转发到cloud control
Cloud control:处理compute节点,网络控制节点,API server和scheduler中间连接
Scheduler:选择一个host去执行命令
compute worker:启动和停止实例,附加和删除卷 等操作
network controller:管理网络资源,分配固定IP,配置vlans
Openstack创建instance的流程
1.API server将消息发送到Cloud Controller
2. Authertication 保用户有权限,然后Cloud Controller将消息发送给Scheduler
3. Scheduler caste 一个消息给一个选择好的host要求他启动一个实例
4.compute worker(选择的那个host)获取到消息
5.6.7.8 compute worker需要一个固定的ip去启动一个实例,所以向network controller发送消息
下面我将详细说明一下:
API
1.可以在dashboard网页上面进行
2.可以用命令行 euca-add-keypair euca-run-instances
用户的请求发送到nova-api,有两种方式
第一种:通过openstack api (nova/api/servers.py 类 class Controller(object))create方法
def create(self, req, body):
“”” Creates a new server for a given user “””
if ‘server’ in body:
body[‘server’][‘key_name’] = self._get_key_name(req, body)
extra_values = None
extra_values, instances = self.helper.create_instance(
req, body, self.compute_api.create)
第二种:通过ec2 api (nova/api/cloud.py 中类 CloudController )
调用def run_instances(self, context, **kwargs):

(instances, resv_id) = self.compute_api.create(context,
instance_type=instance_types.get_instance_type_by_name(
kwargs.get(‘instance_type’, None)),

最终调用的Compute API create():
查看这种类型的instance是否达到最大值
如果不存在安全组,就创建个
生成MAC地址和hostnames
给scheduler发送一个消息去运行这个实例
CAST
当然maxCount为1(默认值为1)的时候 调用RPC.cast方法向scheduler发送运行实例的消息
Openstack创建instance的流程
在openstack中通过RPC.cast来发送消息,消息的分发通过RabbitMQ。消息发送方(Compute API)往
topic exchange(scheduler topic)发送一个消息,消息消费者(Scheduler worker)从队列中获得消息,
cast调用不需要返回值。
[python] view plaincopy
def _schedule_run_instance(self,

return rpc_method(context,
FLAGS.scheduler_topic,
{“method”: “run_instance”,
“args”: {“topic”: FLAGS.compute_topic,
“request_spec”: request_spec,
“admin_password”: admin_password,
“injected_files”: injected_files,
“requested_networks”: requested_networks,
“is_first_time”: True,
“filter_properties”: filter_properties}})
Scheduler
scheduler接收到消息,然后通过设定的scheduler策略选择一个目的host,如:zone scheduler
选择一个主机在特定的可获取的zone上面。最后发送一个cast消息到特定的host上面
[python] view plaincopy
def cast_to_compute_host(context, host, method, update_db=True, **kwargs):
“””Cast request to a compute host queue”””
if update_db:
# fall back on the id if the uuid is not present
instance_id = kwargs.get(‘instance_id’, None)
instance_uuid = kwargs.get(‘instance_uuid’, instance_id)
if instance_uuid is not None:
now = utils.utcnow()
db.instance_update(context, instance_uuid,
{‘host’: host, ‘scheduled_at’: now})
rpc.cast(context,
db.queue_get_for(context, ‘compute’, host),
{“method”: method, “args”: kwargs})
LOG.debug(_(“Casted ‘%(method)s’ to compute ‘%(host)s’”) % locals())
Compute
compute worker进程接收到消息执行方法(nova/compute/manager.py)
[python] view plaincopy
def _run_instance(self, context, instance_uuid,
requested_networks=None,
injected_files=[],
admin_password=None,
is_first_time=False,
**kwargs):
“””Launch a new instance with specified options.”””
context = context.elevated()
try:
instance = self.db.instance_get_by_uuid(context, instance_uuid)
self._check_instance_not_already_created(context, instance)
image_meta = self._check_image_size(context, instance)
self._start_building(context, instance)
self._notify_about_instance_usage(instance, “create.start”)
network_info = self._allocate_network(context, instance,
requested_networks)
try:
block_device_info = self._prep_block_device(context, instance)
instance = self._spawn(context, instance, image_meta,
network_info, block_device_info,
injected_files, admin_password)

检查instance是否已经在运行
分配一个固定的ip地址
如果没有设置vlan和网桥,设置一下
最后通过虚拟化的driver spawn一个instance
network controller
network_info = self._allocate_network(context, instance,
requested_networks)
调用network的API的allocate_for_instance方法
[python] view plaincopy
def allocate_for_instance(self, context, instance, **kwargs):
“””Allocates all network structures for an instance.
:returns: network info as from get_instance_nw_info() below
“””
args = kwargs
args[‘instance_id’] = instance[‘id’]
args[‘instance_uuid’] = instance[‘uuid’]
args[‘project_id’] = instance[‘project_id’]
args[‘host’] = instance[‘host’]
args[‘rxtx_factor’] = instance[‘instance_type’][‘rxtx_factor’]
nw_info = rpc.call(context, FLAGS.network_topic,
{‘method’: ‘allocate_for_instance’,
‘args’: args})
RPC.call 与RPC.cast最大的不同 就是call方法需要一个response

Openstack创建instance的流程
Spawn instance
接下来我要说的就是虚拟化的driver spawn instance,我们这里使用的是libvirt(nova/virt/libvirt/lconnection.py)
[python] view plaincopy
def spawn(self, context, instance, image_meta, network_info,
block_device_info=None):
xml = self.to_xml(instance, network_info, image_meta, False,
block_device_info=block_device_info)
self.firewall_driver.setup_basic_filtering(instance, network_info)
self.firewall_driver.prepare_instance_filter(instance, network_info)
self._create_image(context, instance, xml, network_info=network_info,
block_device_info=block_device_info)
self._create_new_domain(xml)
LOG.debug(_(“Instance is running”), instance=instance)
self._enable_hairpin(instance)
self.firewall_driver.apply_instance_filter(instance, network_info)
def _wait_for_boot():
“””Called at an interval until the VM is running.”””
try:
state = self.get_info(instance)[‘state’]
except exception.NotFound:
LOG.error(_(“During reboot, instance disappeared.”),
instance=instance)
raise utils.LoopingCallDone
if state == power_state.RUNNING:
LOG.info(_(“Instance spawned successfully.”),
instance=instance)
raise utils.LoopingCallDone
timer = utils.LoopingCall(_wait_for_boot)
return timer.start(interval=0.5, now=True)
通过libvirt xml文件,然后根据xml文件生成instance
准备network filter,默认的fierwall driver是iptables
image的创建(详细情况以后再介绍)
def _create_image(self, context, instance, libvirt_xml, suffix=”,

disk_images=None, network_info=None,
block_device_info=None):

最后虚拟化driver的spawn()方法中调用driver 的creatXML()

如何安装openstack tempest

如果您是用 DevStack 安装 OS 环境,Tempest 项目会自动被下载及配置在路径 /opt/stack/tempest。如果您是手动安装 OS 环境,或者用 IBM installer 安装 OS 环境,需要在社区手动下载 Tempest 项目并进行配置。
Tempest 下载地址 https://github.com/openstack/tempest,下载命令如下:
git clone https://github.com/openstack/tempest.git

Tempest 下载后,需要安装 unittest2 以及 nose Python 等库相关依赖。如果下载基于 OS Grizzly、OS Havana 最新的 tempest 项目,进入到 tempest 所在文件夹执行以下命令:
python setup.py install

如果下载 folsom 以及以前版本的 tempest 项目, 需要执行以下命令安装:
Unbuntu: pip install -r tools/pip-requirres(test-requires)
Redhat: pip-python install -r tools/pip-requires(test-requires)

openstack instance 主机 哪个

metadata字面上是元数据,是一个不容易理解的概念。
  在除了openstack的其他场合也经常会碰到。
  openstack里的metadata,是提供一个机制给用户,可以设定每一个instance 的参数。
  比如想给instance设置某个属性,比如主机名。
  metadata的一个重要应用,是设置每个instance的ssh公钥。
  公钥的设置有两种方式:
  1、创建instance时注入文件镜像
  2、启动instance后,通过metadata获取,然后用脚本写入
  第二种方式更加灵活,可以给非root用户注入公钥。

OpenStack创建虚拟机VM报错 Instance building... 0% complete Error building instance

先查看一下scheduler的日志,是否分配到compute,然后查看一下compute的日志。
可能存在的原因就是存储空间不足吧,nova-network的ip无法分配也可能导致创建失败。。。
你先查看一下,然后再追问吧

运行openstack-status为什么不出表格

Openstack有很多项目,比如nova是虚拟机管理,neutron是虚拟网络管理,glance是存储管理,而horizon是负责Openstack的统一界面。horizon的源代码和neutron的不太一样,分布在两个地方,一个是/usr/lib/python2.7/dist-packages/horizon下面,这里放的是一些最基本的、可以共享的类、表格和模板等。另一个是/usr/share/openstack-dashboard下面,这里放的是跟界面有直接关系、更加具体的类、表格和模板等,也是我们需要修改的地方。

openstack的orchestration起什么作用

OpenStack云计算平台,帮助服务商和企业内部实现类似于 Amazon EC2 和 S3 的云基础架构服务(Infrastructure as a Service, IaaS)。OpenStack 包含两个主要模块:Nova 和 Swift,前者是 NASA 开发的虚拟服务器部署和业务计算模块;后者是 Rackspace开发的分布式云存储模块,两者可以一起用,也可以分开单独用。OpenStack除了有 Rackspace 和 NASA 的大力支持外,还有包括 Dell、Citrix、 Cisco、 Canonical等重量级公司的贡献和支持,发展速度非常快,有取代另一个业界领先开源云平台 Eucalyptus 的态势。

openstack keystone创建域时报错

该程序在创建密码插件时,企图找到同等服务失败,无法与URL指向的网络地址建立连接。此程序比较可疑:1. 安装程序要捆绑密码插件;2. 所列网址也不是标准的互联网地址格式(需要通过35375端口)。

最新文章