Exemple #1
0
    def create(environment_params, tenant_id):
        #tagging environment by tenant_id for later checks
        """
        Creates environment with specified params, in particular - name
        :param environment_params: Dict, e.g. {'name': 'env-name'}
        :param tenant_id: Tenant Id
        :return: Created Environment
        """

        objects = {'?': {
            'id': uuidutils.generate_uuid(),
        }}
        objects.update(environment_params)
        objects.update(
            EnvironmentServices.generate_default_networks(objects['name']))
        objects['?']['type'] = 'io.murano.Environment'
        environment_params['tenant_id'] = tenant_id

        data = {
            'Objects': objects,
            'Attributes': []
        }

        environment = models.Environment()
        environment.update(environment_params)

        unit = db_session.get_session()
        with unit.begin():
            unit.add(environment)

        #saving environment as Json to itself
        environment.update({'description': data})
        environment.save(unit)

        return environment
 def initialize(self, environment):
     if StatusReporter.transport is None:
         StatusReporter.transport = \
             messaging.get_transport(config.CONF)
     self._notifier = messaging.Notifier(
         StatusReporter.transport,
         publisher_id=uuidutils.generate_uuid(),
         topic='murano')
     self._environment_id = environment.object_id
 def initialize(self, environment):
     if InstanceReportNotifier.transport is None:
         InstanceReportNotifier.transport = \
             messaging.get_transport(config.CONF)
     self._notifier = messaging.Notifier(
         InstanceReportNotifier.transport,
         publisher_id=uuidutils.generate_uuid(),
         topic='murano')
     self._environment_id = environment.object_id
    def _get_test_object(class_name, class_file):
        class_file = os.path.abspath(class_file)

        extension_length = os.path.splitext(class_file)
        object_file = class_file[: -len(extension_length)] + "json"

        if os.path.exists(object_file):
            with open(object_file) as stream:
                return json.load(stream)
        else:
            return {"Objects": {"?": {"id": uuidutils.generate_uuid(), "type": class_name}}}
Exemple #5
0
 def generate_default_networks(env_name):
     # TODO(ativelkov):
     # This is a temporary workaround. Need to find a better way:
     # These objects have to be created in runtime when the environment is
     # deployed for the first time. Currently there is no way to persist
     # such changes, so we have to create the objects on the API side
     return {
         'defaultNetworks': {
             'environment': {
                 '?': {
                     'id': uuidutils.generate_uuid(),
                     'type': DEFAULT_NETWORKS['environment']
                 },
                 'name': env_name + '-network'
             },
             'flat': None
         }
     }
    def _get_test_object(class_name, class_file):
        class_file = os.path.abspath(class_file)

        extension_length = os.path.splitext(class_file)
        object_file = class_file[:-len(extension_length)] + 'json'

        if os.path.exists(object_file):
            with open(object_file) as stream:
                return json.load(stream)
        else:
            return {
                "Objects": {
                    "?": {
                        "id": uuidutils.generate_uuid(),
                        "type": class_name
                    }
                }
            }