Example #1
0
    def _cleanup_users(self):
        exception_list = list()
        for user in self.operator_cloud.list_users():
            if user['name'].startswith(self.user_prefix):
                try:
                    self.operator_cloud.delete_user(user['id'])
                except Exception as e:
                    exception_list.append(str(e))
                    continue

        if exception_list:
            raise OpenStackCloudException('\n'.join(exception_list))
Example #2
0
    def _cleanup_roles(self):
        exception_list = list()
        for role in self.cloud.list_roles():
            if role['name'].startswith(self.role_prefix):
                try:
                    self.cloud.delete_role(role['name'])
                except Exception as e:
                    exception_list.append(str(e))
                    continue

        if exception_list:
            raise OpenStackCloudException('\n'.join(exception_list))
Example #3
0
    def _cleanup_groups(self):
        exception_list = list()
        for group in self.cloud.list_groups():
            if group['name'].startswith(self.group_prefix):
                try:
                    self.cloud.delete_group(group['id'])
                except Exception as e:
                    exception_list.append(str(e))
                    continue

        if exception_list:
            # Raise an error: we must make users aware that something went
            # wrong
            raise OpenStackCloudException('\n'.join(exception_list))
Example #4
0
    def test_create_failing_volume(self, mock_requests, MockLandoWorkerClient,
                                   MockJobSettings):
        job_id = 1
        mock_settings, report = make_mock_settings_and_report(job_id)
        report.create_volume_error = OpenStackCloudException(
            'unable to create volume')
        MockJobSettings.return_value = mock_settings
        lando = Lando(MagicMock())
        lando.start_job(MagicMock(job_id=job_id))
        expected_report = """
Set job state to R.
Send progress notification. Job:1 State:R Step:EMPTY
Created vm name for job 1.
Created volume name for job 1.
Set job step to V.
Send progress notification. Job:1 State:R Step:V
Set job state to E.
Send progress notification. Job:1 State:E Step:V
"""
        self.assertMultiLineEqual(expected_report.strip(), report.text.strip())