Skip to content

Conversation

@yadvr
Copy link
Member

@yadvr yadvr commented Mar 13, 2019

Problem: Not able to configure a sort order for the zone that are listed in various views in the UI.
Root Cause: There was no mechanism to accept sort key for existing zones or UI widget to drag them in a certain order.
Solution: The order can now be configured through the editZone API by providing sort_key parameter for zones, or by reordering the zones in the Zones list in the UI. Database changes include updating table “data_center” which contains the “sort_key” column containing integer values and defaults to zero.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

51236319-da9d2a80-1997-11e9-9c23-b8a4e5e27ccd

This adds support to allow admins to sort zones, and based on the sorted
order the zones will be listed in UI and API.

Signed-off-by: Rohit Yadav <[email protected]>
@yadvr
Copy link
Member Author

yadvr commented Mar 13, 2019

@borisstoyanov @PaulAngus hold testing until master is available again. This introduces an upgrade path that is missing between 4.12 and 4.13. The sql changes are:

DROP PROCEDURE IF EXISTS `cloud`.`IDEMPOTENT_ADD_COLUMN`;

CREATE PROCEDURE `cloud`.`IDEMPOTENT_ADD_COLUMN` (
		IN in_table_name VARCHAR(200)
    , IN in_column_name VARCHAR(200)
    , IN in_column_definition VARCHAR(1000)
)
BEGIN

    DECLARE CONTINUE HANDLER FOR 1060 BEGIN END; SET @ddl = CONCAT('ALTER TABLE ', in_table_name); SET @ddl = CONCAT(@ddl, ' ', 'ADD COLUMN') ; SET @ddl = CONCAT(@ddl, ' ', in_column_name); SET @ddl = CONCAT(@ddl, ' ', in_column_definition); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; END;

-- Add sort_key to data_center
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.data_center', 'sort_key', 'INT(32) NOT NULL DEFAULT 0');
DROP VIEW IF EXISTS `cloud`.`data_center_view`;
CREATE VIEW `cloud`.`data_center_view` AS
    select
        data_center.id,
        data_center.uuid,
        data_center.name,
        data_center.is_security_group_enabled,
        data_center.is_local_storage_enabled,
        data_center.description,
        data_center.dns1,
        data_center.dns2,
        data_center.ip6_dns1,
        data_center.ip6_dns2,
        data_center.internal_dns1,
        data_center.internal_dns2,
        data_center.guest_network_cidr,
        data_center.domain,
        data_center.networktype,
        data_center.allocation_state,
        data_center.zone_token,
        data_center.dhcp_provider,
        data_center.removed,
        data_center.sort_key,
        domain.id domain_id,
        domain.uuid domain_uuid,
        domain.name domain_name,
        domain.path domain_path,
        dedicated_resources.affinity_group_id,
        dedicated_resources.account_id,
        affinity_group.uuid affinity_group_uuid
    from
        `cloud`.`data_center`
            left join
        `cloud`.`domain` ON data_center.domain_id = domain.id
            left join
        `cloud`.`dedicated_resources` ON data_center.id = dedicated_resources.data_center_id
            left join
        `cloud`.`affinity_group` ON dedicated_resources.affinity_group_id = affinity_group.id; 

@yadvr yadvr changed the title server: add support for sorting zones in UI/api [WIP] server: add support for sorting zones in UI/api Mar 13, 2019
@yadvr yadvr closed this Mar 13, 2019
@yadvr
Copy link
Member Author

yadvr commented Apr 5, 2019

Moved: #3242

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant