Couple to vswitch.

    Input parameters:
    :userid:            USERID of the guest, last 8 if length > 8
    :network_info:      dict of network info
173657
def coupleTo_vswitch(userid, vswitch_name):
    
    print("\nCoupleing to vswitch for %s ..." % userid)
    vswitch_info = client.send_request('guest_nic_couple_to_vswitch', 
                                       userid, '1000', vswitch_name)

    if vswitch_info['overallRC']:
        raise RuntimeError("Failed to couple to vswitch for guest %s!\n%s" % 
                           (userid, vswitch_info))
    else:
        print("Succeeded to couple to vswitch for guest %s!" % userid)
1347119
def unbind(self, ticket, device_id, user_id):
        
        return self._post(
            'unbind',
            data={
                'ticket': ticket,
                'device_id': device_id,
                'openid': user_id
            }
        )
1219869
def switch_update_record_with_switch(self, userid, interface,
                                         switch=None):
        """"""
        if not self._get_switch_by_user_interface(userid, interface):
            msg = "User %s with nic %s does not exist in DB" % (userid,
                                                                interface)
            LOG.error(msg)
            obj_desc = ('User %s with nic %s' % (userid, interface))
            raise exception.SDKObjectNotExistError(obj_desc,
                                                   modID=self._module_id)

        if switch is not None:
            with get_network_conn() as conn:
                conn.execute("UPDATE switch SET switch=? "
                             "WHERE userid=? and interface=?",
                             (switch, userid, interface))
                LOG.debug("Set switch to %s for user %s with nic %s "
                          "in switch table" %
                          (switch, userid, interface))
        else:
            with get_network_conn() as conn:
                conn.execute("UPDATE switch SET switch=NULL "
                             "WHERE userid=? and interface=?",
                             (userid, interface))
                LOG.debug("Set switch to None for user %s with nic %s "
                          "in switch table" %
                          (userid, interface))
1033331
function(userId, appId) {
        if(!appId){
            return userId + '-' + config.creds.appId + '@' + config.endpoints.chat;
        }
        return userId + '-' + appId + '@' + config.endpoints.chat;
    }
743297
def user_info(name, **client_args):
    '''
    
    '''
    matching_users = (user for user in list_users(**client_args)
                      if user.get('user') == name)

    try:
        return next(matching_users)
    except StopIteration:
        pass
466486
def switch_add_record(self, userid, interface, port=None,
                          switch=None, comments=None):
        """"""
        with get_network_conn() as conn:
            conn.execute("INSERT INTO switch VALUES (?, ?, ?, ?, ?)",
                         (userid, interface, switch, port, comments))
            LOG.debug("New record in the switch table: user %s, "
                      "nic %s, port %s" %
                      (userid, interface, port))
312635
def addSwitch(self, name=None):
        '''
        
        '''
        if name is None:
            while True:
                name = 's' + str(self.__snum)
                self.__snum += 1
                if name not in self.__nxgraph:
                    break
        self.__addNode(name, Switch)
        return name
76211
def _update_port_group_info(self, switches=None):
        """"""
        if switches is None:
            switches = self._switches.keys()
        for switch_ip in switches:
            client = self._switches.get(switch_ip)
            ret = self._run_eos_cmds(['show interfaces'], client)
            if not ret or len(ret) == 0:
                LOG.warning("Unable to retrieve interface info for %s",
                            switch_ip)
                continue
            intf_info = ret[0]
            self._port_group_info[switch_ip] = intf_info.get('interfaces', {})
128583
def run_guest():
    

    # user input the properties of guest, image and network.
    _user_input_properties()

    # run a guest.
    _run_guest(GUEST_USERID, IMAGE_PATH, IMAGE_OS_VERSION, GUEST_PROFILE, 
               GUEST_VCPUS, GUEST_MEMORY, NETWORK_INFO, VSWITCH_NAME, DISKS_LIST)
396284
def _get_vswitch_name(self, network_type, physical_network):
        """"""
        if network_type != constants.TYPE_LOCAL:
            vswitch_name = self._get_vswitch_for_physical_network(
                physical_network)
        else:
            vswitch_name = self._local_network_vswitch

        if vswitch_name:
            return vswitch_name

        err_msg = _("No vSwitch configured for physical network "
                    "'%(physical_network)s'. Neutron network type: "
                    "'%(network_type)s'.")
        raise exception.NetworkingHyperVException(
            err_msg % dict(physical_network=physical_network,
                           network_type=network_type))
1045085
def uid(self):
        
        if not self._uid:
            if self.config.daemon.user:
                self._uid = pwd.getpwnam(self.config.daemon.user).pw_uid
            else:
                self._uid = os.getuid()
        return self._uid
414395
def get_all_vswitches(content):
    '''
    
    '''
    vswitches = []
    hosts = get_all_hosts(content)
    for h in hosts:
        for s in h.config.network.vswitch:
            vswitches.append(s)
    return vswitches
1233339
def _port_bound(self, port_id, network_id, network_type, physical_network,
                    segmentation_id, port_security_enabled, set_port_sriov):
        """"""
        LOG.debug("Binding port %s", port_id)

        if network_id not in self._network_vswitch_map:
            self._provision_network(
                port_id, network_id, network_type,
                physical_network, segmentation_id)

        vswitch_map = self._network_vswitch_map[network_id]
        vswitch_map['ports'].append(port_id)

        LOG.debug("Trying to connect the current port to vswitch %r.",
                  vswitch_map['vswitch_name'])
        self._utils.connect_vnic_to_vswitch(
            vswitch_name=vswitch_map['vswitch_name'],
            switch_port_name=port_id,
        )
        if set_port_sriov:
            LOG.debug("Enabling SR-IOV for port: %s", port_id)
            self._utils.set_vswitch_port_sriov(port_id, True)
934318
def get_user(id)
      return @users[id] if @users.key? id
      user = User.new id
      @users[id] = user
      broadcast(:added, user)
      user
    end
1282092
def guest_delete_nic(self, userid, vdev, active=False):
        
        self._networkops.delete_nic(userid, vdev, active=active)
66768
def guest_pause(self, userid):
        
        action = "pause guest '%s'" % userid
        with zvmutils.log_and_reraise_sdkbase_error(action):
            self._vmops.guest_pause(userid)
170212
async def NetworkInfo(self, bindings, unit):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='Uniter',
                   request='NetworkInfo',
                   version=5,
                   params=_params)
        _params['bindings'] = bindings
        _params['unit'] = unit
        reply = await self.rpc(msg)
        return reply