コード例 #1
0
def build_commands(resource_id, restype):
    if is_read_only():
        return ""

    fragments = ["<h2>Commands</h2>"]

    fragments.append(build_command("Edit", "/edit/%s" % resource_id))

    fragments.append(build_command("Delete", "/cmd/delete?rid=%s" % resource_id, confirm="Are you sure to delete resource?"))

    options = [(p, p) for p in sorted(PRED)]
    args = [('select', 'pred', options), ('input', 'rid2', 45)]
    fragments.append(build_command("Associate from subject", "/cmd/createassoc?rid=%s&dir=from" % resource_id, args))
    fragments.append(build_command("Associate to object", "/cmd/createassoc?rid=%s&dir=to" % resource_id, args, variant="1"))

    from pyon.ion.resource import LCE, LCS, AS
    event_list = LCE.keys()
    options = zip(event_list, event_list)
    args = [('select', 'lcevent', options)]
    fragments.append(build_command("Execute Lifecycle Event", "/cmd/execute_lcs?rid=%s" % resource_id, args))

    state_list = LCS.keys() + AS.keys()
    options = zip(state_list, state_list)
    args = [('select', 'lcstate', options)]
    fragments.append(build_command("Change Lifecycle State", "/cmd/set_lcs?rid=%s" % resource_id, args))

    if restype == "ActorIdentity":
        fragments.append(build_command("Unlock User", "/cmd/unlock_user?rid=%s" % resource_id))

    if adminui_instance.plugin:
        adminui_instance.plugin.resource_commands(resource_id, restype, fragments)

    return "".join(fragments)
コード例 #2
0
ファイル: admin_ui.py プロジェクト: mkl-/scioncc
def build_commands(resource_id, restype):
    if is_read_only():
        return ""

    fragments = ["<h2>Commands</h2>"]

    fragments.append(build_command("Edit", "/edit/%s" % resource_id))

    fragments.append(build_command("Delete", "/cmd/delete?rid=%s" % resource_id, confirm="Are you sure to delete resource?"))

    options = [(p, p) for p in sorted(PRED)]
    args = [('select', 'pred', options), ('input', 'rid2', 45)]
    fragments.append(build_command("Associate from subject", "/cmd/createassoc?rid=%s&dir=from" % resource_id, args))
    fragments.append(build_command("Associate to object", "/cmd/createassoc?rid=%s&dir=to" % resource_id, args))

    from pyon.ion.resource import LCE, LCS, AS
    event_list = LCE.keys()
    options = zip(event_list, event_list)
    args = [('select', 'lcevent', options)]
    fragments.append(build_command("Execute Lifecycle Event", "/cmd/execute_lcs?rid=%s" % resource_id, args))

    state_list = LCS.keys() + AS.keys()
    options = zip(state_list, state_list)
    args = [('select', 'lcstate', options)]
    fragments.append(build_command("Change Lifecycle State", "/cmd/set_lcs?rid=%s" % resource_id, args))


    fragments.append("</table>")
    return "".join(fragments)
コード例 #3
0
    def test_events(self):
        self.rr.read.return_value = "this is a resource"

        #if True: self.fail("%s" % LCE.keys())
        for event in LCE.values():
            self.rr.reset_mock()
            success, msg = self.policy.check_lcs_precondition_satisfied("rsrc_id", event)
            self.assertTrue(success)
            self.assertEqual("ResourceLCSPolicy base class not overridden!", msg)