Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions irods/manager/zone_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,14 @@ def zone_report(self):
response = conn.recv()
logger.debug(response.int_info)
return response.get_json_encoded_struct()

def modify(self, zone_name, attribute, value):
"""Modify a zone attribute."""
if attribute == "connection":
attribute = "conn" # server expects this string
message_body = GeneralAdminRequest("modify", "zone", zone_name, attribute, value)
request = iRODSMessage("RODS_API_REQ", msg=message_body, int_info=api_number["GENERAL_ADMIN_AN"])
with self.sess.pool.get_connection() as conn:
conn.send(request)
response = conn.recv()
logger.debug(response.int_info)
2 changes: 2 additions & 0 deletions irods/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class Zone(Model):
id = Column(Integer, "ZONE_ID", 101)
name = Column(String, "ZONE_NAME", 102)
type = Column(String, "ZONE_TYPE", 103)
connection = Column(String, "ZONE_CONNECTION", 104)
comment = Column(String, "ZONE_COMMENT", 105)
Comment thread
trel marked this conversation as resolved.


class User(Model):
Expand Down
44 changes: 41 additions & 3 deletions irods/test/zone_test.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#! /usr/bin/env python

from datetime import datetime as _datetime
import os
import sys
import unittest
from datetime import datetime as _datetime

from irods.models import User, Collection
from irods.access import iRODSAccess
from irods.collection import iRODSCollection
from irods.exception import CollectionDoesNotExist
import irods.test.helpers as helpers
from irods.models import Collection, User, Zone
from irods.test import helpers


class TestRemoteZone(unittest.TestCase):
Expand Down Expand Up @@ -68,6 +68,44 @@ def test_create_common_username_remote_then_local__issue_764(self):
if zone:
zone.remove()

def test_create_remote_zone_and_update_properties__issue_816(self):
newzone = None
try:
# create new zone
newzonename = "zone816"
newzone = self.sess.zones.create(newzonename, "remote")

# new values
new_connection = "apples:1247"
new_comment = "zone816 comment 1"

# modify by method
newzone.modify("connection", new_connection)
newzone.modify("comment", new_comment)

# confirm via get
refreshed_zone = self.sess.zones.get(newzonename)
self.assertEqual(refreshed_zone.connection, new_connection)
self.assertEqual(refreshed_zone.comment, new_comment)

# new values again
new_connection = "bananas:1247"
new_comment = "zone816 comment 2"

# modify by parameter
self.sess.zones.modify(newzonename, "connection", new_connection)
self.sess.zones.modify(newzonename, "conn", new_connection)
self.sess.zones.modify(newzonename, "comment", new_comment)

# confirm via query
query_zone = self.sess.query(Zone).filter(Zone.name == newzonename).one()
self.assertEqual(query_zone[Zone.connection], new_connection)
self.assertEqual(query_zone[Zone.comment], new_comment)

finally:
if newzone:
newzone.remove()


if __name__ == "__main__":
# let the tests find the parent irods lib
Expand Down
6 changes: 6 additions & 0 deletions irods/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ def __init__(self, manager, result=None):
self.id = result[Zone.id]
self.name = result[Zone.name]
self.type = result[Zone.type]
self.connection = result[Zone.connection]
self.comment = result[Zone.comment]

def remove(self):
self.manager.remove(self.name)

def modify(self, attribute, value):
"""Modify a zone attribute."""
self.manager.modify(self.name, attribute, value)

def __repr__(self):
"""Render a user-friendly string representation for the iRODSZone object."""
return "<iRODSZone {id} {name} {type}>".format(**vars(self))
Loading