This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch 4.19
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.19 by this push:
     new b82ea3de2d2 Update pre-populated quota tariffs' unit types (#8591)
b82ea3de2d2 is described below

commit b82ea3de2d2eec3bf1f3cd8145dadc87a51f35bf
Author: Bryan Lima <[email protected]>
AuthorDate: Wed Mar 6 13:36:22 2024 -0300

    Update pre-populated quota tariffs' unit types (#8591)
---
 .../com/cloud/upgrade/DatabaseUpgradeChecker.java  |  2 +
 .../com/cloud/upgrade/dao/Upgrade41900to41910.java | 66 ++++++++++++++++++++++
 .../META-INF/db/schema-41900to41910-cleanup.sql    | 20 +++++++
 .../resources/META-INF/db/schema-41900to41910.sql  | 32 +++++++++++
 4 files changed, 120 insertions(+)

diff --git 
a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java 
b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
index 697782dc1db..614e6058aa6 100644
--- a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
+++ b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
@@ -85,6 +85,7 @@ import com.cloud.upgrade.dao.Upgrade41710to41720;
 import com.cloud.upgrade.dao.Upgrade41720to41800;
 import com.cloud.upgrade.dao.Upgrade41800to41810;
 import com.cloud.upgrade.dao.Upgrade41810to41900;
+import com.cloud.upgrade.dao.Upgrade41900to41910;
 import com.cloud.upgrade.dao.Upgrade420to421;
 import com.cloud.upgrade.dao.Upgrade421to430;
 import com.cloud.upgrade.dao.Upgrade430to440;
@@ -224,6 +225,7 @@ public class DatabaseUpgradeChecker implements 
SystemIntegrityChecker {
                 .next("4.17.2.0", new Upgrade41720to41800())
                 .next("4.18.0.0", new Upgrade41800to41810())
                 .next("4.18.1.0", new Upgrade41810to41900())
+                .next("4.19.0.0", new Upgrade41900to41910())
                 .build();
     }
 
diff --git 
a/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41900to41910.java 
b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41900to41910.java
new file mode 100644
index 00000000000..6085faba634
--- /dev/null
+++ b/engine/schema/src/main/java/com/cloud/upgrade/dao/Upgrade41900to41910.java
@@ -0,0 +1,66 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package com.cloud.upgrade.dao;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
+import java.io.InputStream;
+import java.sql.Connection;
+
+public class Upgrade41900to41910 implements DbUpgrade {
+
+    @Override
+    public String[] getUpgradableVersionRange() {
+        return new String[] {"4.19.0.0", "4.19.1.0"};
+    }
+
+    @Override
+    public String getUpgradedVersion() {
+        return "4.19.1.0";
+    }
+
+    @Override
+    public boolean supportsRollingUpgrade() {
+        return false;
+    }
+
+    @Override
+    public InputStream[] getPrepareScripts() {
+        final String scriptFile = "META-INF/db/schema-41900to41910.sql";
+        final InputStream script = 
Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
+        if (script == null) {
+            throw new CloudRuntimeException("Unable to find " + scriptFile);
+        }
+
+        return new InputStream[] {script};
+    }
+
+    @Override
+    public void performDataMigration(Connection conn) {
+    }
+
+    @Override
+    public InputStream[] getCleanupScripts() {
+        final String scriptFile = 
"META-INF/db/schema-41900to41910-cleanup.sql";
+        final InputStream script = 
Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
+        if (script == null) {
+            throw new CloudRuntimeException("Unable to find " + scriptFile);
+        }
+
+        return new InputStream[] {script};
+    }
+}
diff --git 
a/engine/schema/src/main/resources/META-INF/db/schema-41900to41910-cleanup.sql 
b/engine/schema/src/main/resources/META-INF/db/schema-41900to41910-cleanup.sql
new file mode 100644
index 00000000000..b580d42686f
--- /dev/null
+++ 
b/engine/schema/src/main/resources/META-INF/db/schema-41900to41910-cleanup.sql
@@ -0,0 +1,20 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+--;
+-- Schema upgrade cleanup from 4.19.0.0 to 4.19.1.0
+--;
diff --git 
a/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql 
b/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql
new file mode 100644
index 00000000000..e704d61d70c
--- /dev/null
+++ b/engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql
@@ -0,0 +1,32 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+--;
+-- Schema upgrade from 4.19.0.0 to 4.19.1.0
+--;
+
+-- Updates the populated Quota tariff's types VM_DISK_BYTES_READ, 
VM_DISK_BYTES_WRITE, VM_DISK_IO_READ and VM_DISK_IO_WRITE to the correct unit.
+
+UPDATE cloud_usage.quota_tariff
+SET usage_unit = 'Bytes', updated_on = NOW()
+WHERE effective_on = '2010-05-04 00:00:00'
+AND name IN ('VM_DISK_BYTES_READ', 'VM_DISK_BYTES_WRITE');
+
+UPDATE cloud_usage.quota_tariff
+SET usage_unit = 'IOPS', updated_on = NOW()
+WHERE effective_on = '2010-05-04 00:00:00'
+AND name IN ('VM_DISK_IO_READ', 'VM_DISK_IO_WRITE');

Reply via email to