def _construct_sharded(self):
        """Construct command line strings for a sharded cluster."""

        current_version = self.getMongoDVersion()

        num_mongos = self.args['mongos'] if self.args['mongos'] > 0 else 1
        shard_names = self._get_shard_names(self.args)

        # create shards as stand-alones or replica sets
        nextport = self.args['port'] + num_mongos
        for shard in shard_names:
            if (self.args['single'] and
                    LooseVersion(current_version) >= LooseVersion("3.6.0")):
                errmsg = " \n * In MongoDB 3.6 and above a Shard must be " \
                         "made up of a replica set. Please use --replicaset " \
                         "option when starting a sharded cluster.*"
                raise SystemExit(errmsg)

            elif (self.args['single'] and
                    LooseVersion(current_version) < LooseVersion("3.6.0")):
                self.shard_connection_str.append(
                    self._construct_single(
                        self.dir, nextport, name=shard, extra='--shardsvr'))
                nextport += 1
            elif self.args['replicaset']:
                self.shard_connection_str.append(
                    self._construct_replset(
                        self.dir, nextport, shard,
                        num_nodes=list(range(self.args['nodes'])),
                        arbiter=self.args['arbiter'], extra='--shardsvr'))
                nextport += self.args['nodes']
                if self.args['arbiter']:
                    nextport += 1

        # start up config server(s)
        config_string = []

        # SCCC config servers (MongoDB <3.3.0)
        if not self.args['csrs'] and self.args['config'] >= 3:
            config_names = ['config1', 'config2', 'config3']
        else:
            config_names = ['config']

        # CSRS config servers (MongoDB >=3.1.0)
        if self.args['csrs']:
            config_string.append(self._construct_config(self.dir, nextport,
                                                        "configRepl", True))
        else:
            for name in config_names:
                self._construct_config(self.dir, nextport, name)
                config_string.append('%s:%i' % (self.args['hostname'],
                                                nextport))
                nextport += 1

        # multiple mongos use <datadir>/mongos/ as subdir for log files
        if num_mongos > 1:
            mongosdir = os.path.join(self.dir, 'mongos')
            if not os.path.exists(mongosdir):
                if self.args['verbose']:
                    print("creating directory: %s" % mongosdir)
                os.makedirs(mongosdir)

        # start up mongos, but put them to the front of the port range
        nextport = self.args['port']
        for i in range(num_mongos):
            if num_mongos > 1:
                mongos_logfile = 'mongos/mongos_%i.log' % nextport
            else:
                mongos_logfile = 'mongos.log'
            self._construct_mongos(os.path.join(self.dir, mongos_logfile),
                                   nextport, ','.join(config_string))

            nextport += 1
Construct command line strings for a sharded cluster.