Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Libraries

    basebox 0.1.5

    Download button

    No screenshots available
    Downloads: 60  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    David Hughes | More programs
    Other/Proprietary Li... / FREE
    September 3rd, 2012, 14:27 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    basebox description

    A small library for interacting with Vagrant boxes using Fabric

    basebox is a small Python library for building and interacting with Vagrant boxes using Fabric. Its goals are somewhat similar to the veewee project, but is specifically geared toward developing and testing Fabric deployments.

    A simple example: the @basebox decorator

    from fabric.api import sudo
    from basebox.build import basebox

    @basebox(name='sample', base='http://files.vagrantup.com/precise64.box')
    def build_sample_box(*packages):
     for package in packages:
     sudo('apt-get install -y %s' % package)


    This example performs the following actions:

    - Constructs a temporary vagrant box based on base
    - Brings the box up, connects to it, and executes the contents of build_sample_box()
    - Halts, packages, and installs the box as sample
    - Cleans up after itself

    Running

    > fab build_sample_box:nginx,postgresql,rabbitmq-server

    installs a sample box with the specified packages preinstalled on it.

    The parameters to basebox can be overridden in the call to the function it decorates, so the following commands will result in an identical box being installed as 'base':

    > vagrant box add precise64 http://files.vagrantup.com/precise64.box
    > fab build_sample_box:nginx,postgresql,rabbitmq-server,name=base,base=precise64


    Finer grained control with the tempbox context manager

    While basebox instantiates, boots, and connects to its box to execute its context, sometimes this is undesirable. The tempbox context manager merely creates a vagrant context with a minimalist Vagrantfile, and cleans up the context upon exiting. Any actions on the vagrant box, such as booting, connecting, and packaging, must happen through the yielded VagrantContext object ('box' in the following example).

    import os

    from fabric.api import sudo
    from basebox.build import tempbox
    from cuisine import mode_local

    def build_sample_box(packages=[], name='sample', base='http://files.vagrantup.com/precise64.box'):
     with tempbox(basebox=base) as box:
     box.up()
     with box.connect():
     for package in packages:
     sudo('apt-get install -y %s' % package)
     box.halt()
     box.package(install_as=name)

    with mode_local():
     build_sample_box(packages=['nginx', 'postgresql', 'rabbitmq-server'])


    This code is more verbose, but it does essentially the same thing as the @basebox example, and allows more control over the box's lifecycle. When used in conjunction with the methods for interacting with the underlying VirtualBox, this can enable more advanced build functionality. This sample packages a box with an alternate NIC (a step I've used when the default NIC was causing network reliability and speed issues):

    from basebox.build import tempbox
    from cuisine import mode_local

    def package_with_alternate_nic(nic, package_out):
     with tempbox() as box:
     # Power-cycle the box to make sure it's instantiated
     box.up()
     box.halt()

     # Run 'VBoxManage modifyvm' to update the box's settings
     box.modify(nictype1=nic)

     # Package modified box
     box.package(output=package_out)

    with mode_local():
     package_with_alternate_nic('virtio', 'virtio.box')



    Product's homepage

    Requirements:

    · Python
    · python-vagrant
    · Oracle VM VirtualBox

      


    TAGS:

    Vagrant boxes | Python library | Python | Vagrant | boxes

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM