instance_body : ID width LPAREN instance_ports RPAREN
972068
def p_instance_body_array(self, p):
        ''
        p[0] = (p[1], p[4], p[2])
        p.set_lineno(0, p.lineno(1))
67740
def p_instance_port_arg_exp(self, p):
        ''
        p[0] = PortArg(p[2], p[4], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
15390
def addInstance(self, inst_id):
        
        self.instances.add(inst_id)
        self.requestTracker.add_instance(inst_id)
        self.numOrderedRequests[inst_id] = (0, 0)
        rm = self.create_throughput_measurement(self.config)

        self.throughputs[inst_id] = rm
        lm = self.latency_measurement_cls(self.config)
        self.clientAvgReqLatencies[inst_id] = lm
        if self.acc_monitor:
            self.acc_monitor.add_instance(inst_id)
121194
def ip(args):
    
    if len(args) != 0:
        sys.exit(not p.print_help())

    s = InstanceSkeleton()
    print("IP address:", s.private_ip_address, file=sys.stderr)
    print("Instance type:", s.instance_type, file=sys.stderr)
501385
def instance(cls, size):
        
        if not getattr(cls, "_instance", None):
            cls._instance = {}
        if size not in cls._instance:
            cls._instance[size] = ThreadPool(size)
        return cls._instance[size]
285029
def p_width(self, p):
        ''
        p[0] = Width(p[2], p[4], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
1187308
def from_instance(instance):
    
    url = instance.get('url')
    if not url:
        raise ConfigurationError("A URL must be specified in the instance")

    pshard_stats = is_affirmative(instance.get('pshard_stats', False))
    pshard_graceful_to = is_affirmative(instance.get('pshard_graceful_timeout', False))
    node_name_as_host = is_affirmative(instance.get('node_name_as_host', False))
    index_stats = is_affirmative(instance.get('index_stats', False))
    cluster_stats = is_affirmative(instance.get('cluster_stats', False))
    if 'is_external' in instance:
        cluster_stats = is_affirmative(instance.get('is_external', False))
    pending_task_stats = is_affirmative(instance.get('pending_task_stats', True))
    admin_forwarder = is_affirmative(instance.get('admin_forwarder', False))

    # Support URLs that have a path in them from the config, for
    # backwards-compatibility.
    parsed = urlparse(url)
    if parsed[2] and not admin_forwarder:
        url = '{}://{}'.format(parsed[0], parsed[1])
    port = parsed.port
    host = parsed.hostname

    custom_tags = instance.get('tags', [])
    service_check_tags = ['host:{}'.format(host), 'port:{}'.format(port)]
    service_check_tags.extend(custom_tags)

    # Tag by URL so we can differentiate the metrics
    # from multiple instances
    tags = ['url:{}'.format(url)]
    tags.extend(custom_tags)

    timeout = instance.get('timeout') or DEFAULT_TIMEOUT

    config = ESInstanceConfig(
        admin_forwarder=admin_forwarder,
        pshard_stats=pshard_stats,
        pshard_graceful_to=pshard_graceful_to,
        node_name_as_host=node_name_as_host,
        cluster_stats=cluster_stats,
        index_stats=index_stats,
        password=instance.get('password'),
        service_check_tags=service_check_tags,
        health_tags=[],
        ssl_cert=instance.get('ssl_cert'),
        ssl_key=instance.get('ssl_key'),
        ssl_verify=instance.get('ssl_verify'),
        tags=tags,
        timeout=timeout,
        url=url,
        username=instance.get('username'),
        pending_task_stats=pending_task_stats,
    )
    return config
296980
def lvresize(size=None, lvpath=None, extents=None):
    '''
    

    '''
    if size and extents:
        log.error('Error: Please specify only one of size or extents')
        return {}

    cmd = ['lvresize']

    if size:
        cmd.extend(['-L', '{0}'.format(size)])
    elif extents:
        cmd.extend(['-l', '{0}'.format(extents)])
    else:
        log.error('Error: Either size or extents must be specified')
        return {}

    cmd.append(lvpath)
    cmd_ret = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
    return {'Output from lvresize': cmd_ret[0].strip()}
906181
def network_traffic_ports(instance):
    
    for key, obj in instance['objects'].items():
        if ('type' in obj and obj['type'] == 'network-traffic' and
                ('src_port' not in obj or 'dst_port' not in obj)):
            yield JSONError("The Network Traffic object '%s' should contain "
                            "both the 'src_port' and 'dst_port' properties."
                            % key, instance['id'], 'network-traffic-ports')
481245
function lpad (str, width) {
  while (String(str).length < width) {
    str = ' ' + str
  }
  return str
}
257705
function dbinomLog(size, p) {
      if (p === 0) { return function(x) { return x === 0 ? 0 : -Infinity; }; }
      if (p === 1) { return function(x) { return x === size ? 0 : -Infinity; }; }
      return function(x) {
         if (x === 0) {
            if (size === 0) { return 0; }
            return size * log1p(-p);
         }
         if (x === size) { return size * Math.log(p); }
         return stirlerr(size) - stirlerr(x) - stirlerr(size - x) -
            bd0(x, size * p) - bd0(size - x, size * (1 - p)) +
            0.5 * Math.log(size / (C.twopi * x * (size - x)));
      };
   }
1323187
def str_with_sizes(self, max_name, max_remote_id, max_size):
        
        name_str = self.name.ljust(max_name)
        remote_id_str = self.remote_id.ljust(max_remote_id)
        size_str = self.size.ljust(max_size)
        return u'{}    {}    {}    {}'.format(name_str, remote_id_str, size_str, self.file_hash)
1201966
def avail_sizes(conn=None):
    '''
    
    '''
    if not conn:
        conn = get_conn()
    raw_sizes = conn.list_sizes('all')  # get *all* the machine types!
    sizes = []
    for size in raw_sizes:
        zone = size.extra['zone']
        size.extra['zone'] = {}
        size.extra['zone'].update(zone.__dict__)
        mtype = {}
        mtype.update(size.__dict__)
        sizes.append(mtype)
    return sizes
1102877
def path_size(p: tcod.path.AStar) -> int:
    
    return int(lib.TCOD_path_size(p._path_c))
1003370
def p_instance_bodylist(self, p):
        ''
        p[0] = p[1] + (p[3],)
        p.set_lineno(0, p.lineno(1))
1024817
def show_instance(name, conn=None, call=None):
    '''
    

    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The show_instance action must be called with -a or --action.'
        )
    if conn is None:
        conn = get_conn()

    node = conn.get_server(name, bare=True)
    ret = dict(node)
    ret['id'] = node.id
    ret['name'] = node.name
    ret['size'] = conn.get_flavor(node.flavor.id).name
    ret['state'] = node.status
    ret['private_ips'] = _get_ips(node, 'private')
    ret['public_ips'] = _get_ips(node, 'public')
    ret['floating_ips'] = _get_ips(node, 'floating')
    ret['fixed_ips'] = _get_ips(node, 'fixed')
    if isinstance(node.image, six.string_types):
        ret['image'] = node.image
    else:
        ret['image'] = conn.get_image(node.image.id).name
    return ret
945273
def instance_provisioned(device_id):
    """"""
    session = db.get_reader_session()
    with session.begin():
        port_model = models_v2.Port
        res = bool(session.query(port_model)
                   .filter(port_model.device_id == device_id).count())
    return res