Пример #1
0
    def GET(self):
        """ List all Edges.
        HTTP Success:
            200 OK
        HTTP Error:
            404 Not Found
            500 InternalError
        :returns: A list containing all Edges.
        """
        header('Content-Type', 'application/x-json-stream')
        params = input()

        try:
            status = None
            if 'status' in params:
                status = params['status']
            edges = get_edges(status=status)
        except exceptions.NoObject as error:
            raise self.generate_http_response(HTTP_STATUS_CODE.NotFound, exc_cls=error.__class__.__name__, exc_msg=error)
        except exceptions.ESSException as error:
            raise self.generate_http_response(HTTP_STATUS_CODE.InternalError, exc_cls=error.__class__.__name__, exc_msg=error)
        except Exception as error:
            print(error)
            print(format_exc())
            raise self.generate_http_response(HTTP_STATUS_CODE.InternalError, exc_cls=exceptions.CoreException.__name__, exc_msg=error)

        raise self.generate_http_response(HTTP_STATUS_CODE.OK, data=[e.to_dict() for e in edges])
Пример #2
0
    def test_create_and_check_for_edge_core(self):
        """ Edge (CORE): Test the creation, query, and deletion of a Edge """
        edge_name = 'test_edge_%s' % str(uuid())
        edge_name = edge_name[:29]
        properties = {
            'edge_type': 'EDGE',
            'status': 'ACTIVE',
            'is_independent': True,
            'continent': 'US',
            'country_name': 'US',
            'region_code': 'US',
            'city': 'Madison',
            'longitude': '111111',
            'latitude': '2222222',
            'total_space': 0,
            'used_space': 0,
            'num_files': 0
        }
        register_edge(edge_name, **properties)
        edge = get_edge(edge_name)

        assert_equal(edge.edge_name, edge_name)
        assert_equal(str(edge.edge_type), properties['edge_type'])
        assert_equal(str(edge.status), properties['status'])
        assert_equal(edge.is_independent, properties['is_independent'])
        assert_equal(edge.continent, properties['continent'])
        assert_equal(edge.country_name, properties['country_name'])
        assert_equal(edge.region_code, properties['region_code'])
        assert_equal(edge.city, properties['city'])
        assert_equal(edge.longitude, properties['longitude'])
        assert_equal(edge.latitude, properties['latitude'])
        assert_equal(edge.total_space, properties['total_space'])
        assert_equal(edge.used_space, properties['used_space'])
        assert_equal(edge.num_files, properties['num_files'])

        assert_equal(edge.edge_id, get_edge_id(edge_name))

        with assert_raises(exceptions.NoObject):
            get_edge_id('not_exist_edge')

        with assert_raises(exceptions.NoObject):
            get_edge('not_exist_edge')

        with assert_raises(exceptions.DuplicatedObject):
            register_edge(edge_name)

        update_edge(edge_name, parameters={'status': 'LOSTHEARTBEAT'})
        edge = get_edge(edge_name)
        assert_equal(str(edge.status), 'LOSTHEARTBEAT')

        edges = get_edges()
        assert_true(len(edges) >= 1)
        render_json(**edges[0])
        edges[0].to_dict()

        edges = get_edges(status='LOSTHEARTBEAT')
        assert_true(len(edges) >= 1)

        delete_edge(edge_name)

        with assert_raises(exceptions.NoObject):
            get_edge(edge_name)
Пример #3
0
 def get_resources(self):
     self.edges = get_edges(status=EdgeStatus.ACTIVE)