def __init__(self, hostname, username, password, verify=True, prefix=""):
"""
Constructor, creating the class. It requires specifying a
hostname, username and password to access the API. After
initialization, a connected is established.
:param hostname: Foreman host
:type hostname: str
:param username: API username
:type username: str
:param password: corresponding password
:type password: str
:param verify: force SSL verification
:type verify: bool
:param prefix: API prefix (e.g. /katello)
:type prefix: str
"""
#disable SSL warning outputs
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
#set connection information
self.HOSTNAME = self.validate_hostname(hostname)
self.USERNAME = username
self.PASSWORD = password
self.VERIFY = verify
self.URL = "https://{0}{1}/api/v2".format(self.HOSTNAME, prefix)
#start session and check API version if Foreman API
self.__connect()
if prefix == "":
self.validate_api_support()
评论列表
文章目录