示例#1
0
 def apply_assignments(self, application):
     new_assignments = []
     for juju_machine_id, at in self.get_all_assignments(application):
         label = atype_to_label([at])[0]
         plabel = ""
         if label != "":
             plabel += "{}".format(label)
         plabel += self.deployed_juju_machines.get(juju_machine_id,
                                                   juju_machine_id)
         new_assignments.append(plabel)
     application.placement_spec = new_assignments
示例#2
0
 def apply_assignments(self, application):
     new_assignments = []
     for juju_machine_id, at in self.get_all_assignments(application):
         label = atype_to_label([at])[0]
         plabel = ""
         if label != "":
             plabel += "{}".format(label)
         plabel += self.deployed_juju_machines.get(juju_machine_id,
                                                   juju_machine_id)
         new_assignments.append(plabel)
     application.placement_spec = new_assignments
示例#3
0
    def update_assignments(self):
        assignments = []

        mps = self.controller.get_all_assignments(self.juju_machine_id)
        if len(mps) > 0:
            if self.show_assignments:
                ad = defaultdict(list)
                for application, atype in mps:
                    ad[atype].append(application)
                astr = " ".join([
                    "{}{}".format(
                        atype_to_label([atype])[0], ",".join(
                            [application.service_name for application in al]))
                    for atype, al in ad.items()
                ])
                assignments.append(astr)
        else:
            if self.show_assignments:
                assignments.append("-")

        if any([application == self.application for application, _ in mps]):
            action = self.do_remove
            label = "Remove"
        else:
            action = self.do_select
            label = "Select"

        self.select_button = PlainButton(label, action)

        cols = [Text(s) for s in assignments]

        current_assignments = [a for a, _ in mps if a == self.application]
        if self.all_assigned and len(current_assignments) == 0:
            cols.append(Text(""))
        else:
            cols += [
                AttrMap(self.select_button, 'text', 'button_secondary focus')
            ]
        opts = self.unselected_columns.options()
        self.unselected_columns.contents[4:] = [(w, opts) for w in cols]
    def update_assignments(self):
        assignments = []

        mps = self.controller.get_all_assignments(self.juju_machine_id)
        if len(mps) > 0:
            if self.show_assignments:
                ad = defaultdict(list)
                for application, atype in mps:
                    ad[atype].append(application)
                astr = " ".join(["{}{}".format(
                    atype_to_label([atype])[0],
                    ",".join([application.service_name
                              for application in al]))
                    for atype, al in ad.items()])
                assignments.append(astr)
        else:
            if self.show_assignments:
                assignments.append("-")

        if any([application == self.application for application, _ in mps]):
            action = self.do_remove
            label = "Remove"
        else:
            action = self.do_select
            label = "Select"

        self.select_button = PlainButton(label, action)

        cols = [Text(s) for s in assignments]

        current_assignments = [a for a, _ in mps if a == self.application]
        if self.all_assigned and len(current_assignments) == 0:
            cols.append(Text(""))
        else:
            cols += [AttrMap(self.select_button, 'text',
                             'button_secondary focus')]
        opts = self.unselected_columns.options()
        self.unselected_columns.contents[4:] = [(w, opts) for w in cols]