Example #1
0
def sign_up():
    print("Sign up")
    email = cli_ui.ask_string("Please enter Email ID")
    does_email_exist = database.find('Users', f'email = "{email}"')

    if len(does_email_exist) > 0:
        helper.clear_screen()
        print("An account linked to this ID already exists")
        return False
    else:
        pwd1 = cli_ui.ask_password("please enter password")
        database.insert('Users', {'email': email, 'password': pwd1})
        helper.clear_screen()
        print("Signed Up.")
        return login()
Example #2
0
def login():
    global user_info
    print("Login")
    email = cli_ui.ask_string("Email")
    password = cli_ui.ask_password("Password")
    does_user_exist = database.find(
        'Users', f'email = "{email}" AND password="******"')
    
    if len(does_user_exist) > 0:
        user_info = user.User(does_user_exist[0][0], email, database)
        helper.clear_screen()
        print("Logged in")
        return True
    else:
        helper.clear_screen()
        print("Incorrect ID or Password")
        return False
Example #3
0
    def restore(self, items):
        jobs = []

        for item in items:
            self.logger.info("Restoring replication target `{}`".format(
                item['config']['targetClusterName']))

            config = filter_fields(item['config'], [
                'targetClusterAddress', 'targetGateway', 'sourceGateway',
                'replicationSetup'
            ])

            username = cli_ui.ask_string('Username')
            password = cli_ui.ask_password('Password')
            ca_certs = ask_multiline_string('Trusted Root Certificate').strip()
            realm = cli_ui.ask_string('Realm')

            config['username'] = username
            config['password'] = password
            if ca_certs:
                config['caCerts'] = ca_certs
            if realm:
                config['realm'] = realm

            try:
                response = self.rubrik.post('internal',
                                            '/replication/target',
                                            config,
                                            timeout=120)
                created_on = datetime.datetime.utcnow().strftime(
                    '%Y-%m-%dT%H:%M:%S%z')
                jobs += ({
                    'id': response['id'],
                    'type': 'ADD_REPLICATION_TARGET',
                    'name': response['targetClusterName'],
                    'createdOn': created_on,
                    'configType': self.config_name
                }, )

            except rubrik_cdm.exceptions.APICallException as e:
                self.logger.error(e)

        return jobs
Example #4
0
    def _add_nfs_location(self, config):
        encryption_password = cli_ui.ask_password(
            'Encryption Password (leave blank to disable)')
        if not encryption_password.strip():
            config['definition']['disableEncryption'] = True
        else:
            config['definition']['encryptionPassword'] = encryption_password

        response = self.rubrik.post('internal',
                                    '/archive/nfs',
                                    config['definition'],
                                    timeout=120)
        created_on = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S%z')

        return {
            'id': response['jobInstanceId'],
            'type': 'ADD_NFS_SHARE',
            'name': config['definition']['name'],
            'createdOn': created_on,
            'configType': self.config_name
        }
Example #5
0
    def _add_object_store_location(self, config):
        if 'Azure' == config['definition']['objectStoreType']:
            config['definition']['secretKey'] = cli_ui.ask_password(
                'Access Key')
            config['definition']['pemFileContent'] = ask_multiline_string(
                'RSA Key').strip()

        # TODO: Handle S3 archives!

        response = self.rubrik.post('internal',
                                    '/archive/object_store',
                                    config['definition'],
                                    timeout=120)
        created_on = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S%z')

        return {
            'id': response['jobInstanceId'],
            'type': 'ADD_OBJECT_STORE',
            'name': config['definition']['name'],
            'createdOn': created_on,
            'configType': self.config_name
        }
Example #6
0
def test_empty_password() -> None:
    with mock.patch("getpass.getpass") as m:
        m.side_effect = [""]
        actual = cli_ui.ask_password(
            "Please enter your password or just press enter to skip")
        assert actual == ""
Example #7
0
def test_ask_password() -> None:
    with mock.patch("getpass.getpass") as m:
        m.side_effect = ["chocolate!", ""]
        res = cli_ui.ask_password("guilty pleasure?")
        assert res == "chocolate!"