Skip to content
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

Fix for netscaler migration and ansible config #2888

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 55 additions & 52 deletions python/avi/migrationtools/ansible/ansible_config_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,58 +442,61 @@ def generate_traffic(self, ansible_dict, f5server, f5username, f5password,
partition = data['partition-vs-mappings']
else:
partition = self.partitions
ip = vs[VIP][0]['ip_address']['addr']
port = vs[SERVICES][0]['port']
vip = '%s:%s' % (ip, port)
if trafic_obj.get_status_vs(
vs[NAME], vip, f5server, f5username, f5password, tenant,
partitions=partition):

vs_dict = dict()
vs_dict[NAME] = vs[NAME]
vs_dict[VIP] = vs[VIP]
vs_dict[SERVICES] = vs[SERVICES]
vs_dict[CONTROLLER] = CONTROLLER_INPUT
vs_dict[USERNAME] = USER_NAME
vs_dict[PASSWORD] = PASSWORD_NAME
vs_dict[API_VERSION] = self.api_version

if POOL_REF in vs:
sep_ele = vs[POOL_REF].split('&')
removed_ref = sep_ele[0].split('?')
vs_dict[POOL_REF] = removed_ref[0] + '?' + sep_ele[1]
f5_dict = self.get_f5_attributes(vs_dict)
f5_virtual_address_dict = \
self.get_f5_virtual_address_attrs(vs_dict)
# Call to distinguish between f5 and netscaler
trafic_obj.create_ansible_disable(f5_dict, ansible_dict)
if instace_type == 'f5':
trafic_obj.create_virtual_address_disable(
f5_virtual_address_dict, ansible_dict)
trafic_obj.create_avi_ansible_enable(
vs_dict, ansible_dict, test_vip=self.test_vip)
# Getting the request type
if APPLICATION_PROFILE_REF in vs:
self.generate_avi_vs_traffic(
vs_dict, ansible_dict,
vs[APPLICATION_PROFILE_REF],
tenant=tenant,
test_vip=self.test_vip
)
else:
self.generate_avi_vs_traffic(
vs_dict, ansible_dict,
'http',
tenant=tenant
)
if self.test_vip:
trafic_obj.update_avi_ansible_vip(
vs_dict, ansible_dict)
trafic_obj.create_avi_ansible_disable(vs_dict, ansible_dict)
trafic_obj.create_ansible_enable(f5_dict, ansible_dict)
if instace_type == 'f5':
trafic_obj.create_virtual_address_enable(
f5_virtual_address_dict, ansible_dict)
if vs['vh_type'] != 'VS_TYPE_VH_SNI':
vsvip = vs['vsvip_ref'].split('=')[2].split('&')[0]
vipobj = [vip for vip in self.avi_cfg['VsVip'] if vip[NAME] == vsvip][0]
ip = vipobj[VIP][0]['ip_address']['addr']
port = vs[SERVICES][0]['port']
vip = '%s:%s' % (ip, port)
if trafic_obj.get_status_vs(
vs[NAME], vip, f5server, f5username, f5password, tenant,
partitions=partition):

vs_dict = dict()
vs_dict[NAME] = vs[NAME]
vs_dict[VIP] = vipobj[VIP]
vs_dict[SERVICES] = vs[SERVICES]
vs_dict[CONTROLLER] = CONTROLLER_INPUT
vs_dict[USERNAME] = USER_NAME
vs_dict[PASSWORD] = PASSWORD_NAME
vs_dict[API_VERSION] = self.api_version

if POOL_REF in vs:
sep_ele = vs[POOL_REF].split('&')
removed_ref = sep_ele[0].split('?')
vs_dict[POOL_REF] = removed_ref[0] + '?' + sep_ele[1]
f5_dict = self.get_f5_attributes(vs_dict)
f5_virtual_address_dict = \
self.get_f5_virtual_address_attrs(vs_dict)
# Call to distinguish between f5 and netscaler
trafic_obj.create_ansible_disable(f5_dict, ansible_dict)
if instace_type == 'f5':
trafic_obj.create_virtual_address_disable(
f5_virtual_address_dict, ansible_dict)
trafic_obj.create_avi_ansible_enable(
vs_dict, ansible_dict, test_vip=self.test_vip)
# Getting the request type
if APPLICATION_PROFILE_REF in vs:
self.generate_avi_vs_traffic(
vs_dict, ansible_dict,
vs[APPLICATION_PROFILE_REF],
tenant=tenant,
test_vip=self.test_vip
)
else:
self.generate_avi_vs_traffic(
vs_dict, ansible_dict,
'http',
tenant=tenant
)
if self.test_vip:
trafic_obj.update_avi_ansible_vip(
vs_dict, ansible_dict)
trafic_obj.create_avi_ansible_disable(vs_dict, ansible_dict)
trafic_obj.create_ansible_enable(f5_dict, ansible_dict)
if instace_type == 'f5':
trafic_obj.create_virtual_address_enable(
f5_virtual_address_dict, ansible_dict)
# Added call to check progress.
progressbar_count += 1
msg = "Ansible Generate Traffic..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@ def convert_monitor(self, ns_monitor, input_dir, netscalar_command,

custom_header = ns_monitor.get('customHeaders')
if custom_header:
avi_monitor['https_monitor'].update({
avi_monitor['https_monitor'] = {
'exact_http_request': True,
'http_request': (send + ' HTTP/1.0' + "\r\n" +
custom_header + "\r\n").replace('"',
'').replace('\\r\\n', '\r\n') if
send else ('HTTP/1.0' + "\r\n" +
custom_header + "\r\n").replace('"',
'').replace('\\r\\n', '\r\n')
})
}
elif mon_type == 'HTTP':
avi_monitor["type"] = "HEALTH_MONITOR_HTTP"
send = ns_monitor.get('httpRequest', None)
Expand Down