Saverio_180237
Dec 30, 2014Nimbostratus
Upload data group file list with Python Bigsuds iControl
Hello,
Short version: What is the correct way to upload an external data group file using the python bigsuds API ?
Long version:
I am trying to use python and bigsuds to create Data Groups based on external files.
I managed to create the data group using the following method:
b.LocalLB.Class.create_external_class_v2(["datagroup_name_test"],["file_name_test"])
It works but the file_name_test must be already there, uploaded before via web interface. I created a file dg.txt with the following content:
"name1" := "value1",
"name2" := "value2",
"name3" := "value3",
And I wrote the following function to upload it:
def uploadfile(bigip,filename):
fileobj = open(filename,'r')
DF_CHUNK_SIZE = 1024
done = False
first = True
while not done:
text = base64.b64encode(fileobj.read(DF_CHUNK_SIZE))
if first:
chain_type = 'FILE_FIRST'
first = False
else:
if len(text) < DF_CHUNK_SIZE:
chain_type = 'FILE_LAST'
done = True
else:
chain_type = 'FILE_MIDDLE'
bigip.System.ConfigSync.upload_file(file_name="/config/filestore/files_d/Common_d/data_group_d/"+filename,file_context=dict(file_data=text,chain_type=chain_type))
I cant upload the file, I get this error:
ServerError: Server raised fault: 'Exception caught in System::urn:iControl:System/ConfigSync::upload_file()
Exception: Common::OperationFailed
primary_error_code : 16908289 (0x01020001)
secondary_error_code : 0
error_string : Error opening file for write operations'
I feel I am doing it in the wrong way. What is the correct way to upload an external data group file using the python bigsuds API ?