e6d67dca74
These tools are not meant to be used as-is They need a full rework. They are more reference material than anything else right now. I also had to do some awful stuff to them to get them to pass the gate in a hurry, code looks bad because of it. I am cleaning them up as I go. We will remove these in the future once they are no longer useful to reference any longer. Change-Id: I8f13ef282a2a05e72c53a0c307832a46db18d2b4
69 lines
1.8 KiB
Python
69 lines
1.8 KiB
Python
#!/usr/bin/python
|
|
|
|
# Copyright 2016 Sam Yaple
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
# Copied and licensed from https://github.com/SamYaple/osdk
|
|
|
|
|
|
from datetime import datetime
|
|
from osdk import osdk
|
|
from uuid import UUID
|
|
|
|
|
|
def get_timestamp(o):
|
|
return datetime.fromtimestamp(
|
|
o.metadata['timestamp']).strftime('%Y-%m-%d %H:%M:%S')
|
|
|
|
|
|
def convert_size(size_in_bytes):
|
|
sizes = {4: " TiB", 3: " GiB", 2: " MiB", 1: "KiB", 0: "B"}
|
|
|
|
for i in range(len(sizes), 1, -1):
|
|
size = int(size_in_bytes / 1024**i)
|
|
if size > 0:
|
|
break
|
|
|
|
return str(size) + sizes[i]
|
|
|
|
|
|
def print_header(o):
|
|
formated_out = """Version:\t%(version)s
|
|
Creation Date:\t%(timestamp)s
|
|
Incremental:\t%(incremental)s
|
|
Volume Size:\t%(volume_size)s
|
|
Segment Size:\t%(segment_size)s
|
|
Backup Set:\t%(backup_set)s"""
|
|
|
|
dict_out = dict()
|
|
dict_out['backup_set'] = UUID(bytes=o.metadata['bases'][-1])
|
|
dict_out['version'] = o.metadata['version']
|
|
dict_out['incremental'] = o.metadata['incremental']
|
|
dict_out['timestamp'] = get_timestamp(o)
|
|
dict_out['volume_size'] = convert_size(o.metadata['sectors'] * 512)
|
|
dict_out['segment_size'] = convert_size(o.metadata['segment_size'])
|
|
|
|
print(formated_out % dict_out)
|
|
|
|
|
|
def main():
|
|
manifest = 'manifest1.osdk'
|
|
o = osdk(manifest)
|
|
o.read_manifest()
|
|
|
|
print_header(o)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|