Return a list of expected ceph pools in a ceph + cinder + glance
        test scenario, based on OpenStack release and whether ceph radosgw
        is flagged as present or not.
321618
def get_ceph_expected_pools(self, radosgw=False):
        """"""

        if self._get_openstack_release() == self.trusty_icehouse:
            # Icehouse
            pools = [
                'data',
                'metadata',
                'rbd',
                'cinder-ceph',
                'glance'
            ]
        elif (self.trusty_kilo <= self._get_openstack_release() <=
              self.zesty_ocata):
            # Kilo through Ocata
            pools = [
                'rbd',
                'cinder-ceph',
                'glance'
            ]
        else:
            # Pike and later
            pools = [
                'cinder-ceph',
                'glance'
            ]

        if radosgw:
            pools.extend([
                '.rgw.root',
                '.rgw.control',
                '.rgw',
                '.rgw.gc',
                '.users.uid'
            ])

        return pools
5830
function(includeClusterScoped) {
    var kinds = [];
    var rejectedKinds = _.map(Constants.AVAILABLE_KINDS_BLACKLIST, function(kind) {
      return _.isString(kind) ?
              { kind: kind, group: '' } :
              kind;
    });

    // ignore the legacy openshift kinds, these have been migrated to api groups
    _.each(_.pickBy(API_CFG, function(value, key) {
      return key !== 'openshift';
    }), function(api) {
      _.each(api.resources.v1, function(resource) {
        if (resource.namespaced || includeClusterScoped) {
          // Exclude subresources and any rejected kinds
          if (_.includes(resource.name, '/') || _.find(rejectedKinds, { kind: resource.kind, group: '' })) {
            return;
          }

          kinds.push({
            kind: resource.kind,
            group:  ''
          });
        }
      });
    });

   // Kinds under api groups
    _.each(APIS_CFG.groups, function(group) {

      // Use the console's default version first, and the server's preferred version second
      var preferredVersion = defaultVersion[group.name] || group.preferredVersion;
      _.each(group.versions[preferredVersion].resources, function(resource) {
        // Exclude subresources and any rejected kinds
        if (_.includes(resource.name, '/') || _.find(rejectedKinds, {kind: resource.kind, group: group.name})) {
          return;
        }


        if(excludeKindFromAPIGroupList(group.name, resource.kind)) {
          return;
        }

        if (resource.namespaced || includeClusterScoped) {
          kinds.push({
            kind: resource.kind,
            group: group.name
          });
        }
      });
    });

    return _.uniqBy(kinds, function(value) {
      return value.group + "/" + value.kind;
    });
  }
600626
def list_available_tools(self):
        
        benchmarks = []

        if self.alternative_config_dir:
            for n in glob.glob(os.path.join(self.alternative_config_dir, self.BENCHMARKS_DIR, '*.conf')):
                benchmarks.append(BenchmarkToolConfiguration(n))

        for n in glob.glob(os.path.join(self.default_config_dir, self.BENCHMARKS_DIR, '*.conf')):
            benchmarks.append(BenchmarkToolConfiguration(n))

        return benchmarks
509698
def create_pool(service, name, replicas=3, pg_num=None):
    """"""
    if pool_exists(service, name):
        log("Ceph pool {} already exists, skipping creation".format(name),
            level=WARNING)
        return

    if not pg_num:
        # Calculate the number of placement groups based
        # on upstream recommended best practices.
        osds = get_osds(service)
        if osds:
            pg_num = (len(osds) * 100 // replicas)
        else:
            # NOTE(james-page): Default to 200 for older ceph versions
            # which don't support OSD query from cli
            pg_num = 200

    cmd = ['ceph', '--id', service, 'osd', 'pool', 'create', name, str(pg_num)]
    check_call(cmd)

    update_pool(service, name, settings={'size': str(replicas)})
996149
def get_openstack_cloud(auth=None):
    '''
    
    '''
    if auth is None:
        auth = __salt__['config.option']('keystone', {})
    if 'shade_oscloud' in __context__:
        if __context__['shade_oscloud'].auth == auth:
            return __context__['shade_oscloud']
    __context__['shade_oscloud'] = shade.openstack_cloud(**auth)
    return __context__['shade_oscloud']
1277166
def get_default_config(self):
        
        config = super(CephCollector, self).get_default_config()
        config.update({
            'socket_path': '/var/run/ceph',
            'socket_prefix': 'ceph-',
            'socket_ext': 'asok',
            'ceph_binary': '/usr/bin/ceph',
        })
        return config
749799
def present(name, provider):
    '''
    
    '''
    ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}

    is_present = list(__salt__['cloud.action']('queues_exists', provider=provider, name=name)[provider].values())[0]

    if not is_present:
        if __opts__['test']:
            msg = 'Rackspace queue {0} is set to be created.'.format(name)
            ret['comment'] = msg
            ret['result'] = None
            return ret
        created = __salt__['cloud.action']('queues_create', provider=provider, name=name)
        if created:
            queue = __salt__['cloud.action']('queues_show', provider=provider, name=name)
            ret['changes']['old'] = {}
            ret['changes']['new'] = {'queue': queue}
        else:
            ret['result'] = False
            ret['comment'] = 'Failed to create {0} Rackspace queue.'.format(name)
            return ret
    else:
        ret['comment'] = '{0} present.'.format(name)

    return ret
590532
def envs(ignore_cache=False):
    '''
    
    '''
    if not ignore_cache:
        env_cache = os.path.join(__opts__['cachedir'], 'hgfs/envs.p')
        cache_match = salt.fileserver.check_env_cache(__opts__, env_cache)
        if cache_match is not None:
            return cache_match
    ret = set()
    for repo in init():
        repo['repo'].open()
        if repo['branch_method'] in ('branches', 'mixed'):
            for branch in _all_branches(repo['repo']):
                branch_name = branch[0]
                if branch_name == repo['base']:
                    branch_name = 'base'
                ret.add(branch_name)
        if repo['branch_method'] in ('bookmarks', 'mixed'):
            for bookmark in _all_bookmarks(repo['repo']):
                bookmark_name = bookmark[0]
                if bookmark_name == repo['base']:
                    bookmark_name = 'base'
                ret.add(bookmark_name)
        ret.update([x[0] for x in _all_tags(repo['repo'])])
        repo['repo'].close()
    return [x for x in sorted(ret) if _env_is_exposed(x)]
839446
def list(self, path=None, with_metadata=False):
        ''''''

        path = path.strip('/') if path else ''

        if self.upstream:
            return self.upstream.list(path, with_metadata=with_metadata)
        else:
            raise NotImplementedError()
476776
def check(self):
        

        status = True
        synced = True

        xbin = self.xbin.value()
        ybin = self.ybin.value()
        nwin = self.nwin.value()

        # individual window checks
        g = get_root(self).globals
        for xsw, ysw, nxw, nyw in \
                zip(self.xs[:nwin], self.ys[:nwin],
                    self.nx[:nwin], self.ny[:nwin]):

            xsw.config(bg=g.COL['main'])
            ysw.config(bg=g.COL['main'])
            nxw.config(bg=g.COL['main'])
            nyw.config(bg=g.COL['main'])
            status = status if xsw.ok() else False
            status = status if ysw.ok() else False
            status = status if nxw.ok() else False
            status = status if nyw.ok() else False
            xs = xsw.value()
            ys = ysw.value()
            nx = nxw.value()
            ny = nyw.value()

            # Are unbinned dimensions consistent with binning factors?
            if nx is None or nx % xbin != 0:
                nxw.config(bg=g.COL['error'])
                status = False
            elif (nx // xbin) % 4 != 0:
                """
                The NGC collects pixel data in chunks before transmission.
                As a result, to avoid loss of data from frames, the binned
                x-size must be a multiple of 4.
                """
                nxw.config(bg=g.COL['error'])
                status = False

            if ny is None or ny % ybin != 0:
                nyw.config(bg=g.COL['error'])
                status = False

            # Are the windows synchronised? This means that they
            # would be consistent with the pixels generated were
            # the whole CCD to be binned by the same factors
            # If relevant values are not set, we count that as
            # "synced" because the purpose of this is to enable
            # / disable the sync button and we don't want it to be
            # enabled just because xs or ys are not set.
            if (xs is not None and ys is not None and nx is not None and
                ny is not None):
                    if (xs < 1025 and ((xs - 1) % xbin != 0 or (ys - 1) % ybin != 0)
                        or ((xs-1025) % xbin != 0 or (ys - 1) % ybin != 0)):
                        synced = False

            # Range checks
            if xs is None or nx is None or xs + nx - 1 > xsw.imax:
                xsw.config(bg=g.COL['error'])
                status = False

            if ys is None or ny is None or ys + ny - 1 > ysw.imax:
                ysw.config(bg=g.COL['error'])
                status = False

        # Overlap checks. Compare each window with the next one, requiring
        # no y overlap and that the second is higher than the first
        if status:
            n1 = 0
            for ysw1, nyw1 in zip(self.ys[:nwin-1], self.ny[:nwin-1]):

                ys1 = ysw1.value()
                ny1 = nyw1.value()

                n1 += 1
                ysw2 = self.ys[n1]

                ys2 = ysw2.value()

                if ys2 < ys1 + ny1:
                    ysw2.config(bg=g.COL['error'])
                    status = False

        if synced:
            self.sbutt.config(bg=g.COL['main'])
            self.sbutt.disable()
        else:
            if not self.frozen:
                self.sbutt.enable()
            self.sbutt.config(bg=g.COL['warn'])

        return status
570726
def get_snapshots(working_dir, start_block=None, end_block=None):
    

    # make this usable even if we haven't explicitly configured virtualchain 
    impl = sys.modules[__name__]
    return BlockstackDB.get_consensus_hashes(impl, working_dir, start_block_height=start_block, end_block_height=end_block)
1333303
def has_bitshifts(self):
        

        def _has_bitshifts(expr):
            if isinstance(expr, pyvex.IRExpr.Binop):
                return expr.op.startswith("Iop_Shl") or expr.op.startswith("Iop_Shr") \
                       or expr.op.startswith("Iop_Sar")
            return False

        found_bitops = False

        for block in self._function.blocks:
            if block.size == 0:
                continue
            for stmt in block.vex.statements:
                if isinstance(stmt, pyvex.IRStmt.Put):
                    found_bitops = found_bitops or _has_bitshifts(stmt.data)
                elif isinstance(stmt, pyvex.IRStmt.WrTmp):
                    found_bitops = found_bitops or _has_bitshifts(stmt.data)

            if found_bitops:
                break

        if found_bitops:
            return { CodeTags.HAS_BITSHIFTS }
        return None
321162
def _verify_realtime_streams(self, hw):
        
        print("--> Testing realtime data (takes 2 seconds)")
        time.sleep(2.1)
        reports = [x for x in hw.iter_reports()]
        reports_seen = {key: 0 for key in self._realtime_streams}

        for report in reports:
            stream_value = report.visible_readings[0].stream
            if reports_seen.get(stream_value) is not None:
                reports_seen[stream_value] += 1

        for stream in reports_seen.keys():
            if reports_seen[stream] < 2:
                raise ArgumentError("Realtime Stream not pushing any reports", stream=hex(stream), \
                    reports_seen=reports_seen[stream])
1070830
def do_watch(self, *args):
        
        tables = []
        if not self.engine.cached_descriptions:
            self.engine.describe_all()
        all_tables = list(self.engine.cached_descriptions)
        for arg in args:
            candidates = set((t for t in all_tables if fnmatch(t, arg)))
            for t in sorted(candidates):
                if t not in tables:
                    tables.append(t)

        mon = Monitor(self.engine, tables)
        mon.start()
704029
def returnListOfCreds():
    '''
        
    '''
    listCreds = []
    # If a accounts.cfg has not been found, creating it by copying from default
    configPath = os.path.join(configuration.getConfigPath()["appPath"], "accounts.cfg")

    # Checking if the configuration file exists
    if not os.path.exists(configPath):
        # Copy the data from the default folder
        defaultConfigPath = os.path.join(configuration.getConfigPath()["appPathDefaults"], "accounts.cfg")

        try:
            with open(defaultConfigPath) as iF:
                cont = iF.read()
                with open(configPath, "w") as oF:
                    oF.write(cont)
        except Exception, e:
            raise errors.ConfigurationFileNotFoundError(configPath, defaultConfigPath);
            return listCreds

    # Reading the configuration file
    config = ConfigParser.ConfigParser()
    config.read(configPath)

    # Iterating through all the sections, which contain the platforms
    for platform in config.sections():
        # Initializing values
        creds = {}

        incomplete = False

        # Iterating through parametgers
        for (param, value) in config.items(platform):
            if value == '':
                incomplete = True
                break
            creds[param] = value

        # Appending credentials if possible
        try:
            if not incomplete:
                listCreds.append((platform, creds["login"], creds["password"]))
        except:
            pass

    return listCreds
625211
def get_cdk_stacks(module_path, env_vars, context_opts):
    """"""
    LOGGER.debug('Listing stacks in the CDK app prior to '
                 'diff')
    return subprocess.check_output(
        generate_node_command(
            command='cdk',
            command_opts=['list'] + context_opts,
            path=module_path),
        env=env_vars
    ).strip().split('\n')
556725
def get_mon_initial_members(args, error_on_empty=False, _cfg=None):
    
    if _cfg:
        cfg = _cfg
    else:
        cfg = conf.ceph.load(args)
    mon_initial_members = cfg.safe_get('global', 'mon_initial_members')
    if not mon_initial_members:
        if error_on_empty:
            raise exc.NeedHostError(
                'could not find `mon initial members` defined in ceph.conf'
            )
    else:
        mon_initial_members = re.split(r'[,\s]+', mon_initial_members)
    return mon_initial_members