Revision 5106d1bc kamaki/cli/commands/astakos.py
b/kamaki/cli/commands/astakos.py | ||
---|---|---|
790 | 790 |
|
791 | 791 |
arguments = dict( |
792 | 792 |
specs_path=ValueArgument( |
793 |
'Specification file path (content must be in json)', '--spec-file') |
|
793 |
'Specification file (contents in json)', '--spec-file'), |
|
794 |
project_name=ValueArgument('Name the project', '--name'), |
|
795 |
owner_uuid=ValueArgument('Project owner', '--owner'), |
|
796 |
homepage_url=ValueArgument('Project homepage', '--homepage'), |
|
797 |
description=ValueArgument('Describe the project', '--description'), |
|
798 |
start_date=DateArgument('When to start the project', '--start-date'), |
|
799 |
end_date=DateArgument('When to end the project', '--end-date'), |
|
800 |
join_policy=PolicyArgument( |
|
801 |
'Set join policy (%s)' % ', '.join(PolicyArgument.policies), |
|
802 |
'--join-policy'), |
|
803 |
leave_policy=PolicyArgument( |
|
804 |
'Set leave policy (%s)' % ', '.join(PolicyArgument.policies), |
|
805 |
'--leave-policy'), |
|
806 |
resource_capacities=ProjectResourceArgument( |
|
807 |
'Set the member and project capacities for resources (repeatable) ' |
|
808 |
'e.g., --resource cyclades.cpu=1,5 means "members will have at ' |
|
809 |
'most 1 cpu but the project will have at most 5" To see all ' |
|
810 |
'resources: kamaki resource list', |
|
811 |
'--resource') |
|
794 | 812 |
) |
813 |
required = [ |
|
814 |
'specs_path', 'owner_uuid', 'homepage_url', 'description', |
|
815 |
'project_name', 'start_date', 'end_date', 'join_policy', |
|
816 |
'leave_policy', 'resource_capacities', ] |
|
795 | 817 |
|
796 | 818 |
@errors.generic.all |
797 | 819 |
@errors.user.astakosclient |
798 | 820 |
@apply_notification |
799 | 821 |
def _run(self, project_id): |
800 |
input_stream = open(abspath(self['specs_path'])) if ( |
|
801 |
self['specs_path']) else self._in |
|
802 |
specs = load(input_stream) |
|
822 |
specs = dict() |
|
823 |
if self['specs_path']: |
|
824 |
with open(abspath(self['specs_path'])) as f: |
|
825 |
specs = load(f) |
|
826 |
for key, arg in ( |
|
827 |
('name', self['project_name']), |
|
828 |
('owner', self['owner_uuid']), |
|
829 |
('homepage', self['homepage_url']), |
|
830 |
('description', self['description']), |
|
831 |
('start_date', self['start_date']), |
|
832 |
('end_date', self['end_date']), |
|
833 |
('join_policy', self['join_policy']), |
|
834 |
('leave_policy', self['leave_policy']), |
|
835 |
('resources', self['resource_capacities'])): |
|
836 |
if arg: |
|
837 |
specs[key] = arg |
|
838 |
|
|
803 | 839 |
self._print( |
804 |
self.client.modify_project(project_id, specs), |
|
805 |
self.print_dict) |
|
840 |
self.client.modify_project(project_id, specs), self.print_dict) |
|
806 | 841 |
|
807 | 842 |
def main(self, project_id): |
808 | 843 |
super(self.__class__, self)._run() |
Also available in: Unified diff