Revision d62cba24
b/kamaki/cli/commands/cyclades.py | ||
---|---|---|
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 | 34 |
from base64 import b64encode |
35 |
from os.path import exists |
|
35 |
from os.path import exists, expanduser
|
|
36 | 36 |
from io import StringIO |
37 | 37 |
from pydoc import pager |
38 | 38 |
|
... | ... | |
67 | 67 |
' [server-path=]SERVER_PATH: destination location inside server Image', |
68 | 68 |
' [owner=]OWNER: virtual servers user id for the remote file', |
69 | 69 |
' [group=]GROUP: virtual servers group id or name for the remote file', |
70 |
' [mode=]MODE: permission in octal (e.g., 0777 or o+rwx)',
|
|
70 |
' [mode=]MODE: permission in octal (e.g., 0777)', |
|
71 | 71 |
'e.g., -p /tmp/my.file,owner=root,mode=0777'] |
72 | 72 |
|
73 | 73 |
|
... | ... | |
351 | 351 |
details=howto_personality) |
352 | 352 |
|
353 | 353 |
self._value.append(dict(path=path)) |
354 |
with open(path) as f:
|
|
354 |
with open(expanduser(path)) as f:
|
|
355 | 355 |
self._value[i]['contents'] = b64encode(f.read()) |
356 | 356 |
for k, v in self.terms[1:]: |
357 | 357 |
try: |
... | ... | |
361 | 361 |
self._value[i][v] = termlist.pop(0) |
362 | 362 |
except IndexError: |
363 | 363 |
continue |
364 |
if k in ('mode', ) and self._value[i][v]: |
|
365 |
try: |
|
366 |
self._value[i][v] = int(self._value[i][v], 8) |
|
367 |
except ValueError as ve: |
|
368 |
raise CLIInvalidArgument( |
|
369 |
'Personality mode must be in octal', details=[ |
|
370 |
'%s' % ve]) |
|
364 | 371 |
|
365 | 372 |
|
366 | 373 |
@command(server_cmds) |
Also available in: Unified diff