Exemple #1
0
    def __init__(self, machine_type: str, site_name: str):
        self._configuration = getattr(Configuration(), site_name)
        self.cloud_stack_client = CloudStack(
            end_point=self._configuration.end_point,
            api_key=self._configuration.api_key,
            api_secret=self._configuration.api_secret,
            event_loop=runtime._meta_runner.runners[asyncio].event_loop,
        )
        self._machine_type = machine_type
        self._site_name = site_name

        key_translator = StaticMapping(
            remote_resource_uuid="id", drone_uuid="name", resource_status="state"
        )

        translator_functions = StaticMapping(
            created=lambda date: datetime.strptime(date, "%Y-%m-%dT%H:%M:%S%z"),
            updated=lambda date: datetime.strptime(date, "%Y-%m-%dT%H:%M:%S%z"),
            state=lambda x, translator=StaticMapping(
                Present=ResourceStatus.Booting,
                Running=ResourceStatus.Running,
                Stopped=ResourceStatus.Stopped,
                Expunged=ResourceStatus.Deleted,
                Destroyed=ResourceStatus.Deleted,
            ): translator[x],
        )

        self.handle_response = partial(
            self.handle_response,
            key_translator=key_translator,
            translator_functions=translator_functions,
        )
Exemple #2
0
 def test_update_configuration(self):
     with open(os.path.join(self.test_path, "OpenStack.yml"),
               "r") as config_file:
         config_file_content = yaml.safe_load(config_file)
     self.configuration1 = Configuration(config_file_content)
     self.assertEqual(
         self.configuration1.OpenStack,
         AttributeDict(api_key="qwertzuiop", api_secret="katze123"),
     )
Exemple #3
0
    def __init__(self, machine_type: str, site_name: str):
        self._configuration = getattr(Configuration(), site_name)
        self._machine_type = machine_type
        self._site_name = site_name

        auth = AuthPassword(
            auth_url=self._configuration.auth_url,
            username=self._configuration.username,
            password=self._configuration.password,
            project_name=self._configuration.project_name,
            user_domain_name=self._configuration.user_domain_name,
            project_domain_name=self._configuration.project_domain_name,
        )

        self.nova = NovaClient(session=auth)

        key_translator = StaticMapping(
            remote_resource_uuid="id", drone_uuid="name", resource_status="status"
        )

        translator_functions = StaticMapping(
            created=lambda date: datetime.strptime(date, "%Y-%m-%dT%H:%M:%SZ"),
            updated=lambda date: datetime.strptime(date, "%Y-%m-%dT%H:%M:%SZ"),
            status=lambda x, translator=StaticMapping(
                BUILD=ResourceStatus.Booting,
                ACTIVE=ResourceStatus.Running,
                SHUTOFF=ResourceStatus.Stopped,
                ERROR=ResourceStatus.Error,
            ): translator[x],
        )

        self.handle_response = partial(
            self.handle_response,
            key_translator=key_translator,
            translator_functions=translator_functions,
        )
Exemple #4
0
 def setUp(self):
     self.test_path = os.path.dirname(os.path.realpath(__file__))
     self.configuration1 = Configuration(
         os.path.join(self.test_path, "CloudStackAIO.yml"))
     self.configuration2 = Configuration()
Exemple #5
0
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys

sys.path.insert(0, os.path.abspath("../.."))
from tardis import __about__  # noqa E402

# Add necessary configuration to build documentation without import errors
from tardis.configuration.configuration import Configuration  # noqa E402

configuration = Configuration({
    "Plugins": {
        "SqliteRegistry": {
            "db_file": ":memory:"
        }
    },
    "Sites": []
})

# -- Project information -----------------------------------------------------

project = __about__.__title__
copyright = __about__.__copyright__
author = __about__.__author__

# The short X.Y version
version = __about__.__version__
# The full version, including alpha/beta/rc tags
release = version
Exemple #6
0
 def __init__(self):
     config = Configuration()
     self.dummy_config = config.BatchSystem
Exemple #7
0
 def __init__(self):
     config = Configuration()
     self.fake_config = config.BatchSystem
     self._drained_machines = {}