import json


def _get_optional_fields_from_file(vm_config_file):
    """
    Retrieve optional `version` and `ipv4_address` fields from MMDS config.

    Parse the vm config json file and retrieves optional  fields from MMDS
    config. Default values are used for the fields that are not specified.

    :return: a pair of (version, ipv4_address) fields from mmds config.
    """
    # Get MMDS version and IPv4 address configured from the file.
    with open(vm_config_file, encoding='utf-8') as json_file:
        mmds_config = json.load(json_file)["mmds-config"]
        # Default to V1 if version is not specified.
        version = mmds_config.get("version", "V1")
        # Set to default if IPv4 is not specified .
        ipv4_address = mmds_config.get("ipv4_address", "169.254.169.254")

        return version, ipv4_address