试图从类数组管理中访问函数add_array,但是会引发错误“失败,错误:'str'对象没有属性'addarray'”
包装器: def add_array(self,vendor_name,arrayname,username,password,control_host = None,is_ocum = False):
self.log.info("Adding array management entry")
self.log.info(vendor_name)
self.commcell.array_management.add_array(vendor_name, arrayname, username, password, control_host=control_host, is_ocum=is_ocum)
self.log.info("Add array done 1 ")
control_host_array = self.execute_query(self.get_controlhost_id, arrayname)
self.log.info("Execdsafsadf successful")
print(control_host_array)
self.log.info("Add array was successful")
def模板(个体): self.add_array(self.snap_engine_at_array,self.arrayname,self.username,self.password,self.controlhost,is_ocum = False)
调用frm类arraymanagement.py: def add_array(自我,供应商名称,阵列名称,用户名,密码,control_host =无,is_ocum = False): 打印(供应商名称) “”“此方法将有助于在阵列管理中添加阵列条目 精氨酸: vendor_name:供应商名称 array_name:数组的名称 control_host:必要时控制阵列的主机 用户名/密码:访问数组的凭据 array_type:用于netapp来指定使用主文件服务器还是OCUM,默认情况下它是主文件服务器。“”“
print(username)
print(password)
request_json = {
"clientId": 0,
"flags": 0,
"assocType": 0,
"copyId": 0,
"appId": 0,
"availableMAs": [
{
"arrayControllerId": 0,
"mediaAgent": {
"name": "",
"id": 0
}
},
],
"hostDG": {
"doNotMoveDevices": True,
"isOverridden": False,
"hostDGName": "",
"useOnlySpouseDevices": False,
"flags": 0,
"deviceGroupOption": 0
},
"arrayDG": {
"isOverridden": False,
"arrayDGName": "",
"flags": 0,
"disableDG": False,
"useDevicesFromThisDG": False
},
"configList": {},
"array": {
"name": "",
"id": 0
},
"vendor": {
"name": "",
"id": 0
},
"info": {
"passwordEdit": False,
"offlineReason": "",
"arrayType": 0,
"flags": 0,
"description": "",
"ctrlHostName": control_host,
"offlineCode": 0,
"isEnabled": True,
"arrayInfoType": 0,
"uniqueIdentifier": "",
"securityAssociations": {
"processHiddenPermission": 0
},
"userPswd": {
"userName": username,
"password": password,
},
"arraySecurity": {},
"arrayName": {
"name": array_name,
"id": 0
},
"vendor": {
"name": vendor_name,
"id": 0
},
"client": {
"name": "",
"id": 0
}
}
}
array_type_dict1 = {
"info": {
"arrayType": 2
}
}
array_type_dict2 = {
"info": {
"arrayType": 1
}
}
array_type_dict3 = {
"info": {
"arrayType": 0
}
}
print(request_json)
if vendor_name == "NetApp":
request_json["info"].update(array_type_dict1["info"]),
if vendor_name == "NetApp" and is_ocum:
request_json["info"].update(array_type_dict2["info"]),
else:
request_json["info"].update(array_type_dict3["info"]),
print(request_json)
flag, response = self.commcell._cvpysdk_object.make_request(
'POST', self._StorageArrays, request_json
)
if flag:
if response.json():
if 'success' in response.json():
return
elif 'errorCode' in response.json():
error_message = response.json()['errorMessage']
elif "errorCode" in response.json() == 1:
raise exception("Failed to add array, failing the test case")
return