Exemple #1
0
        def makeCommand(discoItems):
            c = makeExecutingCommand(iq)
            a = Actions()
            a.setDefault("complete")
            c.set_actions(a)

            form = data_form.Form(
                formType="form",
                title=u"Delete communications channels",
                instructions=[u"Please select the channel to delete"],
                formNamespace=collab.COLLAB_NS,
            )

            form.addField(
                data_form.Field(
                    var="name",
                    label=u"Channel name",
                    desc=u"Please choose the channel to delete",
                    required=True,
                    fieldType="list-multi",
                    options=[data_form.Option(o.nodeIdentifier) for o in discoItems],
                )
            )

            c.set_form(form)
            return c.toElement()
Exemple #2
0
    def test_command_set_actions(self):
        c = Command('testNode', status='executing')
        a = Actions()
        a.setDefault('next')
        c.set_actions(a)

        self.assertEquals(c.actions, a)
Exemple #3
0
    def renderToElement(self, iq, state):
        c = makeExecutingCommand(iq)
        a = Actions()
        a.setDefault("complete")
        c.set_actions(a)

        form = data_form.Form(
            formType="form",
            title=u"Configure the load balancing",
            instructions=[u"Please set the frequency (per second) for checking the load."],
            formNamespace=collab.COLLAB_NS,
        )

        form.addField(
            data_form.Field(
                var="frequency",
                label=u"Frequency",
                desc=u"Please set the desired frequency per second",
                required=True,
                fieldType="text-single",
            )
        )

        c.set_form(form)
        return defer.succeed(c.toElement())
Exemple #4
0
        def makeCommand(registered):
            c = makeExecutingCommand(iq)
            a = Actions()
            a.setDefault("complete")
            c.set_actions(a)

            form = data_form.Form(
                formType="form",
                title=u"Register a machine",
                instructions=[
                    "Please give domain name details of the machine",
                    "that needs to be registered with the Collab system",
                ],
                formNamespace=collab.COLLAB_NS,
            )

            form.addField(
                data_form.Field(
                    var="machine",
                    label=u"Machine",
                    desc=u"Please give details of the machine domain name",
                    required=True,
                    fieldType="text-single",
                )
            )

            form.addField(data_form.Field(var="ForExample", label="For example:", fieldType="fixed"))

            for r in registered:
                form.addField(data_form.Field(var="registered_%s" % r, label=r, fieldType="fixed"))

            c.set_form(form)
            return c.toElement()
Exemple #5
0
        def makeCommand(subs):
            [log.msg(a) for a in subs]

            c = makeExecutingCommand(iq)
            a = Actions()
            a.setDefault("complete")
            a.add("prev")
            c.set_actions(a)

            form = data_form.Form(
                formType="form",
                title=u"Configure channel",
                instructions=[u"Set all output for %s" % psnode],
                formNamespace=collab.COLLAB_NS,
            )

            form.addField(
                data_form.Field(
                    var="subscribers",
                    label=u"Subscribers",
                    desc=u"Please choose who receives the output from %s" % psnode,
                    required=True,
                    fieldType="list-multi",
                    options=self._getOptions(subs, pubs, admins),
                )
            )

            c.set_form(form)
            return c.toElement()
Exemple #6
0
 def test_remove(self):
     a = Actions()
     a.add('prev')
     a.add('next')
     a.remove('prev')
     self.assertEquals(len(a.actions), 1)
     self.assertTrue('next' in a.actions)        
Exemple #7
0
        def makeCommand(registered):
            c = makeExecutingCommand(iq)
            a = Actions()
            a.setDefault("complete")
            c.set_actions(a)

            form = data_form.Form(
                formType="form",
                title=u"Unregister a machine",
                instructions=[u"Please select the machine to be unregistered"],
                formNamespace=collab.COLLAB_NS,
            )

            form.addField(
                data_form.Field(
                    var="machines",
                    label=u"Machines",
                    desc=u"Please select the machine domain names to remove",
                    required=True,
                    fieldType="list-multi",
                    options=[data_form.Option(m) for m in registered],
                )
            )

            c.set_form(form)
            return c.toElement()
Exemple #8
0
    def renderToElement(self, iq, state):
        c = makeExecutingCommand(iq)
        a = Actions()
        a.setDefault("complete")
        c.set_actions(a)

        form = data_form.Form(
            formType="form",
            title=u"Unregister a client",
            instructions=[u"Please choose which client to unregister."],
            formNamespace=collab.COLLAB_NS,
        )

        form.addField(
            data_form.Field(
                var="client_jid",
                label=u"Client identifier",
                desc=u"Please choose which client",
                required=True,
                fieldType="text-single",
            )
        )

        c.set_form(form)
        return defer.succeed(c.toElement())
Exemple #9
0
    def renderToElement(self, iq, state):
        c = makeExecutingCommand(iq)
        a = Actions()
        a.setDefault("complete")
        c.set_actions(a)

        form = data_form.Form(
            formType="form",
            title=u"Configure the portfolio",
            instructions=[u"Please choose the parameters of a large homogeneous portfolio."],
            formNamespace=collab.COLLAB_NS,
        )

        form.addField(
            data_form.Field(
                var="default_probability",
                label=u"Default Probability",
                desc=u"Please set the uniform asset default probability",
                required=True,
                fieldType="text-single",
            )
        )

        form.addField(
            data_form.Field(
                var="base_correlation",
                label=u"Base Correlation",
                desc=u"Please set the portfolio base correlation",
                required=True,
                fieldType="text-single",
            )
        )

        form.addField(
            data_form.Field(
                var="number_issuers",
                label=u"Number of Issuers",
                desc=u"Please set the number of defaultible issuers in the portfolio",
                required=True,
                fieldType="text-single",
            )
        )

        form.addField(
            data_form.Field(
                var="number_runs",
                label=u"Number of runs",
                desc=u"Please set the minimum number of runs to perform",
                required=True,
                fieldType="text-single",
            )
        )

        c.set_form(form)
        return defer.succeed(c.toElement())
Exemple #10
0
        def makeCommand(admins):
            c = makeExecutingCommand(iq)
            a = Actions()
            a.setDefault("next")
            a.add("prev")
            a.add("complete")
            c.set_actions(a)

            form = data_form.Form(
                formType="form",
                title=u"Configure channel",
                instructions=[u"Set all owners for %s" % psnode],
                formNamespace=collab.COLLAB_NS,
            )

            form.addField(
                data_form.Field(
                    var="admins",
                    label=u"Administrators",
                    desc=u"Please choose the owners for %s" % psnode,
                    required=True,
                    fieldType="list-multi",
                    options=self._getOptions(admins),
                )
            )

            c.set_form(form)
            return c.toElement()
Exemple #11
0
                def makeCommand(errors, outputs, inputs):
                    c = makeExecutingCommand(iq)
                    a = Actions()
                    a.setDefault("complete")
                    c.set_actions(a)

                    form = data_form.Form(
                        formType="form",
                        title=u"Input, output and error channels for %s" % self.jid.full(),
                        formNamespace=collab.COLLAB_NS,
                    )

                    form.addField(
                        data_form.Field(
                            var="input_channels",
                            label=u"Input channels",
                            required=False,
                            fieldType="text-multi",
                            values=inputs,
                        )
                    )

                    form.addField(
                        data_form.Field(
                            var="output_channels",
                            label=u"Output channels",
                            required=False,
                            fieldType="text-multi",
                            values=outputs,
                        )
                    )

                    form.addField(
                        data_form.Field(
                            var="error_channels",
                            label=u"Error channels",
                            required=False,
                            fieldType="text-multi",
                            values=errors,
                        )
                    )

                    c.set_form(form)
                    return c.toElement()
Exemple #12
0
    def test_fromElement_bad(self):
        el = Element((None, 'actions'))
        el['execute'] = 'next'
        el.addElement('next')
        el.addElement('wrong')

        a = Actions.fromElement(el)
        self.assertEquals(len(a.actions), 1)
        self.assertTrue('next' in a.actions)
        self.assertEquals(a.default, 'next')
Exemple #13
0
    def test_fromElement(self):
        el = Element((collab.COMMAND_NS, 'command'))
        el['node'] = 'testNode'
        el['sessionid'] = 'sessionid1'
        el['status'] = 'completed'
        
        a = Actions()
        a.setDefault('next')
        el.addChild(a.toElement())

        form = data_form.Form(
            formType='form',
            title=u'Unregister a machine',
            instructions=[u'Please select the machine to be unregistered'],
            formNamespace=collab.COLLAB_NS
            )

        form.addField(data_form.Field(
            var = 'machine',
            label = u'Machine',
            desc = u'Please select a machine domain name',
            required = True,
            fieldType='list-multi',
            options = [data_form.Option(m) for m in ['one', 'two', 'three']]
            ))

        el.addChild(form.toElement())

        n1 = Note('a test note')
        el.addChild(n1.toElement())

        c = Command.fromElement(el)

        self.assertEquals(c.node, 'testNode')
        self.assertEquals(c.defaultUri, collab.COMMAND_NS)
        self.assertEquals(c.status, 'completed')
        self.assertEquals(c.sessionid, 'sessionid1')

        self.assertEquals(len(c.notes), 1)
        self.assertEquals(c.notes[0].toElement().toXml(), n1.toElement().toXml())
        self.assertEquals(c.form.toElement().toXml(), form.toElement().toXml())
        self.assertEquals(c.actions.toElement().toXml(), a.toElement().toXml())        
Exemple #14
0
        def makeCommand(components):
            c = makeExecutingCommand(iq)
            a = Actions()
            a.setDefault("next")
            a.add("complete")
            c.set_actions(a)

            form = data_form.Form(
                formType="form",
                title=u"Create a communications channel",
                instructions=[
                    u"Please select a Collab component to associate with the channel",
                    u"and a suggested name for the channel",
                ],
                formNamespace=collab.COLLAB_NS,
            )

            form.addField(
                data_form.Field(
                    var="component",
                    label=u"Collab component type",
                    desc=u"Please choose the type of Collab component to associate",
                    required=True,
                    fieldType="list-single",
                    options=[data_form.Option(o) for o in components],
                )
            )

            form.addField(
                data_form.Field(
                    var="name",
                    label=u"Suggested name",
                    desc=u"Please suggest a name for the channel",
                    required=True,
                    fieldType="text-single",
                )
            )

            c.set_form(form)
            return c.toElement()
Exemple #15
0
            def makeCommand(registered, components):
                c = makeExecutingCommand(iq)
                a = Actions()
                a.setDefault("complete")
                c.set_actions(a)

                form = data_form.Form(
                    formType="form",
                    title=u"Create a Collab Component",
                    instructions=[u"Please select a Collab component to create and a machine to run it on"],
                    formNamespace=collab.COLLAB_NS,
                )

                form.addField(
                    data_form.Field(
                        var="component",
                        label=u"Collab component type",
                        desc=u"Please choose the type of Collab component to create",
                        required=True,
                        fieldType="list-single",
                        options=[data_form.Option(o) for o in components],
                    )
                )

                form.addField(
                    data_form.Field(
                        var="machine",
                        label=u"Registered machines",
                        desc=u"Please choose a machine to run the Collab component on",
                        required=True,
                        fieldType="list-single",
                        options=[data_form.Option(m) for m in registered],
                    )
                )

                c.set_form(form)
                return c.toElement()
Exemple #16
0
    def test_toElement(self):
        a = Actions()
        a.setDefault('next')
        a.add('prev')

        el = Element((None, 'actions'))
        el['execute'] = 'next'
        el.addElement('prev')
        el.addElement('next')

        self.assertEquals(a.toElement().toXml(), el.toXml())
Exemple #17
0
    def setUp(self):
        def iq():
            iq = Element((None, "iq"))
            iq["type"] = "set"
            iq["to"] = "*****@*****.**"
            iq["from"] = "*****@*****.**"
            iq["id"] = "id1"
            return iq

        def cancel():
            cmd = Element((collab.COMMAND_NS, "command"))
            cmd["node"] = "collabs_nodes_add"
            cmd["sessionid"] = "sessionid1"
            cmd["action"] = "cancel"
            return cmd

        def prev():
            cmd = Element((collab.COMMAND_NS, "command"))
            cmd["node"] = "collabs_nodes_add"
            cmd["sessionid"] = "sessionid1"
            cmd["action"] = "prev"
            return cmd

        def nex():
            cmd = Element((collab.COMMAND_NS, "command"))
            cmd["node"] = "collabs_nodes_add"
            cmd["sessionid"] = "sessionid1"
            cmd["action"] = "execute"
            return cmd

        def nex_start():
            cmd = Element((collab.COMMAND_NS, "command"))
            cmd["node"] = "collabs_nodes_add"
            cmd["action"] = "execute"
            return cmd

        def result_iq():
            iq = Element((None, "iq"))
            iq["type"] = "result"
            iq["to"] = "*****@*****.**"
            iq["from"] = "*****@*****.**"
            iq["id"] = "id1"
            return iq

        self.cancel_iq = iq()
        self.cancel_iq.addChild(cancel())

        self.prev_iq = iq()
        self.prev_iq.addChild(prev())

        self.cmd = Command(node="collabs_nodes_add", status="executing", sessionid="sessionid1")
        actions = Actions()
        actions.setDefault("next")
        self.cmd.set_actions(actions)

        form = data_form.Form(
            formType="form",
            title=u"Unregister a machine",
            instructions=[u"Please select the machine to be unregistered"],
            formNamespace=collab.COLLAB_NS,
        )

        form.addField(
            data_form.Field(
                var="machine",
                label=u"Machine",
                desc=u"Please select a machine domain name",
                required=True,
                fieldType="list-multi",
                options=[data_form.Option(m) for m in set(["master.local", "mini.local"])],
            )
        )
        self.cmd.set_form(form)

        self.next_iq = iq()
        cmd = self.next_iq.addChild(nex())
        x = cmd.addElement("x", defaultUri=data_form.NS_X_DATA)
        x["type"] = "submit"
        field = x.addElement("field")
        field["var"] = "service"
        field.addElement("value", content="something")

        self.next_start_iq = iq()
        self.next_start_iq.addChild(nex_start())

        self.state = dict({"one": 1})
Exemple #18
0
 def test_setDefault(self):
     a = Actions()
     a.setDefault('next')
     self.assertEquals(len(a.actions), 1)
     self.assertTrue('next' in a.actions)
     self.assertEquals(a.default, 'next')
Exemple #19
0
 def test_remove_not_there(self):
     a = Actions()
     a.add('next')
     a.remove('wrong')
     self.assertEquals(len(a.actions), 1)
     self.assertTrue('next' in a.actions)        
Exemple #20
0
 def test_add(self):
     a = Actions()
     a.add('next')
     self.assertEquals(len(a.actions), 1)
     self.assertTrue('next' in a.actions)