LCOV - code coverage report
Current view: top level - pkg/storaged/lvm2 - utils.jsx Coverage Total Hit
Test: cockpit Lines: 100.0 % 26 26
Test Date: 2026-07-13 10:00:01

            Line data    Source code
       1              : /*
       2              :  * Copyright (C) 2023 Red Hat, Inc.
       3              :  * SPDX-License-Identifier: LGPL-2.1-or-later
       4              :  */
       5              : 
       6          113 : import cockpit from "cockpit";
       7              : 
       8              : import { get_block_link_parts } from "../utils.js";
       9              : 
      10              : export function check_partial_lvols(client, path, enter_warning) {
      11              :     if (client.lvols_status[path] && client.lvols_status[path] != "") {
      12              :         enter_warning(path, {
      13              :             warning: "partial-lvol",
      14              :             danger: client.lvols_status[path] != "degraded"
      15              :         });
      16              :     }
      17              : }
      18              : 
      19           18 : export function pvs_to_spaces(client, pvs) {
      20           18 :     return pvs.map(pvol => {
      21           18 :         const block = client.blocks[pvol.path];
      22           18 :         const parts = get_block_link_parts(client, pvol.path);
      23           18 :         const text = cockpit.format(parts.format, parts.link);
      24           18 :         return { type: 'block', block, size: pvol.FreeSize, desc: text, pvol };
      25           18 :     });
      26           18 : }
      27              : 
      28           10 : export function next_default_logical_volume_name(client, vgroup, prefix) {
      29           10 :     function find_lvol(name) {
      30           10 :         const lvols = client.vgroups_lvols[vgroup.path];
      31            3 :         for (let i = 0; i < lvols.length; i++) {
      32            3 :             if (lvols[i].Name == name)
      33            3 :                 return lvols[i];
      34            3 :         }
      35           10 :         return null;
      36           10 :     }
      37              : 
      38           10 :     let name;
      39           10 :     for (let i = 0; i < 1000; i++) {
      40           10 :         name = prefix + i.toFixed();
      41           10 :         if (!find_lvol(name))
      42           10 :             break;
      43           10 :     }
      44              : 
      45           10 :     return name;
      46           10 : }
        

Generated by: LCOV version 2.0-1