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(config_to_api_list(config))
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(config_to_api_list(config))
def add_role_type_info(self, role_type, config): """ Add a role type setup info. @param role_type: Role type @param config: A dictionary of role type configuration """ rt_config = config_to_api_list(config) rt_config['roleType'] = role_type if self.config is None: self.config = { } if not self.config.has_key(ROLETYPES_CFG_KEY): self.config[ROLETYPES_CFG_KEY] = [ ] self.config[ROLETYPES_CFG_KEY].append(rt_config)
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 = config_to_api_list(svc_config) else: data = { } if rt_configs: rt_list = [ ] for rt, cfg in rt_configs.iteritems(): rt_data = 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)
def add_role_type_info(self, role_type, config): """ Add a role type setup info. @param role_type: Role type @param config: A dictionary of role type configuration """ rt_config = config_to_api_list(config) rt_config['roleType'] = role_type if self.config is None: self.config = {} if not self.config.has_key(ROLETYPES_CFG_KEY): self.config[ROLETYPES_CFG_KEY] = [] self.config[ROLETYPES_CFG_KEY].append(rt_config)
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 = config_to_api_list(svc_config) else: data = {} if rt_configs: rt_list = [] for rt, cfg in rt_configs.iteritems(): rt_data = 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)
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 config_to_api_list(config) or None self.roles.append({ 'name' : role_name, 'type' : role_type, 'hostRef' : { 'hostId' : host_id }, 'config' : api_config_list })
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 config_to_api_list( config) or None self.roles.append({ 'name': role_name, 'type': role_type, 'hostRef': { 'hostId': host_id }, 'config': api_config_list })