# Path: oslo_vmware/vim_util.py
# LOG = logging.getLogger(__name__)
# def get_moref(value, type_):
# def get_moref_value(moref):
# def get_moref_type(moref):
# def build_selection_spec(client_factory, name):
# def build_traversal_spec(client_factory, name, type_, path, skip, select_set):
# def build_recursive_traversal_spec(client_factory):
# def build_property_spec(client_factory, type_='VirtualMachine',
#                         properties_to_collect=None, all_properties=False):
# def build_object_spec(client_factory, root_folder, traversal_specs):
# def build_property_filter_spec(client_factory, property_specs, object_specs):
# def get_objects(vim, type_, max_objects, properties_to_collect=None,
#                 all_properties=False):
# def get_object_properties(vim, moref, properties_to_collect, skip_op_id=False):
# def get_object_properties_dict(vim, moref, properties_to_collect):
# def _get_token(retrieve_result):
# def cancel_retrieval(vim, retrieve_result):
# def continue_retrieval(vim, retrieve_result):
#     def __init__(self, vim, retrieve_result):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, traceback):
#     def __iter__(self):
# def get_object_property(vim, moref, property_name, skip_op_id=False):
# def find_extension(vim, key):
# def register_extension(vim, key, type, label='OpenStack',
#                        summary='OpenStack services', version='1.0'):
# def get_vc_version(session):
# def get_inventory_path(vim, entity_ref, max_objects=100):
# def get_http_service_request_spec(client_factory, method, uri):
# def get_prop_spec(client_factory, spec_type, properties):
# def get_obj_spec(client_factory, obj, select_set=None):
# def get_prop_filter_spec(client_factory, obj_spec, prop_spec):
# def get_properties_for_a_collection_of_objects(vim, type_,
#                                                obj_list, properties,
#                                                max_objects=None):
# def propset_dict(propset):
# def storage_placement_spec(client_factory,
#                            dsc_ref,
#                            type,
#                            clone_spec=None,
#                            config_spec=None,
#                            relocate_spec=None,
#                            vm_ref=None,
#                            folder=None,
#                            clone_name=None,
#                            res_pool_ref=None,
#                            host_ref=None):
# def serialize_object(obj):
# class WithRetrieval(object):


import logging
from oslo_vmware import vim_util
    config = client_factory.create('ns0:VMwareDVSPortSetting')
    if trunk_mode:
        config.vlan = get_trunk_vlan_spec(session)
    elif vlan_id:
        config.vlan = get_vlan_spec(session, vlan_id)
    pg_spec.defaultPortConfig = config
    return pg_spec


def add_port_group(session, dvs_moref, name, vlan_id=None,
                   trunk_mode=False):
    """Add a new port group to the dvs_moref

    :param session: vCenter soap session
    :param dvs_moref: managed DVS object reference
    :param name: the name of the port group
    :param vlan_id: vlan_id for the port
    :param trunk_mode: indicates if the port will have trunk mode or use
                       specific tag above
    :returns: The new portgroup moref
    """
    pg_spec = get_port_group_spec(session, name, vlan_id,
                                  trunk_mode=trunk_mode)
    task = session.invoke_api(session.vim,
                              'CreateDVPortgroup_Task',
                              dvs_moref,
                              spec=pg_spec)
    task_info = session.wait_for_task(task)
    LOG.info("%(name)s create on %(dvs)s with %(value)s.",
             {'name': name,

# Path: oslo_vmware/vim_util.py
# LOG = logging.getLogger(__name__)
# def get_moref(value, type_):
# def get_moref_value(moref):
# def get_moref_type(moref):
# def build_selection_spec(client_factory, name):
# def build_traversal_spec(client_factory, name, type_, path, skip, select_set):
# def build_recursive_traversal_spec(client_factory):
# def build_property_spec(client_factory, type_='VirtualMachine',
#                         properties_to_collect=None, all_properties=False):
# def build_object_spec(client_factory, root_folder, traversal_specs):
# def build_property_filter_spec(client_factory, property_specs, object_specs):
# def get_objects(vim, type_, max_objects, properties_to_collect=None,
#                 all_properties=False):
# def get_object_properties(vim, moref, properties_to_collect, skip_op_id=False):
# def get_object_properties_dict(vim, moref, properties_to_collect):
# def _get_token(retrieve_result):
# def cancel_retrieval(vim, retrieve_result):
# def continue_retrieval(vim, retrieve_result):
#     def __init__(self, vim, retrieve_result):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, traceback):
#     def __iter__(self):
# def get_object_property(vim, moref, property_name, skip_op_id=False):
# def find_extension(vim, key):
# def register_extension(vim, key, type, label='OpenStack',
#                        summary='OpenStack services', version='1.0'):
# def get_vc_version(session):
# def get_inventory_path(vim, entity_ref, max_objects=100):
# def get_http_service_request_spec(client_factory, method, uri):
# def get_prop_spec(client_factory, spec_type, properties):
# def get_obj_spec(client_factory, obj, select_set=None):
# def get_prop_filter_spec(client_factory, obj_spec, prop_spec):
# def get_properties_for_a_collection_of_objects(vim, type_,
#                                                obj_list, properties,
#                                                max_objects=None):
# def propset_dict(propset):
# def storage_placement_spec(client_factory,
#                            dsc_ref,
#                            type,
#                            clone_spec=None,
#                            config_spec=None,
#                            relocate_spec=None,
#                            vm_ref=None,
#                            folder=None,
#                            clone_name=None,
#                            res_pool_ref=None,
#                            host_ref=None):
# def serialize_object(obj):
# class WithRetrieval(object):


# Path: oslo_vmware/dvs_util.py
import logging
from oslo_vmware import vim_util

    config = client_factory.create('ns0:VMwareDVSPortSetting')
    if trunk_mode:
        config.vlan = get_trunk_vlan_spec(session)
    elif vlan_id:
        config.vlan = get_vlan_spec(session, vlan_id)
    pg_spec.defaultPortConfig = config
    return pg_spec


def add_port_group(session, dvs_moref, name, vlan_id=None,
                   trunk_mode=False):
    """Add a new port group to the dvs_moref

    :param session: vCenter soap session
    :param dvs_moref: managed DVS object reference
    :param name: the name of the port group
    :param vlan_id: vlan_id for the port
    :param trunk_mode: indicates if the port will have trunk mode or use
                       specific tag above
    :returns: The new portgroup moref
    """
    pg_spec = get_port_group_spec(session, name, vlan_id,
                                  trunk_mode=trunk_mode)
    task = session.invoke_api(session.vim,
                              'CreateDVPortgroup_Task',
                              dvs_moref,
                              spec=pg_spec)
    task_info = session.wait_for_task(task)
    LOG.info("%(name)s create on %(dvs)s with %(value)s.",
             {'name': name,

              'dvs': vim_util.get_moref_value(dvs_moref),