Revision 4573f225
b/kamaki/cli/commands/astakos.py | ||
---|---|---|
1 |
# Copyright 2011-2013 GRNET S.A. All rights reserved.
|
|
1 |
# Copyright 2011-2014 GRNET S.A. All rights reserved.
|
|
2 | 2 |
# |
3 | 3 |
# Redistribution and use in source and binary forms, with or |
4 | 4 |
# without modification, are permitted provided that the following |
... | ... | |
603 | 603 |
"homepage": homepage, # optional |
604 | 604 |
"description": description, # optional |
605 | 605 |
"comments": comments, # optional |
606 |
"max_members": max_members, # optional |
|
607 |
"private": true | false, # optional |
|
606 | 608 |
"start_date": date, # optional |
607 | 609 |
"end_date": date, |
608 | 610 |
"join_policy": "auto" | "moderated" | "closed", # default: "moderated" |
... | ... | |
684 | 686 |
|
685 | 687 |
class ProjectResourceArgument(KeyValueArgument): |
686 | 688 |
""""A <resource>=<member_capacity>,<project_capacity> argument e.g., |
687 |
--resource cyclades.cpu=5,1""" |
|
689 |
--resource cyclades.cpu=5,1 |
|
690 |
""" |
|
688 | 691 |
@property |
689 | 692 |
def value(self): |
690 | 693 |
return super(ProjectResourceArgument, self).value |
... | ... | |
726 | 729 |
owner_uuid=ValueArgument('Project owner', '--owner'), |
727 | 730 |
homepage_url=ValueArgument('Project homepage', '--homepage'), |
728 | 731 |
description=ValueArgument('Describe the project', '--description'), |
732 |
max_members=IntArgument('Maximum subscribers', '--max-members'), |
|
733 |
private=FlagArgument('Set if the project is private', '--private'), |
|
729 | 734 |
start_date=DateArgument('When to start the project', '--start-date'), |
730 | 735 |
end_date=DateArgument('When to end the project', '--end-date'), |
731 | 736 |
join_policy=PolicyArgument( |
... | ... | |
756 | 761 |
('owner', self['owner_uuid']), |
757 | 762 |
('homepage', self['homepage_url']), |
758 | 763 |
('description', self['description']), |
764 |
('max_members', self['max_members']), |
|
765 |
('private', self['private']), |
|
759 | 766 |
('start_date', self['start_date']), |
760 | 767 |
('end_date', self['end_date']), |
761 | 768 |
('join_policy', self['join_policy']), |
... | ... | |
781 | 788 |
|
782 | 789 |
@command(project_commands) |
783 | 790 |
class project_modify(_init_synnefo_astakosclient, _optional_json): |
784 |
"""Modify a project (input a json-dict) |
|
785 |
Project details must be provided as a json-formated dict from the standard |
|
786 |
input, or through a file |
|
787 |
""" |
|
791 |
"""Modify properties of a project""" |
|
788 | 792 |
|
789 | 793 |
__doc__ += _project_specs |
790 | 794 |
|
... | ... | |
795 | 799 |
owner_uuid=ValueArgument('Project owner', '--owner'), |
796 | 800 |
homepage_url=ValueArgument('Project homepage', '--homepage'), |
797 | 801 |
description=ValueArgument('Describe the project', '--description'), |
802 |
max_members=IntArgument('Maximum subscribers', '--max-members'), |
|
803 |
private=FlagArgument('Set if the project is private', '--private'), |
|
798 | 804 |
start_date=DateArgument('When to start the project', '--start-date'), |
799 | 805 |
end_date=DateArgument('When to end the project', '--end-date'), |
800 | 806 |
join_policy=PolicyArgument( |
... | ... | |
813 | 819 |
required = [ |
814 | 820 |
'specs_path', 'owner_uuid', 'homepage_url', 'description', |
815 | 821 |
'project_name', 'start_date', 'end_date', 'join_policy', |
816 |
'leave_policy', 'resource_capacities', ] |
|
822 |
'leave_policy', 'resource_capacities', 'max_members', 'private']
|
|
817 | 823 |
|
818 | 824 |
@errors.generic.all |
819 | 825 |
@errors.user.astakosclient |
... | ... | |
828 | 834 |
('owner', self['owner_uuid']), |
829 | 835 |
('homepage', self['homepage_url']), |
830 | 836 |
('description', self['description']), |
837 |
('max_members', self['max_members']), |
|
838 |
('private', self['private']), |
|
831 | 839 |
('start_date', self['start_date']), |
832 | 840 |
('end_date', self['end_date']), |
833 | 841 |
('join_policy', self['join_policy']), |
... | ... | |
941 | 949 |
"""List all memberships""" |
942 | 950 |
|
943 | 951 |
arguments = dict( |
944 |
project=IntArgument('Filter by project id', '--with-project-id')
|
|
952 |
project=IntArgument('Filter by project id', '--project-id') |
|
945 | 953 |
) |
946 | 954 |
|
947 | 955 |
@errors.generic.all |
... | ... | |
966 | 974 |
|
967 | 975 |
def main(self, membership_id): |
968 | 976 |
super(self.__class__, self)._run() |
969 |
self._run(membership_id) |
|
977 |
self._run(memb_id=membership_id)
|
|
970 | 978 |
|
971 | 979 |
|
972 | 980 |
class _membership_action(_init_synnefo_astakosclient, _optional_json): |
973 | 981 |
|
974 | 982 |
action = '' |
983 |
arguments = dict(reason=ValueArgument('Reason for the action', '--reason')) |
|
975 | 984 |
|
976 | 985 |
@errors.generic.all |
977 | 986 |
@errors.user.astakosclient |
... | ... | |
979 | 988 |
self._print(self.client.membership_action( |
980 | 989 |
memb_id, self.action, quote_a_reason)) |
981 | 990 |
|
982 |
def main(self, membership_id, quote_a_reason=''):
|
|
991 |
def main(self, membership_id): |
|
983 | 992 |
super(_membership_action, self)._run() |
984 |
self._run(membership_id, quote_a_reason)
|
|
993 |
self._run(membership_id, self['reason'] or '')
|
|
985 | 994 |
|
986 | 995 |
|
987 | 996 |
@command(membership_commands) |
... | ... | |
1014 | 1023 |
action = 'remove' |
1015 | 1024 |
|
1016 | 1025 |
|
1017 |
@command(membership_commands)
|
|
1018 |
class membership_join(_init_synnefo_astakosclient):
|
|
1026 |
@command(project_commands)
|
|
1027 |
class project_join(_init_synnefo_astakosclient):
|
|
1019 | 1028 |
"""Join a project""" |
1020 | 1029 |
|
1021 | 1030 |
@errors.generic.all |
... | ... | |
1024 | 1033 |
self.writeln(self.client.join_project(project_id)) |
1025 | 1034 |
|
1026 | 1035 |
def main(self, project_id): |
1027 |
super(membership_join, self)._run()
|
|
1036 |
super(project_join, self)._run()
|
|
1028 | 1037 |
self._run(project_id) |
1029 | 1038 |
|
1030 | 1039 |
|
1031 |
@command(membership_commands) |
|
1032 |
class membership_enroll(_init_synnefo_astakosclient): |
|
1033 |
"""Enroll somebody to a project you manage""" |
|
1040 |
@command(project_commands) |
|
1041 |
class project_enroll(_init_synnefo_astakosclient): |
|
1042 |
"""Enroll a user to a project""" |
|
1043 |
|
|
1044 |
arguments = dict(email=ValueArgument('User e-mail', '--email')) |
|
1045 |
required = ('email', ) |
|
1034 | 1046 |
|
1035 | 1047 |
@errors.generic.all |
1036 | 1048 |
@errors.user.astakosclient |
1037 | 1049 |
def _run(self, project_id, email): |
1038 | 1050 |
self.writeln(self.client.enroll_member(project_id, email)) |
1039 | 1051 |
|
1040 |
def main(self, project_id, email): |
|
1041 |
super(membership_enroll, self)._run() |
|
1042 |
self._run(project_id, email) |
|
1052 |
def main(self, project_id): |
|
1053 |
super(project_enroll, self)._run() |
|
1054 |
self._run(project_id, self['email']) |
Also available in: Unified diff