def create_cluster(self, name, ssh_public_key=None, **cluster_params): cluster = models.ClusterCreateParams(name=name, ssh_public_key=ssh_public_key, **cluster_params) log.info("Creating cluster with params %s", cluster.__dict__) result = self.client.register_cluster(new_cluster_params=cluster) return result
def create_cluster(self, name, overrides={}): existing_ids = [x['id'] for x in self.list_clusters() if x['name'] == name] if existing_ids: error(f"Cluster {name} already there. Leaving") sys.exit(1) if name.endswith('-day2'): self.create_day2_cluster(name, overrides) return self.set_default_values(overrides) new_cluster_params = default_cluster_params new_cluster_params['name'] = name extra_overrides = {} allowed_parameters = self._allowed_parameters(models.ClusterCreateParams) for parameter in overrides: if parameter == 'network_type' and overrides[parameter] not in ['OpenShiftSDN', 'OVNKubernetes']: extra_overrides[parameter] = overrides[parameter] continue if parameter in ['cluster_networks', 'service_networks']: extra_overrides[parameter] = overrides[parameter] continue if parameter in allowed_parameters: new_cluster_params[parameter] = overrides[parameter] elif parameter not in ['api_ip', 'ingress_ip']: extra_overrides[parameter] = overrides[parameter] else: warning(f"Omitting parameter {parameter} at creation time") cluster_params = models.ClusterCreateParams(**new_cluster_params) self.client.v2_register_cluster(new_cluster_params=cluster_params) if extra_overrides: self.update_cluster(name, extra_overrides)