def _write_partition(virtual_size, dev):
    dest = '/dev/%s' % dev
    primary_first = MBR_SIZE_SECTORS
    primary_last = MBR_SIZE_SECTORS + 1 - (virtual_size / SECTOR_SIZE)

    LOG.debug(_('Writing partition table %(primary_first)d %(primary_last)d'
            ' to %(dest)s...') % locals())

    def execute(*cmd, **kwargs):
        return utils.execute(*cmd, **kwargs)

    execute('parted', '--script', dest, 'mklabel', 'msdos', run_as_root=True)
    execute('parted', '--script', dest, 'mkpart', 'primary',
            '%ds' % primary_first,
            '%ds' % primary_last,
            run_as_root=True)

    LOG.debug(_('Writing partition table %s done.'), dest)
dataset/ETHPy150Open nii-cloud/dodai-compute/nova/virt/xenapi/vm_utils.py/_write_partition/swapped operands of `-`