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

Dataset fixes.

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