def test_create_over_api(self): """Verify Cluster is created over API and kubeconfig is set""" url = url_for('api.cluster_list') data = self.create_kwargs_cluster data['provisioner'] = 'Provisioner:{}'.format(data['provisioner'].id) data['owner'] = 'User:{}'.format(data['owner'].id) # create response = self.client.post(url, data=json.dumps(data), headers=self.auth_header, content_type='application/json') assert response.status_code == 200 # load cluster_id = response.json['id'] obj = Cluster.load(self.namespace, cluster_id) validation, _ = obj.validate() assert validation # check parameters assert obj.kubeconfig == data['kubeconfig'] return obj
def test_load(self, cluster): get_id = cluster.id cluster.save() loaded = Cluster.load(get_id) assert loaded == cluster assert hasattr(loaded, '_key'), 'Loaded object is missing _key'
def test_load(self, cluster): cluster.save() get_id = cluster.id loaded = Cluster.load(cluster._object_namespace, get_id) assert loaded.get_dict(True) == cluster.get_dict(True) assert hasattr(loaded, '_key'), 'Loaded object is missing _key'
def cluster_detail(cluster_id): # read uuid try: object_id = UUID(cluster_id, version=4) except ValueError: abort(404) # load object try: obj = Cluster.load(object_id) except NameError: abort(404) return jsonify(obj.get_dict())
def test_kubeconfig_load_is_dict(self, cluster): cluster.save() loaded = Cluster.load(cluster._object_namespace, cluster.id) assert isinstance(loaded.kubeconfig, dict), 'Loaded kubeconfig is not dict'
#!/usr/bin/env python3 from kqueen.server import create_app from kqueen.models import Cluster app = create_app() with app.app_context(): cluster = Cluster.load('demoorg', 'c02d3b7c-d06e-11e7-973c-68f72873a109') print(cluster) print(cluster.get_dict()) print(cluster.engine) print(cluster.provisioner.get_engine_cls()) # cluster.engine.provision() print(cluster.engine.get_kubeconfig()) # cluster.engine.deprovision()
#!/usr/bin/env python3 from kqueen.server import create_app from kqueen.models import Cluster app = create_app() with app.app_context(): cluster = Cluster.load('demoorg', '9212695e-3aad-434d-ba26-3403481d37a1') print(cluster) print(cluster.get_dict()) print(cluster.engine) print(cluster.provisioner.get_engine_cls()) cluster.engine.provision() print(cluster.engine.get_kubeconfig())