Commit 33fa8086 authored by Leigh Stoller's avatar Leigh Stoller

Differentiate imported image from local images.

parent 9304219b
......@@ -26,6 +26,7 @@ include_once("webtask.php");
include_once("imageid_defs.php");
include_once("osiddefs.php3");
include_once("node_defs.php");
include_once("instance_defs.php");
chdir("apt");
#
......@@ -89,15 +90,31 @@ function Do_GetInfo()
$pid = $image->pid();
$gid = $image->gid();
$name = $image->imagename();
if ($image->isdataset()) {
$domain .= ":${pid}";
if ($pid != $gid) {
$domain .= ":${gid}";
$urn = null;
if ($image->metadata_url()) {
if ($image->origin_urn() && $image->origin_name()) {
list ($auth,$type,$id) = Instance::ParseURN($image->origin_urn());
$urn = "urn:publicid:IDN+${auth}+";
if ($image->isdataset()) {
$urn .= "imdataset+" . $image->origin_name();
}
else {
$urn .= "image+" . $image->origin_name();
}
}
$urn = "urn:publicid:IDN+${domain}+imdataset+${name}";
}
else {
$urn = "urn:publicid:IDN+${domain}+image+${pid}//${name}";
if ($image->isdataset()) {
$domain .= ":${pid}";
if ($pid != $gid) {
$domain .= ":${gid}";
}
$urn = "urn:publicid:IDN+${domain}+imdataset+${name}";
}
else {
$urn = "urn:publicid:IDN+${domain}+image+${pid}//${name}";
}
}
$blob = array();
......@@ -128,8 +145,17 @@ function Do_GetInfo()
if ($embedded) {
$blob["version_url"] .= "&embedded=1";
}
$blob["version_file_url"] = "$TBBASE/image_metadata.php?uuid=$uuid";
$blob["image_file_url"] = "$TBBASE/image_metadata.php?uuid=$image_uuid";
#
# An imported image has a metadata_url and an imagefile_url.
#
if ($image->metadata_url()) {
$blob["metadata_url"] = $image->metadata_url();
$blob["imagefile_url"] = $image->imagefile_url();
}
else {
$blob["version_url"] = "$TBBASE/image_metadata.php?uuid=$uuid";
$blob["image_url"] = "$TBBASE/image_metadata.php?uuid=$image_uuid";
}
if (!$image->isdataset()) {
if ($image->architecture()) {
......
......@@ -314,17 +314,36 @@
<td>SHA1 Hash</td>
<td><%- fields.hash %></td>
</tr>
<% } %>
<% if (_.has(fields, "metadata_url")) { %>
<tr>
<td>Image UUID</td>
<td><%- fields.image_uuid %></td>
</tr>
<tr>
<td>Version UUID</td>
<td><%- fields.uuid %></td>
</tr>
<tr>
<td>Metadata URL</td>
<td><a href="<%= fields.metadata_url %>">https://...</a></td>
</tr>
<tr>
<td>Imagefile URL</td>
<td><a href="<%= fields.imagefile_url %>">https://...</a></td>
</tr>
<% } else { %>
<tr>
<td>Image UUID (URL)</td>
<td><%- fields.image_uuid %>
(<a href="<%= fields.image_file_url %>">https://...</a>)</td>
</tr>
<tr>
<td>Version UUID (URL)</td>
<td><%- fields.uuid %>
(<a href="<%= fields.version_file_url %>">https://...</a>)</td>
</tr>
<% } %>
<tr>
<td>Image UUID (URL)</td>
<td><%- fields.image_uuid %>
(<a href="<%= fields.image_file_url %>">https://...</a>)</td>
</tr>
<tr>
<td>Version UUID (URL)</td>
<td><%- fields.uuid %>
(<a href="<%= fields.version_file_url %>">https://...</a>)</td>
</tr>
<tr>
<td>ID</td>
<td><%- fields.imageid %></td>
......
......@@ -465,6 +465,9 @@ class Image
function hash() { return $this->field("hash"); }
function metadata_url() { return $this->field("metadata_url"); }
function imagefile_url() { return $this->field("imagefile_url"); }
function origin_uuid() { return $this->field("origin_uuid"); }
function origin_name() { return $this->field("origin_name"); }
function origin_urn() { return $this->field("origin_urn"); }
function logfileid() { return $this->field("logfileid"); }
function noexport() { return $this->field("noexport"); }
function ready() { return $this->field("ready"); }
......
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