Exemple #1
0
    def test_create_and_check_for_edge_rest(self):
        """ Edge (REST): Test the creation, query, and deletion of a Edge """
        host = get_rest_host()

        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
        }

        client = Client(host=host)
        client.register_edge(edge_name, **properties)

        edge = client.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'])

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

        with assert_raises(exceptions.DuplicatedObject):
            client.register_edge(edge_name, **properties)

        client.update_edge(edge_name, status='LOSTHEARTBEAT')
        edge = client.get_edge(edge_name)
        assert_equal(str(edge['status']), 'LOSTHEARTBEAT')

        edges = client.list_edges()
        assert_true(len(edges) >= 1)

        client.delete_edge(edge_name)

        with assert_raises(exceptions.NoObject):
            client.get_edge(edge_name)
Exemple #2
0
    'continent': 'US',
    'country_name': 'US',
    'region_code': 'US',
    'city': 'Madison',
    'time_zone': 'timeZone',
    'longitude': '111111',
    'latitude': '2222222',
    'total_space': 0,
    'used_space': 0,
    'num_files': 0
}

client = Client(host='https://aipanda182.cern.ch:8443')

try:
    client.register_edge('my_edge_name2', **edge_properties)
except exceptions.DuplicatedObject as ex:
    print(ex)

edge = client.get_edge('my_edge_name2')
print('get edge:')
print(edge)

edges = client.list_edges()
print('list edges:')
print(edges)

status = client.update_edge('my_edge_name2', city='MyCity')
print('update edge:')
print(status)