Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenNebula 3PAR Backup
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
FeldHost Public Projects
OpenNebula 3PAR Backup
Commits
18ecf579
Commit
18ecf579
authored
Oct 30, 2019
by
Kristian Feldsam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added email notifications on errors
Signed-off-by:
Kristián Feldsam
<
feldsam@gmail.com
>
parent
8ae347a5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
2 deletions
+23
-2
backup.py
backup.py
+7
-0
config.sample.py
config.sample.py
+5
-1
drivers/_3par.py
drivers/_3par.py
+2
-0
functions.py
functions.py
+9
-1
No files found.
backup.py
View file @
18ecf579
...
...
@@ -40,6 +40,9 @@ images = functions.filter_images(all_images, datastores, args)
from
drivers
import
_3par
_3par
.
login
()
# starting backup
functions
.
send_email
(
'Backup started! Images count: %d'
%
len
(
images
))
for
image_key
in
images
:
image
=
images
[
image_key
]
datastore
=
datastores
[
image
.
DATASTORE_ID
]
...
...
@@ -78,6 +81,7 @@ for image_key in images:
if
vmDiskId
is
None
:
# error
print
'Can not found VM Disk ID for image %d:%s attached to VM %d:%s'
%
(
image
.
ID
,
image
.
NAME
,
vmId
,
vm
.
NAME
)
functions
.
send_email
(
'Can not found VM Disk ID for image %d:%s attached to VM %d:%s'
%
(
image
.
ID
,
image
.
NAME
,
vmId
,
vm
.
NAME
))
continue
if
args
.
verbose
:
...
...
@@ -93,6 +97,7 @@ for image_key in images:
_3par
.
backup_live
(
one
,
image
,
vm
,
vmDiskId
,
args
.
verbose
)
except
Exception
as
ex
:
print
ex
functions
.
send_email
(
'Error backup image %d:%s: "%s"'
%
(
image
.
ID
,
image
.
NAME
,
ex
))
continue
# unlock VM
...
...
@@ -110,6 +115,7 @@ for image_key in images:
_3par
.
backup
(
image
,
args
.
verbose
)
except
Exception
as
ex
:
print
ex
functions
.
send_email
(
'Error backup image %d:%s: "%s"'
%
(
image
.
ID
,
image
.
NAME
,
ex
))
continue
# non-persistent
...
...
@@ -121,6 +127,7 @@ for image_key in images:
_3par
.
backup
(
image
,
args
.
verbose
)
except
Exception
as
ex
:
print
ex
functions
.
send_email
(
'Error backup image %d:%s: "%s"'
%
(
image
.
ID
,
image
.
NAME
,
ex
))
continue
# unlock image
...
...
config.sample.py
View file @
18ecf579
...
...
@@ -22,4 +22,8 @@ _3PAR = {
}
# export volumes to host - backup host name defined in 3PAR
EXPORT_HOST
=
'backup.hostname'
\ No newline at end of file
EXPORT_HOST
=
'backup.hostname'
# email settings, we use local email server localhost:25
EMAIL_SEND_FROM
=
'backup@domain.tld'
EMAIL_SEND_TO
=
'admin@domain.tld'
drivers/_3par.py
View file @
18ecf579
...
...
@@ -4,6 +4,7 @@ import sys
import
time
from
hpe3parclient
import
client
,
exceptions
import
config
import
functions
base_path
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
sys
.
argv
[
0
]))
cl
=
client
.
HPE3ParClient
(
config
.
_3PAR
[
'api'
],
False
,
config
.
_3PAR
[
'secure'
],
None
,
True
)
...
...
@@ -16,6 +17,7 @@ def login():
cl
.
login
(
config
.
_3PAR
[
'username'
],
config
.
_3PAR
[
'password'
])
except
exceptions
.
HTTPUnauthorized
:
print
"Login failed."
functions
.
send_email
(
'Can not login to 3PAR!'
)
def
logout
():
...
...
functions.py
View file @
18ecf579
import
subprocess
import
smtplib
import
config
...
...
@@ -132,4 +133,11 @@ def borgbackup_info():
try
:
return
subprocess
.
check_output
(
'borg info %s'
%
(
config
.
BACKUP_REPO
),
shell
=
True
)
except
subprocess
.
CalledProcessError
as
ex
:
raise
Exception
(
'Can not issue borg info command on repo %s!'
%
(
config
.
BACKUP_REPO
),
ex
)
\ No newline at end of file
raise
Exception
(
'Can not issue borg info command on repo %s!'
%
(
config
.
BACKUP_REPO
),
ex
)
def
send_email
(
log
):
msg
=
'Subject: %s
\n\n
%s'
%
(
'Cloud Backup Information'
,
log
)
server
=
smtplib
.
SMTP
(
"localhost"
,
25
,
)
server
.
sendmail
(
config
.
EMAIL_SEND_FROM
,
config
.
EMAIL_SEND_TO
,
msg
)
server
.
quit
()
Write
Preview
Markdown
is supported
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