def create(self, desc, project_id, owner, wifi_props=None, lte_props=None):
        """Create new project."""

        if project_id in self.projects:
            raise ValueError("Project %s already defined" % project_id)

        if owner not in self.accounts_manager.accounts:
            raise ValueError("Undefined account %s" % owner)

        project = Project(project_id=project_id, desc=desc, owner=owner)

        if wifi_props:
            project.wifi_props = EmbeddedWiFiProps(**wifi_props)

        if lte_props:
            project.lte_props = EmbeddedLTEProps(**lte_props)

        project.save()

        self.projects[project_id] = project

        project.upsert_wifi_slice(slice_id=0)

        project.upsert_lte_slice(slice_id=0)

        self.projects[project_id].start_services()

        return self.projects[project_id]
Esempio n. 2
0
    def create(self, desc, project_id, owner, wifi_props=None, lte_props=None):
        """Create new project."""

        project = super().create(desc=desc, project_id=project_id, owner=owner)

        try:

            if wifi_props:
                project.wifi_props = EmbeddedWiFiProps(**wifi_props)

            if lte_props:
                project.lte_props = EmbeddedLTEProps(**lte_props)

            project.save()

            project.upsert_wifi_slice(slice_id=0)
            project.upsert_lte_slice(slice_id=0)

        except ValueError as ex:
            self.remove(project.project_id)
            raise ValueError(ex)

        except ValidationError as ex:
            self.remove(project.project_id)
            raise ValueError(ex)

        return self.projects[project_id]