'Helper function for providers supporting :class:`.NodeAuthPassword` or
:class:`.NodeAuthSSHKey`
Validates that only a supported object type is passed to the auth
parameter and raises an exception if it is not.
If no :class:`.NodeAuthPassword` object is provided but one is expected
then a password is automatically generated.'

def _get_and_check_auth(self, auth):

    if isinstance(auth, NodeAuthPassword):
        if ('password' in self.features['create_node']):
            return auth
        raise LibcloudError('Password    provided    as    authentication    information,    but    passwordnot    supported', driver=self)
    if isinstance(auth, NodeAuthSSHKey):
        if ('ssh_key' in self.features['create_node']):
            return auth
        raise LibcloudError('SSH    Key    provided    as    authentication    information,    but    SSH    Keynot    supported', driver=self)
    if ('password' in self.features['create_node']):
        value = os.urandom(16)
        value = binascii.hexlify(value).decode('ascii')
        password = ''
        for char in value:
            if ((not char.isdigit()) and char.islower()):
                if (random.randint(0, 1) == 1):
                    char = char.upper()
            password += char
        return NodeAuthPassword(password, generated=True)
    if auth:
        raise LibcloudError('"auth"    argument    provided,    but    it    was    not    a    NodeAuthPasswordor    NodeAuthSSHKey    object', driver=self)
