def __new__(cls, client: vcd_client.Client): """Create the right ovdc class for the negotiated API version. For apiVersion < 35 return MetadataBasedOvdc class For apiVersoin >= 35 return PolicyBasedOvdc class :param pyvcloud.vcd.client client: vcd client :return: instance of version specific client side Ovdc class """ api_version = client.get_vcd_api_version() if api_version < vcd_client.VcdApiVersionObj.VERSION_35.value: return MetadataBasedOvdc(client) elif api_version >= vcd_client.VcdApiVersionObj.VERSION_35.value: # noqa: E501 return PolicyBasedOvdc(client)
def __init__(self, sysadmin_client: vcd_client.Client, debug_logger=logger.SERVER_LOGGER, log_wire=True): # Ensure correct credentials and api version vcd_utils.raise_error_if_user_not_from_system_org(sysadmin_client) client_api_version = sysadmin_client.get_vcd_api_version() if client_api_version < constants.MQTT_MIN_API_VERSION: raise ValueError(f'API version {client_api_version} ' f'is less than required version ' f'{constants.MQTT_MIN_API_VERSION} to use MQTT') self._sysadmin_client: vcd_client.Client = sysadmin_client wire_logger = logger.NULL_LOGGER if log_wire: wire_logger = logger.SERVER_CLOUDAPI_WIRE_LOGGER self._wire_logger = wire_logger self._debug_logger = debug_logger self._cloudapi_client = vcd_utils.get_cloudapi_client_from_vcd_client( client=self._sysadmin_client, logger_debug=self._debug_logger, logger_wire=self._wire_logger)
def __new__(cls, client: vcd_client.Client, k8_runtime=None): """Create the right cluster class for the negotiated API version. In case of ApiVersion.VERSION_35, return specific instance if the cluster kind is known up-front. If the cluster entity kind is unknown, return instance of DefEntityCluster for all common operations like get_cluster_info(), list_clusters() :param pyvcloud.vcd.client client: vcd client :return: instance of version specific client side cluster """ api_version = client.get_vcd_api_version() if api_version < vcd_client.VcdApiVersionObj.VERSION_35.value: return LegacyClusterNative(client) elif api_version >= vcd_client.VcdApiVersionObj.VERSION_35.value: if k8_runtime in CSE_SERVER_RUNTIMES: return DEClusterNative(client) elif k8_runtime == ClusterEntityKind.TKG_S.value: return DEClusterTKGS(client) else: return DECluster(client)