def _get_server(self, attr_name): """lookup server info by name from context attr_name: either a name for a server created by yardstick or a dict with attribute name mapping when using external heat templates """ if isinstance(attr_name, collections.Mapping): node_name, cname = self.split_host_name(attr_name['name']) if cname is None or cname != self.name: return None # Create a dummy server instance for holding the *_ip attributes server = Server(node_name, self, {}) server.public_ip = self.stack.outputs.get( attr_name.get("public_ip_attr", object()), None) server.private_ip = self.stack.outputs.get( attr_name.get("private_ip_attr", object()), None) else: try: server = self._server_map[attr_name] except KeyError: attr_name_no_suffix = attr_name.split("-")[0] server = self._server_map.get(attr_name_no_suffix, None) if server is None: return None pkey = pkg_resources.resource_string( 'yardstick.resources', h_join('files/yardstick_key', self.name)).decode('utf-8') key_filename = pkg_resources.resource_filename( 'yardstick.resources', h_join('files/yardstick_key', self.name)) result = { "user": server.context.user, "pkey": pkey, "key_filename": key_filename, "private_ip": server.private_ip, "interfaces": server.interfaces, "routing_table": self.generate_routing_table(server), # empty IPv6 routing table "nd_route_tbl": [], # we want to save the contex name so we can generate pod.yaml "name": server.name, } # Target server may only have private_ip if server.public_ip: result["ip"] = server.public_ip return result
def _get_server(self, attr_name): """lookup server info by name from context attr_name: either a name for a server created by yardstick or a dict with attribute name mapping when using external heat templates """ key_filename = pkg_resources.resource_filename( 'yardstick.resources', 'files/yardstick_key-' + get_short_key_uuid(self.key_uuid)) if isinstance(attr_name, collections.Mapping): cname = attr_name["name"].split(".")[1] if cname != self.name: return None public_ip = None private_ip = None if "public_ip_attr" in attr_name: public_ip = self.stack.outputs[attr_name["public_ip_attr"]] if "private_ip_attr" in attr_name: private_ip = self.stack.outputs[ attr_name["private_ip_attr"]] # Create a dummy server instance for holding the *_ip attributes server = Server(attr_name["name"].split(".")[0], self, {}) server.public_ip = public_ip server.private_ip = private_ip else: if attr_name not in self._server_map: return None server = self._server_map[attr_name] if server is None: return None result = { "user": server.context.user, "key_filename": key_filename, "private_ip": server.private_ip, "interfaces": server.interfaces, } # Target server may only have private_ip if server.public_ip: result["ip"] = server.public_ip return result
def _get_server(self, attr_name): '''lookup server info by name from context attr_name: either a name for a server created by yardstick or a dict with attribute name mapping when using external heat templates ''' key_filename = pkg_resources.resource_filename( 'yardstick.resources', 'files/yardstick_key') if type(attr_name) is dict: cname = attr_name["name"].split(".")[1] if cname != self.name: return None public_ip = None private_ip = None if "public_ip_attr" in attr_name: public_ip = self.stack.outputs[attr_name["public_ip_attr"]] if "private_ip_attr" in attr_name: private_ip = self.stack.outputs[ attr_name["private_ip_attr"]] # Create a dummy server instance for holding the *_ip attributes server = Server(attr_name["name"].split(".")[0], self, {}) server.public_ip = public_ip server.private_ip = private_ip else: if attr_name not in self._server_map: return None server = self._server_map[attr_name] if server is None: return None result = { "user": server.context.user, "key_filename": key_filename, "private_ip": server.private_ip } # Target server may only have private_ip if server.public_ip: result["ip"] = server.public_ip return result
def _get_server(self, attr_name): """lookup server info by name from context attr_name: either a name for a server created by yardstick or a dict with attribute name mapping when using external heat templates """ key_filename = pkg_resources.resource_filename( 'yardstick.resources', h_join('files/yardstick_key', get_short_key_uuid(self.key_uuid))) if isinstance(attr_name, collections.Mapping): node_name, cname = self.split_name(attr_name['name']) if cname is None or cname != self.name: return None # Create a dummy server instance for holding the *_ip attributes server = Server(node_name, self, {}) server.public_ip = self.stack.outputs.get( attr_name.get("public_ip_attr", object()), None) server.private_ip = self.stack.outputs.get( attr_name.get("private_ip_attr", object()), None) else: server = self._server_map.get(attr_name, None) if server is None: return None result = { "user": server.context.user, "key_filename": key_filename, "private_ip": server.private_ip, "interfaces": server.interfaces, "routing_table": self.generate_routing_table(server), # empty IPv6 routing table "nd_route_tbl": [], } # Target server may only have private_ip if server.public_ip: result["ip"] = server.public_ip return result
def _get_server(self, attr_name): """lookup server info by name from context attr_name: either a name for a server created by yardstick or a dict with attribute name mapping when using external heat templates """ if isinstance(attr_name, collections.Mapping): node_name, cname = self.split_host_name(attr_name['name']) if cname is None or cname != self.name: return None # Create a dummy server instance for holding the *_ip attributes server = Server(node_name, self, {}) server.public_ip = self.stack.outputs.get( attr_name.get("public_ip_attr", object()), None) server.private_ip = self.stack.outputs.get( attr_name.get("private_ip_attr", object()), None) # Try to find interfaces for key, value in attr_name.get("interfaces", {}).items(): value["local_ip"] = server.private_ip for k in ["local_mac", "netmask", "gateway_ip"]: # Keep explicit None or missing entry as is value[k] = self.stack.outputs.get(value[k]) server.interfaces.update({key: value}) else: try: server = self._server_map[attr_name] except KeyError: attr_name_no_suffix = attr_name.split("-")[0] server = self._server_map.get(attr_name_no_suffix, None) if server is None: return None # Get the pkey if self.yardstick_gen_key_file: pkey = pkg_resources.resource_string( 'yardstick.resources', h_join('files/yardstick_key', self.name)).decode('utf-8') key_filename = pkg_resources.resource_filename('yardstick.resources', h_join('files/yardstick_key', self.name)) else: # make sure the file exists before attempting to open it if not os.path.exists(self.key_filename): LOG.error("The key_filename provided %s does not exist!", self.key_filename) else: try: pkey = open(self.key_filename, 'r').read().decode('utf-8') key_filename = self.key_filename except IOError: LOG.error("The key_filename provided (%s) is unreadable.", self.key_filename) result = { "user": server.context.user, "pkey": pkey, "key_filename": key_filename, "private_ip": server.private_ip, "interfaces": server.interfaces, "routing_table": self.generate_routing_table(server), # empty IPv6 routing table "nd_route_tbl": [], # we want to save the contex name so we can generate pod.yaml "name": server.name, } # Target server may only have private_ip if server.public_ip: result["ip"] = server.public_ip return result