def test_read_file_does_not_exist_default_settings(self):
        # Arrange
        reader = CloudShellConfigReader()

        # Act
        config = reader.read()

        # Assert
        self.assertEqual(config.host, 'localhost')
        self.assertEqual(config.port, 9000)
        self.assertEqual(config.username, 'admin')
        self.assertEqual(config.password, 'admin')
        self.assertEqual(config.domain, 'Global')
    def test_read_file_is_empty_default_settings(self):
        # Arrange
        self.fs.CreateFile('shell_name/cloudshell_config.yml', contents='')
        os.chdir('shell_name')
        reader = CloudShellConfigReader()

        # Act
        config = reader.read()

        # Assert
        self.assertEqual(config.host, 'localhost')
        self.assertEqual(config.port, 9000)
        self.assertEqual(config.username, 'admin')
        self.assertEqual(config.password, 'admin')
        self.assertEqual(config.domain, 'Global')
Пример #3
0
 def __init__(self,
              cloudshell_config_reader=None,
              dependencies_packager=None):
     self.cloudshell_config_reader = cloudshell_config_reader or Configuration(
         CloudShellConfigReader())
     self.dependencies_packager = dependencies_packager or PythonDependenciesPackager(
     )
def create_session_from_config() -> CloudShellAPISession:
    """ Create session from data in shellfoundry config. """
    config = Configuration(CloudShellConfigReader()).read()
    session = CloudShellAPISession(config.host, config.username, config.password, config.domain)
    # session.domain is Domain ID so we save the domain name in session.domain_name
    session.domain_name = config.domain
    return session
Пример #5
0
    def __init__(self,
                 template_compiler=None,
                 template_retriever=None,
                 repository_downloader=None,
                 standards=None,
                 standard_versions=None,
                 shell_name_validations=None):
        """
        :param CookiecutterTemplateCompiler template_compiler:
        :param TemplateRetriever template_retriever:
        :param RepositoryDownloader repository_downloader:
        :param Standards standards:
        :param StandardVersionsFactory standard_versions:
        :param ShellNameValidations shell_name_validations:
        """

        self.cloudshell_config_reader = Configuration(CloudShellConfigReader())
        self.template_retriever = template_retriever or TemplateRetriever()
        self.repository_downloader = repository_downloader or RepositoryDownloader(
        )
        self.template_compiler = template_compiler or CookiecutterTemplateCompiler(
        )
        self.standards = standards or Standards()
        self.standard_versions = standard_versions or StandardVersionsFactory()
        self.shell_name_validations = shell_name_validations or ShellNameValidations(
        )
Пример #6
0
class InstallCommandExecutor(object):
    def __init__(self):
        self.config_reader = CloudShellConfigReader()
        self.installer = ShellInstaller()

    def install(self):
        project = self.config_reader.read()
        self.installer.install(project.name, project.install)
Пример #7
0
    def __init__(self, repository_downloader=None, template_retriever=None):
        """
        :param TemplateRetriever template_retriever:
        :param RepositoryDownloader repository_downloader:
        """

        self.cloudshell_config_reader = Configuration(CloudShellConfigReader())
        self.template_retriever = template_retriever or TemplateRetriever()
        self.repository_downloader = repository_downloader or RepositoryDownloader()
Пример #8
0
 def __init__(self, default_view=None, template_retriever=None, standards=None):
     """
     :param str default_view:
     :param Standards standards:
     """
     dv = default_view or Configuration(ShellFoundryConfig()).read().defaultview
     self.template_retriever = template_retriever or FilteredTemplateRetriever(dv, TemplateRetriever())
     self.show_info_msg = default_view is None
     self.standards = standards or Standards()
     self.cloudshell_config_reader = Configuration(CloudShellConfigReader())
Пример #9
0
 def __init__(self,
              cloudshell_config_reader=None,
              installer=None,
              shell_config_reader=None,
              shell_package_installer=None):
     self.cloudshell_config_reader = cloudshell_config_reader or Configuration(
         CloudShellConfigReader())
     self.installer = installer or ShellInstaller()
     self.shell_config_reader = shell_config_reader or ShellConfigReader()
     self.shell_package_installer = shell_package_installer or ShellPackageInstaller(
     )
    def test_read_config_all_settings_are_set(self):
        # Arrange
        self.fs.CreateFile('shell_name/cloudshell_config.yml', contents="""
install:
    host: my_server
    port: 123
    username: my_user
    password: my_password
    domain: my_domain
    """)
        os.chdir('shell_name')
        reader = CloudShellConfigReader()

        # Act
        config = reader.read()

        # Assert
        self.assertEqual(config.host, 'my_server')
        self.assertEqual(config.port, 123)
        self.assertEqual(config.username, 'my_user')
        self.assertEqual(config.password, 'my_password')
        self.assertEqual(config.domain, 'my_domain')
Пример #11
0
 def __init__(self,
              repository_downloader=None,
              shell_name_validations=None,
              shell_gen_validations=None):
     """
     :param RepositoryDownloader repository_downloader:
     :param ShellNameValidations shell_name_validations:
     """
     self.repository_downloader = repository_downloader or RepositoryDownloader(
     )
     self.shell_name_validations = shell_name_validations or ShellNameValidations(
     )
     self.shell_gen_validations = shell_gen_validations or ShellGenerationValidations(
     )
     self.cloudshell_config_reader = Configuration(CloudShellConfigReader())
Пример #12
0
    def test_read_config_data_from_global_configuration(self, get_app_dir_mock):
        # Arrange
        self.fs.CreateFile('Quali/shellfoundry/global_config.yml', contents="""
install:
  host: somehostaddress
""")
        get_app_dir_mock.return_value = 'Quali/shellfoundry/'
        reader = Configuration(CloudShellConfigReader())

        # Act
        config = reader.read()

        # Assert
        self.assertEqual(config.host, 'somehostaddress')
        self.assertEqual(config.port, 9000)
        self.assertEqual(config.username, 'admin')
        self.assertEqual(config.password, 'admin')
        self.assertEqual(config.domain, 'Global')
Пример #13
0
 def __init__(self, abort_if_major=False):
     self.abort_if_major = abort_if_major
     self.cloudshell_config_reader = Configuration(CloudShellConfigReader())
Пример #14
0
 def __init__(self):
     self.cloudshell_config_reader = Configuration(CloudShellConfigReader())
Пример #15
0
 def __init__(self):
     self.config_reader = CloudShellConfigReader()
     self.installer = ShellInstaller()
Пример #16
0
 def __init__(self, cs_config=None):
     """
     :type cs_config shellfoundry.models.install_config.InstallConfig
     """
     self._cs_config = cs_config or Configuration(
         CloudShellConfigReader()).read()
Пример #17
0
 def __init__(self, cloudshell_config_reader=None, driver_generator=None):
     self.cloudshell_config_reader = cloudshell_config_reader or Configuration(
         CloudShellConfigReader())
     self.driver_generator = driver_generator or DriverGenerator()