Remove all entry points to modify machines

[?]
Mar 4, 2013, 9:05 PM
JOVVHIJXYJN3RNRXZHPMHYHMIA3KRCL4UCJ5RM6S6ZOZY66LKKHQC

Dependencies

  • [2] LSZLZHJY Allow users to edit their own settings
  • [3] SGNXIOI4 Hydra/32: Add option to force evaluation of a certain jobset via web interface (for admins only)
  • [4] CQTN62OH Die tabs die
  • [5] XDDCO6CH * hydra: add dependency list with links to logfiles
  • [6] QT4FO2HP refactored admin controller, using chains, to avoid using requireadmin on each endpoint
  • [7] R2PON6R7 Allow non-admin users to see the machine status page
  • [8] UICHT2PS Add a search feature
  • [9] IQ5NESOO machines: Read /etc/nix.machines instead of using the BuildMachines table
  • [10] PALLP4UY is not in hydra-server's scope
  • [11] WRIU3S5E * UI for cloning builds (not functional yet).
  • [12] D5QIOJGP * Move everything up one directory.
  • [13] ZWCTAZGL added newsitems, added some admin options to clear various caches.
  • [14] SMTMFEKE hydra: add missing templates
  • [15] ODNCGFQ5 * Improved the navigation bar: don't include all projects (since that
  • [16] 67NFGL7D add links in admin page to clear queue (all non-running builds, and all non-running old (non-current) builds)
  • [17] MOX7XJ2E Merge the BuildSchedulingInfo table into the Builds table
  • [18] JARRBLZD Bootstrapify the Hydra forms (except the project and jobset edit pages)
  • [19] P5X4P6VK * Renaming "release sets" to "views" (not finished yet). Having
  • [20] IK2KI6KZ Add create-user action that was mostly present already.
  • [21] 36M6DGIT Show the runtime/build dependencies in the build page
  • [22] 2BUX775I * More release -> view.
  • [23] RBNQKATL * Adding persistant releases. A release is a named set of builds.
  • [24] D5ZR3ZY6 hydra: missing property
  • [25] RXSEJG7W Do not delete builds when clearing the queue. Fixes #8.
  • [26] JY7BXXOP Split viewing and editing a project
  • [27] Q5WS4WKQ hydra: add comment that file is generated by hydra to /etc/nix.machines
  • [28] QL55ECJ6 - adapted ui for hydra, more in line with nixos.org website
  • [29] VH5ZABDR Add a page to show the latest evaluations for the entire server
  • [30] SZYDW2DG hydra: added some user admin
  • [31] NEQ4BISO Add bootstrap.zip
  • [32] TRDGNILT Remove unused file
  • [33] QTC3SYBM Jobset page: Load the jobs and status tabs on demand
  • [34] 6KJXJB7N qualify ordery_by clauses when necessary, remove unnecessary order_by's, reported by Ludo, resulted in errors in sqlite
  • [35] OX6NYJDV Split viewing and editing a jobset
  • [36] EFWN7JBV * Added a status page that shows all the currently executing build steps.
  • [37] 75XUS62Y * Added a page to quickly see all failed builds and failed evaluations
  • [38] FV2M6MOT hydra: use autoconf/-make
  • [39] 5DSDXORD hydra: missing plain.tt
  • [40] U4TD3AIQ Add support for viewing jobset evaluations
  • [41] PZL3SZM3 Give every page a consistent title
  • [42] KXGOUX7P * Creating releases.
  • [43] OR5SJ42Y Show releases in a tab on the project page
  • [44] 3JBUMW3E forgot to commit a file
  • [45] PP4LPADG hydra: buildmachine disabled by default, add some default constraints
  • [46] 3PNG7NIB Remove trailing whitespace
  • [47] 6FRLEP4P first try for timeline of last 24 hours in hydra
  • [48] RSEGBU6C Hydra/20: Jobset clone feature
  • [49] AS2OXLRM * Editing releases.
  • [50] SMCOU72F hydra: add some admin for adding/enabling/etc build machines

Change contents

  • edit in src/lib/Hydra/Controller/Admin.pm at line 14
    [3.26][3.26:62](),[3.62][3.0:43](),[3.43][3.0:1](),[3.1][3.85:149](),[3.85][3.85:149](),[3.149][3.540:983](),[3.983][3.568:597](),[3.568][3.568:597](),[3.597][3.2:3](),[3.3][3.597:716](),[3.597][3.597:716](),[3.30][3.0:1](),[3.716][3.0:1](),[3.155][3.0:1](),[3.1][3.717:849](),[3.849][3.2:27](),[3.27][3.879:882](),[3.879][3.879:882](),[3.882][3.4:5]()
    sub nixMachines {
    my ($c) = @_;
    my $result = "# GENERATED BY HYDRA\n";
    foreach my $machine ($c->model("DB::BuildMachines")->all) {
    if($machine->enabled) {
    $result = $result . $machine->username . '@'. $machine->hostname . ' ';
    foreach my $system ($machine->buildmachinesystemtypes) {
    $result = $result . $system->system .',';
    }
    chop $result;
    $result = $result . ' '. $machine->ssh_key . ' ' . $machine->maxconcurrent . ' '. $machine->speedfactor . ' ' . $machine->options . "\n";
    }
    }
    return $result;
    }
    sub saveNixMachines {
    my ($c) = @_;
    die("File not writable: /etc/nix.machines") if ! -w "/etc/nix.machines" ;
    open (NIXMACHINES, '>/etc/nix.machines') or die("Could not write to /etc/nix.machines");
    print NIXMACHINES nixMachines($c);
    close (NIXMACHINES);
    }
  • edit in src/lib/Hydra/Controller/Admin.pm at line 32
    [3.1981][3.380:383](),[3.383][3.1984:2287](),[3.1984][3.1984:2287]()
    }
    sub machine : Chained('admin') PathPart('machine') CaptureArgs(1) {
    my ($self, $c, $machineName) = @_;
    requireAdmin($c);
    my $machine = $c->model('DB::BuildMachines')->find($machineName)
    or notFound($c, "Machine $machineName doesn't exist.");
    $c->stash->{machine} = $machine;
  • edit in src/lib/Hydra/Controller/Admin.pm at line 35
    [3.385][3.2288:2549](),[3.283][3.2288:2549](),[3.2549][3.386:387](),[3.387][3.2549:2712](),[3.2549][3.2549:2712](),[3.2712][3.388:575](),[3.575][3.2759:2767](),[3.2759][3.2759:2767](),[3.2767][3.1793:1794](),[3.581][3.2767:2792](),[3.1794][3.2767:2792](),[3.2767][3.2767:2792](),[3.2792][3.1795:1796](),[3.587][3.2792:2837](),[3.1796][3.2792:2837](),[3.2792][3.2792:2837](),[3.2837][3.588:589](),[3.589][3.2837:2857](),[3.2837][3.2837:2857](),[3.2857][3.590:618](),[3.618][3.2882:3210](),[3.2882][3.2882:3210](),[3.3210][3.0:63](),[3.63][3.279:339](),[3.339][3.3272:3631](),[3.3272][3.3272:3631](),[3.3631][3.340:341](),[3.341][3.3637:3801](),[3.3637][3.3637:3801](),[3.3801][3.64:94](),[3.94][3.3801:3899](),[3.3801][3.3801:3899](),[3.3899][3.984:1111](),[3.349][3.4012:4100](),[3.1111][3.4012:4100](),[3.4012][3.4012:4100](),[3.4100][3.350:356](),[3.356][3.4109:4111](),[3.4109][3.4109:4111](),[3.4111][3.619:620](),[3.620][3.4111:4235](),[3.4111][3.4111:4235](),[3.4235][3.357:358](),[3.358][3.4240:4578](),[3.4240][3.4240:4578](),[3.4578][3.359:360](),[3.360][3.0:59](),[3.4583][3.0:59](),[3.59][3.4647:4711](),[3.4647][3.4647:4711](),[3.4711][3.361:362](),[3.362][3.4716:4860](),[3.4716][3.4716:4860](),[3.4860][3.60:97](),[3.97][3.4908:4916](),[3.4908][3.4908:4916](),[3.4916][3.98:123](),[3.123][3.4916:4961](),[3.4916][3.4916:4961](),[3.5076][3.5076:5077](),[3.5239][3.5239:5453](),[3.5453][3.621:622](),[3.622][2.4:5](),[2.5][3.5454:5668](),[3.5454][3.5454:5668](),[3.5668][3.0:2](),[3.2][3.623:624](),[3.624][3.2:3](),[3.2][3.2:3]()
    sub machine_edit : Chained('machine') PathPart('edit') Args(0) {
    my ($self, $c) = @_;
    $c->stash->{template} = 'machine.tt';
    $c->stash->{systemtypes} = [$c->model('DB::SystemTypes')->search({}, {order_by => "system"})];
    $c->stash->{edit} = 1;
    }
    sub machine_edit_submit : Chained('machine') PathPart('submit') Args(0) {
    my ($self, $c) = @_;
    requirePost($c);
    txn_do($c->model('DB')->schema, sub {
    if (($c->request->params->{submit} || "") eq "delete") {
    $c->stash->{machine}->delete;
    } else {
    updateMachine($c, $c->stash->{machine});
    }
    });
    saveNixMachines($c);
    $c->res->redirect("/admin/machines");
    }
    sub updateMachine {
    my ($c, $machine) = @_;
    my $hostname = trim $c->request->params->{"hostname"};
    my $username = trim $c->request->params->{"username"};
    my $maxconcurrent = trim $c->request->params->{"maxconcurrent"};
    my $speedfactor = trim $c->request->params->{"speedfactor"};
    my $ssh_key = trim $c->request->params->{"ssh_key"};
    my $options = trim $c->request->params->{"options"};
    my $systems = $c->request->params->{"systems"} ;
    error($c, "Invalid or empty username.") if $username eq "";
    error($c, "Max concurrent builds should be an integer > 0.") if $maxconcurrent eq "" || ! $maxconcurrent =~ m/[0-9]+/;
    error($c, "Speed factor should be an integer > 0.") if $speedfactor eq "" || ! $speedfactor =~ m/[0-9]+/;
    error($c, "Invalid or empty SSH key.") if $ssh_key eq "";
    $machine->update(
    { username => $username
    , maxconcurrent => $maxconcurrent
    , speedfactor => $speedfactor
    , ssh_key => $ssh_key
    , options => $options
    });
    $machine->buildmachinesystemtypes->delete_all;
    if(ref($systems) eq 'ARRAY') {
    for my $s (@$systems) {
    $machine->buildmachinesystemtypes->create({ system => $s}) ;
    }
    } else {
    $machine->buildmachinesystemtypes->create({ system => $systems}) ;
    }
    }
    sub create_machine : Chained('admin') PathPart('create-machine') Args(0) {
    my ($self, $c) = @_;
    requireAdmin($c);
    $c->stash->{template} = 'machine.tt';
    $c->stash->{systemtypes} = [$c->model('DB::SystemTypes')->search({}, {order_by => "system"})];
    $c->stash->{edit} = 1;
    $c->stash->{create} = 1;
    }
    sub create_machine_submit : Chained('admin') PathPart('create-machine/submit') Args(0) {
    my ($self, $c) = @_;
    requireAdmin($c);
    my $hostname = trim $c->request->params->{"hostname"};
    error($c, "Invalid or empty hostname.") if $hostname eq "";
    txn_do($c->model('DB')->schema, sub {
    my $machine = $c->model('DB::BuildMachines')->create(
    { hostname => $hostname });
    updateMachine($c, $machine);
    });
    saveNixMachines($c);
    $c->res->redirect("/admin/machines");
    }
    sub machine_enable : Chained('machine') PathPart('enable') Args(0) {
    my ($self, $c) = @_;
    $c->stash->{machine}->update({ enabled => 1});
    saveNixMachines($c);
    $c->res->redirect("/admin/machines");
    }
    sub machine_disable : Chained('machine') PathPart('disable') Args(0) {
    my ($self, $c) = @_;
    $c->stash->{machine}->update({ enabled => 0});
    saveNixMachines($c);
    $c->res->redirect("/admin/machines");
    }
  • file deletion: machine.tt (----------)
    [3.1486][3.2437:2471](),[3.2471][3.1:1]()
    [% PROCESS common.tt %]
    <form class="form-horizontal" method="post"
    action="[% IF create %][% c.uri_for('/admin/create-machine/submit') %][% ELSE %][% c.uri_for('/admin/machine' machine.hostname 'submit') %][% END %]">
    <fieldset>
    [% IF create %]
    <div class="control-group">
    <label class="control-label">Host name</label>
    <div class="controls">
    <input type="text" class="span3" name="hostname" value="[% machine.hostname %]"></input>
    </div>
    </div>
    [% END %]
    <div class="control-group">
    <label class="control-label">User name</label>
    <div class="controls">
    <input type="text" class="span3" name="username" value="[% machine.username %]"></input>
    </div>
    </div>
    <div class="control-group">
    <label class="control-label">SSH key location</label>
    <div class="controls">
    <input type="text" class="span3" name="ssh_key" value="[% machine.ssh_key %]"></input>
    </div>
    </div>
    <div class="control-group">
    <label class="control-label">Options</label>
    <div class="controls">
    <input type="text" class="span3" name="options" value="[% machine.options %]"></input>
    </div>
    </div>
    <div class="control-group">
    <label class="control-label">Max concurrent builds</label>
    <div class="controls">
    <input type="text" class="span3" name="maxconcurrent" value="[% machine.maxconcurrent %]"></input>
    </div>
    </div>
    <div class="control-group">
    <label class="control-label">Speed factor</label>
    <div class="controls">
    <input type="text" class="span3" name="speedfactor" value="[% machine.speedfactor %]"></input>
    </div>
    </div>
    <div class="control-group">
    <label class="control-label">Systems</label>
    <div class="controls">
    <select class="span3" multiple="1" name="systems">
    [% FOREACH s IN systemtypes;
    checked = false;
    FOREACH ms IN machine.buildmachinesystemtypes;
    checked = ms.system == s.system;
    BREAK IF checked;
    END %]
    <option value="[% s.system %]" [% IF checked %]selected="1"[% END %]>[% s.system %]</option>
    [% END %]
    </select>
    </div>
    </div>
    <div class="form-actions">
    <button type="submit" class="btn btn-primary">
    <i class="icon-ok icon-white"></i>
    [%IF create %]Create[% ELSE %]Apply changes[% END %]
    </button>
    [% IF !create %]
    <button id="delete-machine" type="submit" class="btn btn-danger" name="submit" value="delete">
    <i class="icon-trash icon-white"></i>
    Delete this machine
    </button>
    <script type="text/javascript">
    $("#delete-machine").click(function() {
    return confirm("Are you sure you want to delete this machine?");
    });
    </script>
    [% END %]
    </div>
    </fieldset>
    [% END %]
    [% WRAPPER layout.tt title=(create ? "New machine" : "Machine $machine.hostname") %]