_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q36400
Server.setup_assertion
train
def setup_assertion(self, authn, sp_entity_id, in_response_to, consumer_url, name_id, policy, _issuer, authn_statement, identity, best_effort, sign_response, farg=None, session_not_on_or_after=None, **kwargs): """ Construct and retu...
python
{ "resource": "" }
q36401
Server._authn_response
train
def _authn_response(self, in_response_to, consumer_url, sp_entity_id, identity=None, name_id=None, status=None, authn=None, issuer=None, policy=None, sign_assertion=False, sign_response=False, best_effort=False, encrypt_asse...
python
{ "resource": "" }
q36402
Server.create_attribute_response
train
def create_attribute_response(self, identity, in_response_to, destination, sp_entity_id, userid="", name_id=None, status=None, issuer=None, sign_assertion=False, sign_response=False, a...
python
{ "resource": "" }
q36403
Server.create_authn_response
train
def create_authn_response(self, identity, in_response_to, destination, sp_entity_id, name_id_policy=None, userid=None, name_id=None, authn=None, issuer=None, sign_response=None, sign_assertion=None, e...
python
{ "resource": "" }
q36404
Server.create_name_id_mapping_response
train
def create_name_id_mapping_response(self, name_id=None, encrypted_id=None, in_response_to=None, issuer=None, sign_response=False, status=None, sign_alg=None, di...
python
{ "resource": "" }
q36405
Server.clean_out_user
train
def clean_out_user(self, name_id): """ Remove all authentication statements that belongs to a user identified by a NameID instance :param name_id: NameID instance :return: The local identifier for the user """ lid = self.ident.find_local_id(name_id) logg...
python
{ "resource": "" }
q36406
_mdb_get_database
train
def _mdb_get_database(uri, **kwargs): """ Helper-function to connect to MongoDB and return a database object. The `uri' argument should be either a full MongoDB connection URI string, or just a database name in which case a connection to the default mongo instance at mongodb://localhost:27017 will ...
python
{ "resource": "" }
q36407
add_path
train
def add_path(tdict, path): """ Create or extend an argument tree `tdict` from `path`. :param tdict: a dictionary representing a argument tree :param path: a path list :return: a dictionary Convert a list of items in a 'path' into a nested dict, where the second to last item becomes the key...
python
{ "resource": "" }
q36408
valid_email
train
def valid_email(emailaddress, domains=GENERIC_DOMAINS): """Checks for a syntactically valid email address.""" # Email address must be at least 6 characters in total. # Assuming noone may have addresses of the type a@com if len(emailaddress) < 6: return False # Address too short. # Split u...
python
{ "resource": "" }
q36409
deflate_and_base64_encode
train
def deflate_and_base64_encode(string_val): """ Deflates and the base64 encodes a string :param string_val: The string to deflate and encode :return: The deflated and encoded string """ if not isinstance(string_val, six.binary_type): string_val = string_val.encode('utf-8') return bas...
python
{ "resource": "" }
q36410
rndbytes
train
def rndbytes(size=16, alphabet=""): """ Returns rndstr always as a binary type """ x = rndstr(size, alphabet) if isinstance(x, six.string_types): return x.encode('utf-8') return x
python
{ "resource": "" }
q36411
parse_attribute_map
train
def parse_attribute_map(filenames): """ Expects a file with each line being composed of the oid for the attribute exactly one space, a user friendly name of the attribute and then the type specification of the name. :param filenames: List of filenames on mapfiles. :return: A 2-tuple, one dictio...
python
{ "resource": "" }
q36412
signature
train
def signature(secret, parts): """Generates a signature. All strings are assumed to be utf-8 """ if not isinstance(secret, six.binary_type): secret = secret.encode('utf-8') newparts = [] for part in parts: if not isinstance(part, six.binary_type): part = part.encode('utf-8...
python
{ "resource": "" }
q36413
MetaData.any
train
def any(self, typ, service, binding=None): """ Return any entity that matches the specification :param typ: Type of entity :param service: :param binding: :return: """ res = {} for ent in self.keys(): bind = self.service(ent, typ, serv...
python
{ "resource": "" }
q36414
MetaData.bindings
train
def bindings(self, entity_id, typ, service): """ Get me all the bindings that are registered for a service entity :param entity_id: :param service: :return: """ return self.service(entity_id, typ, service)
python
{ "resource": "" }
q36415
MetaData.with_descriptor
train
def with_descriptor(self, descriptor): ''' Returns any entities with the specified descriptor ''' res = {} desc = "%s_descriptor" % descriptor for eid, ent in self.items(): if desc in ent: res[eid] = ent return res
python
{ "resource": "" }
q36416
MetaData.certs
train
def certs(self, entity_id, descriptor, use="signing"): ''' Returns certificates for the given Entity ''' ent = self[entity_id] def extract_certs(srvs): res = [] for srv in srvs: if "key_descriptor" in srv: for key in sr...
python
{ "resource": "" }
q36417
InMemoryMetaData.service
train
def service(self, entity_id, typ, service, binding=None): """ Get me all services with a specified entity ID and type, that supports the specified version of binding. :param entity_id: The EntityId :param typ: Type of service (idp, attribute_authority, ...) :param service: which...
python
{ "resource": "" }
q36418
InMemoryMetaData.attribute_requirement
train
def attribute_requirement(self, entity_id, index=None): """ Returns what attributes the SP requires and which are optional if any such demands are registered in the Metadata. :param entity_id: The entity id of the SP :param index: which of the attribute consumer services its all about ...
python
{ "resource": "" }
q36419
MetaDataExtern.load
train
def load(self, *args, **kwargs): """ Imports metadata by the use of HTTP GET. If the fingerprint is known the file will be checked for compliance before it is imported. """ response = self.http.send(self.url) if response.status_code == 200: _txt = response.con...
python
{ "resource": "" }
q36420
MetadataStore.entity_categories
train
def entity_categories(self, entity_id): """ Get a list of entity categories for an entity id. :param entity_id: Entity id :return: Entity categories :type entity_id: string :rtype: [string] """ attributes = self.entity_attributes(entity_id) retur...
python
{ "resource": "" }
q36421
MetadataStore.supported_entity_categories
train
def supported_entity_categories(self, entity_id): """ Get a list of entity category support for an entity id. :param entity_id: Entity id :return: Entity category support :type entity_id: string :rtype: [string] """ attributes = self.entity_attributes(en...
python
{ "resource": "" }
q36422
MetadataStore.entity_attributes
train
def entity_attributes(self, entity_id): """ Get all entity attributes for an entry in the metadata. Example return data: {'http://macedir.org/entity-category': ['something', 'something2'], 'http://example.org/saml-foo': ['bar']} :param entity_id: Entity id :re...
python
{ "resource": "" }
q36423
MetadataStore.dumps
train
def dumps(self, format="local"): """ Dumps the content in standard metadata format or the pysaml2 metadata format :param format: Which format to dump in :return: a string """ if format == "local": res = EntitiesDescriptor() for _md in self...
python
{ "resource": "" }
q36424
http_form_post_message
train
def http_form_post_message(message, location, relay_state="", typ="SAMLRequest", **kwargs): """The HTTP POST binding defines a mechanism by which SAML protocol messages may be transmitted within the base64-encoded content of a HTML form control. :param message: The message ...
python
{ "resource": "" }
q36425
http_redirect_message
train
def http_redirect_message(message, location, relay_state="", typ="SAMLRequest", sigalg='', signer=None, **kwargs): """The HTTP Redirect binding defines a mechanism by which SAML protocol messages can be transmitted within URL parameters. Messages are encoded for use with this bindi...
python
{ "resource": "" }
q36426
parse_soap_enveloped_saml
train
def parse_soap_enveloped_saml(text, body_class, header_class=None): """Parses a SOAP enveloped SAML thing and returns header parts and body :param text: The SOAP object as XML :return: header parts and body as saml.samlbase instances """ envelope = defusedxml.ElementTree.fromstring(text) assert...
python
{ "resource": "" }
q36427
Config.load
train
def load(self, cnf, metadata_construction=False): """ The base load method, loads the configuration :param cnf: The configuration as a dictionary :param metadata_construction: Is this only to be able to construct metadata. If so some things can be left out. :return: The Conf...
python
{ "resource": "" }
q36428
Config.load_metadata
train
def load_metadata(self, metadata_conf): """ Loads metadata into an internal structure """ acs = self.attribute_converters if acs is None: raise ConfigurationError( "Missing attribute converter specification") try: ca_certs = self.ca_certs ...
python
{ "resource": "" }
q36429
Config.endpoint
train
def endpoint(self, service, binding=None, context=None): """ Goes through the list of endpoint specifications for the given type of service and returns a list of endpoint that matches the given binding. If no binding is given all endpoints available for that service will be returned. ...
python
{ "resource": "" }
q36430
Config.service_per_endpoint
train
def service_per_endpoint(self, context=None): """ List all endpoint this entity publishes and which service and binding that are behind the endpoint :param context: Type of entity :return: Dictionary with endpoint url as key and a tuple of service and binding as valu...
python
{ "resource": "" }
q36431
SPConfig.ecp_endpoint
train
def ecp_endpoint(self, ipaddress): """ Returns the entity ID of the IdP which the ECP client should talk to :param ipaddress: The IP address of the user client :return: IdP entity ID or None """ _ecp = self.getattr("ecp") if _ecp: for key, eid in _ecp...
python
{ "resource": "" }
q36432
VirtualOrg.members_to_ask
train
def members_to_ask(self, name_id): """Find the member of the Virtual Organization that I haven't already spoken too """ vo_members = self._affiliation_members() for member in self.member: if member not in vo_members: vo_members.append(member) ...
python
{ "resource": "" }
q36433
construct_came_from
train
def construct_came_from(environ): """ The URL that the user used when the process where interupted for single-sign-on processing. """ came_from = environ.get("PATH_INFO") qstr = environ.get("QUERY_STRING", "") if qstr: came_from += "?" + qstr return came_from
python
{ "resource": "" }
q36434
for_me
train
def for_me(conditions, myself): """ Am I among the intended audiences """ if not conditions.audience_restriction: # No audience restriction return True for restriction in conditions.audience_restriction: if not restriction.audience: continue for audience in restriction...
python
{ "resource": "" }
q36435
StatusResponse.issue_instant_ok
train
def issue_instant_ok(self): """ Check that the response was issued at a reasonable time """ upper = time_util.shift_time(time_util.time_in_a_while(days=1), self.timeslack).timetuple() lower = time_util.shift_time(time_util.time_a_while_ago(days=1), ...
python
{ "resource": "" }
q36436
AuthnResponse.decrypt_attributes
train
def decrypt_attributes(self, attribute_statement): """ Decrypts possible encrypted attributes and adds the decrypts to the list of attributes. :param attribute_statement: A SAML.AttributeStatement which might contain both encrypted attributes and attributes. """ ...
python
{ "resource": "" }
q36437
AuthnResponse.get_identity
train
def get_identity(self): """ The assertion can contain zero or more attributeStatements """ ava = {} for _assertion in self.assertions: if _assertion.advice: if _assertion.advice.assertion: for tmp_assertion in _assertion.advice.assertion: ...
python
{ "resource": "" }
q36438
AuthnResponse.get_subject
train
def get_subject(self): """ The assertion must contain a Subject """ assert self.assertion.subject subject = self.assertion.subject subjconf = [] if not self.verify_attesting_entity(subject.subject_confirmation): raise VerificationError("No valid attesting add...
python
{ "resource": "" }
q36439
AuthnResponse.decrypt_assertions
train
def decrypt_assertions(self, encrypted_assertions, decr_txt, issuer=None, verified=False): """ Moves the decrypted assertion from the encrypted assertion to a list. :param encrypted_assertions: A list of encrypted assertions. :param decr_txt: The string representation contai...
python
{ "resource": "" }
q36440
AuthnResponse.find_encrypt_data_assertion_list
train
def find_encrypt_data_assertion_list(self, _assertions): """ Verifies if a list of assertions contains encrypted data in the advice element. :param _assertions: A list of assertions. :return: True encrypted data exists otherwise false. """ for _assertion in _assertions: ...
python
{ "resource": "" }
q36441
AuthnResponse.find_encrypt_data
train
def find_encrypt_data(self, resp): """ Verifies if a saml response contains encrypted assertions with encrypted data. :param resp: A saml response. :return: True encrypted data exists otherwise false. """ if resp.encrypted_assertion: res = self.find_encrypt_d...
python
{ "resource": "" }
q36442
AuthnResponse.verify
train
def verify(self, keys=None): """ Verify that the assertion is syntactically correct and the signature is correct if present. :param keys: If not the default key file should be used then use one of these. """ try: res = self._verify() except Assertion...
python
{ "resource": "" }
q36443
AuthnResponse.verify_recipient
train
def verify_recipient(self, recipient): """ Verify that I'm the recipient of the assertion :param recipient: A URI specifying the entity or location to which an attesting entity can present the assertion. :return: True/False """ if not self.conv_info: ...
python
{ "resource": "" }
q36444
signed
train
def signed(item): """ Is any part of the document signed ? :param item: A Samlbase instance :return: True if some part of it is signed """ if SIG in item.c_children.keys() and item.signature: return True else: for prop in item.c_child_order: child = getattr(item,...
python
{ "resource": "" }
q36445
get_xmlsec_binary
train
def get_xmlsec_binary(paths=None): """ Tries to find the xmlsec1 binary. :param paths: Non-system path paths which should be searched when looking for xmlsec1 :return: full name of the xmlsec1 binary found. If no binaries are found then an exception is raised. """ if os.name == ...
python
{ "resource": "" }
q36446
_get_xmlsec_cryptobackend
train
def _get_xmlsec_cryptobackend(path=None, search_paths=None): """ Initialize a CryptoBackendXmlSec1 crypto backend. This function is now internal to this module. """ if path is None: path = get_xmlsec_binary(paths=search_paths) return CryptoBackendXmlSec1(path)
python
{ "resource": "" }
q36447
make_temp
train
def make_temp(string, suffix='', decode=True, delete=True): """ xmlsec needs files in some cases where only strings exist, hence the need for this function. It creates a temporary file with the string as only content. :param string: The information to be placed in the file :param suffix: The tempor...
python
{ "resource": "" }
q36448
active_cert
train
def active_cert(key): """ Verifies that a key is active that is present time is after not_before and before not_after. :param key: The Key :return: True if the key is active else False """ try: cert_str = pem_format(key) cert = crypto.load_certificate(crypto.FILETYPE_PEM, ce...
python
{ "resource": "" }
q36449
cert_from_key_info
train
def cert_from_key_info(key_info, ignore_age=False): """ Get all X509 certs from a KeyInfo instance. Care is taken to make sure that the certs are continues sequences of bytes. All certificates appearing in an X509Data element MUST relate to the validation key by either containing it or being part of a ...
python
{ "resource": "" }
q36450
cert_from_instance
train
def cert_from_instance(instance): """ Find certificates that are part of an instance :param instance: An instance :return: possible empty list of certificates """ if instance.signature: if instance.signature.key_info: return cert_from_key_info(instance.signature.key_info, ...
python
{ "resource": "" }
q36451
parse_xmlsec_output
train
def parse_xmlsec_output(output): """ Parse the output from xmlsec to try to find out if the command was successfull or not. :param output: The output from Popen :return: A boolean; True if the command was a success otherwise False """ for line in output.splitlines(): if line == 'OK': ...
python
{ "resource": "" }
q36452
read_cert_from_file
train
def read_cert_from_file(cert_file, cert_type): """ Reads a certificate from a file. The assumption is that there is only one certificate in the file :param cert_file: The name of the file :param cert_type: The certificate type :return: A base64 encoded certificate as a string or the empty string ...
python
{ "resource": "" }
q36453
security_context
train
def security_context(conf): """ Creates a security context based on the configuration :param conf: The configuration, this is a Config instance :return: A SecurityContext instance """ if not conf: return None try: metadata = conf.metadata except AttributeError: meta...
python
{ "resource": "" }
q36454
pre_signature_part
train
def pre_signature_part(ident, public_key=None, identifier=None, digest_alg=None, sign_alg=None): """ If an assertion is to be signed the signature part has to be preset with which algorithms to be used, this function returns such a preset part. :param ident: The identifier of the assertion, so you ...
python
{ "resource": "" }
q36455
SecurityContext.verify_signature
train
def verify_signature(self, signedtext, cert_file=None, cert_type='pem', node_name=NODE_NAME, node_id=None, id_attr=''): """ Verifies the signature of a XML document. :param signedtext: The XML document as a string :param cert_file: The public key that was used to sign the document :para...
python
{ "resource": "" }
q36456
SecurityContext.correctly_signed_message
train
def correctly_signed_message(self, decoded_xml, msgtype, must=False, origdoc=None, only_valid_cert=False): """Check if a request is correctly signed, if we have metadata for the entity that sent the info use that, if not use the key that are in the message if any. :param decoded_xml: Th...
python
{ "resource": "" }
q36457
SecurityContext.correctly_signed_response
train
def correctly_signed_response(self, decoded_xml, must=False, origdoc=None, only_valid_cert=False, require_response_signature=False, **kwargs): """ Check if a instance is correctly signed, if we have metadata for the IdP that sent the info use that, if not use the key that are in the message if a...
python
{ "resource": "" }
q36458
SecurityContext.sign_statement
train
def sign_statement(self, statement, node_name, key=None, key_file=None, node_id=None, id_attr=''): """Sign a SAML statement. :param statement: The statement to be signed :param node_name: string like 'urn:oasis:names:...:Assertion' :param key: The key to be used for the signing, either ...
python
{ "resource": "" }
q36459
SecurityContext.sign_assertion
train
def sign_assertion(self, statement, **kwargs): """Sign a SAML assertion. See sign_statement() for the kwargs. :param statement: The statement to be signed :return: The signed statement """ return self.sign_statement( statement, class_name(saml.Assertion(...
python
{ "resource": "" }
q36460
SecurityContext.sign_attribute_query
train
def sign_attribute_query(self, statement, **kwargs): """Sign a SAML attribute query. See sign_statement() for the kwargs. :param statement: The statement to be signed :return: The signed statement """ return self.sign_statement( statement, class_name(sam...
python
{ "resource": "" }
q36461
SecurityContext.multiple_signatures
train
def multiple_signatures(self, statement, to_sign, key=None, key_file=None, sign_alg=None, digest_alg=None): """ Sign multiple parts of a statement :param statement: The statement that should be sign, this is XML text :param to_sign: A list of (items, id, id attribute name) tuples that ...
python
{ "resource": "" }
q36462
parse_soap_enveloped_saml_thingy
train
def parse_soap_enveloped_saml_thingy(text, expected_tags): """Parses a SOAP enveloped SAML thing and returns the thing as a string. :param text: The SOAP object as XML string :param expected_tags: What the tag of the SAML thingy is expected to be. :return: SAML thingy as a string """ envelo...
python
{ "resource": "" }
q36463
class_instances_from_soap_enveloped_saml_thingies
train
def class_instances_from_soap_enveloped_saml_thingies(text, modules): """Parses a SOAP enveloped header and body SAML thing and returns the thing as a dictionary class instance. :param text: The SOAP object as XML :param modules: modules representing xsd schemas :return: The body and headers as cla...
python
{ "resource": "" }
q36464
soap_fault
train
def soap_fault(message=None, actor=None, code=None, detail=None): """ Create a SOAP Fault message :param message: Human readable error message :param actor: Who discovered the error :param code: Error code :param detail: More specific error message :return: A SOAP Fault message as a string ...
python
{ "resource": "" }
q36465
AESCipher._deprecation_notice
train
def _deprecation_notice(cls): """Warn about deprecation of this class.""" _deprecation_msg = ( '{name} {type} is deprecated. ' 'It will be removed in the next version. ' 'Use saml2.cryptography.symmetric instead.' ).format(name=cls.__name__, type=type(cls).__n...
python
{ "resource": "" }
q36466
OpenSSLWrapper.create_certificate
train
def create_certificate(self, cert_info, request=False, valid_from=0, valid_to=315360000, sn=1, key_length=1024, hash_alg="sha256", write_to_file=False, cert_dir="", cipher_passphrase=None): """ Can create certificate reques...
python
{ "resource": "" }
q36467
OpenSSLWrapper.verify
train
def verify(self, signing_cert_str, cert_str): """ Verifies if a certificate is valid and signed by a given certificate. :param signing_cert_str: This certificate will be used to verify the signature. Must be a string representation ...
python
{ "resource": "" }
q36468
HTTPBase.cookies
train
def cookies(self, url): """ Return cookies that are matching the path and are still valid :param url: :return: """ part = urlparse(url) #if part.port: # _domain = "%s:%s" % (part.hostname, part.port) #else: _domain = part.hostname ...
python
{ "resource": "" }
q36469
HTTPBase.set_cookie
train
def set_cookie(self, kaka, request): """Returns a http_cookiejar.Cookie based on a set-cookie header line""" if not kaka: return part = urlparse(request.url) _domain = part.hostname logger.debug("%s: '%s'", _domain, kaka) for cookie_name, morsel in kaka.ite...
python
{ "resource": "" }
q36470
HTTPBase.use_http_post
train
def use_http_post(message, destination, relay_state, typ="SAMLRequest"): """ Return a urlencoded message that should be POSTed to the recipient. :param message: The response :param destination: Where the response should be sent :param relay_state: The ...
python
{ "resource": "" }
q36471
HTTPBase.use_http_form_post
train
def use_http_form_post(message, destination, relay_state, typ="SAMLRequest"): """ Return a form that will automagically execute and POST the message to the recipient. :param message: :param destination: :param relay_state: :param typ: W...
python
{ "resource": "" }
q36472
HTTPBase.use_soap
train
def use_soap(self, request, destination="", soap_headers=None, sign=False, **kwargs): """ Construct the necessary information for using SOAP+POST :param request: :param destination: :param soap_headers: :param sign: :return: dictionary ""...
python
{ "resource": "" }
q36473
HTTPBase.send_using_soap
train
def send_using_soap(self, request, destination, headers=None, sign=False): """ Send a message using SOAP+POST :param request: :param destination: :param headers: :param sign: :return: """ # _response = self.server.post(soap_message, headers, path...
python
{ "resource": "" }
q36474
HTTPBase.use_http_get
train
def use_http_get(message, destination, relay_state, typ="SAMLRequest", sigalg="", signer=None, **kwargs): """ Send a message using GET, this is the HTTP-Redirect case so no direct response is expected to this request. :param message: :param destination: ...
python
{ "resource": "" }
q36475
extract
train
def extract(environ, empty=False, err=False): """Extracts strings in form data and returns a dict. :param environ: WSGI environ :param empty: Stops on empty fields (default: Fault) :param err: Stops on errors in fields (default: Fault) """ formdata = cgi.parse(environ['wsgi.input'], environ, em...
python
{ "resource": "" }
q36476
cookie_signature
train
def cookie_signature(seed, *parts): """Generates a cookie signature.""" sha1 = hmac.new(seed, digestmod=hashlib.sha1) for part in parts: if part: sha1.update(part) return sha1.hexdigest()
python
{ "resource": "" }
q36477
make_cookie
train
def make_cookie(name, load, seed, expire=0, domain="", path="", timestamp=""): """ Create and return a cookie :param name: Cookie name :param load: Cookie load :param seed: A seed for the HMAC function :param expire: Number of minutes before this cookie goes stale :param dom...
python
{ "resource": "" }
q36478
HttpClient.set_basic_auth
train
def set_basic_auth(self, username, password, realm): """ Set up basic auth for the client @param username: Login name. @param password: Login password. @param realm: The authentication realm. @return: The current object """ self._passmgr.add_password(realm, self._base_url, username, pass...
python
{ "resource": "" }
q36479
query_timeseries
train
def query_timeseries(resource_root, query, from_time=None, to_time=None, desired_rollup=None, must_use_desired_rollup=None, by_post=False): """ Query for time series data from the CM time series data store. @param query: Query string. @param from_time: Start of the period to query (optional). @type from_t...
python
{ "resource": "" }
q36480
get_parcel
train
def get_parcel(resource_root, product, version, cluster_name="default"): """ Lookup a parcel by name @param resource_root: The root Resource object. @param product: Parcel product name @param version: Parcel version @param cluster_name: Cluster name @return: An ApiService object """ return _get_parcel...
python
{ "resource": "" }
q36481
get_all_parcels
train
def get_all_parcels(resource_root, cluster_name="default", view=None): """ Get all parcels @param resource_root: The root Resource object. @param cluster_name: Cluster name @return: A list of ApiParcel objects. @since: API v3 """ return call(resource_root.get, PARCELS_PATH % (cluster_name,), ApiPa...
python
{ "resource": "" }
q36482
do_bulk_config_update
train
def do_bulk_config_update(hostnames): """ Given a list of hostnames, update the configs of all the datanodes, tasktrackers and regionservers on those hosts. """ api = ApiResource(CM_HOST, username=CM_USER, password=CM_PASSWD) hosts = collect_hosts(api, hostnames) # Set config for h in hosts: config...
python
{ "resource": "" }
q36483
collect_hosts
train
def collect_hosts(api, wanted_hostnames): """ Return a list of ApiHost objects for the set of hosts that we want to change config for. """ all_hosts = api.get_all_hosts(view='full') all_hostnames = set([ h.hostname for h in all_hosts]) wanted_hostnames = set(wanted_hostnames) unknown_hosts = wanted_hos...
python
{ "resource": "" }
q36484
configure_roles_on_host
train
def configure_roles_on_host(api, host): """ Go through all the roles on this host, and configure them if they match the role types that we care about. """ for role_ref in host.roleRefs: # Mgmt service/role has no cluster name. Skip over those. if role_ref.get('clusterName') is None: continue ...
python
{ "resource": "" }
q36485
read_host_file
train
def read_host_file(path): """ Read the host file. Return a list of hostnames. """ res = [] for l in file(path).xreadlines(): hostname = l.strip() if hostname: res.append(hostname) return res
python
{ "resource": "" }
q36486
ClouderaManager.get_commands
train
def get_commands(self, view=None): """ Retrieve a list of running global commands. @param view: View to materialize ('full' or 'summary') @return: A list of running commands. """ return self._get("commands", ApiCommand, True, params = view and dict(view=view) or None)
python
{ "resource": "" }
q36487
ClouderaManager.update_license
train
def update_license(self, license_text): """ Install or update the Cloudera Manager license. @param license_text: the license in text form """ content = ( '--MULTI_BOUNDARY', 'Content-Disposition: form-data; name="license"', '', license_text, '--MULTI_BOUNDARY...
python
{ "resource": "" }
q36488
ClouderaManager.import_admin_credentials
train
def import_admin_credentials(self, username, password): """ Imports the KDC Account Manager credentials needed by Cloudera Manager to create kerberos principals needed by CDH services. @param username Username of the Account Manager. Full name including the Kerberos realm must be specified. ...
python
{ "resource": "" }
q36489
ClouderaManager.collect_diagnostic_data
train
def collect_diagnostic_data(self, start_datetime, end_datetime, includeInfoLog=False): """ This method is deprecated as of CM 4.5. You should use collect_diagnostic_data_45. Issue the command to collect diagnostic data. @param start_datetime: The start of the collection period. Type datetime. @...
python
{ "resource": "" }
q36490
ClouderaManager.collect_diagnostic_data_45
train
def collect_diagnostic_data_45(self, end_datetime, bundle_size_bytes, cluster_name=None, roles=None, collect_metrics=False, start_datetime=None): """ Issue the command to collect diagnostic data. If start_datetime is specified, diagnostic data is collected for the entire per...
python
{ "resource": "" }
q36491
ClouderaManager.create_peer
train
def create_peer(self, name, url, username, password, peer_type="REPLICATION"): """ Create a new peer for replication. @param name: The name of the peer. @param url: The url of the peer. @param username: The admin username to use to setup the remote side of the peer connection. @param password: ...
python
{ "resource": "" }
q36492
ClouderaManager._get_peer_type_param
train
def _get_peer_type_param(self, peer_type): """ Checks if the resource_root's API version is >= 11 and construct type param. """ params = None if self._get_resource_root().version >= 11: params = { 'type': peer_type, } return params
python
{ "resource": "" }
q36493
ClouderaManager.delete_peer
train
def delete_peer(self, name, peer_type="REPLICATION"): """ Delete a replication peer. @param name: The name of the peer. @param peer_type: Added in v11. The type of the peer. Defaults to 'REPLICATION'. @return: The deleted peer. @since: API v3 """ params = self._get_peer_type_param(peer_...
python
{ "resource": "" }
q36494
ClouderaManager.update_peer
train
def update_peer(self, current_name, new_name, new_url, username, password, peer_type="REPLICATION"): """ Update a replication peer. @param current_name: The name of the peer to updated. @param new_name: The new name for the peer. @param new_url: The new url for the peer. @param user...
python
{ "resource": "" }
q36495
ClouderaManager.get_peer
train
def get_peer(self, name, peer_type="REPLICATION"): """ Retrieve a replication peer by name. @param name: The name of the peer. @param peer_type: Added in v11. The type of the peer. Defaults to 'REPLICATION'. @return: The peer. @since: API v3 """ params = self._get_peer_type_param(peer_t...
python
{ "resource": "" }
q36496
ClouderaManager.host_install
train
def host_install(self, user_name, host_names, ssh_port=None, password=None, private_key=None, passphrase=None, parallel_install_count=None, cm_repo_url=None, gpg_key_custom_url=None, java_install_strategy=None, unlimited_jce=None): """ Install Cloudera Manager Agent on a set of hos...
python
{ "resource": "" }
q36497
ClouderaManager.import_cluster_template
train
def import_cluster_template(self, api_cluster_template, add_repositories=False): """ Create a cluster according to the provided template @param api_cluster_template: cluster template to import @param add_repositories: if true the parcels repositories in the cluster template will be added. @return: ...
python
{ "resource": "" }
q36498
do_get_aliases
train
def do_get_aliases(name): """ Get aliases for given metric name """ metric_schemas = MetricSchemas() aliases = metric_schemas.get_aliases(name) for alias in aliases: do_print(alias)
python
{ "resource": "" }
q36499
get_supported_types
train
def get_supported_types(resource_root, category_name): """ Lookup all supported types in a category. @param resource_root: The root Resource object. @param category_name: The category name @return: An ApiExternalAcccountType list """ return call(resource_root.get, EXTERNAL_ACCOUNT_FETCH_PATH % ("sup...
python
{ "resource": "" }