async def _build_widget(self): ws = [] if not self.application.is_subordinate: ws.append(OptionWidget("Units", "int", "How many units to deploy.", self.application.num_units, current_value=self.num_units_copy, value_changed_callback=self.handle_scale)) constraints_ow = OptionWidget( "Constraints", "string", "Set constraints on the application, ie. cores=4 mem=4G.", self.application.constraints, current_value=self.constraints_copy, value_changed_callback=self.handle_constraints) ws.append(constraints_ow) ws.append(self.constraints_error_label) ws += await self.get_whitelisted_option_widgets() self.toggle_show_all_button_index = len(ws) + 1 self.toggle_show_all_button = SecondaryButton( "Show Advanced Configuration", lambda sender: app.loop.create_task( self.do_toggle_show_all_config())) if await self.get_non_whitelisted_option_widgets(): ws += [HR(), Columns([('weight', 1, Text(" ")), (36, self.toggle_show_all_button)])] for widget in ws: self.widget.contents.append((widget, self.widget.options()))
def get_option_widgets(self): ws = [] service_id = self.application.csid.as_str_without_rev() options = self.metadata_controller.get_options(service_id) metadata = app.config.get('metadata', None) if metadata is None: return [] options_whitelist = metadata.get('options-whitelist', None) if options_whitelist is None: return [] svc_opts_whitelist = options_whitelist.get( self.application.service_name, []) hidden = [n for n in options.keys() if n not in svc_opts_whitelist] log.info("Hiding options not in the whitelist: {}".format(hidden)) for opname in svc_opts_whitelist: opdict = options[opname] cv = self.application.options.get(opname, None) ow = OptionWidget(opname, opdict['Type'], opdict['Description'], opdict['Default'], current_value=cv, value_changed_callback=self.handle_edit) ws.append(ow) return ws
def add_option_widget(self, opname, opdict): cv = self.service.options.get(opname, None) ow = OptionWidget(opname, opdict['Type'], opdict['Description'], opdict['Default'], current_value=cv, value_changed_callback=self.handle_edit) self.pile.contents.insert(7, (ow, self.pile.options())) self._invalidate() return ow
def _get_option_widgets(self, opnames, options): ws = [] for opname in opnames: opdict = options[opname] cv = self.application.options.get(opname, None) ow = OptionWidget(opname, opdict['Type'], opdict['Description'], opdict['Default'], current_value=cv, value_changed_callback=self.handle_edit) ws.append(ow) return ws
def build_widgets(self): ws = [Text("Configure {}".format(self.application.service_name))] num_unit_ow = OptionWidget("Units", "int", "How many units to deploy.", self.application.orig_num_units, current_value=self.application.num_units, value_changed_callback=self.handle_scale) ws.append(num_unit_ow) ws += self.get_option_widgets() ws += [ HR(), PlainButton("Cancel", self.do_cancel), PlainButton("Accept Changes", self.do_commit) ] self.pile = Pile(ws) return Padding.center_90(Filler(self.pile, valign="top"))
def _get_option_widgets(self, opnames, options): ws = [] for opname in opnames: try: opdict = options[opname] except KeyError: app.log.debug( "Unknown charm option ({}), skipping".format(opname)) continue cv = self.application.options.get(opname, None) ow = OptionWidget(opname, opdict['Type'], opdict['Description'], opdict['Default'], current_value=cv, value_changed_callback=self.handle_edit) ws.append(ow) return ws
def build_widget(self): ws = [] num_unit_ow = OptionWidget("Units", "int", "How many units to deploy.", self.application.orig_num_units, current_value=self.num_units_copy, value_changed_callback=self.handle_scale) ws.append(num_unit_ow) ws += self.get_whitelisted_option_widgets() self.toggle_show_all_button_index = len(ws) + 1 self.toggle_show_all_button = SecondaryButton( "Show Advanced Configuration", self.do_toggle_show_all_config) ws += [ HR(), Columns([('weight', 1, Text(" ")), (36, self.toggle_show_all_button)]) ] return ws
def build_widgets(self): ws = [Text("Configure {}".format(self.application.service_name))] num_unit_ow = OptionWidget("Units", "int", "How many units to deploy.", self.application.orig_num_units, current_value=self.num_units_copy, value_changed_callback=self.handle_scale) ws.append(num_unit_ow) ws += self.get_whitelisted_option_widgets() self.toggle_show_all_button_index = len(ws) + 1 self.toggle_show_all_button = PlainButton( "Show Advanced Configuration", self.do_toggle_show_all_config) ws += [ HR(), Columns([('weight', 1, Text(" ")), (36, Color.button_secondary(self.toggle_show_all_button)) ]) ] self.pile = Pile(ws) return Padding.center_90(Filler(self.pile, valign="top"))