Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
63b8516e
Commit
63b8516e
authored
Jun 06, 2017
by
Leigh B Stoller
Browse files
More work on issue
#269
; push/pull deprecation info to/from image
server. Not sure what to do with it yet, need to get with Jon.
parent
bab98782
Changes
4
Hide whitespace changes
Inline
Side-by-side
protogeni/lib/GeniIMS.pm.in
View file @
63b8516e
...
...
@@ -321,6 +321,26 @@ sub VerifyBlob($)
}
return
GeniResponse
->
MalformedArgsResponse
(
"Illegal created"
)
if
(
!defined(str2time($blob->{'created'})));
#
Another
date
,
optional
if
(
exists
($
blob
->{
'deprecated'
}))
{
if
(
ref
($
blob
->{
'deprecated'
})
eq
'Frontier::RPC2::DateTime::ISO8601'
)
{
$
blob
->{
'deprecated'
}
=
$
blob
->{
'deprecated'
}->
value
;
}
return
GeniResponse
->
MalformedArgsResponse
(
"Illegal deprecated date"
)
if
(
!defined(str2time($blob->{'deprecated'})));
return
GeniResponse
->
MalformedArgsResponse
(
"Malformed: "
.
"deprecated_iserror"
)
if
(
exists
($
blob
->{
"deprecated_iserror"
})
&&
$
blob
->{
"deprecated_iserror"
}
!~ /^\d+$/);
return
GeniResponse
->
MalformedArgsResponse
(
"Malformed: "
.
"deprecated_message"
)
if
(
exists
($
blob
->{
"deprecated_message"
})
&&
!TBcheck_dbslot($blob->{'deprecated_message'},
"default"
,
'tinytext'
,
TBDB_CHECKDBSLOT_WARN
|
TBDB_CHECKDBSLOT_ERROR
));
}
return
GeniResponse
->
MalformedArgsResponse
(
"Illegal arch"
)
if
(
!$blob->{'isdataset'} &&
$
blob
->{
'arch'
}
!~ /^(i386|x86_64|aarch64)$/);
...
...
@@ -428,6 +448,7 @@ sub UpdateImage($$)
my
($
imagedata
,
$
blob
)
=
@
_
;
my
$
image_uuid
=
$
blob
->{
'image_uuid'
};
my
$
version_uuid
=
$
blob
->{
'version_uuid'
};
my
$
deprecated_clause
=
""
;
#
Verify
uuid
consistency
.
if
($
imagedata
->{
'image_uuid'
}
ne
$
image_uuid
)
{
...
...
@@ -455,6 +476,24 @@ sub UpdateImage($$)
);
my
$
created
=
timelocal
(
strptime
($
blob
->{
'created'
}));
#
#
Watch
for
a
deprecated
image
.
#
if
(
exists
($
blob
->{
'deprecated'
}))
{
my
$
deprecated
=
timelocal
(
strptime
($
blob
->{
'deprecated'
}));
$
deprecated_clause
=
",deprecated=FROM_UNIXTIME($deprecated) "
;
if
(
exists
($
blob
->{
'deprecated_iserror'
}))
{
my
$
iserror
=
($
blob
->{
'deprecated_iserror'
}
?
1
:
0
);
$
deprecated_clause
.=
",deprecated_iserror='$iserror' "
;
}
if
(
exists
($
blob
->{
'deprecated_message'
})
&&
$
blob
->{
'deprecated_message'
}
ne
""
)
{
my
$
message
=
DBQuoteSpecial
($
blob
->{
'deprecated_message'
});
$
deprecated_clause
.=
",deprecated_message=${message} "
;
}
}
#
#
Process
the
image
permissions
first
.
#
...
...
@@ -482,6 +521,7 @@ sub UpdateImage($$)
" created=FROM_UNIXTIME($created), "
.
join
(
","
,
map
(
"$_="
.
DBQuoteSpecial
($
sets
{$
_
}),
keys
(%
sets
)))
.
" "
.
"$deprecated_clause "
.
"where version_uuid='$version_uuid'"
))
{
return
GeniResponse
->
Create
(
GENIRESPONSE_ERROR
);
}
...
...
@@ -775,6 +815,14 @@ sub GetImageInfo($)
my
$
row
=
$
query_result
->
fetchrow_hashref
();
$
blob
->{
'maxversion'
}
=
$
row
->{
"version"
};
}
if
(
defined
($
row
->{
'deprecated'
}))
{
$
blob
->{
'deprecated'
}
=
TBDateStringGMT
(
str2time
($
row
->{
'deprecated'
}));
$
blob
->{
'deprecated_iserror'
}
=
$
row
->{
'deprecated_iserror'
};
if
(
defined
($
row
->{
'deprecated_message'
}))
{
$
blob
->{
'deprecated_message'
}
=
$
row
->{
'deprecated_message'
};
}
}
return
$
blob
;
};
...
...
protogeni/scripts/postimagedata.in
View file @
63b8516e
...
...
@@ -358,6 +358,17 @@ sub PostImageInfo($)
"
image_permissions
"
=>
[]
,
};
#
# Send along deprecated info.
#
if
(
defined
(
$image
->
deprecated
()))
{
$blob
->
{'
deprecated
'}
=
TBDateStringGMT
(
str2time
(
$image
->
deprecated
()));
$blob
->
{'
deprecated_iserror
'}
=
$image
->
deprecated_iserror
();
if
(
defined
(
$image
->
deprecated_message
())
&&
$image
->
deprecated_message
()
ne
"")
{
$blob
->
{'
deprecated_message
'}
=
$image
->
deprecated_message
();
}
}
#
# If this is a nonlocal image, send the origin along so that the
# image server knows we are a copy.
#
...
...
sql/imageserver.sql
View file @
63b8516e
...
...
@@ -70,6 +70,9 @@ CREATE TABLE `image_versions` (
`types_known_working`
text
default
NULL
,
`types_known_notworking`
text
default
NULL
,
`types_unknown`
text
default
NULL
,
`deprecated`
datetime
default
NULL
,
`deprecated_iserror`
tinyint
(
1
)
NOT
NULL
default
'0'
,
`deprecated_message`
mediumtext
,
PRIMARY
KEY
(
`urn`
,
`version`
),
UNIQUE
KEY
`version_uuid`
(
`version_uuid`
)
)
ENGINE
=
MyISAM
DEFAULT
CHARSET
=
latin1
;
...
...
utils/deprecate_image.in
View file @
63b8516e
...
...
@@ -50,6 +50,8 @@ my $message;
# Configure variables
#
my
$TB
=
"
@prefix
@
";
my
$PGENISUPPORT
=
@PROTOGENI_SUPPORT@
;
my
$POSTIMAGEDATA
=
"
$TB
/sbin/protogeni/postimagedata
";
#
# Untaint the path
...
...
@@ -68,6 +70,7 @@ $| = 1;
use
lib
"
@prefix
@/lib
";
use
User
;
use
OSImage
;
use
libEmulab
;
# Protos
sub
fatal
($);
...
...
@@ -122,6 +125,16 @@ if (@ARGV > 1) {
}
$image
->
Deprecate
(
$message
,
$iserror
)
==
0
or
fatal
("
Could not set deprecation info for image
");
if
(
$PGENISUPPORT
&&
GetSiteVar
("
protogeni/use_imagetracker
"))
{
my
$imageid
=
$image
->
imageid
();
print
"
Posting image
$imageid
to the image server ...
\n
";
system
("
$POSTIMAGEDATA
$imageid
");
if
(
$?
)
{
print
STDERR
"
Could not post alias to the image server
\n
";
}
}
exit
(
0
);
sub
fatal
($)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment