Commit 1f0cdf67 authored by Leigh B Stoller's avatar Leigh B Stoller

Dataset fixes.

parent 3059271b
...@@ -145,7 +145,8 @@ sub DoCreate() ...@@ -145,7 +145,8 @@ sub DoCreate()
{ {
my $usage = sub { my $usage = sub {
print STDERR "Usage: manage_dataset create ". print STDERR "Usage: manage_dataset create ".
"[-t type] [-f fstype] [-e expiration] -s size pid/name\n"; "[-t type] [-f fstype] [-e expiration] [-p privacy] ".
"-s size pid/name\n";
exit(-1); exit(-1);
}; };
my $aggregate_urn = "urn:publicid:IDN+apt.emulab.net+authority+cm"; my $aggregate_urn = "urn:publicid:IDN+apt.emulab.net+authority+cm";
...@@ -153,11 +154,12 @@ sub DoCreate() ...@@ -153,11 +154,12 @@ sub DoCreate()
my $errmsg; my $errmsg;
my $pid; my $pid;
my $expires; my $expires;
my $privacy = "private";
my $size; my $size;
my $type = "stdataset"; my $type = "stdataset";
my $fstype; my $fstype;
my $optlist = "ds:t:e:f:w:"; my $optlist = "ds:t:e:f:w:p:";
my %options = (); my %options = ();
if (! getopts($optlist, \%options)) { if (! getopts($optlist, \%options)) {
&$usage(); &$usage();
...@@ -175,6 +177,11 @@ sub DoCreate() ...@@ -175,6 +177,11 @@ sub DoCreate()
&$usage() &$usage()
if ($fstype !~ /^(ext2|ext3|ext4|ufs|ufs2)$/); if ($fstype !~ /^(ext2|ext3|ext4|ufs|ufs2)$/);
} }
if (defined($options{"p"})) {
$privacy = $options{"p"};
&$usage()
if ($privacy !~ /^(private|shared|public)$/);
}
if (defined($options{"s"})) { if (defined($options{"s"})) {
if ($options{"s"} =~ /^(\d+)$/) { if ($options{"s"} =~ /^(\d+)$/) {
$size = $1; $size = $1;
...@@ -236,6 +243,12 @@ sub DoCreate() ...@@ -236,6 +243,12 @@ sub DoCreate()
if (defined($fstype)); if (defined($fstype));
$blob->{"expires"} = TBDateStringLocal($expires) $blob->{"expires"} = TBDateStringLocal($expires)
if (defined($expires)); if (defined($expires));
if ($privacy eq "shared") {
$blob->{'shared'} = 1;
}
elsif ($privacy eq "public") {
$blob->{'public'} = 1;
}
my $dataset = APT_Dataset->Create($blob); my $dataset = APT_Dataset->Create($blob);
if (!defined($dataset)) { if (!defined($dataset)) {
......
...@@ -118,13 +118,13 @@ function Do_CreateDataSet() ...@@ -118,13 +118,13 @@ function Do_CreateDataSet()
$command .= " -s " . $formfields["dataset_size"]; $command .= " -s " . $formfields["dataset_size"];
} }
# Permission bits. # Permission bits.
if ($formfields["dataset_who"] != "public" || if ($formfields["dataset_who"] != "public" &&
$formfields["dataset_who"] != "shared" || $formfields["dataset_who"] != "shared" &&
$formfields["dataset_who"] != "private") { $formfields["dataset_who"] != "private") {
$errors["dataset_who"] = "Illegal value"; $errors["dataset_who"] = "Illegal value";
} }
else { else {
$command .= " -f " . $formfields["dataset_fstype"]; $command .= " -p " . $formfields["dataset_who"];
} }
if (count($errors)) { if (count($errors)) {
SPITAJAX_ERROR(2, $errors); SPITAJAX_ERROR(2, $errors);
......
...@@ -103,6 +103,8 @@ class Dataset ...@@ -103,6 +103,8 @@ class Dataset
function size() { return $this->field("size"); } function size() { return $this->field("size"); }
function locked() { return $this->field("locked"); } function locked() { return $this->field("locked"); }
function locker_pid() { return $this->field("locker_pid"); } function locker_pid() { return $this->field("locker_pid"); }
function ispublic() { return $this->field("public"); }
function shared() { return $this->field("shared"); }
function islocal() { return 0; } function islocal() { return 0; }
# #
...@@ -121,6 +123,18 @@ class Dataset ...@@ -121,6 +123,18 @@ class Dataset
return 0; return 0;
} }
#
# Return a privacy string (public,shared,private).
#
function PrivacyString() {
if ($this->shared())
return "shared";
elseif ($this->ispublic())
return "public";
else
return "private";
}
# #
# Form a URN for the dataset. # Form a URN for the dataset.
# #
......
...@@ -91,6 +91,7 @@ $fields["dataset_lastused"] = ($dataset->last_used() ? ...@@ -91,6 +91,7 @@ $fields["dataset_lastused"] = ($dataset->last_used() ?
$fields["dataset_uuid"] = $uuid; $fields["dataset_uuid"] = $uuid;
$fields["dataset_idx"] = $dataset->idx(); $fields["dataset_idx"] = $dataset->idx();
$fields["dataset_urn"] = $dataset->URN(); $fields["dataset_urn"] = $dataset->URN();
$fields["dataset_who"] = $dataset->PrivacyString();
# #
# The state is a bit of a problem, since local leases do not have # The state is a bit of a problem, since local leases do not have
......
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
<div class='format-me' data-key='dataset_who'> <div class='format-me' data-key='dataset_who'>
<div class='radio'> <div class='radio'>
<label> <label>
<input type='radio' name='formfields[dataset_who]' <input type='radio' name='dataset_who'
id='dataset_who_public' id='dataset_who_public'
<% if (formfields.dataset_who == "public") { <% if (formfields.dataset_who == "public") {
%>checked<% } %> %>checked<% } %>
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
</div> </div>
<div class='radio'> <div class='radio'>
<label> <label>
<input type='radio' name='formfields[dataset_who]' <input type='radio' name='dataset_who'
id='dataset_who_registered' id='dataset_who_registered'
<% if (formfields.dataset_who == "shared") { <% if (formfields.dataset_who == "shared") {
%>checked<% } %> %>checked<% } %>
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
</div> </div>
<div class='radio'> <div class='radio'>
<label> <label>
<input type='radio' name='formfields[dataset_who]' <input type='radio' name='dataset_who'
id='dataset_who_private' id='dataset_who_private'
<% if (formfields.dataset_who == "private") { <% if (formfields.dataset_who == "private") {
%>checked<% } %> %>checked<% } %>
......
...@@ -59,6 +59,10 @@ ...@@ -59,6 +59,10 @@
<td>State</td> <td>State</td>
<td><%- formfields.dataset_state %></td> <td><%- formfields.dataset_state %></td>
</tr> </tr>
<tr>
<td>Privacy</td>
<td><%- formfields.dataset_who %></td>
</tr>
<tr> <tr>
<td>URN</td> <td>URN</td>
<td><%- formfields.dataset_urn %></td> <td><%- formfields.dataset_urn %></td>
......
...@@ -150,6 +150,14 @@ class Lease ...@@ -150,6 +150,14 @@ class Lease
} }
return 0; return 0;
} }
#
# Return a privacy string (public,shared,private).
#
function PrivacyString() {
return "private";
}
# #
# Form a URN for the dataset. # Form a URN for the dataset.
# #
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment