def test_push_project(self):
     package_path = self.test_package_location
     result = publishutil.push_to_platform(package_path=package_path,
                                           platform=Platform(url="http://fg-cn-sandman2.cs.upb.de:1234"))
     self.assertTrue('service_uuid' in result)
     caught = False
     try:
         result = publishutil.push_to_platform(package_path=package_path,
                                               platform=Platform(
                                                   url="http://fg-cn-sandman2.cs.upb.de:1010"))  # wrong port
     except ExtNotReachable:
         caught = True
     self.assertTrue(caught)
Exemplo n.º 2
0
def create_service_on_platform(ws_id, platform_id, service_data):
    """
    Deploys the service on the referenced Platform
    :param ws_id:
    :param platform_id:
    :param service_data:
    :return: A  message if the function was deployed successfully
    """
    service_id = int(service_data['id'])
    session = db_session()
    try:
        workspace = session.query(Workspace).filter(Workspace.id == ws_id).first()
        project = session.query(Project). \
            join(Service). \
            filter(Project.services.any(Service.id == service_id)). \
            filter(Project.workspace == workspace). \
            first()  # type: Project
        if not len(project.services) == 1:
            raise InvalidArgument(
                "Project must have exactly one service "
                "to push to platform. Number of services: {}".format(
                    len(project.services)))

        platform = session.query(Platform).filter(Platform.id == platform_id). \
            filter(Platform.workspace == workspace).first()
        package_path = pack_project(project)
        service_uuid = push_to_platform(package_path, platform)
        logger.info("Pushed to platform: " + str(service_uuid))
        # deploy to private catalogue
        service = project.services[0].as_dict()
        publish_private_nsfs(ws_id, service["descriptor"], is_vnf=False)
        publish_referenced_functions(ws_id, project.id, service["descriptor"])
        return {'message': 'Deployed successfully: {}'.format(str(service_uuid))}
    finally:
        session.commit()
    def test_push_project(self):
        package_path = self.test_package_location
        session = db_session()
        ws = session.query(Workspace).filter(Workspace.id == self.wsid).first()
        result = publishutil.push_to_platform(package_path=package_path, ws=ws)
        self.assertTrue('service_uuid' in result)

        caught = False
        try:
            ws.platforms[0].url = get_config()['test']['platform-instance-wrong']
            update_workspace_descriptor(ws)
            result = publishutil.push_to_platform(package_path=package_path,
                                                  ws=ws)  # wrong port
        except ExtNotReachable:
            caught = True
        self.assertTrue(caught)
        session.rollback()
 def test_deploy_project(self):
     package_path = self.test_package_location
     result = publishutil.push_to_platform(package_path=package_path,
                                           platform=Platform(url="http://fg-cn-sandman2.cs.upb.de:1234"))
     self.assertTrue('service_uuid' in result)
     result = publishutil.deploy_on_platform(service_uuid=result,
                                             platform=Platform(url="http://fg-cn-sandman2.cs.upb.de:1234"))
     self.assertTrue(result)
    def test_push_project(self):
        package_path = self.test_package_location
        session = db_session()
        ws = session.query(Workspace).filter(Workspace.id == self.wsid).first()
        result = publishutil.push_to_platform(package_path=package_path, ws=ws)
        self.assertTrue('service_uuid' in result)

        caught = False
        try:
            ws.platforms[0].url = get_config(
            )['test']['platform-instance-wrong']
            update_workspace_descriptor(ws)
            result = publishutil.push_to_platform(package_path=package_path,
                                                  ws=ws)  # wrong port
        except ExtNotReachable:
            caught = True
        self.assertTrue(caught)
        session.rollback()
Exemplo n.º 6
0
def create_service_on_platform(ws_id, platform_id, service_data):
    """
    Deploys the service on the referenced Platform

    :param ws_id: The workspace ID
    :param platform_id: The platform ID
    :param service_data: The service descriptor data
    :return: A  message if the function was deployed successfully
    """
    # TODO test this!
    service_id = int(service_data['id'])
    session = db_session()
    try:
        workspace = session.query(Workspace).filter(
            Workspace.id == ws_id).first()
        project = session.query(Project). \
            join(Service). \
            filter(Project.services.any(Service.id == service_id)). \
            filter(Project.workspace == workspace). \
            first()  # type: Project
        if not len(project.services) == 1:
            raise InvalidArgument(
                "Project must have exactly one service "
                "to push to platform. Number of services: {}".format(
                    len(project.services)))

        platform = session.query(Platform).filter(Platform.id == platform_id). \
            filter(Platform.workspace == workspace).first()
        package_path = pack_project(project)
        service_uuid = push_to_platform(package_path, platform.workspace)
        logger.info("Pushed to platform: " + str(service_uuid))
        # deploy to private catalogue
        service = project.services[0].as_dict()
        publish_private_nsfs(ws_id, service["descriptor"], is_vnf=False)
        publish_referenced_functions(ws_id, project.id, service["descriptor"])
        return {
            'message': 'Deployed successfully: {}'.format(str(service_uuid))
        }
    finally:
        session.commit()