Skip to main content

A library for plugging and unplugging virtual interfaces in OpenStack.

Project description

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...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

os_vif-1.2.1.tar.gz (41.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

os_vif-1.2.1-py2-none-any.whl (52.0 kB view details)

Uploaded Python 2

File details

Details for the file os_vif-1.2.1.tar.gz.

File metadata

  • Download URL: os_vif-1.2.1.tar.gz
  • Upload date:
  • Size: 41.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for os_vif-1.2.1.tar.gz
Algorithm Hash digest
SHA256 57d5b306a63bcc7fde7dcab7b15929010ae03863c983368b749f97106a2ee9e5
MD5 d2ca5f7ca7fb8503e60ea3efb9563981
BLAKE2b-256 8c5860dde09af6f46766b3a7c61a523a9041ff182187d7dfa2340e04de5aff0f

See more details on using hashes here.

File details

Details for the file os_vif-1.2.1-py2-none-any.whl.

File metadata

File hashes

Hashes for os_vif-1.2.1-py2-none-any.whl
Algorithm Hash digest
SHA256 cacc975869099f4194cc4fb8fef4fd8d6c2045e8da3fbc2665ed6273d986b217
MD5 3aa14e1e338e472d9d92b1a24bbf5631
BLAKE2b-256 fea7446d30466d24b582c8ddec873a4a2a14e2df017e79a2072d9ffc2036a3d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page