}
if ($options['verbose']) {
    echo "parsing nodelist\n";
}
$nodes = vchamilo_parse_csv_nodelist($options['nodes'], $plugininstance);
if ($options['lint']) {
    ctrace("Lint mode:\n");
    print_object($nodes);
    die;
}
if (empty($nodes)) {
    cli_error('Node list empty');
}
ctrace('Starting generation');
// Get main admin for further replacement.
$admin = $DB->get_record('user', array('username' => 'admin'));
foreach ($nodes as $data) {
    ctrace('Making node ' . $data->root_web);
    if (!empty($data->template)) {
        ctrace('Using template ' . $data->template);
        if (!vchamilo_template_exists($data->template)) {
            ctrace('Template not found. Skipping node.');
            continue;
        }
    }
    if ($DB->get_record('vchamilo', array('root_web' => $data->root_web))) {
        ctrace('Node exists. skipping');
        continue;
    }
    $data->what = 'addinstance';
    $data->registeronly = false;
if ($options['verbose']) {
    echo "parsing nodelist\n";
}
$nodes = vchamilo_parse_csv_nodelist($options['nodes'], $plugininstance);
if ($options['lint']) {
    ctrace("Lint mode:\n");
    print_object($nodes);
    die;
}
if (empty($nodes)) {
    cli_error(get_string('cliemptynodelist', 'block_vmoodle'));
}
ctrace('Starting CLI processing');
foreach ($nodes as $n) {
    ctrace('Destroying node :' . $n->vhostname);
    if (!$DB->get_record('vchamilo', array('root_web' => $n->root_web))) {
        ctrace('Node does not exist. Skipping');
        continue;
    }
    /*
     * This launches automatically all steps of the controller.management.php script several times
     * with the "doadd" action and progressing in steps.
     */
    $action = "fulldeleteinstances";
    $automation = true;
    $return = (include $_configuration['root_sys'] . '/plugin/vchamilo/views/manage.controller.php');
    if ($interactive) {
        $input = readline("Continue (y/n|r) ?\n");
        if ($input == 'r' || $input == 'R') {
            $vmoodlestep--;
        } elseif ($input == 'n' || $input == 'N') {