Integration library between network (Neutron) and compute (Nova) providers
Go to file
Sean Mooney 54172168e2 remove use of contextlib and with nested
- The use of contextlib and "with nested" statements are deprecated.
- This change remove the deprecation warning by refactoring all
  unit test that used "with neted" statements to create mocks via
  with the decorator syntax.
- This chage removes all depencies on contexlib.

trivial_fix

Change-Id: I6d929e59306f9289f717fff3fb79542e804396b6
2016-11-22 23:09:46 +00:00
doc/source os-vif: add initial documentation about object model 2016-09-28 12:04:58 +01:00
os_vif host_info: add ability to filter list of supported vifs 2016-11-08 13:09:50 +00:00
releasenotes remove use of contextlib and with nested 2016-11-22 23:09:46 +00:00
vif_plug_linux_bridge remove use of contextlib and with nested 2016-11-22 23:09:46 +00:00
vif_plug_ovs remove use of contextlib and with nested 2016-11-22 23:09:46 +00:00
.coveragerc Import of code from https://github.com/jaypipes/os_vif 2016-01-13 12:56:01 -05:00
.gitignore Start using reno for release notes 2016-05-03 13:53:29 +01:00
.gitreview Added .gitreview 2015-11-11 16:10:58 +00:00
.mailmap Import of code from https://github.com/jaypipes/os_vif 2016-01-13 12:56:01 -05:00
.testr.conf Import of code from https://github.com/jaypipes/os_vif 2016-01-13 12:56:01 -05:00
babel.cfg Import of code from https://github.com/jaypipes/os_vif 2016-01-13 12:56:01 -05:00
CONTRIBUTING.rst Import of code from https://github.com/jaypipes/os_vif 2016-01-13 12:56:01 -05:00
HACKING.rst Import of code from https://github.com/jaypipes/os_vif 2016-01-13 12:56:01 -05:00
LICENSE Import of code from https://github.com/jaypipes/os_vif 2016-01-13 12:56:01 -05:00
MANIFEST.in Import of code from https://github.com/jaypipes/os_vif 2016-01-13 12:56:01 -05:00
README.rst Provide plugins an oslo_config group for their setup 2016-02-16 11:06:58 +00:00
requirements.txt Updated from global requirements 2016-11-02 15:38:51 +00:00
setup.cfg vif_plug_ovs: merge both plugins into one 2016-04-04 17:57:39 +01:00
setup.py Updated from global requirements 2016-05-23 12:03:15 +00:00
test-requirements.txt Updated from global requirements 2016-11-02 15:38:51 +00:00
tox.ini Trivial: clean up oslo-incubator related stuff 2016-08-03 13:56:05 +08:00

os-vif

A library for plugging and unplugging virtual interfaces in OpenStack.

Features

  • A base VIF plugin class that supplies a plug() and unplug() interface
  • Versioned objects that represent a virtual interface and its components

Usage

The interface to the os_vif library is very simple. To begin using the library, first call the os_vif.initialize() function. This will load all installed plugins and register the object model:

import os_vif

os_vif.initialize()

Once the os_vif library is initialized, there are only two other library functions: os_vif.plug() and os_vif.unplug(). Both methods accept a single argument of type `os_vif.objects.VIF`:

import uuid

from nova import objects as nova_objects
from os_vif import exception as vif_exc
from os_vif import objects as vif_objects
from os_vif import vnic_types

instance_uuid = 'd7a730ca-3c28-49c3-8f26-4662b909fe8a'
instance = nova_objects.Instance.get_by_uuid(instance_uuid)
instance_info = vif_objects.InstanceInfo(
    uuid=instance.uuid,
    name=instance.name,
    project_id=instance.project_id)

subnet = vif_objects.Subnet(cidr='192.168.1.0/24')
subnets = vif_objects.SubnetList([subnet])
network = vif_objects.Network(label='tenantnet',
                              subnets=subnets,
                              multi_host=False,
                              should_provide_vlan=False,
                              should_provide_bridge=False)

vif_uuid = uuid.uuid4()
vif = vif_objects.VIFVHostUser(id=vif_uuid,
                               address=None,
                               network=network,
                               plugin='vhostuser',
                               path='/path/to/socket',
                               mode=vif_objects.fields.VIFVHostUserMode.SERVER)

# Now do the actual plug operations to connect the VIF to
# the backing network interface.
try:
    os_vif.plug(vif)
except vif_exc.PlugException as err:
    # Handle the failure...

# If you are removing a virtual machine and its interfaces,
# you would use the unplug() operation:
try:
    os_vif.unplug(vif)
except vif_exc.UnplugException as err:
    # Handle the failure...