Пример #1
0
    def set_config(self, config):
        """Set the service configuration

        :param config: A dictionary of config key/value
        """
        if self.config is None:
            self.config = {}
        self.config.update(types.config_to_api_list(config))
Пример #2
0
    def set_config(self, config):
        """Set the service configuration

        :param config: A dictionary of config key/value
        """
        if self.config is None:
            self.config = {}
        self.config.update(types.config_to_api_list(config))
Пример #3
0
    def update_config(self, svc_config, **rt_configs):
        """Update the service's configuration

        :param svc_config: Dictionary with service configuration to update.
        :param rt_configs: Dict of role type configurations to update.
        :return: 2-tuple (service config dictionary, role type configurations)
        """
        path = self._path() + "/config"

        if svc_config:
            data = types.config_to_api_list(svc_config)
        else:
            data = {}
        if rt_configs:
            rt_list = []
            for rt, cfg in six.iteritems(rt_configs):
                rt_data = types.config_to_api_list(cfg)
                rt_data["roleType"] = rt
                rt_list.append(rt_data)
            data[ROLETYPES_CFG_KEY] = rt_list

        resp = self._get_resource_root().put(path, data=json.dumps(data))
        return self._parse_svc_config(resp)
Пример #4
0
    def update_config(self, svc_config, **rt_configs):
        """Update the service's configuration

        :param svc_config: Dictionary with service configuration to update.
        :param rt_configs: Dict of role type configurations to update.
        :return: 2-tuple (service config dictionary, role type configurations)
        """
        path = self._path() + '/config'

        if svc_config:
            data = types.config_to_api_list(svc_config)
        else:
            data = {}
        if rt_configs:
            rt_list = []
            for rt, cfg in six.iteritems(rt_configs):
                rt_data = types.config_to_api_list(cfg)
                rt_data['roleType'] = rt
                rt_list.append(rt_data)
            data[ROLETYPES_CFG_KEY] = rt_list

        resp = self._get_resource_root().put(path, data=json.dumps(data))
        return self._parse_svc_config(resp)
Пример #5
0
    def add_role_info(self, role_name, role_type, host_id, config=None):
        """Add a role info

        The role will be created along with the service setup.

        :param role_name: Role name
        :param role_type: Role type
        :param host_id: The host where the role should run
        :param config: (Optional) A dictionary of role config values
        """
        if self.roles is None:
            self.roles = []
        api_config_list = config is not None and types.config_to_api_list(config) or None
        self.roles.append(
            {"name": role_name, "type": role_type, "hostRef": {"hostId": host_id}, "config": api_config_list}
        )
Пример #6
0
    def add_role_info(self, role_name, role_type, host_id, config=None):
        """Add a role info

        The role will be created along with the service setup.

        :param role_name: Role name
        :param role_type: Role type
        :param host_id: The host where the role should run
        :param config: (Optional) A dictionary of role config values
        """
        if self.roles is None:
            self.roles = []
        api_config_list = (config is not None
                           and types.config_to_api_list(config)
                           or None)
        self.roles.append({
            'name': role_name,
            'type': role_type,
            'hostRef': {'hostId': host_id},
            'config': api_config_list})