Last active
August 29, 2015 13:55
-
-
Save kcollasarundell/8780795 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "metadata": { | |
| "name": "fraus" | |
| }, | |
| "nbformat": 3, | |
| "nbformat_minor": 0, | |
| "worksheets": [ | |
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "def tb_to_gib(size):\n size_bytes = float(size)*1000**4\n size_GiB = int(size_bytes/1024**3)\n return size_GiB\n\ndef pool_size(pools):\n rawpoolsize = float(0)\n for disks in pools:\n rawpoolsize = rawpoolsize + (disks[\"numdisks\"] * disks[\"size\"])\n return tb_to_gib(rawpoolsize)\n\ndef whatfits(pool_size, volumes):\n remaining = pool_size\n for vol, size in volumes.iteritems():\n size = size*1024\n remaining = remaining - size\n if remaining > 0:\n print vol, size,\"GiB fits with\", remaining\n else:\n print vol, size, \"doesn't fit\", abs(remaining), \"GiB over\"\n ", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [], | |
| "prompt_number": 3 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "volumes = {\"store\": 2.4, \"homes\": 340.0/1024,\"shared\": 8.90 }", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [], | |
| "prompt_number": 4 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "pool = [{\"numdisks\": 4, \"size\": 2}]\nreplication_factor = 2\nrawpoolsize = pool_size(pool)\n \nprint \"total size =\", rawpoolsize\navailable = rawpoolsize/replication_factor\nprint 'available space', available, \"GiB\"\n\nwhatfits(available, volumes)", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "total size = 7450\navailable space 3725 GiB\nhomes 340.0 GiB fits with 3385.0\nstore 2457.6 GiB fits with 927.4\nshared 9113.6 doesn't fit 8186.2 GiB over\n" | |
| } | |
| ], | |
| "prompt_number": 5 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "pool = [{\"numdisks\": 8, \"size\": 2},{\"numdisks\": 4, \"size\":1.5},{\"numdisks\": 4,\"size\": .750}]\nreplication_factor = 2\nrawpoolsize = pool_size(pool)\n \nprint \"total size =\", rawpoolsize\navailable = rawpoolsize/replication_factor\nprint 'available space', available, \"GiB\"\n\nwhatfits(available, volumes)", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "total size = 23283\navailable space 11641 GiB\nhomes 340.0 GiB fits with 11301.0\nstore 2457.6 GiB fits with 8843.4\nshared 9113.6 doesn't fit 270.2 GiB over\n" | |
| } | |
| ], | |
| "prompt_number": 6 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "pool = [{\"numdisks\": 15, \"size\": 2}]\nreplication_factor = 2\nrawpoolsize = pool_size(pool)\n \nprint \"total size =\", rawpoolsize\navailable = rawpoolsize/replication_factor\nprint 'available space', available, \"GiB\"\n\nwhatfits(available, volumes)", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": "total size = 27939\navailable space 13969 GiB\nhomes 340.0 GiB fits with 13629.0\nstore 2457.6 GiB fits with 11171.4\nshared 9113.6 GiB fits with 2057.8\n" | |
| } | |
| ], | |
| "prompt_number": 7 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [], | |
| "prompt_number": 7 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": "", | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [], | |
| "prompt_number": 7 | |
| } | |
| ], | |
| "metadata": {} | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment