SlideShare ist ein Scribd-Unternehmen logo
1 von 12
Downloaden Sie, um offline zu lesen
A FIRST STEP INTO NOVA
         by can.
NOVA 2011.3 DIABLO/


• setup.py:安装脚本

• bin:可执行程序,
 比如nova-manage等

• nova:核心文件
/SETUP.PY
try:
    from DistUtilsExtra.auto import setup
except ImportError:
    from setuptools import setup
...

setup(name='nova',
      version=version.canonical_version_string(),
      description='cloud computing fabric controller',
      author='OpenStack',
      author_email='nova@lists.launchpad.net',
      url='http://www.openstack.org/',
      cmdclass=nova_cmdclass,
      packages=find_packages(exclude=['bin', 'smoketests']),
      include_package_data=True,
      test_suite='nose.collector',
      data_files=find_data_files('share/nova', 'tools'),
      scripts=['bin/nova-ajax-console-proxy',
               'bin/nova-api',
               'bin/nova-compute',
...
/BIN

• 其实都是python脚本

• nova-api/compute/
 network/scheduler等
 是服务的启动程序

• nova-manage是给管
 理员的命令行程序
...
               /BIN/NOVA-API
        for api in flags.FLAGS.enabled_apis:
            servers.append(service.WSGIService(api))
        service.serve(*servers)
        service.wait()

  ...



       /BIN/NOVA-COMPUTE
...

      server = service.Service.create(binary='nova-compute')
      service.serve(server)
      service.wait()

...
NOVA的SERVICE


• 分为两种,Service和WSGIService

• 前者供内部调用,通过RPC(remote       procedure call)模块

• 后者对外提供API,通过http
神奇的FLAGS
• 整个项目统⼀一采用flags模块处理可由用户定义的参数,
 包括配置文件、通过命令行传入的参数等

• 基于开源代码python-gflags

• 可以分布式地定义参数,即每个模块只需定义自己需要
 的,通过”import”引入其它模块定义的参数。有利于模块
 化
# from /nova/service.py
flags.DEFINE_string('ec2_listen', "0.0.0.0",
                    'IP address for EC2 API to listen')
flags.DEFINE_integer('ec2_listen_port', 8773, 'port for ec2 api to listen')
flags.DEFINE_string('osapi_listen', "0.0.0.0",
                    'IP address for OpenStack API to listen')
flags.DEFINE_integer('osapi_listen_port', 8774, 'port for os api to listen')
/NOVA/SCHEDULER

• 目录下面
 有”__init__.py”说
 明这是⼀一个模块

• manager统⼀一对外
 的接口

• 通过dirver兼容不
 同的底层结构
SCHEDULERS
nova.scheduler.driver.Scheduler
   ChanceScheduler
       SimpleScheduler
          VsaScheduler
             VsaSchedulerLeastUsedHost
             VsaSchedulerMostAvailCapacity
   AbstractScheduler
       BaseScheduler
          LeastCostScheduler
   MultiScheduler
   ZoneScheduler
自定义调度算法
# from /nova/scheduler/chance.py
class ChanceScheduler(driver.Scheduler):
    """Implements Scheduler as a random node selector."""

   def schedule(self, context, topic, *_args, **_kwargs):
       """Picks a host that is up at random."""

       hosts = self.hosts_up(context, topic)
       if not hosts:
           raise driver.NoValidHost(_("Scheduler was unable to locate a host"
                                      " for this request. Is the appropriate"
                                      " service running?"))
       return hosts[int(random.random() * len(hosts))]



   外界通过manager调用schedule_**()方法,若所
   需方法不存在,使用schedule()
nova-compute nova-network
nova-schedule



                逻辑结构
“物理”结构?
                    user

                  nova-api

 nova-compute   nova-network        nova-***

FLAGS     db       RPC         context    LOG

Weitere ähnliche Inhalte

Was ist angesagt?

Devsumi2012 攻めの運用の極意
Devsumi2012 攻めの運用の極意Devsumi2012 攻めの運用の極意
Devsumi2012 攻めの運用の極意
Ryosuke IWANAGA
 

Was ist angesagt? (20)

Vancouver presentation
Vancouver presentationVancouver presentation
Vancouver presentation
 
Configuration Management in Ansible
Configuration Management in Ansible Configuration Management in Ansible
Configuration Management in Ansible
 
Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Webエンジニアから見たiOS5
Webエンジニアから見たiOS5
 
Devsumi2012 攻めの運用の極意
Devsumi2012 攻めの運用の極意Devsumi2012 攻めの運用の極意
Devsumi2012 攻めの運用の極意
 
Introduction to Ansible - Peter Halligan
Introduction to Ansible - Peter HalliganIntroduction to Ansible - Peter Halligan
Introduction to Ansible - Peter Halligan
 
Ansible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy MykhailiutaAnsible 101, Gennadiy Mykhailiuta
Ansible 101, Gennadiy Mykhailiuta
 
LAMP Stack (Reloaded) - Infrastructure as Code with Terraform & Packer
LAMP Stack (Reloaded) - Infrastructure as Code with Terraform & PackerLAMP Stack (Reloaded) - Infrastructure as Code with Terraform & Packer
LAMP Stack (Reloaded) - Infrastructure as Code with Terraform & Packer
 
Developers’ mDay 2019. - Rastko Vasiljević, SuperAdmins – Infrastructure as c...
Developers’ mDay 2019. - Rastko Vasiljević, SuperAdmins – Infrastructure as c...Developers’ mDay 2019. - Rastko Vasiljević, SuperAdmins – Infrastructure as c...
Developers’ mDay 2019. - Rastko Vasiljević, SuperAdmins – Infrastructure as c...
 
Web scraping with nutch solr part 2
Web scraping with nutch solr part 2Web scraping with nutch solr part 2
Web scraping with nutch solr part 2
 
Terraform Modules and Continuous Deployment
Terraform Modules and Continuous DeploymentTerraform Modules and Continuous Deployment
Terraform Modules and Continuous Deployment
 
To Hire, or to train, that is the question (Percona Live 2014)
To Hire, or to train, that is the question (Percona Live 2014)To Hire, or to train, that is the question (Percona Live 2014)
To Hire, or to train, that is the question (Percona Live 2014)
 
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueRestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message Queue
 
Ansible
AnsibleAnsible
Ansible
 
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
[오픈소스컨설팅] EFK Stack 소개와 설치 방법[오픈소스컨설팅] EFK Stack 소개와 설치 방법
[오픈소스컨설팅] EFK Stack 소개와 설치 방법
 
{{more}} Kibana4
{{more}} Kibana4{{more}} Kibana4
{{more}} Kibana4
 
Terraform Immutablish Infrastructure with Consul-Template
Terraform Immutablish Infrastructure with Consul-TemplateTerraform Immutablish Infrastructure with Consul-Template
Terraform Immutablish Infrastructure with Consul-Template
 
Creating Reusable Puppet Profiles
Creating Reusable Puppet ProfilesCreating Reusable Puppet Profiles
Creating Reusable Puppet Profiles
 
Ansible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetupAnsible loves Python, Python Philadelphia meetup
Ansible loves Python, Python Philadelphia meetup
 
Jk rubyslava 25
Jk rubyslava 25Jk rubyslava 25
Jk rubyslava 25
 
More tips n tricks
More tips n tricksMore tips n tricks
More tips n tricks
 

Andere mochten auch

Mid Term Presentation
Mid Term PresentationMid Term Presentation
Mid Term Presentation
Stephendid
 
Breach of privacy in australia
Breach of privacy in australiaBreach of privacy in australia
Breach of privacy in australia
Atul
 
Definitive Consulting E Brochure
Definitive Consulting E BrochureDefinitive Consulting E Brochure
Definitive Consulting E Brochure
racheltaylor
 
Mritunjay Axon Network Solution
Mritunjay Axon Network SolutionMritunjay Axon Network Solution
Mritunjay Axon Network Solution
Mritunjay Kumar
 
Sales Strategy For Cool headS(Acadmic Case Study)
Sales Strategy For Cool headS(Acadmic Case Study)Sales Strategy For Cool headS(Acadmic Case Study)
Sales Strategy For Cool headS(Acadmic Case Study)
Mritunjay Kumar
 
National geographic
National geographicNational geographic
National geographic
OMD
 
Fiduciary obligations and breach of confidence examining the high court’s g...
Fiduciary obligations and breach of confidence   examining the high court’s g...Fiduciary obligations and breach of confidence   examining the high court’s g...
Fiduciary obligations and breach of confidence examining the high court’s g...
Atul
 
The importance of risk analysis and management, and corporate governance
The importance of risk analysis and management, and corporate governanceThe importance of risk analysis and management, and corporate governance
The importance of risk analysis and management, and corporate governance
Atul
 

Andere mochten auch (18)

FOSS4G 2010. Keynote: "Beyond Open Source".
FOSS4G 2010. Keynote: "Beyond Open Source".FOSS4G 2010. Keynote: "Beyond Open Source".
FOSS4G 2010. Keynote: "Beyond Open Source".
 
Abc Conveyorbook1 080100
Abc Conveyorbook1 080100Abc Conveyorbook1 080100
Abc Conveyorbook1 080100
 
Sustainable Drink Presentation
Sustainable Drink PresentationSustainable Drink Presentation
Sustainable Drink Presentation
 
gvSIG Mobile and gvSIG Mini as SDI & LBS clients
gvSIG Mobile and gvSIG Mini as SDI & LBS clientsgvSIG Mobile and gvSIG Mini as SDI & LBS clients
gvSIG Mobile and gvSIG Mini as SDI & LBS clients
 
Pension Plan
Pension PlanPension Plan
Pension Plan
 
Mid Term Presentation
Mid Term PresentationMid Term Presentation
Mid Term Presentation
 
ASOLIVAL. La apuesta empresarial por el software libre
ASOLIVAL. La apuesta empresarial por el software libreASOLIVAL. La apuesta empresarial por el software libre
ASOLIVAL. La apuesta empresarial por el software libre
 
Breach of privacy in australia
Breach of privacy in australiaBreach of privacy in australia
Breach of privacy in australia
 
Definitive Consulting E Brochure
Definitive Consulting E BrochureDefinitive Consulting E Brochure
Definitive Consulting E Brochure
 
Tobacco Sponsorship In F1
Tobacco Sponsorship In F1Tobacco Sponsorship In F1
Tobacco Sponsorship In F1
 
Mritunjay Axon Network Solution
Mritunjay Axon Network SolutionMritunjay Axon Network Solution
Mritunjay Axon Network Solution
 
Sales Strategy For Cool headS(Acadmic Case Study)
Sales Strategy For Cool headS(Acadmic Case Study)Sales Strategy For Cool headS(Acadmic Case Study)
Sales Strategy For Cool headS(Acadmic Case Study)
 
National geographic
National geographicNational geographic
National geographic
 
Fiduciary obligations and breach of confidence examining the high court’s g...
Fiduciary obligations and breach of confidence   examining the high court’s g...Fiduciary obligations and breach of confidence   examining the high court’s g...
Fiduciary obligations and breach of confidence examining the high court’s g...
 
The importance of risk analysis and management, and corporate governance
The importance of risk analysis and management, and corporate governanceThe importance of risk analysis and management, and corporate governance
The importance of risk analysis and management, and corporate governance
 
Comparison of Mobile GIS applications
Comparison of Mobile GIS applicationsComparison of Mobile GIS applications
Comparison of Mobile GIS applications
 
Building Organisational Resilience
Building Organisational ResilienceBuilding Organisational Resilience
Building Organisational Resilience
 
Chivalry
ChivalryChivalry
Chivalry
 

Ähnlich wie openstack源码分析(1)

X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
Yiwei Ma
 

Ähnlich wie openstack源码分析(1) (20)

Gr8conf EU 2018 - Bring you infrastructure under control with Infrastructor
Gr8conf EU 2018 - Bring you infrastructure under control with InfrastructorGr8conf EU 2018 - Bring you infrastructure under control with Infrastructor
Gr8conf EU 2018 - Bring you infrastructure under control with Infrastructor
 
Extending functionality in nginx, with modules!
Extending functionality in nginx, with modules!Extending functionality in nginx, with modules!
Extending functionality in nginx, with modules!
 
Automating complex infrastructures with Puppet
Automating complex infrastructures with PuppetAutomating complex infrastructures with Puppet
Automating complex infrastructures with Puppet
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
 
Custom deployments with sbt-native-packager
Custom deployments with sbt-native-packagerCustom deployments with sbt-native-packager
Custom deployments with sbt-native-packager
 
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
Nagios Conference 2014 - Mike Weber - Expanding NRDS Capabilities on Linux Sy...
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache Mesos
 
Infrastructure testing with Molecule and TestInfra
Infrastructure testing with Molecule and TestInfraInfrastructure testing with Molecule and TestInfra
Infrastructure testing with Molecule and TestInfra
 
Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...
Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...
Nagios Conference 2014 - Rob Hassing - How To Maintain Over 20 Monitoring App...
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
 
PaaSTA: Autoscaling at Yelp
PaaSTA: Autoscaling at YelpPaaSTA: Autoscaling at Yelp
PaaSTA: Autoscaling at Yelp
 
OSDC 2015: Bernd Erk | Why favour Icinga over Nagios
OSDC 2015: Bernd Erk | Why favour Icinga over NagiosOSDC 2015: Bernd Erk | Why favour Icinga over Nagios
OSDC 2015: Bernd Erk | Why favour Icinga over Nagios
 
Chef or how to make computers do the work for us
Chef or how to make computers do the work for usChef or how to make computers do the work for us
Chef or how to make computers do the work for us
 
Practical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails AppPractical Chef and Capistrano for Your Rails App
Practical Chef and Capistrano for Your Rails App
 
Deploying datacenters with Puppet - PuppetCamp Europe 2010
Deploying datacenters with Puppet - PuppetCamp Europe 2010Deploying datacenters with Puppet - PuppetCamp Europe 2010
Deploying datacenters with Puppet - PuppetCamp Europe 2010
 
Ansible & Salt - Vincent Boon
Ansible & Salt - Vincent BoonAnsible & Salt - Vincent Boon
Ansible & Salt - Vincent Boon
 
Null Bachaav - May 07 Attack Monitoring workshop.
Null Bachaav - May 07 Attack Monitoring workshop.Null Bachaav - May 07 Attack Monitoring workshop.
Null Bachaav - May 07 Attack Monitoring workshop.
 
Why favour Icinga over Nagios @ FrOSCon 2015
Why favour Icinga over Nagios @ FrOSCon 2015Why favour Icinga over Nagios @ FrOSCon 2015
Why favour Icinga over Nagios @ FrOSCon 2015
 
Osic tech talk presentation on ironic inspector
Osic tech talk presentation on ironic inspectorOsic tech talk presentation on ironic inspector
Osic tech talk presentation on ironic inspector
 
Why favour Icinga over Nagios - Rootconf 2015
Why favour Icinga over Nagios - Rootconf 2015Why favour Icinga over Nagios - Rootconf 2015
Why favour Icinga over Nagios - Rootconf 2015
 

Kürzlich hochgeladen

🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...
🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...
🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...
Apsara Of India
 
IATA GEOGRAPHY AREAS in the world, HM111
IATA GEOGRAPHY AREAS in the world, HM111IATA GEOGRAPHY AREAS in the world, HM111
IATA GEOGRAPHY AREAS in the world, HM111
2022472524
 
Sample sample sample sample sample sample
Sample sample sample sample sample sampleSample sample sample sample sample sample
Sample sample sample sample sample sample
Casey Keith
 
Sample sample sample sample sample sample
Sample sample sample sample sample sampleSample sample sample sample sample sample
Sample sample sample sample sample sample
Casey Keith
 
sample sample sample sample sample sample
sample sample sample sample sample samplesample sample sample sample sample sample
sample sample sample sample sample sample
Casey Keith
 

Kürzlich hochgeladen (20)

Mathura Call Girls 8250077686 Service Offer VIP Hot Model
Mathura Call Girls 8250077686 Service Offer VIP Hot ModelMathura Call Girls 8250077686 Service Offer VIP Hot Model
Mathura Call Girls 8250077686 Service Offer VIP Hot Model
 
Sun World Bana Hills, Vienam Part 2 (越南 巴拿山太陽世界 下集).ppsx
Sun World Bana Hills, Vienam Part 2  (越南 巴拿山太陽世界 下集).ppsxSun World Bana Hills, Vienam Part 2  (越南 巴拿山太陽世界 下集).ppsx
Sun World Bana Hills, Vienam Part 2 (越南 巴拿山太陽世界 下集).ppsx
 
ITALY - Visa Options for expats and digital nomads
ITALY - Visa Options for expats and digital nomadsITALY - Visa Options for expats and digital nomads
ITALY - Visa Options for expats and digital nomads
 
Genuine 8250077686 Hot and Beautiful 💕 Chennai Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Chennai Escorts call GirlsGenuine 8250077686 Hot and Beautiful 💕 Chennai Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Chennai Escorts call Girls
 
Siliguri Call Girls 8250077686 Service Offer VIP Hot Model
Siliguri Call Girls 8250077686 Service Offer VIP Hot ModelSiliguri Call Girls 8250077686 Service Offer VIP Hot Model
Siliguri Call Girls 8250077686 Service Offer VIP Hot Model
 
🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...
🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...
🔥HOT🔥📲9602870969🔥Prostitute Service in Udaipur Call Girls in City Palace Lake...
 
Papi kondalu Call Girls 8250077686 Service Offer VIP Hot Model
Papi kondalu Call Girls 8250077686 Service Offer VIP Hot ModelPapi kondalu Call Girls 8250077686 Service Offer VIP Hot Model
Papi kondalu Call Girls 8250077686 Service Offer VIP Hot Model
 
Andheri East Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Andheri East Call Girls 🥰 8617370543 Service Offer VIP Hot ModelAndheri East Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Andheri East Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Darjeeling Call Girls 8250077686 Service Offer VIP Hot Model
Darjeeling Call Girls 8250077686 Service Offer VIP Hot ModelDarjeeling Call Girls 8250077686 Service Offer VIP Hot Model
Darjeeling Call Girls 8250077686 Service Offer VIP Hot Model
 
Andheri Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Andheri Call Girls 🥰 8617370543 Service Offer VIP Hot ModelAndheri Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Andheri Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Discover Mathura And Vrindavan A Spritual Journey.pdf
Discover Mathura And Vrindavan A Spritual Journey.pdfDiscover Mathura And Vrindavan A Spritual Journey.pdf
Discover Mathura And Vrindavan A Spritual Journey.pdf
 
Alipore Call Girls - 📞 8617697112 🔝 Top Class Call Girls Service Available
Alipore Call Girls - 📞 8617697112 🔝 Top Class Call Girls Service AvailableAlipore Call Girls - 📞 8617697112 🔝 Top Class Call Girls Service Available
Alipore Call Girls - 📞 8617697112 🔝 Top Class Call Girls Service Available
 
Bhubaneswar Call Girls 8250077686 Service Offer VIP Hot Model
Bhubaneswar Call Girls 8250077686 Service Offer VIP Hot ModelBhubaneswar Call Girls 8250077686 Service Offer VIP Hot Model
Bhubaneswar Call Girls 8250077686 Service Offer VIP Hot Model
 
IATA GEOGRAPHY AREAS in the world, HM111
IATA GEOGRAPHY AREAS in the world, HM111IATA GEOGRAPHY AREAS in the world, HM111
IATA GEOGRAPHY AREAS in the world, HM111
 
Kanpur Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Kanpur Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort ServiceKanpur Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
Kanpur Call Girls Service ☎ ️82500–77686 ☎️ Enjoy 24/7 Escort Service
 
Hire 💕 8617697112 Reckong Peo Call Girls Service Call Girls Agency
Hire 💕 8617697112 Reckong Peo Call Girls Service Call Girls AgencyHire 💕 8617697112 Reckong Peo Call Girls Service Call Girls Agency
Hire 💕 8617697112 Reckong Peo Call Girls Service Call Girls Agency
 
Sample sample sample sample sample sample
Sample sample sample sample sample sampleSample sample sample sample sample sample
Sample sample sample sample sample sample
 
Sample sample sample sample sample sample
Sample sample sample sample sample sampleSample sample sample sample sample sample
Sample sample sample sample sample sample
 
Genuine 8250077686 Hot and Beautiful 💕 Visakhapatnam Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Visakhapatnam Escorts call GirlsGenuine 8250077686 Hot and Beautiful 💕 Visakhapatnam Escorts call Girls
Genuine 8250077686 Hot and Beautiful 💕 Visakhapatnam Escorts call Girls
 
sample sample sample sample sample sample
sample sample sample sample sample samplesample sample sample sample sample sample
sample sample sample sample sample sample
 

openstack源码分析(1)

  • 1. A FIRST STEP INTO NOVA by can.
  • 2. NOVA 2011.3 DIABLO/ • setup.py:安装脚本 • bin:可执行程序, 比如nova-manage等 • nova:核心文件
  • 3. /SETUP.PY try: from DistUtilsExtra.auto import setup except ImportError: from setuptools import setup ... setup(name='nova', version=version.canonical_version_string(), description='cloud computing fabric controller', author='OpenStack', author_email='nova@lists.launchpad.net', url='http://www.openstack.org/', cmdclass=nova_cmdclass, packages=find_packages(exclude=['bin', 'smoketests']), include_package_data=True, test_suite='nose.collector', data_files=find_data_files('share/nova', 'tools'), scripts=['bin/nova-ajax-console-proxy', 'bin/nova-api', 'bin/nova-compute', ...
  • 4. /BIN • 其实都是python脚本 • nova-api/compute/ network/scheduler等 是服务的启动程序 • nova-manage是给管 理员的命令行程序
  • 5. ... /BIN/NOVA-API for api in flags.FLAGS.enabled_apis: servers.append(service.WSGIService(api)) service.serve(*servers) service.wait() ... /BIN/NOVA-COMPUTE ... server = service.Service.create(binary='nova-compute') service.serve(server) service.wait() ...
  • 7. 神奇的FLAGS • 整个项目统⼀一采用flags模块处理可由用户定义的参数, 包括配置文件、通过命令行传入的参数等 • 基于开源代码python-gflags • 可以分布式地定义参数,即每个模块只需定义自己需要 的,通过”import”引入其它模块定义的参数。有利于模块 化 # from /nova/service.py flags.DEFINE_string('ec2_listen', "0.0.0.0", 'IP address for EC2 API to listen') flags.DEFINE_integer('ec2_listen_port', 8773, 'port for ec2 api to listen') flags.DEFINE_string('osapi_listen', "0.0.0.0", 'IP address for OpenStack API to listen') flags.DEFINE_integer('osapi_listen_port', 8774, 'port for os api to listen')
  • 8. /NOVA/SCHEDULER • 目录下面 有”__init__.py”说 明这是⼀一个模块 • manager统⼀一对外 的接口 • 通过dirver兼容不 同的底层结构
  • 9. SCHEDULERS nova.scheduler.driver.Scheduler ChanceScheduler SimpleScheduler VsaScheduler VsaSchedulerLeastUsedHost VsaSchedulerMostAvailCapacity AbstractScheduler BaseScheduler LeastCostScheduler MultiScheduler ZoneScheduler
  • 10. 自定义调度算法 # from /nova/scheduler/chance.py class ChanceScheduler(driver.Scheduler): """Implements Scheduler as a random node selector.""" def schedule(self, context, topic, *_args, **_kwargs): """Picks a host that is up at random.""" hosts = self.hosts_up(context, topic) if not hosts: raise driver.NoValidHost(_("Scheduler was unable to locate a host" " for this request. Is the appropriate" " service running?")) return hosts[int(random.random() * len(hosts))] 外界通过manager调用schedule_**()方法,若所 需方法不存在,使用schedule()
  • 12. “物理”结构? user nova-api nova-compute nova-network nova-*** FLAGS db RPC context LOG