Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Transactional flag #789

Merged
merged 13 commits into from Oct 5, 2023
3 changes: 2 additions & 1 deletion service/lib/agama/dbus/storage/volume_conversion/to_dbus.rb
Expand Up @@ -42,7 +42,8 @@ def convert
"FsType" => volume.fs_type&.to_human_string || "",
"MinSize" => volume.min_size&.to_i,
"AutoSize" => volume.auto_size?,
"Snapshots" => volume.btrfs.snapshots?
"Snapshots" => volume.btrfs.snapshots?,
"ReadOnly" => volume.btrfs.read_only?
}.tap do |target|
max_size_conversion(target)
outline_conversion(target)
Expand Down
Expand Up @@ -76,6 +76,7 @@
"MinSize" => 0,
"AutoSize" => false,
"Snapshots" => false,
"ReadOnly" => false,
"Outline" => {
"Required" => false,
"FsTypes" => [],
Expand Down
Expand Up @@ -44,6 +44,7 @@
volume.outline = volume_outline
volume.fs_type = Y2Storage::Filesystems::Type::EXT4
volume.btrfs.snapshots = true
volume.btrfs.read_only = true
volume.mount_options = ["rw", "default"]
volume.device = "/dev/sda"
volume.separate_vg_name = "/dev/system"
Expand All @@ -64,6 +65,7 @@
"MinSize" => 0,
"AutoSize" => false,
"Snapshots" => false,
"ReadOnly" => false,
"Outline" => {
"Required" => false,
"FsTypes" => [],
Expand All @@ -84,6 +86,7 @@
"MaxSize" => 2048,
"AutoSize" => true,
"Snapshots" => true,
"ReadOnly" => true,
"Outline" => {
"Required" => true,
"FsTypes" => ["Ext3", "Ext4"],
Expand Down
6 changes: 5 additions & 1 deletion web/src/client/storage.js
Expand Up @@ -238,6 +238,7 @@ class ProposalManager {
* @property {number} [maxSize]
* @property {boolean} autoSize
* @property {boolean} snapshots
* @property {boolean} readOnly
* @property {VolumeOutline} outline
*
* @typedef {object} VolumeOutline
Expand Down Expand Up @@ -348,7 +349,8 @@ class ProposalManager {
MinSize: { t: "t", v: volume.minSize },
MaxSize: { t: "t", v: volume.maxSize },
AutoSize: { t: "b", v: volume.autoSize },
Snapshots: { t: "b", v: volume.snapshots }
Snapshots: { t: "b", v: volume.snapshots },
ReadOnly: { t: "b", v: volume.readOnly },
});
};

Expand Down Expand Up @@ -377,6 +379,7 @@ class ProposalManager {
* @property {CockpitNumber} [MaxSize]
* @property {CockpitBoolean} AutoSize
* @property {CockpitBoolean} Snapshots
* @property {CockpitBoolean} ReadOnly
* @property {CockpitVolumeOutline} Outline
*
* @typedef {Object} DBusVolumeOutline
Expand Down Expand Up @@ -430,6 +433,7 @@ class ProposalManager {
maxSize: dbusVolume.MaxSize?.v,
autoSize: dbusVolume.AutoSize.v,
snapshots: dbusVolume.Snapshots.v,
readOnly: dbusVolume.ReadOnly.v,
outline: buildOutline(dbusVolume.Outline.v)
};
}
Expand Down
8 changes: 8 additions & 0 deletions web/src/client/storage.test.js
Expand Up @@ -163,6 +163,7 @@ const contexts = {
MaxSize: { t: "x", v: 2048 },
AutoSize: { t: "b", v: true },
Snapshots: { t: "b", v: true },
ReadOnly: { t: "b", v: true },
Outline: {
t: "a{sv}",
v: {
Expand All @@ -182,6 +183,7 @@ const contexts = {
MaxSize: { t: "x", v: 4096 },
AutoSize: { t: "b", v: false },
Snapshots: { t: "b", v: false },
ReadOnly: { t: "b", v: false },
Outline: {
t: "a{sv}",
v: {
Expand Down Expand Up @@ -712,6 +714,7 @@ describe("#proposal", () => {
MaxSize: { t: "x", v: 4096 },
AutoSize: { t: "b", v: false },
Snapshots: { t: "b", v: false },
ReadOnly: { t: "b", v: false },
Outline: {
t: "a{sv}",
v: {
Expand All @@ -731,6 +734,7 @@ describe("#proposal", () => {
MaxSize: { t: "x", v: 2048 },
AutoSize: { t: "b", v: false },
Snapshots: { t: "b", v: false },
ReadOnly: { t: "b", v: false },
Outline: {
t: "a{sv}",
v: {
Expand Down Expand Up @@ -759,6 +763,7 @@ describe("#proposal", () => {
maxSize: 4096,
autoSize: false,
snapshots: false,
readOnly: false,
outline: {
required: false,
fsTypes: ["Ext4", "XFS"],
Expand All @@ -778,6 +783,7 @@ describe("#proposal", () => {
maxSize: 2048,
autoSize: false,
snapshots: false,
readOnly: false,
outline: {
required: false,
fsTypes: ["Ext4", "XFS"],
Expand Down Expand Up @@ -825,6 +831,7 @@ describe("#proposal", () => {
maxSize: 2048,
autoSize: true,
snapshots: true,
readOnly: true,
outline: {
required: true,
fsTypes: ["Btrfs", "Ext3"],
Expand All @@ -841,6 +848,7 @@ describe("#proposal", () => {
maxSize: 4096,
autoSize: false,
snapshots: false,
readOnly: false,
outline: {
required: false,
fsTypes: ["Ext4", "XFS"],
Expand Down
6 changes: 6 additions & 0 deletions web/src/components/storage/ProposalVolumes.jsx
Expand Up @@ -201,6 +201,10 @@ const VolumeRow = ({ columns, volume, options, isLoading, onEdit, onDelete }) =>

const Details = ({ volume, options }) => {
const hasSnapshots = volume.fsType === "Btrfs" && volume.snapshots;
const readOnly = volume.fsType === "Btrfs" && volume.readOnly;
console.log("details:");
console.log(volume);
console.log(options);
dgdavid marked this conversation as resolved.
Show resolved Hide resolved

// TRANSLATORS: the filesystem uses a logical volume (LVM)
const text = `${volume.fsType} ${options.lvm ? _("logical volume") : _("partition")}`;
Expand All @@ -214,6 +218,8 @@ const VolumeRow = ({ columns, volume, options, isLoading, onEdit, onDelete }) =>
<If condition={options.encryption} then={<Em icon={lockIcon}>{_("encrypted")}</Em>} />
{/* TRANSLATORS: filesystem flag, it allows creating snapshots */}
<If condition={hasSnapshots} then={<Em icon={snapshotsIcon}>{_("with snapshots")}</Em>} />
{/* TRANSLATORS: filesystem flag, system is read only */}
dgdavid marked this conversation as resolved.
Show resolved Hide resolved
<If condition={readOnly} then={<Em>{_("read-only")}</Em>} />
</div>
);
};
Expand Down