Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-image-creator
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
itminedu
snf-image-creator
Commits
e22aa3a9
Commit
e22aa3a9
authored
13 years ago
by
Nikos Skalkotos
Browse files
Options
Downloads
Patches
Plain Diff
Seperate snapshoting from get_device in Disk class
parent
997ac76a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
image_creator/disk.py
+9
-6
9 additions, 6 deletions
image_creator/disk.py
image_creator/main.py
+7
-2
7 additions, 2 deletions
image_creator/main.py
with
16 additions
and
8 deletions
image_creator/disk.py
+
9
−
6
View file @
e22aa3a9
...
@@ -93,11 +93,9 @@ class Disk(object):
...
@@ -93,11 +93,9 @@ class Disk(object):
job
,
args
=
self
.
_cleanup_jobs
.
pop
()
job
,
args
=
self
.
_cleanup_jobs
.
pop
()
job
(
*
args
)
job
(
*
args
)
def
get_device
(
self
):
def
snapshot
(
self
):
"""
Returns a newly created DiskDevice instance.
"""
Creates a snapshot of the original source media of the Disk
instance.
This instance is a snapshot of the original source media of
the Disk instance.
"""
"""
output
(
"
Examining source media `%s
'
...
"
%
self
.
source
,
False
)
output
(
"
Examining source media `%s
'
...
"
%
self
.
source
,
False
)
...
@@ -141,7 +139,12 @@ class Disk(object):
...
@@ -141,7 +139,12 @@ class Disk(object):
finally
:
finally
:
os
.
unlink
(
table
)
os
.
unlink
(
table
)
success
(
'
done
'
)
success
(
'
done
'
)
new_device
=
DiskDevice
(
"
/dev/mapper/%s
"
%
snapshot
)
return
"
/dev/mapper/%s
"
%
snapshot
def
get_device
(
self
,
media
):
"""
Returns a newly created DiskDevice instance.
"""
new_device
=
DiskDevice
(
media
)
self
.
_devices
.
append
(
new_device
)
self
.
_devices
.
append
(
new_device
)
new_device
.
enable
()
new_device
.
enable
()
return
new_device
return
new_device
...
...
This diff is collapsed.
Click to expand it.
image_creator/main.py
+
7
−
2
View file @
e22aa3a9
...
@@ -161,7 +161,9 @@ def image_creator():
...
@@ -161,7 +161,9 @@ def image_creator():
disk
=
Disk
(
options
.
source
)
disk
=
Disk
(
options
.
source
)
try
:
try
:
dev
=
disk
.
get_device
()
snapshot
=
disk
.
snapshot
()
dev
=
disk
.
get_device
(
snapshot
)
dev
.
mount
()
dev
.
mount
()
osclass
=
get_os_class
(
dev
.
distro
,
dev
.
ostype
)
osclass
=
get_os_class
(
dev
.
distro
,
dev
.
ostype
)
...
@@ -201,10 +203,13 @@ def image_creator():
...
@@ -201,10 +203,13 @@ def image_creator():
dev
.
dump
(
options
.
outfile
)
dev
.
dump
(
options
.
outfile
)
# Destroy the device. We only need the snapshot from now on
disk
.
destroy_device
(
dev
)
if
options
.
upload
:
if
options
.
upload
:
output
(
"
Uploading image to pithos...
"
,
False
)
output
(
"
Uploading image to pithos...
"
,
False
)
kamaki
=
Kamaki
(
options
.
account
,
options
.
token
)
kamaki
=
Kamaki
(
options
.
account
,
options
.
token
)
kamaki
.
upload
(
dev
.
device
,
size
,
options
.
upload
)
kamaki
.
upload
(
snapshot
,
size
,
options
.
upload
)
output
(
"
done
"
)
output
(
"
done
"
)
finally
:
finally
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment