fix #2864: add owner option to sync
instead of hard-coding 'backup@pam'. this allows a bit more flexibility (e.g., syncing to a datastore that can directly be used as restore source) without overly complicating things. Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
fa7aceeb15
commit
f1694b062d
@ -45,6 +45,10 @@ pub fn list_sync_jobs(
|
|||||||
store: {
|
store: {
|
||||||
schema: DATASTORE_SCHEMA,
|
schema: DATASTORE_SCHEMA,
|
||||||
},
|
},
|
||||||
|
owner: {
|
||||||
|
type: Authid,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
remote: {
|
remote: {
|
||||||
schema: REMOTE_ID_SCHEMA,
|
schema: REMOTE_ID_SCHEMA,
|
||||||
},
|
},
|
||||||
@ -120,6 +124,8 @@ pub fn read_sync_job(
|
|||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
/// Deletable property name
|
/// Deletable property name
|
||||||
pub enum DeletableProperty {
|
pub enum DeletableProperty {
|
||||||
|
/// Delete the owner property.
|
||||||
|
owner,
|
||||||
/// Delete the comment property.
|
/// Delete the comment property.
|
||||||
comment,
|
comment,
|
||||||
/// Delete the job schedule.
|
/// Delete the job schedule.
|
||||||
@ -139,6 +145,10 @@ pub enum DeletableProperty {
|
|||||||
schema: DATASTORE_SCHEMA,
|
schema: DATASTORE_SCHEMA,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
owner: {
|
||||||
|
type: Authid,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
remote: {
|
remote: {
|
||||||
schema: REMOTE_ID_SCHEMA,
|
schema: REMOTE_ID_SCHEMA,
|
||||||
optional: true,
|
optional: true,
|
||||||
@ -178,6 +188,7 @@ pub enum DeletableProperty {
|
|||||||
pub fn update_sync_job(
|
pub fn update_sync_job(
|
||||||
id: String,
|
id: String,
|
||||||
store: Option<String>,
|
store: Option<String>,
|
||||||
|
owner: Option<Authid>,
|
||||||
remote: Option<String>,
|
remote: Option<String>,
|
||||||
remote_store: Option<String>,
|
remote_store: Option<String>,
|
||||||
remove_vanished: Option<bool>,
|
remove_vanished: Option<bool>,
|
||||||
@ -202,6 +213,7 @@ pub fn update_sync_job(
|
|||||||
if let Some(delete) = delete {
|
if let Some(delete) = delete {
|
||||||
for delete_prop in delete {
|
for delete_prop in delete {
|
||||||
match delete_prop {
|
match delete_prop {
|
||||||
|
DeletableProperty::owner => { data.owner = None; },
|
||||||
DeletableProperty::comment => { data.comment = None; },
|
DeletableProperty::comment => { data.comment = None; },
|
||||||
DeletableProperty::schedule => { data.schedule = None; },
|
DeletableProperty::schedule => { data.schedule = None; },
|
||||||
DeletableProperty::remove_vanished => { data.remove_vanished = None; },
|
DeletableProperty::remove_vanished => { data.remove_vanished = None; },
|
||||||
@ -221,8 +233,8 @@ pub fn update_sync_job(
|
|||||||
if let Some(store) = store { data.store = store; }
|
if let Some(store) = store { data.store = store; }
|
||||||
if let Some(remote) = remote { data.remote = remote; }
|
if let Some(remote) = remote { data.remote = remote; }
|
||||||
if let Some(remote_store) = remote_store { data.remote_store = remote_store; }
|
if let Some(remote_store) = remote_store { data.remote_store = remote_store; }
|
||||||
|
if let Some(owner) = owner { data.owner = owner; }
|
||||||
|
|
||||||
if schedule.is_some() { data.schedule = schedule; }
|
if schedule.is_some() { data.schedule = schedule; }
|
||||||
if remove_vanished.is_some() { data.remove_vanished = remove_vanished; }
|
if remove_vanished.is_some() { data.remove_vanished = remove_vanished; }
|
||||||
|
|
||||||
|
@ -92,6 +92,7 @@ pub fn do_sync_job(
|
|||||||
let worker_future = async move {
|
let worker_future = async move {
|
||||||
|
|
||||||
let delete = sync_job.remove_vanished.unwrap_or(true);
|
let delete = sync_job.remove_vanished.unwrap_or(true);
|
||||||
|
let sync_owner = sync_job.owner.unwrap_or(Authid::backup_auth_id().clone());
|
||||||
let (client, src_repo, tgt_store) = get_pull_parameters(&sync_job.store, &sync_job.remote, &sync_job.remote_store).await?;
|
let (client, src_repo, tgt_store) = get_pull_parameters(&sync_job.store, &sync_job.remote, &sync_job.remote_store).await?;
|
||||||
|
|
||||||
worker.log(format!("Starting datastore sync job '{}'", job_id));
|
worker.log(format!("Starting datastore sync job '{}'", job_id));
|
||||||
@ -101,9 +102,7 @@ pub fn do_sync_job(
|
|||||||
worker.log(format!("Sync datastore '{}' from '{}/{}'",
|
worker.log(format!("Sync datastore '{}' from '{}/{}'",
|
||||||
sync_job.store, sync_job.remote, sync_job.remote_store));
|
sync_job.store, sync_job.remote, sync_job.remote_store));
|
||||||
|
|
||||||
let backup_auth_id = Authid::backup_auth_id();
|
crate::client::pull::pull_store(&worker, &client, &src_repo, tgt_store.clone(), delete, sync_owner).await?;
|
||||||
|
|
||||||
crate::client::pull::pull_store(&worker, &client, &src_repo, tgt_store.clone(), delete, backup_auth_id.clone()).await?;
|
|
||||||
|
|
||||||
worker.log(format!("sync job '{}' end", &job_id));
|
worker.log(format!("sync job '{}' end", &job_id));
|
||||||
|
|
||||||
|
@ -30,6 +30,10 @@ lazy_static! {
|
|||||||
store: {
|
store: {
|
||||||
schema: DATASTORE_SCHEMA,
|
schema: DATASTORE_SCHEMA,
|
||||||
},
|
},
|
||||||
|
"owner": {
|
||||||
|
type: Authid,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
remote: {
|
remote: {
|
||||||
schema: REMOTE_ID_SCHEMA,
|
schema: REMOTE_ID_SCHEMA,
|
||||||
},
|
},
|
||||||
@ -56,6 +60,8 @@ lazy_static! {
|
|||||||
pub struct SyncJobConfig {
|
pub struct SyncJobConfig {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub store: String,
|
pub store: String,
|
||||||
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
pub owner: Option<Authid>,
|
||||||
pub remote: String,
|
pub remote: String,
|
||||||
pub remote_store: String,
|
pub remote_store: String,
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
@ -75,6 +81,10 @@ pub struct SyncJobConfig {
|
|||||||
store: {
|
store: {
|
||||||
schema: DATASTORE_SCHEMA,
|
schema: DATASTORE_SCHEMA,
|
||||||
},
|
},
|
||||||
|
owner: {
|
||||||
|
type: Authid,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
remote: {
|
remote: {
|
||||||
schema: REMOTE_ID_SCHEMA,
|
schema: REMOTE_ID_SCHEMA,
|
||||||
},
|
},
|
||||||
@ -121,6 +131,8 @@ pub struct SyncJobConfig {
|
|||||||
pub struct SyncJobStatus {
|
pub struct SyncJobStatus {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub store: String,
|
pub store: String,
|
||||||
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
pub owner: Option<Authid>,
|
||||||
pub remote: String,
|
pub remote: String,
|
||||||
pub remote_store: String,
|
pub remote_store: String,
|
||||||
#[serde(skip_serializing_if="Option::is_none")]
|
#[serde(skip_serializing_if="Option::is_none")]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Ext.define('pbs-sync-jobs-status', {
|
Ext.define('pbs-sync-jobs-status', {
|
||||||
extend: 'Ext.data.Model',
|
extend: 'Ext.data.Model',
|
||||||
fields: [
|
fields: [
|
||||||
'id', 'remote', 'remote-store', 'store', 'schedule',
|
'id', 'owner', 'remote', 'remote-store', 'store', 'schedule',
|
||||||
'next-run', 'last-run-upid', 'last-run-state', 'last-run-endtime',
|
'next-run', 'last-run-upid', 'last-run-state', 'last-run-endtime',
|
||||||
{
|
{
|
||||||
name: 'duration',
|
name: 'duration',
|
||||||
@ -151,6 +151,11 @@ Ext.define('PBS.config.SyncJobView', {
|
|||||||
return Proxmox.Utils.render_timestamp(value);
|
return Proxmox.Utils.render_timestamp(value);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
render_optional_owner: function(value, metadata, record) {
|
||||||
|
if (!value) return '-';
|
||||||
|
return Ext.String.htmlEncode(value, metadata, record);
|
||||||
|
},
|
||||||
|
|
||||||
startStore: function() { this.getView().getStore().rstore.startUpdate(); },
|
startStore: function() { this.getView().getStore().rstore.startUpdate(); },
|
||||||
stopStore: function() { this.getView().getStore().rstore.stopUpdate(); },
|
stopStore: function() { this.getView().getStore().rstore.stopUpdate(); },
|
||||||
|
|
||||||
@ -250,6 +255,13 @@ Ext.define('PBS.config.SyncJobView', {
|
|||||||
width: 120,
|
width: 120,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
header: gettext('Owner'),
|
||||||
|
dataIndex: 'owner',
|
||||||
|
renderer: 'render_optional_owner',
|
||||||
|
flex: 2,
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
header: gettext('Schedule'),
|
header: gettext('Schedule'),
|
||||||
dataIndex: 'schedule',
|
dataIndex: 'schedule',
|
||||||
|
@ -62,6 +62,26 @@ Ext.define('PBS.window.SyncJobEdit', {
|
|||||||
],
|
],
|
||||||
|
|
||||||
column2: [
|
column2: [
|
||||||
|
{
|
||||||
|
fieldLabel: gettext('Owner'),
|
||||||
|
xtype: 'pbsUserSelector',
|
||||||
|
name: 'owner',
|
||||||
|
allowBlank: true,
|
||||||
|
emptyText: 'backup@pam',
|
||||||
|
getSubmitData: function() {
|
||||||
|
let me = this;
|
||||||
|
let name = me.getName();
|
||||||
|
let val = me.getSubmitValue();
|
||||||
|
|
||||||
|
let data = {};
|
||||||
|
if (val === null || val === "") {
|
||||||
|
data.delete = name;
|
||||||
|
} else {
|
||||||
|
data[name] = val;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldLabel: gettext('Remove vanished'),
|
fieldLabel: gettext('Remove vanished'),
|
||||||
xtype: 'proxmoxcheckbox',
|
xtype: 'proxmoxcheckbox',
|
||||||
|
Loading…
Reference in New Issue
Block a user