# Path: networking_vsphere/nova/virt/vmwareapi/ovsvapp_vc_driver.py
# LOG = log.getLogger(__name__)
# CONF = cfg.CONF
# class OVSvAppVCDriver(vmware_driver.VMwareVCDriver):
#     def __init__(self, virtapi):
#     def spawn(self, context, instance, image_meta, injected_files,
#               admin_password, network_info=None, block_device_info=None):
#     def network_binding_host_id(self, context, instance):
#     def _power_on_vm(self, instance, vm_ref):
#     def _get_mo_id_from_instance(self, instance):
#     def _create_virtual_nic(self, instance, image_info, network_info, vm_ref):
#     def _wait_and_get_portgroup_details(self, session, vm_ref,
#                                         port_group_name):


import mock
import uuid
from oslo_concurrency import lockutils
from oslo_config import fixture as config_fixture
from oslo_utils import uuidutils
from oslo_vmware import vim_util as vutil
from oslotest import moxstubout
from networking_vsphere.nova.virt.vmwareapi import ovsvapp_vc_driver
from nova.compute import power_state
from nova import context
from nova import exception
from nova.image import glance
from nova import objects
from nova import test
from nova.tests.unit import fake_instance
from nova.tests.unit.image import fake as image_fake
from nova.tests.unit import test_flavors
from nova.tests.unit import utils
from nova.tests.unit.virt.vmwareapi import fake as vmwareapi_fake
from nova.tests.unit.virt.vmwareapi import stubs
from nova.virt.vmwareapi import vm_util

        with (
            mock.patch.object(self.conn._vmops, 'spawn', _fake_spawn)
        ):
            self._create_vm(powered_on=power_on)
            info = self._get_info()
            if power_on:
                self._check_vm_info(info, power_state.RUNNING)
            else:
                self._check_vm_info(info, power_state.SHUTDOWN)

    def test_create_vm_powered_off_without_nic(self):
        self.network_info = None
        self._spawn_power_state(False)

    def test_create_vm_powered_on_without_nic(self):
        self.network_info = None
        self._spawn_power_state(True)

    def test_create_vm_with_invalid_portgroup(self):
        """Creates a VM with network but portgroup does not exists on ESX.

           NetworkNotCreated Exception would be raised.

           """
        self.network_info = self._get_network_info(
            network_id="expected_network")
        self.assertRaises(exception.NetworkNotCreated, self._create_vm)

    def test_wait_and_get_portgroup_details_None(self):

# Path: networking_vsphere/nova/virt/vmwareapi/ovsvapp_vc_driver.py
# LOG = log.getLogger(__name__)
# CONF = cfg.CONF
# class OVSvAppVCDriver(vmware_driver.VMwareVCDriver):
#     def __init__(self, virtapi):
#     def spawn(self, context, instance, image_meta, injected_files,
#               admin_password, network_info=None, block_device_info=None):
#     def network_binding_host_id(self, context, instance):
#     def _power_on_vm(self, instance, vm_ref):
#     def _get_mo_id_from_instance(self, instance):
#     def _create_virtual_nic(self, instance, image_info, network_info, vm_ref):
#     def _wait_and_get_portgroup_details(self, session, vm_ref,
#                                         port_group_name):


# Path: networking_vsphere/tests/unit/nova/virt/vmwareapi/test_ovsvapp_vc_driver.py
import mock
import uuid
from oslo_concurrency import lockutils
from oslo_config import fixture as config_fixture
from oslo_utils import uuidutils
from oslo_vmware import vim_util as vutil
from oslotest import moxstubout
from networking_vsphere.nova.virt.vmwareapi import ovsvapp_vc_driver
from nova.compute import power_state
from nova import context
from nova import exception
from nova.image import glance
from nova import objects
from nova import test
from nova.tests.unit import fake_instance
from nova.tests.unit.image import fake as image_fake
from nova.tests.unit import test_flavors
from nova.tests.unit import utils
from nova.tests.unit.virt.vmwareapi import fake as vmwareapi_fake
from nova.tests.unit.virt.vmwareapi import stubs
from nova.virt.vmwareapi import vm_util


        with (
            mock.patch.object(self.conn._vmops, 'spawn', _fake_spawn)
        ):
            self._create_vm(powered_on=power_on)
            info = self._get_info()
            if power_on:
                self._check_vm_info(info, power_state.RUNNING)
            else:
                self._check_vm_info(info, power_state.SHUTDOWN)

    def test_create_vm_powered_off_without_nic(self):
        self.network_info = None
        self._spawn_power_state(False)

    def test_create_vm_powered_on_without_nic(self):
        self.network_info = None
        self._spawn_power_state(True)

    def test_create_vm_with_invalid_portgroup(self):
        """Creates a VM with network but portgroup does not exists on ESX.

           NetworkNotCreated Exception would be raised.

           """
        self.network_info = self._get_network_info(
            network_id="expected_network")
        self.assertRaises(exception.NetworkNotCreated, self._create_vm)

    def test_wait_and_get_portgroup_details_None(self):

        cfg = ovsvapp_vc_driver.CONF