Bug 1018904

Summary: call to ClusterGlusterVolumeBricks::add() successfully adds brick to volume but throws exception
Product: [Red Hat Storage] Red Hat Gluster Storage Reporter: Dustin Tsang <dtsang>
Component: rhsc-sdkAssignee: Darshan <dnarayan>
Status: CLOSED ERRATA QA Contact: Dustin Tsang <dtsang>
Severity: high Docs Contact:
Priority: medium    
Version: 2.1CC: dnarayan, dpati, dtsang, knarra, mmahoney, mmccune, pprakash, rhs-bugs, sharne, ssampat
Target Milestone: ---Keywords: ZStream
Target Release: RHGS 2.1.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: cb11 Doc Type: Bug Fix
Doc Text:
Previously, adding bricks was successful, but an error message was displayed. Now, the error message is not displayed.
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-02-25 07:51:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dustin Tsang 2013-10-14 16:30:33 UTC
Description of problem:
python call to add() successfully adds a brick to volume for ClusterGlusterVolumeBricks broker but throws an exception.

Root Cause: at line 604, where assignment of result to self.__getProxy().add() occurs, self.__getProxy().add() returns empty string. 


<TRACE>
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/brokers.py", line 618, in add
    self.context
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/brokers.py", line 373, in __init__
    Base.__init__(self, context)
  File "/usr/lib/python2.6/site-packages/ovirtsdk/infrastructure/common.py", line 24, in __init__
    self.__context = context
  File "/usr/lib/python2.6/site-packages/ovirtsdk/xml/params.py", line 303, in __setattr__
    object.__setattr__(self.superclass, item, value)
AttributeError: 'str' object has no attribute '_Base__context'
</TRACE>



Version-Release number of selected component (if applicable):
rhsc-cb3

How reproducible:
100% of the time

Steps to Reproduce:
1. create a distributed volume
2. <volume param instance>.bricks.add(<bricks>)

Actual results:

brick successfully added but throws an exception AttributeError: 'str' object has no attribute '_Base__context'


Expected results:
exception is not thrown and ClusterGlusterVolumeBrick broker is returned.

Additional info:

Comment 3 Aravinda VK 2013-11-08 08:29:38 UTC
Please share the snippet used to add brick.

Here is the working example

# ----------------------------------------------------------------------------
from ovirtsdk.api import API
from ovirtsdk.xml import params

ENGINE="https://10.70.42.247/api"
USERNAME="admin@internal"
PASSWORD=<password>
INSECURE=True
CLUSTER_NAME="Default"
VOLNAME = "vol1"
BRICK_DIR="/export/vol1-h"
BRICK_SERVER="10.70.42.165"

api = API(url=ENGINE, username=USERNAME, password=PASSWORD, insecure=INSECURE)

def get_serverid(hosts, ip):
    for host in hosts:
        if ip == host.get_address():
            return host.get_id()
    # No matching Server found
    raise

server_id = get_serverid(api.hosts.list(), BRICK_SERVER)
volume = api.clusters.get(CLUSTER_NAME).glustervolumes.get(VOLNAME)

# List bricks
for brick in volume.bricks.list():
    print brick.get_name()

# Add a Brick
brick = params.GlusterBrick(brick_dir=BRICK_DIR, server_id=server_id)
brick_params = params.GlusterBricks()
brick_params.add_brick(brick)

volume.bricks.add(brick_params)

# List bricks again
for brick in volume.bricks.list():
    print brick.get_name()
# ----------------------------------------------------------------------------

Comment 5 Dustin Tsang 2013-12-13 20:15:50 UTC
verified fix in rhsc-cb11

Comment 6 Shalaka 2014-01-22 06:11:38 UTC
Please review the edited DocText and signoff.

Comment 7 Darshan 2014-01-22 06:45:52 UTC
This issue was seen when bricks was added using python-sdk. So you can modify the Doc_text as follows:

Previously, adding bricks using python-sdk was successful, but an error message was displayed. Now, the error message is not displayed.

Comment 9 errata-xmlrpc 2014-02-25 07:51:23 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHEA-2014-0208.html