- @staticmethod
- def _ip_profile_to_ro(
- ip_profile: Dict[str, Any],
- ) -> Dict[str, Any]:
- """[summary]
-
- Args:
- ip_profile (Dict[str, Any]): [description]
-
- Returns:
- Dict[str, Any]: [description]
- """
- if not ip_profile:
- return None
-
- ro_ip_profile = {
- "ip_version": "IPv4"
- if "v4" in ip_profile.get("ip-version", "ipv4")
- else "IPv6",
- "subnet_address": ip_profile.get("subnet-address"),
- "gateway_address": ip_profile.get("gateway-address"),
- "dhcp_enabled": ip_profile.get("dhcp-params", {}).get("enabled", False),
- "dhcp_start_address": ip_profile.get("dhcp-params", {}).get(
- "start-address", None
- ),
- "dhcp_count": ip_profile.get("dhcp-params", {}).get("count", None),
- }
-
- if ip_profile.get("dns-server"):
- ro_ip_profile["dns_address"] = ";".join(
- [v["address"] for v in ip_profile["dns-server"] if v.get("address")]
- )
-
- if ip_profile.get("security-group"):
- ro_ip_profile["security_group"] = ip_profile["security-group"]
-
- return ro_ip_profile
-