本文整理汇总了Python中cluster.Cluster.cluster_query方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.cluster_query方法的具体用法?Python Cluster.cluster_query怎么用?Python Cluster.cluster_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cluster.Cluster
的用法示例。
在下文中一共展示了Cluster.cluster_query方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exportgroup_create
# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import cluster_query [as 别名]
def exportgroup_create(self, name, project, tenant, varray, exportgrouptype, export_destination=None):
'''
This function will take export group name and project name as input and
It will create the Export group with given name.
parameters:
name : Name of the export group.
project: Name of the project path.
tenant: Container tenant name.
return
returns with status of creation.
'''
# check for existance of export group.
try:
status = self.exportgroup_show(name, project, tenant)
except SOSError as e:
if(e.err_code == SOSError.NOT_FOUND_ERR):
if(tenant == None):
tenant = ""
fullproj = tenant + "/" + project
projuri = Project(self.__ipAddr, self.__port).project_query(fullproj)
nhuri = VirtualArray(self.__ipAddr, self.__port).varray_query(varray)
parms = {
'name' : name,
'project' : projuri,
'varray' : nhuri,
'type' :exportgrouptype
}
if(exportgrouptype and export_destination):
if (exportgrouptype == 'Cluster'):
cluster_obj = Cluster(self.__ipAddr, self.__port)
try:
cluster_uri = cluster_obj.cluster_query(export_destination, fullproj)
except SOSError as e:
raise e
parms['clusters'] = [cluster_uri]
elif (exportgrouptype == 'Host'):
host_obj = Host(self.__ipAddr, self.__port)
try:
host_uri = host_obj.query_by_name(export_destination)
except SOSError as e:
raise e
parms['hosts'] = [host_uri]
# else: # exportgrouptype == Exclusive
# TODO: add code for initiator
body = json.dumps(parms)
(s, h) = common.service_json_request(self.__ipAddr, self.__port, "POST",
self.URI_EXPORT_GROUP, body)
o = common.json_decode(s)
return o
else:
raise e
if(status):
raise SOSError(SOSError.ENTRY_ALREADY_EXISTS_ERR,
"Export group with name " + name + " already exists")
示例2: exportgroup_add_cluster
# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import cluster_query [as 别名]
def exportgroup_add_cluster(self, exportgroupname, tenantname, projectname, clusternames, sync):
exportgroup_uri = self.exportgroup_query(exportgroupname, projectname, tenantname)
cluster_uris = []
clusterObject = Cluster(self.__ipAddr, self.__port)
for clustername in clusternames:
cluster_uris.append(clusterObject.cluster_query(clustername, tenantname))
parms = {}
parms["cluster_changes"] = self._add_list(cluster_uris)
o = self.send_json_request(exportgroup_uri, parms)
return self.check_for_sync(o, sync)
示例3: exportgroup_create
# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import cluster_query [as 别名]
def exportgroup_create(self, name, project, tenant, varray, exportgrouptype, export_destination=None):
"""
This function will take export group name and project name as input
and it will create the Export group with given name.
parameters:
name : Name of the export group.
project: Name of the project path.
tenant: Container tenant name.
return
returns with status of creation.
"""
# check for existance of export group.
try:
status = self.exportgroup_show(name, project, tenant)
except SOSError as e:
if e.err_code == SOSError.NOT_FOUND_ERR:
if tenant is None:
tenant = ""
fullproj = tenant + "/" + project
projObject = Project(self.__ipAddr, self.__port)
projuri = projObject.project_query(fullproj)
varrayObject = VirtualArray(self.__ipAddr, self.__port)
nhuri = varrayObject.varray_query(varray)
parms = {"name": name, "project": projuri, "varray": nhuri, "type": exportgrouptype}
if exportgrouptype and export_destination:
if exportgrouptype == "Cluster":
cluster_obj = Cluster(self.__ipAddr, self.__port)
try:
cluster_uri = cluster_obj.cluster_query(export_destination, fullproj)
except SOSError as e:
raise e
parms["clusters"] = [cluster_uri]
elif exportgrouptype == "Host":
host_obj = Host(self.__ipAddr, self.__port)
try:
host_uri = host_obj.query_by_name(export_destination)
except SOSError as e:
raise e
parms["hosts"] = [host_uri]
body = json.dumps(parms)
(s, h) = common.service_json_request(self.__ipAddr, self.__port, "POST", self.URI_EXPORT_GROUP, body)
o = common.json_decode(s)
return o
else:
raise e
if status:
raise SOSError(SOSError.ENTRY_ALREADY_EXISTS_ERR, "Export group with name " + name + " already exists")
示例4: exportgroup_remove_cluster
# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import cluster_query [as 别名]
def exportgroup_remove_cluster(self, exportgroupname, tenantname, projectname, clusternames, sync):
exportgroup_uri = self.exportgroup_query(exportgroupname, projectname, tenantname)
# cluster search API does not take project parameter.
cluster_uris = []
clusterObject = Cluster(self.__ipAddr, self.__port)
for clustername in clusternames:
cluster_uris.append(clusterObject.cluster_query(clustername, tenantname))
parms = {}
parms["cluster_changes"] = self._remove_list(cluster_uris)
o = self.send_json_request(exportgroup_uri, parms)
return self.check_for_sync(o, sync)
# host
"""
示例5: get_cluster_id
# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import cluster_query [as 别名]
def get_cluster_id(self, clusterName, projectName, tenantName):
clusterObj = Cluster(self.__ipAddr, self.__port)
clusterId = clusterObj.cluster_query(clusterName, projectName, tenantName)
return clusterId