Get current network limit for subflows.
326221
def _GetSubFlowNetworkLimit(self):
    """"""

    subflow_network_limit = None

    if self.runner_args.per_client_network_limit_bytes:
      subflow_network_limit = self.runner_args.per_client_network_limit_bytes

    if self.runner_args.network_bytes_limit:
      remaining_network_quota = (
          self.runner_args.network_bytes_limit -
          self.context.network_bytes_sent)
      if subflow_network_limit is None:
        subflow_network_limit = remaining_network_quota
      else:
        subflow_network_limit = min(subflow_network_limit,
                                    remaining_network_quota)

    return subflow_network_limit
215563
def get_limits(self):
        
        if self.limits != {}:
            return self.limits
        limits = {}
        limits['Groups'] = AwsLimit(
            'Groups',
            self,
            300,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::Group',
        )
        limits['Users'] = AwsLimit(
            'Users',
            self,
            5000,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::User',
        )
        limits['Roles'] = AwsLimit(
            'Roles',
            self,
            1000,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::Role',
        )
        limits['Instance profiles'] = AwsLimit(
            'Instance profiles',
            self,
            1000,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::InstanceProfile',
        )
        limits['Server certificates'] = AwsLimit(
            'Server certificates',
            self,
            20,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::ServerCertificate',
        )
        limits['Policies'] = AwsLimit(
            'Policies',
            self,
            1500,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::Policy',
        )
        limits['Policy Versions In Use'] = AwsLimit(
            'Policy Versions In Use',
            self,
            10000,
            self.warning_threshold,
            self.critical_threshold,
            limit_type='AWS::IAM::ServerCertificate',
        )
        self.limits = limits
        return limits
958287
def find_usage(self):
        
        logger.debug("Checking usage for service %s", self.service_name)
        self.connect()
        for lim in self.limits.values():
            lim._reset_usage()
        self._find_usage_nodes()
        self._find_usage_subnet_groups()
        self._find_usage_parameter_groups()
        self._find_usage_security_groups()
        self._have_usage = True
        logger.debug("Done checking usage.")
143310
def common_wire_version(self):
        """"""
        servers = self.known_servers
        if servers:
            return min(s.max_wire_version for s in self.known_servers)

        return None
1298935
def show_subnetpool(self, subnetpool, **_params):
        """"""
        return self.get(self.subnetpool_path % (subnetpool), params=_params)
942984
def num_streams(self):
        """"""
        self._num_streams = self.lib.iperf_get_test_num_streams(self._test)
        return self._num_streams
1287301
def bandwidth(self, subid, params=None):
        ''' 
        '''
        params = update_params(params, {'SUBID': subid})
        return self.request('/v1/server/bandwidth', params, 'GET')
532472
def stat(self):
        """"""
        return (self._opened_conns, len(self._free_conn), len(self._waitings))
1167570
def get_subnet_flow_logs_list(current_config, subnet):
    
    flow_logs_list = []
    for flow_log in current_config.flow_logs:
        if current_config.flow_logs[flow_log]['ResourceId'] == subnet['SubnetId'] or \
                current_config.flow_logs[flow_log]['ResourceId'] == subnet['VpcId']:
            flow_logs_list.append(flow_log)
    return flow_logs_list
320827
def subvol_quota(self, path, limit):
        
        args = {
            'path': path,
            'limit': limit,
        }

        self._subvol_quota_chk.check(args)

        self._client.sync('btrfs.subvol_quota', args)
1213070
def maybe_rate_limit(client, headers, atexit=False):
    """"""
    # pylint: disable=fixme
    # pylint: disable=global-statement
    # FIXME: Yes, I know this is not great. We'll fix it later. :-)
    global LAST_CLIENT, LAST_HEADERS

    if LAST_CLIENT and LAST_HEADERS:
        # Wait based on previous client/headers
        rate_limit(LAST_CLIENT, LAST_HEADERS, atexit=atexit)

    LAST_CLIENT = copy.copy(client)
    LAST_HEADERS = copy.copy(headers)
507519
def _get_net_io_counters(self):
        
        counters = psutil.net_io_counters(pernic=self.pernic)

        res = {}
        for name, io in counters.iteritems():
            res[name] = io._asdict()
            res[name].update({'tx_per_sec': 0, 'rx_per_sec': 0})

        return res
582717
def _get_vlan_length(buff):
        """"""
        length = 0
        begin = 12

        while(buff[begin:begin+2] in (EtherType.VLAN.to_bytes(2, 'big'),
                                      EtherType.VLAN_QINQ.to_bytes(2, 'big'))):
            length += 4
            begin += 4

        return length
1028371
def rate_limit_status(self):
        
        return bind_api(
            api=self,
            path='/application/rate_limit_status.json',
            payload_type='json',
            allowed_param=['resources'],
            use_cache=False
        )
816775
private int calculateMaxPendingSplits(int splitAffinity, int totalDepth)
    {
        if (totalDepth == 0) {
            return maxPendingSplitsPerTask;
        }
        // Use half the queue for any split
        // Reserve the other half for splits that have some amount of network affinity
        double queueFraction = 0.5 * (1.0 + splitAffinity / (double) totalDepth);
        return (int) Math.ceil(maxPendingSplitsPerTask * queueFraction);
    }
1112970
def get_subdomains_count(db_path=None, zonefiles_dir=None):
    
    opts = get_blockstack_opts()
    if not is_subdomains_enabled(opts):
        log.warn("Subdomain support is disabled")
        return None

    if db_path is None:
        db_path = opts['subdomaindb_path']

    if zonefiles_dir is None:
        zonefiles_dir = opts['zonefiles']

    db = SubdomainDB(db_path, zonefiles_dir)
    return db.get_subdomains_count()
1162132
def find_usage(self):
        
        logger.debug("Checking usage for service %s", self.service_name)
        self.connect()
        for lim in self.limits.values():
            lim._reset_usage()
        self._find_usage_vpcs()
        subnet_to_az = self._find_usage_subnets()
        self._find_usage_ACLs()
        self._find_usage_route_tables()
        self._find_usage_gateways()
        self._find_usage_nat_gateways(subnet_to_az)
        self._find_usages_vpn_gateways()
        self._find_usage_network_interfaces()
        self._have_usage = True
        logger.debug("Done checking usage.")