#!/usr/bin/perl -n
BEGIN {
  print <<'EOF';
<%
from invirt.config import structs as cfg
%>
EOF
}

s/^node.startup = manual/node.startup = automatic/m;
# mako just generally doesn't deal well with lines that start with
# hashes, so we'll strip them
#
# And empty lines too, just for cleanliness
s/^#.*$//m;
print unless /^$/;

END {
  print <<'EOF';
node.session.auth.authmethod = CHAP
node.session.auth.username = ${cfg.iscsi.username}
node.session.auth.password = ${cfg.iscsi.password}

discovery.sendtargets.auth.authmethod = CHAP
discovery.sendtargets.auth.username = ${cfg.iscsi.username}
discovery.sendtargets.auth.password = ${cfg.iscsi.password}
EOF
}
