static gboolean handle_remove_devices (CockpitStorageMDRaid *object, GDBusMethodInvocation *invocation, const gchar *const *arg_devices) { StorageMDRaid *mdraid = STORAGE_MDRAID(object); StorageProvider *provider = storage_object_get_provider (mdraid->object); Daemon *daemon = storage_provider_get_daemon (provider); GDBusObjectManagerServer *object_manager_server = daemon_get_object_manager (daemon); GDBusObjectManager *object_manager = G_DBUS_OBJECT_MANAGER (object_manager_server); GError *error = NULL; if (!auth_check_sender_role (invocation, COCKPIT_ROLE_STORAGE_ADMIN)) return TRUE; int n_devices = 0; for (int i = 0; arg_devices[i]; i++) n_devices += 1; const gchar *udisks_devices[n_devices + 1]; for (int i = 0; arg_devices[i]; i++) { StorageObject *stobj = STORAGE_OBJECT(g_dbus_object_manager_get_object (object_manager, arg_devices[i])); UDisksBlock *block = storage_object_get_udisks_block (stobj); if (block) udisks_devices[i] = g_dbus_proxy_get_object_path (G_DBUS_PROXY(block)); else udisks_devices[i] = "XXX"; } udisks_devices[n_devices] = NULL; for (int i = 0; udisks_devices[i]; i++) { GVariantBuilder options; g_variant_builder_init (&options, G_VARIANT_TYPE("a{sv}")); g_variant_builder_add (&options, "{sv}", "wipe", g_variant_new_boolean (TRUE)); if (!udisks_mdraid_call_remove_device_sync (mdraid->udisks_mdraid, udisks_devices[i], g_variant_builder_end (&options), NULL, &error)) { g_dbus_error_strip_remote_error (error); g_dbus_method_invocation_return_error (invocation, COCKPIT_ERROR, COCKPIT_ERROR_FAILED, "%s", error->message); g_error_free (error); return TRUE; } } cockpit_storage_mdraid_complete_remove_devices (object, invocation); return TRUE; }
static gboolean handle_create_thin_volume (CockpitStorageVolumeGroup *object, GDBusMethodInvocation *invocation, const gchar *arg_name, guint64 arg_size, const gchar *arg_pool) { StorageVolumeGroup *group = STORAGE_VOLUME_GROUP(object); GError *error = NULL; gs_free gchar *result = NULL; const gchar *pool_path = "/"; if (!auth_check_sender_role (invocation, COCKPIT_ROLE_STORAGE_ADMIN)) return TRUE; StorageProvider *provider = storage_object_get_provider (group->object); Daemon *daemon = storage_provider_get_daemon (provider); GDBusObjectManagerServer *object_manager_server = daemon_get_object_manager (daemon); GDBusObjectManager *object_manager = G_DBUS_OBJECT_MANAGER (object_manager_server); StorageObject *pool_object = STORAGE_OBJECT (g_dbus_object_manager_get_object (object_manager, arg_pool)); LvmLogicalVolume *lvm_pool_lvol = storage_object_get_lvm_logical_volume (pool_object); if (lvm_pool_lvol) pool_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (lvm_pool_lvol)); if (!lvm_volume_group_call_create_thin_volume_sync (group->lvm_volume_group, arg_name, arg_size, pool_path, null_asv (), &result, NULL, &error)) { g_dbus_error_strip_remote_error (error); g_dbus_method_invocation_return_error (invocation, COCKPIT_ERROR, COCKPIT_ERROR_FAILED, "%s", error->message); g_error_free (error); } else cockpit_storage_volume_group_complete_create_thin_pool_volume (object, invocation); return TRUE; }
static gboolean handle_empty_device (CockpitStorageVolumeGroup *object, GDBusMethodInvocation *invocation, const gchar *arg_objpath) { StorageVolumeGroup *group = STORAGE_VOLUME_GROUP(object); GError *error = NULL; const gchar *block_path = "/"; if (!auth_check_sender_role (invocation, COCKPIT_ROLE_STORAGE_ADMIN)) return TRUE; StorageProvider *provider = storage_object_get_provider (group->object); Daemon *daemon = storage_provider_get_daemon (provider); GDBusObjectManagerServer *object_manager_server = daemon_get_object_manager (daemon); GDBusObjectManager *object_manager = G_DBUS_OBJECT_MANAGER (object_manager_server); StorageObject *block_object = STORAGE_OBJECT (g_dbus_object_manager_get_object (object_manager, arg_objpath)); UDisksBlock *udisks_block = storage_object_get_udisks_block (block_object); if (udisks_block) block_path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (udisks_block)); g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (group->lvm_volume_group), G_MAXINT); if (!lvm_volume_group_call_empty_device_sync (group->lvm_volume_group, block_path, null_asv (), NULL, &error)) { g_dbus_error_strip_remote_error (error); g_dbus_method_invocation_return_error (invocation, COCKPIT_ERROR, COCKPIT_ERROR_FAILED, "%s", error->message); g_error_free (error); } else cockpit_storage_volume_group_complete_empty_device (object, invocation); g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (group->lvm_volume_group), -1); return TRUE; }
static void storage_provider_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { StorageProvider *provider = STORAGE_PROVIDER (object); switch (prop_id) { case PROP_DAEMON: g_value_set_object (value, storage_provider_get_daemon (provider)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }