# Copyright 2010 OpenStack Foundation
# Copyright 2012 University Of Minho
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import binascii
import collections
import contextlib
import copy
import datetime
import errno
import glob
import io
import os
import random
import re
import shutil
import signal
import sys
import testtools
import threading
import time
import unittest
from castellan import key_manager
import ddt
import eventlet
from eventlet import greenthread
import fixtures
from lxml import etree
import mock
from os_brick import encryptors
from os_brick import exception as brick_exception
from os_brick.initiator import connector
import os_resource_classes as orc
import os_traits as ot
import os_vif
from oslo_concurrency import lockutils
from oslo_concurrency import processutils
from oslo_config import cfg
from oslo_serialization import jsonutils
from oslo_service import loopingcall
from oslo_utils import fileutils
from oslo_utils import fixture as utils_fixture
from oslo_utils.fixture import uuidsentinel as uuids
from oslo_utils import strutils
from oslo_utils import units
from oslo_utils import uuidutils
from oslo_utils import versionutils
from nova.api.metadata import base as instance_metadata
from nova.compute import manager
from nova.compute import power_state
from nova.compute import provider_tree
from nova.compute import task_states
from nova.compute import utils as compute_utils
from nova.compute import vm_states
import nova.conf
from nova import context
from nova.db import constants as db_const
from nova.db.main import api as db
from nova import exception
from nova.network import model as network_model
from nova import objects
from nova.objects import block_device as block_device_obj
from nova.objects import fields
from nova.objects import migrate_data as migrate_data_obj
from nova.objects import virtual_interface as obj_vif
from nova.pci import manager as pci_manager
from nova.pci import utils as pci_utils
import nova.privsep.fs
import nova.privsep.libvirt
from nova.storage import rbd_utils
from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.fixtures import libvirt_data as fake_libvirt_data
from nova.tests.unit import fake_block_device
from nova.tests.unit import fake_diagnostics
from nova.tests.unit import fake_flavor
from nova.tests.unit import fake_instance
from nova.tests.unit import fake_network
import nova.tests.unit.image.fake as fake_image
from nova.tests.unit import matchers
from nova.tests.unit.objects import test_diagnostics
from nova.tests.unit.objects import test_pci_device
from nova.tests.unit.objects import test_vcpu_model
from nova.tests.unit import utils as test_utils
from nova import utils
from nova import version
from nova.virt import block_device as driver_block_device
from nova.virt import driver
from nova.virt import fake
from nova.virt import hardware
from nova.virt.image import model as imgmodel
from nova.virt.libvirt import blockinfo
from nova.virt.libvirt import config as vconfig
from nova.virt.libvirt import designer
from nova.virt.libvirt import driver as libvirt_driver
from nova.virt.libvirt import event as libvirtevent
from nova.virt.libvirt import guest as libvirt_guest
from nova.virt.libvirt import host
from nova.virt.libvirt.host import SEV_KERNEL_PARAM_FILE
from nova.virt.libvirt import imagebackend
from nova.virt.libvirt import imagecache
from nova.virt.libvirt import migration as libvirt_migrate
from nova.virt.libvirt.storage import dmcrypt
from nova.virt.libvirt.storage import lvm
from nova.virt.libvirt import utils as libvirt_utils
from nova.virt.libvirt import vif as libvirt_vif
from nova.virt.libvirt.volume import volume as volume_drivers
CONF = nova.conf.CONF
_fake_network_info = fake_network.fake_get_instance_nw_info
# TODO(sean-k-mooney): move the rest of the static data to fake_libvirt_data
# and use it directly instead of creating local references to the common data
_fake_NodeDevXml = fake_libvirt_data._fake_NodeDevXml
_fake_NodeDevXml_parents = fake_libvirt_data._fake_NodeDevXml_parents
_fake_NodeDevXml_children = fake_libvirt_data._fake_NodeDevXml_children
_fake_cpu_info = {
"arch": "test_arch",
"model": "test_model",
"vendor": "test_vendor",
"topology": {
"sockets": 1,
"cores": 8,
"threads": 16
},
"features": ["feature1", "feature2"]
}
_fake_cpu_info_aarch64 = {
"arch": fields.Architecture.AARCH64,
"model": "test_model",
"vendor": "test_vendor",
"topology": {
"sockets": 1,
"cores": 8,
"threads": 16
},
"features": ["feature1", "feature2"]
}
eph_default_ext = utils.get_hash_str(nova.privsep.fs._DEFAULT_FILE_SYSTEM)[:7]
_fake_qemu64_cpu_feature = """
<cpu mode='custom' match='exact'>
<model fallback='forbid'>qemu64</model>
<feature policy='require' name='svm'/>
<feature policy='require' name='lm'/>
<feature policy='require' name='nx'/>
<feature policy='require' name='syscall'/>
<feature policy='require' name='cx16'/>
<feature policy='require' name='pni'/>
<feature policy='require' name='sse2'/>
<feature policy='require' name='sse'/>
<feature policy='require' name='fxsr'/>
<feature policy='require' name='mmx'/>
<feature policy='require' name='clflush'/>
<feature policy='require' name='pse36'/>
<feature policy='require' name='pat'/>
<feature policy='require' name='cmov'/>
<feature policy='require' name='mca'/>
<feature policy='require' name='pge'/>
<feature policy='require' name='mtrr'/>
<feature policy='require' name='sep'/>
<feature policy='require' name='apic'/>
<feature policy='require' name='cx8'/>
<feature policy='require' name='mce'/>
<feature policy='require' name='pae'/>
<feature policy='require' name='msr'/>
<feature policy='require' name='tsc'/>
<feature policy='require' name='pse'/>
<feature policy='require' name='de'/>
<feature policy='require' name='fpu'/>
</cpu>
"""
_fake_sandy_bridge_cpu_feature = """<cpu mode='custom' match='exact'>
<model fallback='forbid'>SandyBridge</model>
<feature policy='require' name='aes'/>
<feature policy='require' name='apic'/>
<feature policy='require' name='avx'/>
<feature policy='require' name='clflush'/>
<feature policy='require' name='cmov'/>
<feature policy='require' name='cx16'/>
<feature policy='require' name='cx8'/>
<feature policy='require' name='de'/>
<feature policy='require' name='fpu'/>
<feature policy='require' name='fxsr'/>
<feature policy='require' name='lahf_lm'/>
<feature policy='require' name='lm'/>
<feature policy='require' name='mca'/>
<feature policy='require' name='mce'/>
<feature policy='require' name='mmx'/>
<feature policy='require' name='msr'/>
<feature policy='require' name='mtrr'/>
<feature policy='require' name='nx'/>
<feature policy='require' name='pae'/>
<feature policy='require' name='pat'/>
<feature policy='require' name='pclmuldq'/>
<feature policy='require' name='pge'/>
<feature policy='require' name='pni'/>
<feature policy='require' name='popcnt'/>
<feature policy='require' name='pse'/>
<feature policy='require' name='pse36'/>
<feature policy='require' name='rdtscp'/>
<f
nova源码+无标注+OpenStack社区下载
需积分: 0 3 浏览量
更新于2022-06-15
收藏 14.04MB ZIP 举报
Nova是OpenStack项目的核心组件之一,负责计算服务的管理,包括虚拟机的生命周期管理、资源调度、网络配置等。在OpenStack社区下载的nova源码中,你可以深入了解这个开源云计算平台如何处理IaaS(基础设施即服务)的需求。下面将详细探讨Nova的相关知识点。
一、Nova架构
Nova采用微服务架构,由多个服务组成,如nova-api、nova-scheduler、nova-compute等,它们协同工作以提供完整的计算服务。
1. **nova-api**:这是Nova的前端接口,接收并处理RESTful API请求,与OpenStack其他服务进行交互,如Keystone(身份认证)、Glance(镜像服务)和Neutron(网络服务)。
2. **nova-scheduler**:负责选择合适的计算节点来运行实例。它根据预定的策略和资源信息(如CPU、内存、磁盘等)进行决策。
3. **nova-conductor**:作为中间人,处理需要跨多个服务的操作,如磁盘迁移和实例锁定。
4. **nova-compute**:实际执行虚拟机的创建、启动、停止和销毁等操作,与底层虚拟化技术(如KVM、Xen或Virtuozzo)紧密集成。
二、Nova组件交互
Nova通过消息队列(如RabbitMQ)进行组件间的通信,确保高可用性和解耦。例如,当用户请求创建一个新的实例时,nova-api接收到请求后,会通过消息队列通知nova-scheduler选择合适的计算节点,接着nova-scheduler将决定发送给nova-conductor,最后由nova-compute执行实例创建。
三、资源调度策略
Nova支持多种调度策略,如简单的“先到先服务”(First Fit)、“最不使用”(Least Recently Used, LRU)和基于权重的策略。用户可以通过配置文件或API指定调度策略,实现资源的优化分配。
四、虚拟化技术
Nova支持多种虚拟化技术,包括KVM、QEMU、Xen、Hyper-V等。每种技术都有其优缺点,用户可以根据自身需求选择合适的虚拟化技术。例如,KVM通常提供高性能,而Xen更适合已经在使用Xen环境的用户。
五、网络管理
Nova与Neutron(OpenStack的网络服务)紧密协作,提供网络配置功能。Nova可以创建基本的网络接口,而复杂的网络配置则交由Neutron处理,如虚拟私有云(VPC)、负载均衡、端口安全等。
六、扩展性与插件
Nova支持丰富的插件和扩展,允许用户定制特定的功能。例如,Nova可以使用Cinder(块存储服务)提供额外的存储功能,或者通过Heat(编排服务)进行复杂的应用部署。
七、安全性与隔离
Nova通过各种手段确保资源的安全和隔离,如使用安全组进行网络访问控制,使用实例快照备份数据,以及通过QoS(服务质量)设定资源限制。
总结来说,Nova是OpenStack中的核心组件,负责管理和调度计算资源。通过对源码的深入学习,开发者可以更好地理解OpenStack的工作原理,从而定制和优化自己的云环境。此外,参与社区的开发和讨论,也是提升技能、贡献开源的好方式。
高大利炮
- 粉丝: 0
- 资源: 2
最新资源
- 操作系统实验ucore lab3
- DG储能选址定容模型matlab 程序采用改进粒子群算法,考虑时序性得到分布式和储能的选址定容模型,程序运行可靠 这段程序是一个改进的粒子群算法,主要用于解决电力系统中的优化问题 下面我将对程序进行详
- final_work_job1(1).sql
- 区块链与联邦学习结合:FedChain项目详细复现指南
- 西门子S7 和 S7 Plus 协议开发示例
- 模块化多电平变流器 MMC 的VSG控制 同步发电机控制 MATLAB–Simulink仿真模型 5电平三相MMC,采用VSG控制 受端接可编辑三相交流源,直流侧接无穷大电源提供调频能量 设置频率
- 微电网(两台)主从控制孤岛-并网平滑切的分析 分析了: 1.孤岛下VF控制 2.并网下PQ控制 3.孤岛下主从控制 4.孤岛到并网的平滑切控制 5.除模型外还对分布式发电与主动配电网一些常见问题做了
- 第四组二手产品.zip
- 基于小程序的智慧物业平台源代码(java+小程序+mysql+LW).zip
- MVIMG_20241222_194113.jpg