Martin Mucha has uploaded a new change for review.

Change subject: core: macPool per DC, add db column
......................................................................

core: macPool per DC, add db column

* add column mac_pool_ranges (VARCHAR(255)) to table storage_pool

Change-Id: Id30f3c384ecf933daaacdbdd6542e88afb98f7ca
Bug-Url: https://bugzilla.redhat.com/1078844
Signed-off-by: Martin Mucha <mmu...@redhat.com>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StoragePool.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAODbFacadeImpl.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java
M packaging/dbscripts/create_tables.sql
M packaging/dbscripts/storages_sp.sql
A packaging/dbscripts/upgrade/03_05_0120_add_mac_pool_ranges_to_storage_pool.sql
6 files changed, 94 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/95/26795/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StoragePool.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StoragePool.java
index 436fa51..fa3ec6f 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StoragePool.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/StoragePool.java
@@ -49,6 +49,17 @@
 
     private QuotaEnforcementTypeEnum quotaEnforcementType;
 
+    //ranges of macs; two macs joined by '-' forms range, multiple ranges can 
be joined using ','.
+    //String mac = "[a-fA-F0-9][02468aAcCeE](:[a-fA-F0-9]{2}){5}$";
+    //String macRange = mac2 + "-" + mac2;
+    //String macRanges = macRange + "(," + macRange + ")*";
+    @Pattern(regexp = 
"^[a-fA-F0-9][02468aAcCeE](:[a-fA-F0-9]{2}){5}-[a-fA-F0-9][02468aAcCeE](:[a-fA-F0-9]{2}){5}"
 +
+            
"(,[a-fA-F0-9][02468aAcCeE](:[a-fA-F0-9]{2}){5}-[a-fA-F0-9][02468aAcCeE](:[a-fA-F0-9]{2}){5})*$",
+
+            message = "VALIDATION.DATA_CENTER.MAC_POOL_RANGES.INVALID",
+            groups = { CreateEntity.class, UpdateEntity.class })
+    private String macPoolRanges;
+
     public StoragePool() {
         id = Guid.Empty;
         status = StoragePoolStatus.Uninitialized;
@@ -72,6 +83,7 @@
         this.description = value;
     }
 
+    @Override
     public String getComment() {
         if (comment == null) {
             comment = "";
@@ -79,6 +91,7 @@
         return comment;
     }
 
+    @Override
     public void setComment(String value) {
         this.comment = value;
     }
@@ -235,4 +248,11 @@
         this.quotaEnforcementType = quotaEnforcementType;
     }
 
+    public void setMacPoolRanges(String macPoolRanges) {
+        this.macPoolRanges = macPoolRanges;
+    }
+
+    public String getMacPoolRanges() {
+        return macPoolRanges;
+    }
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAODbFacadeImpl.java
index 67bb44c..1b3a91c 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StoragePoolDAODbFacadeImpl.java
@@ -39,6 +39,12 @@
                     .getString("compatibility_version")));
             
entity.setQuotaEnforcementType(QuotaEnforcementTypeEnum.forValue(rs.getInt("quota_enforcement_type")));
             entity.setStoragePoolFormatType(getStorageFormatTypeForPool(rs));
+
+            try {
+                entity.setMacPoolRanges(rs.getString("mac_pool_ranges"));
+            } catch (SQLException e) {
+                //that columns not there.
+            }
             return entity;
         }
     }
@@ -139,7 +145,8 @@
                 .addValue("spm_vds_id", pool.getspm_vds_id())
                 .addValue("quota_enforcement_type", 
pool.getQuotaEnforcementType())
                 .addValue("compatibility_version",
-                        pool.getcompatibility_version());
+                        pool.getcompatibility_version())
+                .addValue("mac_pool_ranges", pool.getMacPoolRanges());
 
         getCallsHandler().executeModification("Insertstorage_pool",
                 parameterSource);
@@ -161,7 +168,8 @@
                 .addValue("compatibility_version",
                         pool.getcompatibility_version())
                 .addValue("quota_enforcement_type",
-                        pool.getQuotaEnforcementType().getValue());
+                        pool.getQuotaEnforcementType().getValue())
+                .addValue("mac_pool_ranges", pool.getMacPoolRanges());
 
         getCallsHandler().executeModification("Updatestorage_pool", 
parameterSource);
     }
@@ -178,7 +186,8 @@
                 .addValue("compatibility_version",
                         pool.getcompatibility_version())
                 .addValue("quota_enforcement_type",
-                        pool.getQuotaEnforcementType().getValue());
+                        pool.getQuotaEnforcementType().getValue())
+                .addValue("mac_pool_ranges", pool.getMacPoolRanges());
 
         getCallsHandler().executeModification("Updatestorage_pool_partial", 
parameterSource);
     }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java
index d403823..d49eac1 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java
@@ -274,6 +274,7 @@
         obj.setName(instance.getName());
         obj.setIsLocal(instance.isLocal());
         obj.setStatus(instance.getStatus());
+        obj.setMacPoolRanges(instance.getMacPoolRanges());
 
         obj.setmaster_domain_version(instance.getmaster_domain_version());
         obj.setLVER(instance.getLVER());
diff --git a/packaging/dbscripts/create_tables.sql 
b/packaging/dbscripts/create_tables.sql
index e525e62..0023e1f 100644
--- a/packaging/dbscripts/create_tables.sql
+++ b/packaging/dbscripts/create_tables.sql
@@ -653,7 +653,8 @@
     compatibility_version character varying(40) DEFAULT '2.2'::character 
varying NOT NULL,
     _create_date timestamp with time zone DEFAULT ('now'::text)::timestamp 
without time zone,
     _update_date timestamp with time zone,
-    quota_enforcement_type integer
+    quota_enforcement_type integer,
+    mac_pool_ranges character varying(255)
 );
 
 
diff --git a/packaging/dbscripts/storages_sp.sql 
b/packaging/dbscripts/storages_sp.sql
index 0861da3..df26713 100644
--- a/packaging/dbscripts/storages_sp.sql
+++ b/packaging/dbscripts/storages_sp.sql
@@ -12,12 +12,34 @@
        v_master_domain_version INTEGER,
        v_spm_vds_id UUID ,
        v_compatibility_version VARCHAR(40),
-       v_quota_enforcement_type INTEGER)
+       v_quota_enforcement_type INTEGER,
+       v_mac_pool_ranges VARCHAR(255))
 RETURNS VOID
    AS $procedure$
 BEGIN
-INSERT INTO storage_pool(description, free_text_comment, id, name, status, 
is_local, 
master_domain_version,spm_vds_id,compatibility_version,quota_enforcement_type)
-       VALUES(v_description, v_free_text_comment, v_id, v_name, v_status, 
v_is_local, 
v_master_domain_version,v_spm_vds_id,v_compatibility_version,v_quota_enforcement_type);
+  INSERT INTO
+      storage_pool(description,
+                    free_text_comment,
+                    id,
+                    name,
+                    status,
+                    is_local,
+                    master_domain_version,
+                    spm_vds_id,
+                    compatibility_version,
+                    quota_enforcement_type,
+                    mac_pool_ranges)
+       VALUES(v_description,
+          v_free_text_comment,
+          v_id,
+          v_name,
+          v_status,
+          v_is_local,
+          v_master_domain_version,
+          v_spm_vds_id,
+          v_compatibility_version,
+          v_quota_enforcement_type,
+          v_mac_pool_ranges);
 END; $procedure$
 LANGUAGE plpgsql;
 
@@ -35,18 +57,29 @@
        v_master_domain_version INTEGER,
        v_spm_vds_id UUID ,
        v_compatibility_version VARCHAR(40),
-       v_quota_enforcement_type INTEGER)
+       v_quota_enforcement_type INTEGER,
+       v_mac_pool_ranges VARCHAR(255))
 RETURNS VOID
 
        --The [storage_pool] table doesn't have a timestamp column. Optimistic 
concurrency logic cannot be generated
    AS $procedure$
 BEGIN
-      UPDATE storage_pool
-      SET description = v_description, free_text_comment = 
v_free_text_comment,  name = v_name, is_local = v_is_local,
-      status = v_status,storage_pool_format_type = 
v_storage_pool_format_type,master_domain_version = v_master_domain_version,
-      spm_vds_id = v_spm_vds_id,compatibility_version = 
v_compatibility_version,
-      _update_date = 
LOCALTIMESTAMP,quota_enforcement_type=v_quota_enforcement_type
-      WHERE id = v_id;
+      UPDATE
+          storage_pool
+      SET description = v_description,
+          free_text_comment = v_free_text_comment,
+          name = v_name,
+          is_local = v_is_local,
+          status = v_status,
+          storage_pool_format_type = v_storage_pool_format_type,
+          master_domain_version = v_master_domain_version,
+          spm_vds_id = v_spm_vds_id,
+          compatibility_version = v_compatibility_version,
+          _update_date = LOCALTIMESTAMP,
+          quota_enforcement_type=v_quota_enforcement_type,
+          mac_pool_ranges = v_mac_pool_ranges
+      WHERE
+          id = v_id;
 END; $procedure$
 LANGUAGE plpgsql;
 
@@ -57,17 +90,26 @@
        v_is_local BOOLEAN,
        v_storage_pool_format_type VARCHAR(50),
        v_compatibility_version VARCHAR(40),
-       v_quota_enforcement_type INTEGER)
+       v_quota_enforcement_type INTEGER,
+       v_mac_pool_ranges VARCHAR(255) )
 RETURNS VOID
 
        --The [storage_pool] table doesn't have a timestamp column. Optimistic 
concurrency logic cannot be generated
    AS $procedure$
 BEGIN
-      UPDATE storage_pool
-      SET description = v_description, free_text_comment = 
v_free_text_comment, name = v_name, is_local = v_is_local,
-      storage_pool_format_type = 
v_storage_pool_format_type,compatibility_version = v_compatibility_version,
-      _update_date = LOCALTIMESTAMP,quota_enforcement_type = 
v_quota_enforcement_type
-      WHERE id = v_id;
+      UPDATE
+        storage_pool
+      SET description = v_description,
+        free_text_comment = v_free_text_comment,
+        name = v_name,
+        is_local = v_is_local,
+        storage_pool_format_type = v_storage_pool_format_type,
+        compatibility_version = v_compatibility_version,
+        _update_date = LOCALTIMESTAMP,
+        quota_enforcement_type = v_quota_enforcement_type,
+        mac_pool_ranges = v_mac_pool_ranges
+      WHERE
+        id = v_id;
 END; $procedure$
 LANGUAGE plpgsql;
 
diff --git 
a/packaging/dbscripts/upgrade/03_05_0120_add_mac_pool_ranges_to_storage_pool.sql
 
b/packaging/dbscripts/upgrade/03_05_0120_add_mac_pool_ranges_to_storage_pool.sql
new file mode 100644
index 0000000..cad8455
--- /dev/null
+++ 
b/packaging/dbscripts/upgrade/03_05_0120_add_mac_pool_ranges_to_storage_pool.sql
@@ -0,0 +1 @@
+select fn_db_add_column('storage_pool', 'mac_pool_ranges', 'mac_pool_ranges 
character varying(255)');


-- 
To view, visit http://gerrit.ovirt.org/26795
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id30f3c384ecf933daaacdbdd6542e88afb98f7ca
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Mucha <mmu...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to