예제 #1
0
 def test_sizes(self):
     self.add_device('test', Size("10 YB"))
     tree = DeviceTree()
     parts = {
         'test1': {'size': {'gib': 1}},
         'test2': {'size': {'mib': 1}},
         'test3': {'size': {'mb': 10, 'yb': 4}},
     }
     for part in parts.values():
         part['targetDevice'] = {'type': 'disk', 'name': 'test'}
     tree.populate({
         'storage': {
             'disk': {'test': {'match': {'allowIncomplete': False,
                                         'name': 'test'}}},
             'btrfs': {},
             'partition': parts
         },
         'fileSystems': {},
         'swapDevices': [],
     })
     result = {dev.path: dev for dev in tree.devices}
     self.assertEqual(Size("1 GiB"), result['/dev/test1'].size)
     self.assertEqual(Size("1 MiB"), result['/dev/test2'].size)
     self.assertEqual(Size("10 MB") + Size("4 YB"),
                      result['/dev/test3'].size)
예제 #2
0
파일: main.py 프로젝트: google38438/nixpart
def main():
    args = parse_args()

    if args.verbosity > 0:
        levels = [logging.INFO, logging.DEBUG]
        if args.verbosity > len(levels):
            level = levels[-1]
        else:
            level = levels[args.verbosity - 1]

        handler = logging.StreamHandler(sys.stderr)

        for name in ['blivet', 'program']:
            logger = logging.getLogger(name)
            logger.setLevel(level)
            logger.addHandler(handler)

    expr = config2json(args.nixos_config,
                       is_json=args.is_json,
                       verbose=args.verbosity > 0)

    devtree = DeviceTree()
    devtree.populate(expr, for_mounting=args.mount is not None)

    if args.dry_run:
        print(devtree.devices)
    elif args.mount is not None:
        devtree.mount(args.mount)
    else:
        devtree.realize()
예제 #3
0
파일: main.py 프로젝트: aszlig/nixpart
def main():
    args = parse_args()

    if args.verbosity > 0:
        levels = [logging.INFO, logging.DEBUG]
        if args.verbosity > len(levels):
            level = levels[-1]
        else:
            level = levels[args.verbosity - 1]

        handler = logging.StreamHandler(sys.stderr)

        for name in ['blivet', 'program']:
            logger = logging.getLogger(name)
            logger.setLevel(level)
            logger.addHandler(handler)

    expr = config2json(args.nixos_config,
                       is_json=args.is_json,
                       verbose=args.verbosity > 0)

    devtree = DeviceTree()
    devtree.populate(expr, for_mounting=args.mount is not None)

    if args.dry_run:
        print(devtree.devices)
    elif args.mount is not None:
        devtree.mount(args.mount)
    else:
        devtree.realize()