[ARVADOS] created: 1.1.3-77-g73ff625
Git user
git at public.curoverse.com
Fri Feb 16 18:48:58 EST 2018
at 73ff6253cc8efac2d0c7e6fa1f95b43b8f90c26b (commit)
commit 73ff6253cc8efac2d0c7e6fa1f95b43b8f90c26b
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date: Fri Feb 16 20:47:49 2018 -0300
12707: Add storage classes attributes to collections.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>
diff --git a/services/api/app/models/collection.rb b/services/api/app/models/collection.rb
index c5fd96e..2fc5b5c 100644
--- a/services/api/app/models/collection.rb
+++ b/services/api/app/models/collection.rb
@@ -15,6 +15,8 @@ class Collection < ArvadosModel
include Trashable
serialize :properties, Hash
+ serialize :storage_classes_desired, Array
+ serialize :storage_classes_confirmed, Array
before_validation :default_empty_manifest
before_validation :check_encoding
@@ -22,6 +24,7 @@ class Collection < ArvadosModel
before_validation :check_signatures
before_validation :strip_signatures_and_update_replication_confirmed
validate :ensure_pdh_matches_manifest_text
+ validate :ensure_storage_classes_desired_is_not_empty
before_save :set_file_names
api_accessible :user, extend: :common do |t|
@@ -34,6 +37,9 @@ class Collection < ArvadosModel
t.add :replication_desired
t.add :replication_confirmed
t.add :replication_confirmed_at
+ t.add :storage_classes_desired
+ t.add :storage_classes_confirmed
+ t.add :storage_classes_confirmed_at
t.add :delete_at
t.add :trash_at
t.add :is_trashed
@@ -155,6 +161,13 @@ class Collection < ArvadosModel
true
end
+ def ensure_storage_classes_desired_is_not_empty
+ if storage_classes_desired.length == 0
+ errors.add(:storage_classes_desired, "shouldn't be empty")
+ false
+ end
+ end
+
def ensure_pdh_matches_manifest_text
if not manifest_text_changed? and not portable_data_hash_changed?
true
@@ -436,7 +449,7 @@ class Collection < ArvadosModel
end
def self.full_text_searchable_columns
- super - ["manifest_text"]
+ super - ["manifest_text", "storage_classes_desired", "storage_classes_confirmed"]
end
def self.where *args
@@ -472,10 +485,13 @@ class Collection < ArvadosModel
end
def ensure_permission_to_save
- if (not current_user.andand.is_admin and
- (replication_confirmed_at_changed? or replication_confirmed_changed?) and
- not (replication_confirmed_at.nil? and replication_confirmed.nil?))
- raise ArvadosModel::PermissionDeniedError.new("replication_confirmed and replication_confirmed_at attributes cannot be changed, except by setting both to nil")
+ if (not current_user.andand.is_admin)
+ if (replication_confirmed_at_changed? or replication_confirmed_changed?) and
+ not (replication_confirmed_at.nil? and replication_confirmed.nil?)
+ raise ArvadosModel::PermissionDeniedError.new("replication_confirmed and replication_confirmed_at attributes cannot be changed, except by setting both to nil")
+ elsif (storage_classes_confirmed_changed? or storage_classes_confirmed_at_changed?) and not (storage_classes_confirmed == [] and storage_classes_confirmed_at.nil?)
+ raise ArvadosModel::PermissionDeniedError.new("storage_classes_confirmed and storage_classes_confirmed_at attributes cannot be changed, except by setting them to [] and nil respectively")
+ end
end
super
end
diff --git a/services/api/db/migrate/2018021620342_add_storage_classes_to_collections.rb b/services/api/db/migrate/2018021620342_add_storage_classes_to_collections.rb
new file mode 100644
index 0000000..112c2ba
--- /dev/null
+++ b/services/api/db/migrate/2018021620342_add_storage_classes_to_collections.rb
@@ -0,0 +1,17 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+class AddStorageClassesToCollections < ActiveRecord::Migration
+ def up
+ add_column :collections, :storage_classes_desired, :jsonb, :default => ["default"]
+ add_column :collections, :storage_classes_confirmed, :jsonb, :default => []
+ add_column :collections, :storage_classes_confirmed_at, :datetime, :default => nil, :null => true
+ end
+
+ def down
+ remove_column :collections, :storage_classes_desired
+ remove_column :collections, :storage_classes_confirmed
+ remove_column :collections, :storage_classes_confirmed_at
+ end
+end
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list