def l_garden(): return Garden( name="parent", connection_type="local", systems=[] # name="parent", connection_type="local", systems=[str(p_sys_1), str(p_sys_2)] )
def create_garden(garden: Garden) -> Garden: """Create a new Garden Args: garden: The Garden to create Returns: The created Garden """ garden.status_info["heartbeat"] = datetime.utcnow() return db.create(garden)
def create_garden(garden: Garden) -> Garden: """Create a new Garden Args: garden: The Garden to create Returns: The created Garden """ # Explicitly load default config options into garden params spec = YapconfSpec(_CONNECTION_SPEC) # bg_host is required to load brewtils garden spec defaults = spec.load_config({"bg_host": ""}) config_map = { "bg_host": "host", "bg_port": "port", "ssl_enabled": "ssl", "bg_url_prefix": "url_prefix", "ca_cert": "ca_cert", "ca_verify": "ca_verify", "client_cert": "client_cert", } if garden.connection_params is None: garden.connection_params = {} garden.connection_params.setdefault("http", {}) for key in config_map: garden.connection_params["http"].setdefault(config_map[key], defaults[key]) garden.status_info["heartbeat"] = datetime.utcnow() return db.create(garden)
def test_update_garden_connection_info(self): child_garden = Garden(name=self.child_garden_name) payload = self.parser.serialize_garden(child_garden) response = self.easy_client.client.session.post( self.easy_client.client.base_url + "api/v1/gardens", data=payload, headers=self.easy_client.client.JSON_HEADERS) assert response.ok created_child = response.json() print(created_child) created_child['connection_type'] = "STOMP" created_child['connection_params'] = { "stomp": { "host": "activemq", "port": 61613, "send_destination": "Beer_Garden_Operations_Parent", "subscribe_destination": "Beer_Garden_Events_Parent", "username": "******", "password": "******", "ssl": { "use_ssl": False }, } } patch = PatchOperation(operation="config", path='', value=created_child) payload = self.parser.serialize_patch(patch) updated_response = self.easy_client.client.session.patch( self.easy_client.client.base_url + "api/v1/gardens/" + self.child_garden_name, data=payload, headers=self.easy_client.client.JSON_HEADERS) assert updated_response.ok
def _prepare_beer_garden(self) -> int: """Ensure the beer garden environment is correct for the tests.""" parent, child, other = [], [], [] gardens = self._get_gardens() garden_count = 0 # partition the gardens on the system for garden in gardens: if garden.name == self.parent_garden_name: parent.append(garden) elif garden.name == self.child_garden_name: child.append(garden) else: other.append(garden) for garden_list, garden_name, the_client, label in [ (parent, self.parent_garden_name, self.easy_client, "parent"), (child, self.child_garden_name, self.easy_client, "child"), ]: if len(garden_list) == 0: # if there is no garden of this type, create one if not the_client.client.session.post( the_client.client.base_url + "api/v1/gardens", data=self.parser.serialize_garden( Garden(name=garden_name)), headers=the_client.client.JSON_HEADERS, ).ok: raise IntegrationTestSetupFailure( f"No {label} garden present and unable to create one") else: garden_count += 1 else: garden_count += 1 _ = garden_list.pop() # so we can be 100% sure that there are exactly 2 gardens (parent and child), # delete any other gardens if they exist for garden in parent + child + other: self.easy_client.client.session.delete( self.easy_client.client.base_url + "api/v1/gardens/" + garden.name) return garden_count
def local_garden(all_systems: bool = False) -> Garden: """Get the local garden definition Args: all_systems: If False, only include "local" systems in the garden systems list Returns: The local Garden """ filter_params = {} if not all_systems: filter_params["local"] = True return Garden( name=config.get("garden.name"), connection_type="LOCAL", status="RUNNING", systems=get_systems(filter_params=filter_params), namespaces=get_namespaces(), )
def c_garden(c_sys_1, c_sys_2): return Garden(name="child", connection_type="http", systems=[c_sys_1, c_sys_2])
def p_garden(p_sys_1, p_sys_2): return Garden(name="parent", connection_type="local", systems=[p_sys_1, p_sys_2])
def bg_garden(garden_dict, bg_system): """An operation as a model.""" dict_copy = copy.deepcopy(garden_dict) dict_copy["systems"] = [bg_system] return Garden(**dict_copy)