[zfs] Update to Calamares coding standards
This commit is contained in:
parent
69ef13ef0c
commit
7108d4a509
@ -53,27 +53,40 @@ ZfsJob::exec()
|
|||||||
{
|
{
|
||||||
QVariantMap pMap;
|
QVariantMap pMap;
|
||||||
if ( partition.canConvert( QVariant::Map ) )
|
if ( partition.canConvert( QVariant::Map ) )
|
||||||
|
{
|
||||||
pMap = partition.toMap();
|
pMap = partition.toMap();
|
||||||
|
}
|
||||||
|
|
||||||
// If it isn't a zfs partition, ignore it
|
// If it isn't a zfs partition, ignore it
|
||||||
if ( pMap[ "fsName" ] != "zfs" )
|
if ( pMap[ "fsName" ] != "zfs" )
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Find the best device identifier, if one isn't available, skip this partition
|
// Find the best device identifier, if one isn't available, skip this partition
|
||||||
QString deviceName;
|
QString deviceName;
|
||||||
if ( pMap[ "partuuid" ].toString() != "" )
|
if ( pMap[ "partuuid" ].toString() != "" )
|
||||||
|
{
|
||||||
deviceName = "/dev/disk/by-partuuid/" + pMap[ "partuuid" ].toString().toLower();
|
deviceName = "/dev/disk/by-partuuid/" + pMap[ "partuuid" ].toString().toLower();
|
||||||
|
}
|
||||||
else if ( pMap[ "device" ].toString() != "" )
|
else if ( pMap[ "device" ].toString() != "" )
|
||||||
|
{
|
||||||
deviceName = pMap[ "device" ].toString().toLower();
|
deviceName = pMap[ "device" ].toString().toLower();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Create the zpool
|
// Create the zpool
|
||||||
auto r
|
auto r
|
||||||
= system->runCommand( { "sh", "-c", "zpool create " + m_poolOptions + " " + m_poolName + " " + deviceName },
|
= system->runCommand( { "sh", "-c", "zpool create " + m_poolOptions + " " + m_poolName + " " + deviceName },
|
||||||
std::chrono::seconds( 10 ) );
|
std::chrono::seconds( 10 ) );
|
||||||
if ( r.getExitCode() != 0 )
|
if ( r.getExitCode() != 0 )
|
||||||
return Calamares::JobResult::error( "message", "Failed to create zpool on " + deviceName );
|
{
|
||||||
|
return Calamares::JobResult::error( tr( "zpool failure" ),
|
||||||
|
tr( "Failed to create zpool on " + deviceName.toLocal8Bit() ) );
|
||||||
|
}
|
||||||
|
|
||||||
// Create the datasets
|
// Create the datasets
|
||||||
for ( const auto& dataset : qAsConst( m_datasets ) )
|
for ( const auto& dataset : qAsConst( m_datasets ) )
|
||||||
@ -97,7 +110,9 @@ ZfsJob::exec()
|
|||||||
+ m_poolName + "/" + dsMap[ "dsName" ].toString() },
|
+ m_poolName + "/" + dsMap[ "dsName" ].toString() },
|
||||||
std::chrono::seconds( 10 ) );
|
std::chrono::seconds( 10 ) );
|
||||||
if ( r.getExitCode() != 0 )
|
if ( r.getExitCode() != 0 )
|
||||||
|
{
|
||||||
cWarning() << "Failed to create dataset" << dsMap[ "dsName" ].toString();
|
cWarning() << "Failed to create dataset" << dsMap[ "dsName" ].toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user