diff --git a/CHANGELOG.md b/CHANGELOG.md index 191e73955dc2add04f347e4981892255a1da7c17..d95aea21e8256a1cc18a5bbd650ab9b958a4abc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.2.0] - 2024-06-11 +### Changed +- source and destination entity names now match except security groups where prefix migrated- is kept + ## [1.1.3] - 2024-05-31 ### Fixed - assert disabled projects diff --git a/ci/lib.py b/ci/lib.py index 473d38f0be827682f3c91177a26212fa4096193d..1d5ae0eac56771333aaa65e51b7c6e98a118cf2d 100644 --- a/ci/lib.py +++ b/ci/lib.py @@ -88,6 +88,10 @@ def normalize_table_data(data): int_list.append(normalize_table_data_field(i_data_field['field'])) return int_list +def get_dst_secgroup_name(args, name=""): + """ translate original secgroup name to destination one """ + return f"{args.destination_secgroup_name_prefix}{name}" + def get_dst_resource_name(args, name=""): """ translate original name to destination one """ return f"{args.destination_entity_name_prefix}{name}" diff --git a/ci/olib.py b/ci/olib.py index 2271136812b1af6a4d1fea542450bfa2c5857e09..1da2a1c6faa429268d38291ad8987eeffbb713e8 100644 --- a/ci/olib.py +++ b/ci/olib.py @@ -10,7 +10,7 @@ import xmltodict import openstack import clib -from lib import log_or_assert, get_dst_resource_name, get_dst_resource_desc, remote_cmd_exec, normalize_table_data, trim_dict, wait_for_ostack_volume_status +from lib import log_or_assert, get_dst_resource_name, get_dst_secgroup_name, get_dst_resource_desc, remote_cmd_exec, normalize_table_data, trim_dict, wait_for_ostack_volume_status def get_destination_network(source_network): """ LUT for networks """ @@ -367,7 +367,7 @@ def get_or_create_dst_server_keypair(args, source_keypairs, src_server, dst_osta def create_security_groups(args, src_ostack_conn, dst_ostack_conn, src_security_group, dst_project, recursion_stack=None): """ create openstack security group[s] """ int_recursion_stack = {} if recursion_stack is None else recursion_stack - int_sg = dst_ostack_conn.network.create_security_group(name=get_dst_resource_name(args, src_security_group.name), + int_sg = dst_ostack_conn.network.create_security_group(name=get_dst_secgroup_name(args, src_security_group.name), description=get_dst_resource_desc(args, src_security_group.description, src_security_group.id), @@ -386,7 +386,7 @@ def create_security_groups(args, src_ostack_conn, dst_ostack_conn, src_security_ i_mod_rule['remote_group_id'] = int_recursion_stack[i_mod_rule['remote_group_id']] # get linked source SG elif _src_sg := src_ostack_conn.network.find_security_group(i_mod_rule['remote_group_id']): - if _dst_sg := dst_ostack_conn.network.find_security_group(get_dst_resource_name(args, _src_sg.name), + if _dst_sg := dst_ostack_conn.network.find_security_group(get_dst_secgroup_name(args, _src_sg.name), project_id=dst_project.id): i_mod_rule['remote_group_id'] = _dst_sg.id else: @@ -409,7 +409,7 @@ def duplicate_ostack_project_security_groups(args, src_ostack_conn, dst_ostack_c for i_src_security_group in src_project_security_groups: j_dst_security_group_found = False for j_dst_security_group in tuple(dst_ostack_conn.network.security_groups(project_id=dst_project.id)): - if get_dst_resource_name(args, i_src_security_group.name) == j_dst_security_group.name and \ + if get_dst_secgroup_name(args, i_src_security_group.name) == j_dst_security_group.name and \ i_src_security_group.id in j_dst_security_group.description: j_dst_security_group_found = True if not j_dst_security_group_found: @@ -425,7 +425,7 @@ def get_or_create_dst_server_security_groups(args, src_ostack_conn, dst_ostack_c i_src_server_security_group = src_ostack_conn.network.find_security_group(i_src_server_security_group_name, project_id=src_project.id) i_dst_server_security_group = None - if i_dst_server_security_group := dst_ostack_conn.network.find_security_group(get_dst_resource_name(args, + if i_dst_server_security_group := dst_ostack_conn.network.find_security_group(get_dst_secgroup_name(args, i_src_server_security_group.name), project_id=dst_project.id): log_or_assert(args, diff --git a/ci/project-migrator.py b/ci/project-migrator.py index 464fc6786a921e47f304ec5f0040e28f260e5259..d208564abebfb947383680267007c68f311583e9 100755 --- a/ci/project-migrator.py +++ b/ci/project-migrator.py @@ -336,8 +336,10 @@ if __name__ == "__main__": help='Destination cloud bootable volumes are made on top of public image. Name of destination cloud image.') AP.add_argument('--destination-ipv4-external-network', default='external-ipv4-general-public', help='Destination cloud IPV4 external network.') - AP.add_argument('--destination-entity-name-prefix', default='migrated-', - help='Destination cloud entity name prefix.') + AP.add_argument('--destination-secgroup-entity-name-prefix', default='migrated-', + help='Destination cloud security_groups entity name prefix.') + AP.add_argument('--destination-entity-name-prefix', default='', + help='Destination cloud entity name prefix (all except secgroups).') AP.add_argument('--destination-entity-description-suffix', default=', migrated(id:{})', help='Destination cloud entity description suffix.')