SlideShare uma empresa Scribd logo
1 de 69
Baixar para ler offline
Small Python Tools for
  Software Release
     Engineering
    Scott Wang a.k.a. lunastorm
Self Introduction

• 學C++起家
• 偶爾慣C
• 結果工作都用Java
• 常常偷懶只寫shell script
• Python??
講一朵開發雲的故事
Release Engineering
• “a sub-discipline in software engineering
  concerned with the compilation, assembly,
  and delivery of source code into finished
  products or other software components.”
  -- Wikipedia
• 對我來說
 • 把code寫好放到production上跑
Version Control
                          出build
寫code
                                   測試
米國
慢。。。

台灣
$$$$$




        http://aws.amazon.com/
Local LAB
installed with XenServer
XenCenter
開VM               砍VM



關VM               複製
         搬VM      VM
      XenCenter
Yum

       Repo




        Local LAB
installed with XenServer
Admin




順利交接
路遙知馬力
     日久見人辛
Admin becomes the bottleneck!
外商

 外商

          菜比八

小Leader
包RPM試試   東西做好了
注意        尛
dependency
找個乾淨機   Production
 器裝看看     VM嗎?
對   找誰要?
Admin   好
Admin




        開會⋯
我包的RPM   等了一天終
 你測一下     於搞定
要再開一台
對
      VM?
Admin




        教召⋯
I WANT MY
F**KING VM!!!
什麼不是雲端運算?
“Cloud Computing”
    Definition by NIST
• On-demand self-service
 • A consumer can unilaterally provision
    computing capabilities, such as server
    time and network storage, as needed
    automatically without requiring human
    interaction with each service’s provider.
“Cloud Computing”
    Definition by NIST

• Rapid elasticity
 • Capabilities can be rapidly and elastically
    provisioned, in some cases automatically,
    to scale rapidly outward and inward
    commensurate with demand.
「真男人 / 女人不需
要桌面環境!!」


How to automate this?
Xen Management API
• Java and Python binding

• Using Java binding

 • 要compile,麻煩

• Using Python binding

 • Trial and error in the interpreter first (勝)
http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/
Give Me VM!
• Objective

 • Create a temporary VM for testing by self
   service

 • Login into it automatically

 • Destroy it when the testing is finished
X
準備作業

• Install a Para-Virtualized VM
• Install Xen Tools in the VM
 • Will report IP via XenBus to XenServer
• Convert the VM to a template
Report

                                         IP



https://community.emc.com/servlet/JiveServlet/showImage/38-3466-30315/Xen.png
動作分解

• 第一動
• import XenAPI
 • XenAPI.py can be downloaded from
    XenServer SDKs
 • Actually a XML-RPC wrapper inside
第二動

• Create XenAPI session
 • session = XenAPI.Session("http://master")
 • session.xenapi.login_with_password("user
    name", "password")
第三動

• Create a VM from a template
 •   template =
     session.xenapi.VM.get_by_name_label(vm_label)
     [0]

 •   name = "spot-" + str(time.time()).replace(".","")

 •   new = session.xenapi.VM.clone(template, name)
第四動


• Provision and start VM
 •   session.xenapi.VM.provision(new)

 •   session.xenapi.VM.start(new, False, False)
Waiting for IP
retry_count = 0

while retry_count < MAX_RETRIES:

 try:

   retry_count = retry_count + 1

   metric = session.xenapi.VM_guest_metrics.

            get_record(session.xenapi.VM.get_record

            (new)['guest_metrics'])

   ip = metric['networks']['0/ip']

   break

 except:

   print "Waiting for IP information..."

   time.sleep(5)
Waiting for SSHd
retry_count = 0

while retry_count < MAX_RETRIES:

 try:

   retry_count = retry_count + 1

   sock = socket.socket(socket.AF_INET, 

           socket.SOCK_STREAM);

   sock.connect((ip, 22))

   sock.close()

   break

 except:

    print "Waiting for sshd to come up..."

    time.sleep(5)
Time to Login!
                                      Returns
                                        after
                                       logout
os.system("ssh -i spot_key -o UserKnownHostsFile=/
dev/null -o StrictHostKeyChecking=no root@" + ip)
Garbage Collection
session.xenapi.VM.hard_shutdown(new)

for vbd in session.xenapi.VM.get_record(new)['VBDs']:

  if session.xenapi.VBD.get_record(vbd)['type'] == 'Disk':

    vdi = session.xenapi.VBD.get_record(vbd)['VDI']

    session.xenapi.VBD.destroy(vbd)

    session.xenapi.VDI.destroy(vdi)

 else:

    session.xenapi.VBD.destroy(vbd)
session.xenapi.VM.destroy(new)
Admin




  山不轉,路轉
Evolution! by @jeffhung
IMAGE_TYPES = [

  { 'key': 'spn-centos53', 'name': 'CentOS 5.3 (Production VM)', 'label': 'SPN-
Production-VM-CentOS-5.3-spot' },

  { 'key': 'spn-centos62', 'name': 'CentOS 6.2 (Production VM)', 'label': 'SPN-
Production-VM-CentOS-6.2-spot' },

  { 'key': 'lucid',   'name': 'Ubuntu 10.04 (Lucid)',    'label': 'Ubuntu-10.04-
spot' },

  { 'key': 'myspn',    'name': 'MySPN Dev VM (CentOS 6.2)', 'label': 'tw-
MySPN-devvm' },

]
Supports Non-
            interactive Mode
parser = optparse.OptionParser(description="Give me a temporary VM that volatile
when I'm done.")

parser.add_option('-l', dest='list', action='store_true',

            help='list available VM image types')

parser.add_option('-t', dest='type', help='VM image type')

parser.add_option('-f', dest='file', action='append',

            help='Preload file to VM instance in / folder')

parser.add_option('-i', dest='init',

            help='Script for initialize VM instance, default to init.sh if file exist')

parser.add_option('-I', dest='interactive', action='store_true',

            help='Run interactively, default enabled if -i not specified')
Automatically Running
          Scripts
print 'Preloading file to newly created VM
instance: ', file



os.system("scp -i spot_key -o
UserKnownHostsFile=/dev/null -o
StrictHostKeyChecking=no " + file + " root@" + ip
+ ":/")



os.system("ssh -i spot_key -o
UserKnownHostsFile=/dev/null -o
StrictHostKeyChecking=no root@" + ip + " “ + file)
Automatic Daily
         Regression Test
• CI System triggers daily build job

• Daily build artifacts will be sent to Yum repository

• Trigger regression test job

• Automatically creates a new VM

• Execute the test scripts

• Destroy the VM
Live Demo
不打假球
References
• XenServer SDKs
  • http://community.citrix.com/display/xs/
    Download+SDKs
• XenAPI Documentation
  • http://docs.vmd.citrix.com/XenServer/
    6.0.0/1.0/en_gb/api/
  • http://downloads.xen.org/Wiki/XenAPI/
    xenapi-1.0.6.pdf
Thank You!
  Questions?
# ./give_me_vm.py 
Available Image Types:

  1) spn-centos53 : CentOS 5.3 (Production VM)

  2) spn-centos62 : CentOS 6.2 (Production VM)

  3) lucid      : Ubuntu 10.04 (Lucid)

  4) myspn        : MySPN Dev VM (CentOS 6.2)

Please choose one of the above: 3
Using image type: Ubuntu-10.04-spot

Will preload file to VM instance: init.sh

Creating VM spot-133826046314 from Ubuntu-10.04-spot...
Done!

Provisioning VM...
Done!

Starting VM...
Done!

Waiting for IP information...

Waiting for IP information...
IP obtained: 10.1.112.84
Preloading file to newly created VM instance: init.sh

Warning: Permanently added '10.1.112.84' (RSA) to the list of known hosts.

init.sh                                   100% 443 0.4KB/s 00:00 

Done!

Running init.sh...

Warning: Permanently added '10.1.112.84' (RSA) to the list of known hosts.

Running init.sh
hello!

Done!

Opening SSH connection...

Warning: Permanently added '10.1.112.84' (RSA) to the list of known hosts.
Linux localhost 2.6.32-33-server #70-Ubuntu SMP Thu Jul 7 22:28:30 UTC
2011 x86_64 GNU/Linux

Ubuntu 10.04.3 LTS



Welcome to the Ubuntu Server!

* Documentation: http://www.ubuntu.com/server/doc



    System information as of Tue May 29 11:02:21 CST 2012



    System load: 0.55         Processes:        86

    Usage of /: 11.0% of 7.23GB Users logged in: 0

    Memory usage: 9%            IP address for eth0: 10.1.112.84

    Swap usage: 0%



    Graph this data and manage this system at https://landscape.canonical.com/



15 packages can be updated.

9 updates are security updates.



Last login: Fri Feb 24 18:19:24 2012 from 10.1.112.190

root@localhost:~#

Mais conteúdo relacionado

Mais procurados

Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeSarah Z
 
Node.js Cloud deployment
Node.js Cloud deploymentNode.js Cloud deployment
Node.js Cloud deploymentNicholas McClay
 
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)Timothy Appnel
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using dockerLarry Cai
 
Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))Michele Orselli
 
Docker puppetcamp london 2013
Docker puppetcamp london 2013Docker puppetcamp london 2013
Docker puppetcamp london 2013Tomas Doran
 
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and JenkinsChasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and JenkinsTomas Doran
 
vert.x 소개 및 개발 실습
vert.x 소개 및 개발 실습vert.x 소개 및 개발 실습
vert.x 소개 및 개발 실습John Kim
 
A Introduction of Packer
A Introduction of PackerA Introduction of Packer
A Introduction of PackerFreyr Lin
 
Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)Chu-Siang Lai
 
Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點William Yeh
 
Introduction to Ansible (Pycon7 2016)
Introduction to Ansible (Pycon7 2016)Introduction to Ansible (Pycon7 2016)
Introduction to Ansible (Pycon7 2016)Ivan Rossi
 
Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Soshi Nemoto
 
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...Puppet
 

Mais procurados (20)

Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less Coffee
 
Cialug August 2021
Cialug August 2021Cialug August 2021
Cialug August 2021
 
Node.js Cloud deployment
Node.js Cloud deploymentNode.js Cloud deployment
Node.js Cloud deployment
 
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)Ansible v2 and Beyond (Ansible Hawai'i Meetup)
Ansible v2 and Beyond (Ansible Hawai'i Meetup)
 
Learn basic ansible using docker
Learn basic ansible using dockerLearn basic ansible using docker
Learn basic ansible using docker
 
Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))Vagrant for real codemotion (moar tips! ;-))
Vagrant for real codemotion (moar tips! ;-))
 
Docker puppetcamp london 2013
Docker puppetcamp london 2013Docker puppetcamp london 2013
Docker puppetcamp london 2013
 
Fabric
FabricFabric
Fabric
 
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and JenkinsChasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
Chasing AMI - Building Amazon machine images with Puppet, Packer and Jenkins
 
vert.x 소개 및 개발 실습
vert.x 소개 및 개발 실습vert.x 소개 및 개발 실습
vert.x 소개 및 개발 실습
 
A Introduction of Packer
A Introduction of PackerA Introduction of Packer
A Introduction of Packer
 
Ansible intro
Ansible introAnsible intro
Ansible intro
 
Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)Automate with Ansible basic (2/e, English)
Automate with Ansible basic (2/e, English)
 
Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點Ansible 實戰:top down 觀點
Ansible 實戰:top down 觀點
 
Introduction to Ansible (Pycon7 2016)
Introduction to Ansible (Pycon7 2016)Introduction to Ansible (Pycon7 2016)
Introduction to Ansible (Pycon7 2016)
 
Vagrant and CentOS 7
Vagrant and CentOS 7Vagrant and CentOS 7
Vagrant and CentOS 7
 
Packer
PackerPacker
Packer
 
Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)Fabric workshop(1) - (MOSG)
Fabric workshop(1) - (MOSG)
 
Testing Terraform
Testing TerraformTesting Terraform
Testing Terraform
 
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
 

Semelhante a Small Python Tools for Software Release Engineering

Using Packer to Migrate XenServer Infrastructure to CloudStack
Using Packer to Migrate XenServer Infrastructure to CloudStackUsing Packer to Migrate XenServer Infrastructure to CloudStack
Using Packer to Migrate XenServer Infrastructure to CloudStackTim Mackey
 
Virtualization and Cloud Computing with Elastic Server On Demand
Virtualization and Cloud Computing with Elastic Server On DemandVirtualization and Cloud Computing with Elastic Server On Demand
Virtualization and Cloud Computing with Elastic Server On DemandYan Pritzker
 
Building cloud stack at scale
Building cloud stack at scaleBuilding cloud stack at scale
Building cloud stack at scaleShapeBlue
 
Modern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSDModern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSDSean Chittenden
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with AnsibleRayed Alrashed
 
Postgres the hardway
Postgres the hardwayPostgres the hardway
Postgres the hardwayDave Pitts
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialTom Croucher
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationSuresh Kumar
 
VMware studio practice in TIM
VMware studio practice in TIMVMware studio practice in TIM
VMware studio practice in TIMYi-Huan Chan
 
[OpenStack Day in Korea 2015] Track 1-4 - VDI OpenStack? It Works!!!
[OpenStack Day in Korea 2015] Track 1-4 - VDI OpenStack? It Works!!![OpenStack Day in Korea 2015] Track 1-4 - VDI OpenStack? It Works!!!
[OpenStack Day in Korea 2015] Track 1-4 - VDI OpenStack? It Works!!!OpenStack Korea Community
 
Puppet and Apache CloudStack
Puppet and Apache CloudStackPuppet and Apache CloudStack
Puppet and Apache CloudStackPuppet
 
Infrastructure as code with Puppet and Apache CloudStack
Infrastructure as code with Puppet and Apache CloudStackInfrastructure as code with Puppet and Apache CloudStack
Infrastructure as code with Puppet and Apache CloudStackke4qqq
 
Hypervisor Security - OpenStack Summit Hong Kong
Hypervisor Security - OpenStack Summit Hong KongHypervisor Security - OpenStack Summit Hong Kong
Hypervisor Security - OpenStack Summit Hong KongRobert Clark
 
“warpdrive”, making Python web application deployment magically easy.
“warpdrive”, making Python web application deployment magically easy.“warpdrive”, making Python web application deployment magically easy.
“warpdrive”, making Python web application deployment magically easy.Graham Dumpleton
 
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...POSSCON
 
Vagrant-Binding JUG Dortmund
Vagrant-Binding JUG DortmundVagrant-Binding JUG Dortmund
Vagrant-Binding JUG DortmundHendrik Ebbers
 
KVM tools and enterprise usage
KVM tools and enterprise usageKVM tools and enterprise usage
KVM tools and enterprise usagevincentvdk
 
Startup guide for kvm on cent os 6
Startup guide for kvm on cent os 6Startup guide for kvm on cent os 6
Startup guide for kvm on cent os 6Carlos Eduardo
 

Semelhante a Small Python Tools for Software Release Engineering (20)

Using Packer to Migrate XenServer Infrastructure to CloudStack
Using Packer to Migrate XenServer Infrastructure to CloudStackUsing Packer to Migrate XenServer Infrastructure to CloudStack
Using Packer to Migrate XenServer Infrastructure to CloudStack
 
Virtualization and Cloud Computing with Elastic Server On Demand
Virtualization and Cloud Computing with Elastic Server On DemandVirtualization and Cloud Computing with Elastic Server On Demand
Virtualization and Cloud Computing with Elastic Server On Demand
 
Building cloud stack at scale
Building cloud stack at scaleBuilding cloud stack at scale
Building cloud stack at scale
 
Modern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSDModern tooling to assist with developing applications on FreeBSD
Modern tooling to assist with developing applications on FreeBSD
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Postgres the hardway
Postgres the hardwayPostgres the hardway
Postgres the hardway
 
OSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js TutorialOSCON 2011 - Node.js Tutorial
OSCON 2011 - Node.js Tutorial
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
CI and CD
CI and CDCI and CD
CI and CD
 
VMware studio practice in TIM
VMware studio practice in TIMVMware studio practice in TIM
VMware studio practice in TIM
 
[OpenStack Day in Korea 2015] Track 1-4 - VDI OpenStack? It Works!!!
[OpenStack Day in Korea 2015] Track 1-4 - VDI OpenStack? It Works!!![OpenStack Day in Korea 2015] Track 1-4 - VDI OpenStack? It Works!!!
[OpenStack Day in Korea 2015] Track 1-4 - VDI OpenStack? It Works!!!
 
Puppet and Apache CloudStack
Puppet and Apache CloudStackPuppet and Apache CloudStack
Puppet and Apache CloudStack
 
Infrastructure as code with Puppet and Apache CloudStack
Infrastructure as code with Puppet and Apache CloudStackInfrastructure as code with Puppet and Apache CloudStack
Infrastructure as code with Puppet and Apache CloudStack
 
Erlang on OSv
Erlang on OSvErlang on OSv
Erlang on OSv
 
Hypervisor Security - OpenStack Summit Hong Kong
Hypervisor Security - OpenStack Summit Hong KongHypervisor Security - OpenStack Summit Hong Kong
Hypervisor Security - OpenStack Summit Hong Kong
 
“warpdrive”, making Python web application deployment magically easy.
“warpdrive”, making Python web application deployment magically easy.“warpdrive”, making Python web application deployment magically easy.
“warpdrive”, making Python web application deployment magically easy.
 
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
Assembling an Open Source Toolchain to Manage Public, Private and Hybrid Clou...
 
Vagrant-Binding JUG Dortmund
Vagrant-Binding JUG DortmundVagrant-Binding JUG Dortmund
Vagrant-Binding JUG Dortmund
 
KVM tools and enterprise usage
KVM tools and enterprise usageKVM tools and enterprise usage
KVM tools and enterprise usage
 
Startup guide for kvm on cent os 6
Startup guide for kvm on cent os 6Startup guide for kvm on cent os 6
Startup guide for kvm on cent os 6
 

Mais de pycontw

Network Security and Analysis with Python
Network Security and Analysis with PythonNetwork Security and Analysis with Python
Network Security and Analysis with Pythonpycontw
 
Python on FreeBSD
Python on FreeBSDPython on FreeBSD
Python on FreeBSDpycontw
 
讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法pycontw
 
CyberLink Meets Python
CyberLink Meets PythonCyberLink Meets Python
CyberLink Meets Pythonpycontw
 
PyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using PythonPyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using Pythonpycontw
 
Developing Python Apps on Windows Azure
Developing Python Apps on Windows AzureDeveloping Python Apps on Windows Azure
Developing Python Apps on Windows Azurepycontw
 
Qt Quick GUI Programming with PySide
Qt Quick GUI Programming with PySideQt Quick GUI Programming with PySide
Qt Quick GUI Programming with PySidepycontw
 
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)pycontw
 
Grid Job Management
Grid Job ManagementGrid Job Management
Grid Job Managementpycontw
 
Python and Startup
Python and StartupPython and Startup
Python and Startuppycontw
 
Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...pycontw
 
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
那些年 Python 攻佔了 GIS / The Year Python Takes Over GISpycontw
 
Introduction to Discrete-Event Simulation Using SimPy
Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy
Introduction to Discrete-Event Simulation Using SimPypycontw
 
Python and the Web
Python and the WebPython and the Web
Python and the Webpycontw
 
Large-scale Array-oriented Computing with Python
Large-scale Array-oriented Computing with PythonLarge-scale Array-oriented Computing with Python
Large-scale Array-oriented Computing with Pythonpycontw
 

Mais de pycontw (15)

Network Security and Analysis with Python
Network Security and Analysis with PythonNetwork Security and Analysis with Python
Network Security and Analysis with Python
 
Python on FreeBSD
Python on FreeBSDPython on FreeBSD
Python on FreeBSD
 
讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法讓 Python Script 擁有圖形化介面的簡單方法
讓 Python Script 擁有圖形化介面的簡單方法
 
CyberLink Meets Python
CyberLink Meets PythonCyberLink Meets Python
CyberLink Meets Python
 
PyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using PythonPyKinect: Body Iteration Application Development Using Python
PyKinect: Body Iteration Application Development Using Python
 
Developing Python Apps on Windows Azure
Developing Python Apps on Windows AzureDeveloping Python Apps on Windows Azure
Developing Python Apps on Windows Azure
 
Qt Quick GUI Programming with PySide
Qt Quick GUI Programming with PySideQt Quick GUI Programming with PySide
Qt Quick GUI Programming with PySide
 
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
 
Grid Job Management
Grid Job ManagementGrid Job Management
Grid Job Management
 
Python and Startup
Python and StartupPython and Startup
Python and Startup
 
Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...Panoramic Video in Environmental Monitoring Software Development and Applica...
Panoramic Video in Environmental Monitoring Software Development and Applica...
 
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
那些年 Python 攻佔了 GIS / The Year Python Takes Over GIS
 
Introduction to Discrete-Event Simulation Using SimPy
Introduction to Discrete-Event Simulation Using SimPyIntroduction to Discrete-Event Simulation Using SimPy
Introduction to Discrete-Event Simulation Using SimPy
 
Python and the Web
Python and the WebPython and the Web
Python and the Web
 
Large-scale Array-oriented Computing with Python
Large-scale Array-oriented Computing with PythonLarge-scale Array-oriented Computing with Python
Large-scale Array-oriented Computing with Python
 

Último

Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 

Último (20)

Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 

Small Python Tools for Software Release Engineering

  • 1. Small Python Tools for Software Release Engineering Scott Wang a.k.a. lunastorm
  • 2. Self Introduction • 學C++起家 • 偶爾慣C • 結果工作都用Java • 常常偷懶只寫shell script • Python??
  • 4. Release Engineering • “a sub-discipline in software engineering concerned with the compilation, assembly, and delivery of source code into finished products or other software components.” -- Wikipedia • 對我來說 • 把code寫好放到production上跑
  • 5. Version Control 出build 寫code 測試
  • 7. $$$$$ http://aws.amazon.com/
  • 8.
  • 11. 開VM 砍VM 關VM 複製 搬VM VM XenCenter
  • 12. Yum
 Repo Local LAB installed with XenServer
  • 14. 路遙知馬力 日久見人辛 Admin becomes the bottleneck!
  • 15. 外商
 外商
 菜比八
 小Leader
  • 16. 包RPM試試 東西做好了
  • 17. 注意 尛 dependency
  • 18. 找個乾淨機 Production 器裝看看 VM嗎?
  • 19. 找誰要?
  • 20. Admin
  • 21. Admin 開會⋯
  • 22. 我包的RPM 等了一天終 你測一下 於搞定
  • 24. Admin 教召⋯
  • 27. “Cloud Computing” Definition by NIST • On-demand self-service • A consumer can unilaterally provision computing capabilities, such as server time and network storage, as needed automatically without requiring human interaction with each service’s provider.
  • 28. “Cloud Computing” Definition by NIST • Rapid elasticity • Capabilities can be rapidly and elastically provisioned, in some cases automatically, to scale rapidly outward and inward commensurate with demand.
  • 30. Xen Management API • Java and Python binding • Using Java binding • 要compile,麻煩 • Using Python binding • Trial and error in the interpreter first (勝)
  • 32. Give Me VM! • Objective • Create a temporary VM for testing by self service • Login into it automatically • Destroy it when the testing is finished
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49. X
  • 50. 準備作業 • Install a Para-Virtualized VM • Install Xen Tools in the VM • Will report IP via XenBus to XenServer • Convert the VM to a template
  • 51. Report
 IP https://community.emc.com/servlet/JiveServlet/showImage/38-3466-30315/Xen.png
  • 52. 動作分解 • 第一動 • import XenAPI • XenAPI.py can be downloaded from XenServer SDKs • Actually a XML-RPC wrapper inside
  • 53. 第二動 • Create XenAPI session • session = XenAPI.Session("http://master") • session.xenapi.login_with_password("user name", "password")
  • 54. 第三動 • Create a VM from a template • template = session.xenapi.VM.get_by_name_label(vm_label) [0] • name = "spot-" + str(time.time()).replace(".","") • new = session.xenapi.VM.clone(template, name)
  • 55. 第四動 • Provision and start VM • session.xenapi.VM.provision(new) • session.xenapi.VM.start(new, False, False)
  • 56. Waiting for IP retry_count = 0
 while retry_count < MAX_RETRIES:
 try:
 retry_count = retry_count + 1
 metric = session.xenapi.VM_guest_metrics.
 get_record(session.xenapi.VM.get_record
 (new)['guest_metrics'])
 ip = metric['networks']['0/ip']
 break
 except:
 print "Waiting for IP information..."
 time.sleep(5)
  • 57. Waiting for SSHd retry_count = 0
 while retry_count < MAX_RETRIES:
 try:
 retry_count = retry_count + 1
 sock = socket.socket(socket.AF_INET, 
 socket.SOCK_STREAM);
 sock.connect((ip, 22))
 sock.close()
 break
 except:
 print "Waiting for sshd to come up..."
 time.sleep(5)
  • 58. Time to Login! Returns after logout os.system("ssh -i spot_key -o UserKnownHostsFile=/ dev/null -o StrictHostKeyChecking=no root@" + ip)
  • 59. Garbage Collection session.xenapi.VM.hard_shutdown(new)
 for vbd in session.xenapi.VM.get_record(new)['VBDs']:
 if session.xenapi.VBD.get_record(vbd)['type'] == 'Disk':
 vdi = session.xenapi.VBD.get_record(vbd)['VDI']
 session.xenapi.VBD.destroy(vbd)
 session.xenapi.VDI.destroy(vdi)
 else:
 session.xenapi.VBD.destroy(vbd) session.xenapi.VM.destroy(new)
  • 61. Evolution! by @jeffhung IMAGE_TYPES = [ { 'key': 'spn-centos53', 'name': 'CentOS 5.3 (Production VM)', 'label': 'SPN- Production-VM-CentOS-5.3-spot' }, { 'key': 'spn-centos62', 'name': 'CentOS 6.2 (Production VM)', 'label': 'SPN- Production-VM-CentOS-6.2-spot' }, { 'key': 'lucid', 'name': 'Ubuntu 10.04 (Lucid)', 'label': 'Ubuntu-10.04- spot' }, { 'key': 'myspn', 'name': 'MySPN Dev VM (CentOS 6.2)', 'label': 'tw- MySPN-devvm' }, ]
  • 62. Supports Non- interactive Mode parser = optparse.OptionParser(description="Give me a temporary VM that volatile when I'm done.") parser.add_option('-l', dest='list', action='store_true', help='list available VM image types') parser.add_option('-t', dest='type', help='VM image type') parser.add_option('-f', dest='file', action='append', help='Preload file to VM instance in / folder') parser.add_option('-i', dest='init', help='Script for initialize VM instance, default to init.sh if file exist') parser.add_option('-I', dest='interactive', action='store_true', help='Run interactively, default enabled if -i not specified')
  • 63. Automatically Running Scripts print 'Preloading file to newly created VM instance: ', file
 
 os.system("scp -i spot_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no " + file + " root@" + ip + ":/")
 
 os.system("ssh -i spot_key -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@" + ip + " “ + file)
  • 64. Automatic Daily Regression Test • CI System triggers daily build job • Daily build artifacts will be sent to Yum repository • Trigger regression test job • Automatically creates a new VM • Execute the test scripts • Destroy the VM
  • 66. References • XenServer SDKs • http://community.citrix.com/display/xs/ Download+SDKs • XenAPI Documentation • http://docs.vmd.citrix.com/XenServer/ 6.0.0/1.0/en_gb/api/ • http://downloads.xen.org/Wiki/XenAPI/ xenapi-1.0.6.pdf
  • 67. Thank You! Questions?
  • 68. # ./give_me_vm.py Available Image Types:
 1) spn-centos53 : CentOS 5.3 (Production VM)
 2) spn-centos62 : CentOS 6.2 (Production VM)
 3) lucid : Ubuntu 10.04 (Lucid)
 4) myspn : MySPN Dev VM (CentOS 6.2)
 Please choose one of the above: 3 Using image type: Ubuntu-10.04-spot
 Will preload file to VM instance: init.sh
 Creating VM spot-133826046314 from Ubuntu-10.04-spot... Done!
 Provisioning VM... Done!
 Starting VM... Done!
 Waiting for IP information...
 Waiting for IP information... IP obtained: 10.1.112.84 Preloading file to newly created VM instance: init.sh
 Warning: Permanently added '10.1.112.84' (RSA) to the list of known hosts.
 init.sh 100% 443 0.4KB/s 00:00 
 Done!

  • 69. Running init.sh...
 Warning: Permanently added '10.1.112.84' (RSA) to the list of known hosts.
 Running init.sh hello!
 Done!
 Opening SSH connection...
 Warning: Permanently added '10.1.112.84' (RSA) to the list of known hosts. Linux localhost 2.6.32-33-server #70-Ubuntu SMP Thu Jul 7 22:28:30 UTC 2011 x86_64 GNU/Linux
 Ubuntu 10.04.3 LTS
 
 Welcome to the Ubuntu Server!
 * Documentation: http://www.ubuntu.com/server/doc
 
 System information as of Tue May 29 11:02:21 CST 2012
 
 System load: 0.55 Processes: 86
 Usage of /: 11.0% of 7.23GB Users logged in: 0
 Memory usage: 9% IP address for eth0: 10.1.112.84
 Swap usage: 0%
 
 Graph this data and manage this system at https://landscape.canonical.com/
 
 15 packages can be updated.
 9 updates are security updates.
 
 Last login: Fri Feb 24 18:19:24 2012 from 10.1.112.190
 root@localhost:~#