~0x44/nova/extdoc

« back to all changes in this revision

Viewing changes to nova/virt/vmwareapi/vif.py

  • Committer: Dan Prince
  • Date: 2011-09-14 15:34:08 UTC
  • mfrom: (1568 nova)
  • mto: This revision was merged to the branch mainline in revision 1570.
  • Revision ID: dan.prince@rackspace.com-20110914153408-y8iqlnz2uphraexp
Merge w/ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""VIF drivers for VMWare."""
19
19
 
20
 
from nova import db
21
20
from nova import exception
22
21
from nova import flags
23
22
from nova import log as logging
24
 
from nova import utils
25
23
from nova.virt.vif import VIFDriver
26
 
from nova.virt.vmwareapi_conn import VMWareAPISession
27
24
from nova.virt.vmwareapi import network_utils
28
25
 
29
26
 
30
27
LOG = logging.getLogger("nova.virt.vmwareapi.vif")
31
28
 
32
29
FLAGS = flags.FLAGS
 
30
FLAGS['vmwareapi_vlan_interface'].SetDefault('vmnic0')
33
31
 
34
32
 
35
33
class VMWareVlanBridgeDriver(VIFDriver):
36
34
    """VIF Driver to setup bridge/VLAN networking using VMWare API."""
37
35
 
38
36
    def plug(self, instance, network, mapping):
 
37
        """Plug the VIF to specified instance using information passed.
 
38
        Currently we are plugging the VIF(s) during instance creation itself.
 
39
        We can use this method when we add support to add additional NIC to
 
40
        an existing instance."""
 
41
        pass
 
42
 
 
43
    def ensure_vlan_bridge(self, session, network):
39
44
        """Create a vlan and bridge unless they already exist."""
40
45
        vlan_num = network['vlan']
41
46
        bridge = network['bridge']
42
 
        bridge_interface = network['bridge_interface']
 
47
        vlan_interface = FLAGS.vmwareapi_vlan_interface
43
48
 
44
 
        # Open vmwareapi session
45
 
        host_ip = FLAGS.vmwareapi_host_ip
46
 
        host_username = FLAGS.vmwareapi_host_username
47
 
        host_password = FLAGS.vmwareapi_host_password
48
 
        if not host_ip or host_username is None or host_password is None:
49
 
            raise Exception(_('Must specify vmwareapi_host_ip, '
50
 
                              'vmwareapi_host_username '
51
 
                              'and vmwareapi_host_password to use '
52
 
                              'connection_type=vmwareapi'))
53
 
        session = VMWareAPISession(host_ip, host_username, host_password,
54
 
                                   FLAGS.vmwareapi_api_retry_count)
55
 
        vlan_interface = bridge_interface
56
49
        # Check if the vlan_interface physical network adapter exists on the
57
50
        # host.
58
51
        if not network_utils.check_if_vlan_interface_exists(session,
92
85
                                               pgroup=pg_vlanid)
93
86
 
94
87
    def unplug(self, instance, network, mapping):
 
88
        """Cleanup operations like deleting port group if no instance
 
89
        is associated with it."""
95
90
        pass