[PATCH RFC] sysprep:add logging feature
Hi Rich, What I felt at using virt-sysprep is that all things are done in silent and there is no log what's done. Please consider to add logging feature what was done at virt-sysprep. For example, deleted /var/log/utmp deleted /etc/..... modified /etc/sysconfing/network... ... What do you think? Thanks, Wanlong Gao Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> --- sysprep/sysprep_operation_cron_spool.ml | 2 ++ sysprep/sysprep_operation_dhcp_client_state.ml | 2 ++ sysprep/sysprep_operation_dhcp_server_state.ml | 2 ++ sysprep/sysprep_operation_hostname.ml | 2 ++ 4 files changed, 8 insertions(+) diff --git a/sysprep/sysprep_operation_cron_spool.ml b/sysprep/sysprep_operation_cron_spool.ml index e67688b..cec18e0 100644 --- a/sysprep/sysprep_operation_cron_spool.ml +++ b/sysprep/sysprep_operation_cron_spool.ml @@ -16,12 +16,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) +open Printf open Sysprep_operation module G = Guestfs let cron_spool_perform g root = Array.iter g#rm_rf (g#glob_expand "/var/spool/cron/*"); + eprintf "Deleted /var/spool/cron/*\n"; [] let cron_spool_op = { diff --git a/sysprep/sysprep_operation_dhcp_client_state.ml b/sysprep/sysprep_operation_dhcp_client_state.ml index e3e87cb..18415c5 100644 --- a/sysprep/sysprep_operation_dhcp_client_state.ml +++ b/sysprep/sysprep_operation_dhcp_client_state.ml @@ -16,6 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) +open Printf open Sysprep_operation module G = Guestfs @@ -27,6 +28,7 @@ let dhcp_client_state_perform g root = fun glob -> Array.iter g#rm_rf (g#glob_expand glob) ) [ "/var/lib/dhclient/*"; "/var/lib/dhcp/*" (* RHEL 3 *) ] ); + eprintf "Deleted /var/lib/dhclient/* /var/lib/dhcp/*\n"; [] let dhcp_client_state_op = { diff --git a/sysprep/sysprep_operation_dhcp_server_state.ml b/sysprep/sysprep_operation_dhcp_server_state.ml index c5251ce..87cb2ed 100644 --- a/sysprep/sysprep_operation_dhcp_server_state.ml +++ b/sysprep/sysprep_operation_dhcp_server_state.ml @@ -16,12 +16,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) +open Printf open Sysprep_operation module G = Guestfs let dhcp_server_state_perform g root = Array.iter g#rm_rf (g#glob_expand "/var/lib/dhcpd/*"); + eprintf "Deleted /var/lib/dhcpd/*\n"; [] let dhcp_server_state_op = { diff --git a/sysprep/sysprep_operation_hostname.ml b/sysprep/sysprep_operation_hostname.ml index 1472a1c..6caf8d7 100644 --- a/sysprep/sysprep_operation_hostname.ml +++ b/sysprep/sysprep_operation_hostname.ml @@ -42,10 +42,12 @@ let hostname_perform g root = String.concat "\n" lines ^ sprintf "\nHOSTNAME=%s\n" !hostname in g#write filename file; + eprintf "Modified HOSTNAME to %s\n" !hostname; [ `Created_files ] | "linux", ("debian"|"ubuntu") -> g#write "/etc/hostname" !hostname; + eprintf "Modified HOSTNAME to %s\n" !hostname; [ `Created_files ] | _ -> [] -- 1.7.10.rc3
On Tue, Apr 03, 2012 at 04:20:28PM +0800, Wanlong Gao wrote:
Hi Rich,
What I felt at using virt-sysprep is that all things are done in silent and there is no log what's done. Please consider to add logging feature what was done at virt-sysprep. For example,
If we do logging, let's allow it to be enabled and disabled on the command line, and add a generic "log" function to utils.ml. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
On 04/03/2012 04:45 PM, Richard W.M. Jones wrote:
On Tue, Apr 03, 2012 at 04:20:28PM +0800, Wanlong Gao wrote:
Hi Rich,
What I felt at using virt-sysprep is that all things are done in silent and there is no log what's done. Please consider to add logging feature what was done at virt-sysprep. For example,
If we do logging, let's allow it to be enabled and disabled on the command line, and add a generic "log" function to utils.ml.
sure thing, will follow your suggestion. Thanks, Wanlong Gao
Rich.
On 04/03/2012 04:45 PM, Richard W.M. Jones wrote:
On Tue, Apr 03, 2012 at 04:20:28PM +0800, Wanlong Gao wrote:
Hi Rich,
What I felt at using virt-sysprep is that all things are done in silent and there is no log what's done. Please consider to add logging feature what was done at virt-sysprep. For example,
If we do logging, let's allow it to be enabled and disabled on the command line, and add a generic "log" function to utils.ml.
what I'm going to do and what we most interested in is, - external guest fish script. - homedir .ssh directroy (It's better if virt-sysprep can prepare a new key for copied guest.) - /var/run files - modify file system's UUID to be an unique. Other than that, I think following should be removed.. - .bash_history file - delete user accounts (should be optional??) - add/modify user accounts(optional) - What do you think Rich? Thanks, Wanlong Gao
Rich.
On Tue, Apr 03, 2012 at 04:54:59PM +0800, Wanlong Gao wrote:
On 04/03/2012 04:45 PM, Richard W.M. Jones wrote:
On Tue, Apr 03, 2012 at 04:20:28PM +0800, Wanlong Gao wrote:
Hi Rich,
What I felt at using virt-sysprep is that all things are done in silent and there is no log what's done. Please consider to add logging feature what was done at virt-sysprep. For example,
If we do logging, let's allow it to be enabled and disabled on the command line, and add a generic "log" function to utils.ml.
what I'm going to do and what we most interested in is,
- external guest fish script.
Does the new --script option do what you want? Note it's a shell script, not a guestfish script (but a shell script should be more flexible). http://libguestfs.org/virt-sysprep.1.html#script
- homedir .ssh directroy (It's better if virt-sysprep can prepare a new key for copied guest.) - /var/run files
This would be simple, *except* that you need to avoid deleting /var/run/lock.
- modify file system's UUID to be an unique.
Not hard, but complicated to ensure that all of the places that the UUID is used have been updated (/etc/fstab obviously, but maybe there are other places).
Other than that, I think following should be removed.. - .bash_history file - delete user accounts (should be optional??) - add/modify user accounts(optional) -
Agreed. I think most of these are in the TODO file, they just need doing ... Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
On 04/03/2012 05:09 PM, Richard W.M. Jones wrote:
On Tue, Apr 03, 2012 at 04:54:59PM +0800, Wanlong Gao wrote:
On 04/03/2012 04:45 PM, Richard W.M. Jones wrote:
On Tue, Apr 03, 2012 at 04:20:28PM +0800, Wanlong Gao wrote:
Hi Rich,
What I felt at using virt-sysprep is that all things are done in silent and there is no log what's done. Please consider to add logging feature what was done at virt-sysprep. For example,
If we do logging, let's allow it to be enabled and disabled on the command line, and add a generic "log" function to utils.ml.
what I'm going to do and what we most interested in is,
- external guest fish script.
Does the new --script option do what you want? Note it's a shell script, not a guestfish script (but a shell script should be more flexible).
yes, this TODO is listed before you rewrite the sysprep.
http://libguestfs.org/virt-sysprep.1.html#script
- homedir .ssh directroy (It's better if virt-sysprep can prepare a new key for copied guest.) - /var/run files
This would be simple, *except* that you need to avoid deleting /var/run/lock.
- modify file system's UUID to be an unique.
Not hard, but complicated to ensure that all of the places that the UUID is used have been updated (/etc/fstab obviously, but maybe there are other places).
Other than that, I think following should be removed.. - .bash_history file - delete user accounts (should be optional??) - add/modify user accounts(optional) -
Agreed. I think most of these are in the TODO file, they just need doing ...
thanks for your suggestions, if you think any one is difficult to implement, please help doing since I'm not familiar with Ocaml. ;) Thanks, Wanlong Gao
Rich.
On Tue, Apr 03, 2012 at 07:07:20PM +0800, Wanlong Gao wrote:
thanks for your suggestions, if you think any one is difficult to implement, please help doing since I'm not familiar with Ocaml. ;)
Luckily it's fairly easy. There is a good book (in English): http://www.cs.caltech.edu/courses/cs134/cs134b/book.pdf http://main.metaprl.org/jyh/publications.html Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
On 04/03/2012 08:01 PM, Richard W.M. Jones wrote:
On Tue, Apr 03, 2012 at 07:07:20PM +0800, Wanlong Gao wrote:
thanks for your suggestions, if you think any one is difficult to implement, please help doing since I'm not familiar with Ocaml. ;)
Luckily it's fairly easy. There is a good book (in English):
http://www.cs.caltech.edu/courses/cs134/cs134b/book.pdf http://main.metaprl.org/jyh/publications.html
Thank you very much Rich. :-D Wanlong Gao
Rich.
participants (2)
-
Richard W.M. Jones -
Wanlong Gao