-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add the procedure files for insert extensions and update guest os category #12482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sureshanaparti
wants to merge
3
commits into
apache:4.22
Choose a base branch
from
shapeblue:add-procedures-to-files
base: 4.22
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+263
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
.../schema/src/main/resources/META-INF/db/procedures/cloud.insert_category_if_not_exists.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| -- 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. | ||
|
|
||
| -- Add new OS categories if not present | ||
| DROP PROCEDURE IF EXISTS `cloud`.`INSERT_CATEGORY_IF_NOT_EXIST`; | ||
| CREATE PROCEDURE `cloud`.`INSERT_CATEGORY_IF_NOT_EXIST`(IN os_name VARCHAR(255)) | ||
| BEGIN | ||
| IF NOT EXISTS ((SELECT 1 FROM `cloud`.`guest_os_category` WHERE name = os_name)) | ||
| THEN | ||
| INSERT INTO `cloud`.`guest_os_category` (name, uuid) | ||
| VALUES (os_name, UUID()) | ||
| ; END IF | ||
| ; END; | ||
46 changes: 46 additions & 0 deletions
46
...ces/META-INF/db/procedures/cloud.insert_extension_custom_action_details_if_not_exists.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| -- 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. | ||
|
|
||
| DROP PROCEDURE IF EXISTS `cloud`.`INSERT_EXTENSION_CUSTOM_ACTION_DETAILS_IF_NOT_EXISTS`; | ||
| CREATE PROCEDURE `cloud`.`INSERT_EXTENSION_CUSTOM_ACTION_DETAILS_IF_NOT_EXISTS` ( | ||
| IN ext_name VARCHAR(255), | ||
| IN action_name VARCHAR(255), | ||
| IN param_json TEXT | ||
| ) | ||
| BEGIN | ||
| DECLARE action_id BIGINT UNSIGNED | ||
| ; SELECT `eca`.`id` INTO action_id FROM `cloud`.`extension_custom_action` `eca` | ||
| JOIN `cloud`.`extension` `e` ON `e`.`id` = `eca`.`extension_id` | ||
| WHERE `eca`.`name` = action_name AND `e`.`name` = ext_name LIMIT 1 | ||
sureshanaparti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ; IF NOT EXISTS ( | ||
| SELECT 1 FROM `cloud`.`extension_custom_action_details` | ||
| WHERE `extension_custom_action_id` = action_id | ||
| AND `name` = 'parameters' | ||
| ) THEN | ||
| INSERT INTO `cloud`.`extension_custom_action_details` ( | ||
| `extension_custom_action_id`, | ||
| `name`, | ||
| `value`, | ||
| `display` | ||
| ) VALUES ( | ||
| action_id, | ||
| 'parameters', | ||
| param_json, | ||
| 0 | ||
| ) | ||
| ; END IF | ||
| ;END; | ||
46 changes: 46 additions & 0 deletions
46
...n/resources/META-INF/db/procedures/cloud.insert_extension_custom_action_if_not_exists.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| -- 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. | ||
|
|
||
| DROP PROCEDURE IF EXISTS `cloud`.`INSERT_EXTENSION_CUSTOM_ACTION_IF_NOT_EXISTS`; | ||
| CREATE PROCEDURE `cloud`.`INSERT_EXTENSION_CUSTOM_ACTION_IF_NOT_EXISTS`( | ||
| IN ext_name VARCHAR(255), | ||
| IN action_name VARCHAR(255), | ||
| IN action_desc VARCHAR(4096), | ||
| IN resource_type VARCHAR(255), | ||
| IN allowed_roles INT UNSIGNED, | ||
| IN success_msg VARCHAR(4096), | ||
| IN error_msg VARCHAR(4096), | ||
| IN timeout_seconds INT UNSIGNED | ||
| ) | ||
| BEGIN | ||
| DECLARE ext_id BIGINT | ||
| ; SELECT `id` INTO ext_id FROM `cloud`.`extension` WHERE `name` = ext_name LIMIT 1 | ||
sureshanaparti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ; IF NOT EXISTS ( | ||
| SELECT 1 FROM `cloud`.`extension_custom_action` WHERE `name` = action_name AND `extension_id` = ext_id | ||
| ) THEN | ||
| INSERT INTO `cloud`.`extension_custom_action` ( | ||
| `uuid`, `name`, `description`, `extension_id`, `resource_type`, | ||
| `allowed_role_types`, `success_message`, `error_message`, | ||
| `enabled`, `timeout`, `created`, `removed` | ||
| ) | ||
| VALUES ( | ||
| UUID(), action_name, action_desc, ext_id, resource_type, | ||
| allowed_roles, success_msg, error_msg, | ||
| 1, timeout_seconds, NOW(), NULL | ||
| ) | ||
| ; END IF | ||
| ;END; | ||
39 changes: 39 additions & 0 deletions
39
...src/main/resources/META-INF/db/procedures/cloud.insert_extension_detail_if_not_exists.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| -- 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. | ||
|
|
||
| DROP PROCEDURE IF EXISTS `cloud`.`INSERT_EXTENSION_DETAIL_IF_NOT_EXISTS`; | ||
| CREATE PROCEDURE `cloud`.`INSERT_EXTENSION_DETAIL_IF_NOT_EXISTS`( | ||
| IN ext_name VARCHAR(255), | ||
| IN detail_key VARCHAR(255), | ||
| IN detail_value TEXT, | ||
| IN display TINYINT(1) | ||
| ) | ||
| BEGIN | ||
| DECLARE ext_id BIGINT | ||
| ; SELECT `id` INTO ext_id FROM `cloud`.`extension` WHERE `name` = ext_name LIMIT 1 | ||
sureshanaparti marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ; IF NOT EXISTS ( | ||
| SELECT 1 FROM `cloud`.`extension_details` | ||
| WHERE `extension_id` = ext_id AND `name` = detail_key | ||
| ) THEN | ||
| INSERT INTO `cloud`.`extension_details` ( | ||
| `extension_id`, `name`, `value`, `display` | ||
| ) | ||
| VALUES ( | ||
| ext_id, detail_key, detail_value, display | ||
| ) | ||
| ; END IF | ||
| ;END; | ||
38 changes: 38 additions & 0 deletions
38
...schema/src/main/resources/META-INF/db/procedures/cloud.insert_extension_if_not_exists.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| -- 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. | ||
|
|
||
| DROP PROCEDURE IF EXISTS `cloud`.`INSERT_EXTENSION_IF_NOT_EXISTS`; | ||
| CREATE PROCEDURE `cloud`.`INSERT_EXTENSION_IF_NOT_EXISTS`( | ||
| IN ext_name VARCHAR(255), | ||
| IN ext_desc VARCHAR(255), | ||
| IN ext_path VARCHAR(255) | ||
| ) | ||
| BEGIN | ||
| IF NOT EXISTS ( | ||
| SELECT 1 FROM `cloud`.`extension` WHERE `name` = ext_name | ||
| ) THEN | ||
| INSERT INTO `cloud`.`extension` ( | ||
| `uuid`, `name`, `description`, `type`, | ||
| `relative_path`, `path_ready`, | ||
| `is_user_defined`, `state`, `created`, `removed` | ||
| ) | ||
| VALUES ( | ||
| UUID(), ext_name, ext_desc, 'Orchestrator', | ||
| ext_path, 1, 0, 'Enabled', NOW(), NULL | ||
| ) | ||
| ; END IF | ||
| ;END; |
33 changes: 33 additions & 0 deletions
33
...schema/src/main/resources/META-INF/db/procedures/cloud.update_category_for_guest_oses.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| -- 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. | ||
|
|
||
| -- Move existing guest OS to new categories | ||
| DROP PROCEDURE IF EXISTS `cloud`.`UPDATE_CATEGORY_FOR_GUEST_OSES`; | ||
| CREATE PROCEDURE `cloud`.`UPDATE_CATEGORY_FOR_GUEST_OSES`(IN category_name VARCHAR(255), IN os_name VARCHAR(255)) | ||
| BEGIN | ||
| DECLARE category_id BIGINT | ||
| ; SELECT `id` INTO category_id | ||
| FROM `cloud`.`guest_os_category` | ||
| WHERE `name` = category_name | ||
| LIMIT 1 | ||
| ; IF category_id IS NULL THEN | ||
| SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Category not found' | ||
| ; END IF | ||
| ; UPDATE `cloud`.`guest_os` | ||
| SET `category_id` = category_id | ||
| WHERE `display_name` LIKE CONCAT('%', os_name, '%') | ||
| ; END; |
34 changes: 34 additions & 0 deletions
34
...esources/META-INF/db/procedures/cloud.update_new_and_delete_old_category_for_guest_os.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| -- 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. | ||
|
|
||
| -- Move existing guest OS whose category will be deleted to Other category | ||
| DROP PROCEDURE IF EXISTS `cloud`.`UPDATE_NEW_AND_DELETE_OLD_CATEGORY_FOR_GUEST_OS`; | ||
| CREATE PROCEDURE `cloud`.`UPDATE_NEW_AND_DELETE_OLD_CATEGORY_FOR_GUEST_OS`(IN to_category_name VARCHAR(255), IN from_category_name VARCHAR(255)) | ||
| BEGIN | ||
| DECLARE to_category_id BIGINT | ||
| ; SELECT id INTO to_category_id | ||
| FROM `cloud`.`guest_os_category` | ||
| WHERE `name` = to_category_name | ||
| LIMIT 1 | ||
| ; IF to_category_id IS NULL THEN | ||
| SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'ToCategory not found' | ||
| ; END IF | ||
| ; UPDATE `cloud`.`guest_os` | ||
| SET `category_id` = to_category_id | ||
| WHERE `category_id` = (SELECT `id` FROM `cloud`.`guest_os_category` WHERE `name` = from_category_name) | ||
| ; UPDATE `cloud`.`guest_os_category` SET `removed`=now() WHERE `name` = from_category_name | ||
| ; END; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.