|
13 | 13 | (defcommand create (name args) |
14 | 14 | "Creates an LXC" |
15 | 15 | (destructuring-bind (&key base template) |
16 | | - (car args) |
| 16 | + args |
17 | 17 | (if base |
18 | 18 | (create-clone base name) |
19 | 19 | (create-base name template)))) |
|
22 | 22 | "Creates a clone of another LXC" |
23 | 23 | (let ((cli-base (adapt-arg base)) |
24 | 24 | (cli-name (adapt-arg name))) |
| 25 | + (format t "Cloning ~A..." cli-base) |
25 | 26 | (run |
26 | 27 | "lxc-clone" |
27 | 28 | "--orig" cli-base |
28 | 29 | "--new" cli-name) |
| 30 | + (format t " done.~%") |
29 | 31 | (init-lxc cli-name *hosts-file*))) |
30 | 32 |
|
31 | 33 | (defun create-base (name template) |
32 | 34 | "Creates an LXC from no base" |
33 | 35 | (let ((cli-name (adapt-arg name)) |
34 | 36 | (cli-template (adapt-arg template))) |
| 37 | + (format t "Creating ~A..." cli-name) |
35 | 38 | (run |
36 | 39 | "lxc-create" |
37 | 40 | "--name" cli-name |
38 | 41 | "-t" cli-template) |
| 42 | + (format t " done.~%") |
39 | 43 | (init-lxc cli-name *hosts-file*))) |
40 | 44 |
|
41 | 45 | (defcommand start (name &rest args) |
42 | 46 | "Starts an LXC" |
43 | 47 | (declare (ignore args)) |
44 | 48 | (let ((cli-name (adapt-arg name))) |
| 49 | + (format t "Starting ~A..." cli-name) |
45 | 50 | (run |
46 | 51 | "lxc-start" |
47 | | - "--name" cli-name))) |
| 52 | + "--name" cli-name) |
| 53 | + (format t " done.~%"))) |
48 | 54 |
|
49 | 55 | (defcommand stop (name &rest args) |
50 | 56 | "Stops an LXC" |
51 | 57 | (declare (ignore args)) |
52 | 58 | (let ((cli-name (adapt-arg name))) |
| 59 | + (format t "Stopping ~A..." cli-name) |
53 | 60 | (run |
54 | 61 | "lxc-stop" |
55 | | - "--name" cli-name))) |
| 62 | + "--name" cli-name) |
| 63 | + (format t " done.~%"))) |
56 | 64 |
|
57 | 65 | (defcommand ls (&rest args) |
58 | 66 | "Lists all the LXC" |
|
65 | 73 | "Destroys an LXC and its leftovers" |
66 | 74 | (declare (ignore args)) |
67 | 75 | (let ((cli-name (adapt-arg name))) |
| 76 | + (format t "Destroying ~A..." cli-name) |
68 | 77 | (run |
69 | 78 | "lxc-destroy" |
70 | 79 | "--name" cli-name) |
71 | | - (remove-lxc-leftovers cli-name))) |
| 80 | + (format t " done.~%") |
| 81 | + (format t "Removing leftovers...") |
| 82 | + (remove-lxc-leftovers cli-name) |
| 83 | + (format t " done.~%"))) |
72 | 84 |
|
73 | 85 | (defcommand package (name &rest args) |
74 | 86 | "Packages an LXC" |
|
86 | 98 | ".") |
87 | 99 | (format t "Created ~A~%" archive))) |
88 | 100 |
|
| 101 | +(defcommand deploy (name args) |
| 102 | + "Deploys an archive created by lxc-wrapper" |
| 103 | + (let* ((cli-name (adapt-arg name)) |
| 104 | + (lxc-path (merge-pathnames (concatenate 'string cli-name "/") |
| 105 | + *lxc-default-folder*))) |
| 106 | + (destructuring-bind (&key archive) |
| 107 | + args |
| 108 | + (run |
| 109 | + "mkdir" "-p" lxc-path) |
| 110 | + (format t "Deploying ~A..." cli-name) |
| 111 | + (run |
| 112 | + "tar" |
| 113 | + "xf" archive |
| 114 | + "-C" lxc-path) |
| 115 | + (fix-lxc-config cli-name lxc-path *lxc-config*) |
| 116 | + (format t " done.~%") |
| 117 | + (init-lxc cli-name *hosts-file*)))) |
89 | 118 | (defun adapt-arg (name) |
90 | 119 | "Adapts an argument to string" |
91 | 120 | (when (symbolp name) |
|
0 commit comments