Create new docker services.

        Args:
            compose_str (string): Docker compose 'file' string

        Return:
            service_names, list
354202
def create_services(self, compose_str: str) -> list:
        
        # Raise an exception if we are not a manager
        if not self._manager:
            raise RuntimeError('Services can only be run on '
                               'swarm manager nodes')

        # Initialise empty list
        services_ids = []

        try:
            service_config = yaml.load(compose_str)

            # Deepcopy the service config
            service_list = copy.deepcopy(service_config)

            # Removing version and service from the dict
            service_config.pop('version')
            service_config.pop('services')

            for service_name in service_list['services']:
                service_exist = self._client.services.list(
                    filters={'name': service_name})
                if not service_exist:
                    service_config['name'] = service_name
                    service_spec = self._parse_services(
                        service_config, service_name, service_list)
                    created_service = self._client.services.create(
                        **service_spec)
                    service_id = created_service.short_id
                    LOG.debug('Service created: %s', service_id)
                    services_ids.append(service_id)
                else:
                    LOG.debug('Services already exists')

        except yaml.YAMLError as exc:
            print(exc)

        # Returning list of services created
        return services_ids
274584
def web_services_from_str(
    list_splitter_fn=ujson.loads,
):
    

    # -------------------------------------------------------------------------
    def class_list_converter(collector_services_str):
        """This function becomes the actual converter used by configman to
        take a string and convert it into the nested sequence of Namespaces,
        one for each class in the list.  It does this by creating a proxy
        class stuffed with its own 'required_config' that's dynamically
        generated."""
        if isinstance(collector_services_str, basestring):
            all_collector_services = list_splitter_fn(collector_services_str)
        else:
            raise TypeError('must be derivative of a basestring')

        # =====================================================================
        class InnerClassList(RequiredConfig):
            """This nested class is a proxy list for the classes.  It collects
            all the config requirements for the listed classes and places them
            each into their own Namespace.
            """
            # we're dynamically creating a class here.  The following block of
            # code is actually adding class level attributes to this new class

            # 1st requirement for configman
            required_config = Namespace()

            # to help the programmer know what Namespaces we added
            subordinate_namespace_names = []

            # for display
            original_input = collector_services_str.replace('\n', '\\n')

            # for each class in the class list
            service_list = []
            for namespace_index, collector_service_element in enumerate(
                all_collector_services
            ):
                service_name = collector_service_element['name']
                service_uri = collector_service_element['uri']
                service_implementation_class = class_converter(
                    collector_service_element['service_implementation_class']
                )

                service_list.append(
                    (
                        service_name,
                        service_uri,
                        service_implementation_class,
                    )
                )
                subordinate_namespace_names.append(service_name)
                # create the new Namespace
                required_config.namespace(service_name)
                a_class_namespace = required_config[service_name]
                a_class_namespace.add_option(
                    "service_implementation_class",
                    doc='fully qualified classname for a class that implements'
                        'the action associtated with the URI',
                    default=service_implementation_class,
                    from_string_converter=class_converter,
                    likely_to_be_changed=True,
                )
                a_class_namespace.add_option(
                    "uri",
                    doc='uri for this service',
                    default=service_uri,
                    likely_to_be_changed=True,
                )

            @classmethod
            def to_str(cls):
                """this method takes this inner class object and turns it back
                into the original string of classnames.  This is used
                primarily as for the output of the 'help' option"""
                return "'%s'" % cls.original_input

        return InnerClassList  # result of class_list_converter

    return class_list_converter
1122953
function rewriteDockerCompose(compose) {
  const services = compose.services;
  if (!services) {
    return compose;
  }
  const host = services._host;
  delete services._host;
  Object.keys(services).forEach((k) => {
    if (!isHelperContainer(k)) {
      mergeWith(services[k], host);
    }
  });
  return compose;
}
931621
async def list(self, *, filters: Mapping = None) -> List[Mapping]:
        

        params = {"filters": clean_filters(filters)}

        response = await self.docker._query_json(
            "services", method="GET", params=params
        )
        return response
1033583
def add_service(self, service_name):
        
        if service_name not in self.manifest['services']:
            self.manifest['services'].append(service_name)
1313581
def __dump_compose_file(path, compose_result, success_msg, already_existed):
    '''
    
    '''
    ret = __dump_docker_compose(path,
                                compose_result['compose_content'],
                                already_existed)
    if isinstance(ret, dict):
        return ret
    return __standardize_result(True, success_msg,
                                compose_result['compose_content'], None)
1373585
def dump(self, dump_file_name=None):
        
        config_dump = {}

        for _, _, category, _, _ in list(self.types_creations.values()):
            try:
                objs = [jsonify_r(i) for i in getattr(self, category)]
            except (TypeError, AttributeError):  # pragma: no cover, simple protection
                logger.warning("Dumping configuration, '%s' not present in the configuration",
                               category)
                continue

            container = getattr(self, category)
            if category == "services":
                objs = sorted(objs,
                              key=lambda o: "%s/%s" % (o["host_name"], o["service_description"]))
            elif hasattr(container, "name_property"):
                name_prop = container.name_property
                objs = sorted(objs, key=lambda o, prop=name_prop: getattr(o, prop, ''))
            config_dump[category] = objs

        if not dump_file_name:
            dump_file_name = os.path.join(tempfile.gettempdir(),
                                          'alignak-%s-cfg-dump-%d.json'
                                          % (self.name, int(time.time())))
        try:
            logger.info('Dumping configuration to: %s', dump_file_name)
            fd = open(dump_file_name, "w")
            fd.write(json.dumps(config_dump, indent=4, separators=(',', ': '), sort_keys=True))
            fd.close()
            logger.info('Dumped')
        except (OSError, IndexError) as exp:  # pragma: no cover, should never happen...
            logger.critical("Error when dumping configuration to %s: %s", dump_file_name, str(exp))
96214
async def CreatePool(self, attrs, name, provider):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='Storage',
                   request='CreatePool',
                   version=3,
                   params=_params)
        _params['attrs'] = attrs
        _params['name'] = name
        _params['provider'] = provider
        reply = await self.rpc(msg)
        return reply
645149
def list(self, service_name, **params):
        
        result = self._invoke_call(service_name, 'list', **params)
        if result is not None:
            return result.get(service_name, list())
        return list()
470038
def _replace_services_in_args(self, args):
        
        _check_type('args', args, list)

        new_args = []
        for arg in args:
            if isinstance(arg, list):
                new_args.append(self._replace_services_in_args(arg))
            elif isinstance(arg, dict):
                new_args.append(self._replace_services_in_kwargs(arg))
            elif isinstance(arg, string_types):
                new_args.append(self._replace_service(arg))
            else:
                new_args.append(arg)
        return new_args
352772
def services(services_file='/etc/services'):
    '''
    
    '''
    res = {}
    with salt.utils.files.fopen(services_file, 'r') as svc_defs:
        for svc_def in svc_defs.readlines():
            svc_def = salt.utils.stringutils.to_unicode(svc_def.strip())
            if not svc_def or svc_def.startswith('#'):
                continue
            elif '#' in svc_def:
                svc_def, comment = svc_def.split('#', 1)
                comment = comment.strip()
            else:
                comment = None
            svc_def = svc_def.split()

            port, proto = svc_def.pop(1).split('/')
            port = int(port)

            for name in svc_def:
                svc_res = res.get(name, {})
                pp_res = svc_res.get(port, False)
                if not pp_res:
                    svc = {
                        'port':  port,
                        'proto': proto,
                    }
                    if comment:
                        svc['desc'] = comment
                    svc_res[port] = svc
                else:
                    curr_proto = pp_res['proto']
                    if isinstance(curr_proto, (list, tuple)):
                        curr_proto.append(proto)
                    else:
                        pp_res['proto'] = [curr_proto, proto]

                    curr_desc = pp_res.get('desc', False)
                    if comment:
                        if not curr_desc:
                            pp_res['desc'] = comment
                        elif comment != curr_desc:
                            pp_res['desc'] = '{0}, {1}'.format(curr_desc, comment)
                res[name] = svc_res

    for svc, data in res.items():
        if len(data) == 1:
            res[svc] = data.values().pop()
            continue
        else:
            res[svc] = list(data.values())

    return res
194157
def create(self):
        
        self.service.create()

        os.environ[predix.config.get_env_key(self.use_class, 'host')] = self.get_eventhub_host()
        os.environ[predix.config.get_env_key(self.use_class, 'port')] = self.get_eventhub_grpc_port()
        os.environ[predix.config.get_env_key(self.use_class, 'wss_publish_uri')] = self.get_publish_wss_uri()
        os.environ[predix.config.get_env_key(self.use_class, 'zone_id')] = self.get_zone_id()
987807
def createService(self, service):
        
        url = self._url + "/createService"
        params = {
            "f" : "json"
        }
        if isinstance(service, str):
            params['service'] = service
        elif isinstance(service, dict):
            params['service'] = json.dumps(service)
        return self._post(url=url,
                             param_dict=params,
                             securityHandler=self._securityHandler,
                             proxy_url=self._proxy_url,
                             proxy_port=self._proxy_port)
454420
function servicesRunning() {
			var composeArgs = ['ps'];

			// If we're tailing just the main service's logs, then we only check that service
			if (service === '<%= dockerCompose.options.mainService %>') {
				composeArgs.push(grunt.config.get('dockerCompose.options.mainService'));
			}

			// get the stdout of docker-compose ps, store as Array, and drop the header lines.
			var serviceList = spawn('docker-compose', composeArgs).stdout.toString().split('\n').slice(2),
				upCount = 0;

			// if we are left with 1 line or less, then nothing is running.
			if (serviceList.length <= 1) {
				return false;
			}

			function isUp(service) {
				if (service.indexOf('Up') > 0) {
					upCount++;
				}
			}

			serviceList.forEach(isUp);

			return upCount > 0;
		}
510554
def create_filters(model, filter_info, resource):
    
    filters = []
    for filter_ in filter_info:
        filters.append(Node(model, filter_, resource, resource.schema).resolve())

    return filters
1070530
def create(self, friendly_name):
        
        data = values.of({'FriendlyName': friendly_name, })

        payload = self._version.create(
            'POST',
            self._uri,
            data=data,
        )

        return ServiceInstance(self._version, payload, )
763367
def add_service(self, cls):
        
        service_name = get_service_name(cls)
        container = self.container_cls(cls, self.config)
        self.service_map[service_name] = container