add mount to task
This commit is contained in:
parent
77bdec498c
commit
60fa6cc156
|
@ -692,8 +692,13 @@ class TaskMgr(threading.Thread):
|
||||||
disk = int(json_task['diskSetting']),
|
disk = int(json_task['diskSetting']),
|
||||||
gpu = int(json_task['gpuSetting'])),
|
gpu = int(json_task['gpuSetting'])),
|
||||||
mount = [Mount(
|
mount = [Mount(
|
||||||
localPath = json_task['mapping'][mapping_key]['mappingLocalDir'],
|
provider = json_task['mapping'][mapping_key]['mappingProvider'],
|
||||||
remotePath=json_task['mapping'][mapping_key]['mappingRemoteDir'])
|
localPath = json_task['mapping'][mapping_key]['mappingMountpath'],
|
||||||
|
remotePath = json_task['mapping'][mapping_key]['mappingBucketName'],
|
||||||
|
accessKey = json_task['mapping'][mapping_key]['mappingAccessKey'],
|
||||||
|
secretKey = json_task['mapping'][mapping_key]['mappingSecretKey'],
|
||||||
|
other = json_task['mapping'][mapping_key]['mappingEndpoint']
|
||||||
|
)
|
||||||
for mapping_key in json_task['mapping']] if 'mapping' in json_task else []
|
for mapping_key in json_task['mapping']] if 'mapping' in json_task else []
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -27,7 +27,7 @@ class OssMounter(object):
|
||||||
# umount oss
|
# umount oss
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class aliyunOssMounter(OssMounter):
|
class AliyunOssMounter(OssMounter):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def mount_oss(datapath, mount_info):
|
def mount_oss(datapath, mount_info):
|
||||||
|
@ -42,7 +42,7 @@ class aliyunOssMounter(OssMounter):
|
||||||
|
|
||||||
cmd = "chmod 640 /etc/passwd-ossfs"
|
cmd = "chmod 640 /etc/passwd-ossfs"
|
||||||
[success1, msg] = OssMounter.execute_cmd(cmd)
|
[success1, msg] = OssMounter.execute_cmd(cmd)
|
||||||
mountpath = datapath+"/"+mount_info.remotePath
|
mountpath = datapath+"/Aliyun/"+mount_info.remotePath
|
||||||
logger.info("Mount oss %s %s" % (mount_info.remotePath, mountpath))
|
logger.info("Mount oss %s %s" % (mount_info.remotePath, mountpath))
|
||||||
if not os.path.isdir(mountpath):
|
if not os.path.isdir(mountpath):
|
||||||
os.makedirs(mountpath)
|
os.makedirs(mountpath)
|
||||||
|
|
|
@ -202,11 +202,12 @@ class TaskWorker(rpc_pb2_grpc.WorkerServicer):
|
||||||
return rpc_pb2.Reply(status=rpc_pb2.Reply.REFUSED, message=msg)
|
return rpc_pb2.Reply(status=rpc_pb2.Reply.REFUSED, message=msg)
|
||||||
|
|
||||||
#mount oss
|
#mount oss
|
||||||
|
rootfs = "/var/lib/lxc/%s/rootfs" % lxcname
|
||||||
self.mount_oss("%s/global/users/%s/oss" % (self.fspath,username), mount_list)
|
self.mount_oss("%s/global/users/%s/oss" % (self.fspath,username), mount_list)
|
||||||
conffile = open("/var/lib/lxc/%s/config" % lxcname, 'a+')
|
conffile = open("/var/lib/lxc/%s/config" % lxcname, 'a+')
|
||||||
mount_str = "lxc.mount.entry = %s/global/users/%s/oss/%s %s/root/oss/%s none bind,rw,create=dir 0 0"
|
mount_str = "lxc.mount.entry = %s/global/users/%s/oss/%s/%s %s/root/oss/%s none bind,rw,create=dir 0 0"
|
||||||
for mount in mount_list:
|
for mount in mount_list:
|
||||||
conffile.write("\n"+ mount_str % (self.fspath, username, mount.remotePath, rootfs, mount.remotePath))
|
conffile.write("\n"+ mount_str % (self.fspath, username, mount.provider, mount.remotePath, rootfs, mount.remotePath))
|
||||||
conffile.close()
|
conffile.close()
|
||||||
|
|
||||||
logger.info("Start container %s..." % lxcname)
|
logger.info("Start container %s..." % lxcname)
|
||||||
|
|
|
@ -121,15 +121,20 @@
|
||||||
$("#collapse" + obj.id).collapse('hide');
|
$("#collapse" + obj.id).collapse('hide');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function chmountPath(obj,task_num,mapping_num) {
|
||||||
|
cellid = 'mapping_mountpath_' + task_num + '_' + mapping_num;
|
||||||
|
$('#'+cellid).val("/root/oss/"+obj.value);
|
||||||
|
}
|
||||||
|
|
||||||
function removeMapping(obj) {
|
function removeMapping(obj) {
|
||||||
$("#mapping_" + obj.id).remove();
|
$("#mapping_" + obj.id).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function addMapping(obj) {
|
function addMapping(obj,task_num) {
|
||||||
mapping_number += 1;
|
mapping_number += 1;
|
||||||
var table = $("#storage_mapping_" + obj.id)[0];
|
var table = $("#storage_mapping_" + obj.id)[0];
|
||||||
var new_mapping = table.insertRow();
|
var new_mapping = table.insertRow();
|
||||||
new_mapping.id = "mapping_" + task_number + "_" + mapping_number;
|
new_mapping.id = "mapping_" + task_num + "_" + mapping_number;
|
||||||
var provider = new_mapping.insertCell();
|
var provider = new_mapping.insertCell();
|
||||||
var bucket_name = new_mapping.insertCell();
|
var bucket_name = new_mapping.insertCell();
|
||||||
var accessKey = new_mapping.insertCell();
|
var accessKey = new_mapping.insertCell();
|
||||||
|
@ -137,20 +142,20 @@
|
||||||
var endpoint = new_mapping.insertCell();
|
var endpoint = new_mapping.insertCell();
|
||||||
var mountpath = new_mapping.insertCell();
|
var mountpath = new_mapping.insertCell();
|
||||||
var remove = new_mapping.insertCell();
|
var remove = new_mapping.insertCell();
|
||||||
bucket_name.innerHTML = '<input type="text" class="form-control" name="mappingBucketName_' + task_number + '_' + mapping_number + '" id="mapping_bucketname_'
|
bucket_name.innerHTML = '<input type="text" class="form-control" name="mappingBucketName_' + task_num + '_' + mapping_number + '" id="mapping_bucketname_'
|
||||||
+ task_number + '_' + mapping_number + '" required/>';
|
+ task_num + '_' + mapping_number + '" onKeyUp="chmountPath(this,'+task_num+','+mapping_number+');" required/>';
|
||||||
accessKey.innerHTML = '<input type="text" class="form-control" name="mappingAccessKey_' + task_number + '_' + mapping_number + '" id="mapping_accessKey_'
|
accessKey.innerHTML = '<input type="text" class="form-control" name="mappingAccessKey_' + task_num + '_' + mapping_number + '" id="mapping_accessKey_'
|
||||||
+ task_number + '_' + mapping_number + '" required/>';
|
+ task_num + '_' + mapping_number + '" required/>';
|
||||||
secretKey.innerHTML = '<input type="text" class="form-control" name="mappingSecretKey_' + task_number + '_' + mapping_number + '" id="mapping_secretKey_'
|
secretKey.innerHTML = '<input type="text" class="form-control" name="mappingSecretKey_' + task_num + '_' + mapping_number + '" id="mapping_secretKey_'
|
||||||
+ task_number + '_' + mapping_number + '" required/>';
|
+ task_num + '_' + mapping_number + '" required/>';
|
||||||
endpoint.innerHTML = 'http://<input type="text" class="form-control" name="mappingEndpoint_' + task_number + '_' + mapping_number + '" id="mapping_endpoint_'
|
endpoint.innerHTML = 'http://<input type="text" class="form-control" name="mappingEndpoint_' + task_num + '_' + mapping_number + '" id="mapping_endpoint_'
|
||||||
+ task_number + '_' + mapping_number + '" required/>';
|
+ task_num + '_' + mapping_number + '" required/>';
|
||||||
mountpath.innerHTML = '<input type="text" class="form-control" name="mappingMountpath_' + task_number + '_' + mapping_number + '" id="mapping_mountpath_'
|
mountpath.innerHTML = '<input type="text" class="form-control" name="mappingMountpath_' + task_num + '_' + mapping_number + '" id="mapping_mountpath_'
|
||||||
+ task_number + '_' + mapping_number + '" required/>';
|
+ task_num + '_' + mapping_number + '" readonly="true" required/>';
|
||||||
provider.innerHTML = '<select class="form-control" name="mappingProvider_' + task_number + '_' + mapping_number + '" id="mapping_provider_'
|
provider.innerHTML = '<select class="form-control" name="mappingProvider_' + task_num + '_' + mapping_number + '" id="mapping_provider_'
|
||||||
+ task_number + '_' + mapping_number + '">'
|
+ task_num + '_' + mapping_number + '">'
|
||||||
+'<option>Aliyun</option></select>';
|
+'<option>Aliyun</option></select>';
|
||||||
remove.innerHTML = '<div class="box-tool pull-left"><button type="button" id="' + task_number + '_' + mapping_number +'" onclick="removeMapping(this)" class="btn btn-xs btn-danger">'
|
remove.innerHTML = '<div class="box-tool pull-left"><button type="button" id="' + task_num + '_' + mapping_number +'" onclick="removeMapping(this)" class="btn btn-xs btn-danger">'
|
||||||
+'Remove</button></div>';
|
+'Remove</button></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +222,7 @@
|
||||||
function addTask() {
|
function addTask() {
|
||||||
task_number += 1;
|
task_number += 1;
|
||||||
var masterip=$("select#masterselector").children('option:selected').val();
|
var masterip=$("select#masterselector").children('option:selected').val();
|
||||||
mapping_number = 0;
|
//mapping_number = 0;
|
||||||
var task_html = '';
|
var task_html = '';
|
||||||
task_html +=
|
task_html +=
|
||||||
'<div class="panel panel-default" id="task_pannel_' + task_number + '">'
|
'<div class="panel panel-default" id="task_pannel_' + task_number + '">'
|
||||||
|
@ -334,7 +339,7 @@
|
||||||
+'</div>'
|
+'</div>'
|
||||||
+'<div class="form-group">'
|
+'<div class="form-group">'
|
||||||
+'<label class="col-sm-2 control-label">Object Storage Mapping<br/>'
|
+'<label class="col-sm-2 control-label">Object Storage Mapping<br/>'
|
||||||
+'<button type="button" id="' + task_number + '" class="btn btn-primary btn-xs" title="add an external storage mapping" onclick="addMapping(this)">'
|
+'<button type="button" id="' + task_number + '" class="btn btn-primary btn-xs" title="add an external storage mapping" onclick="addMapping(this,'+task_number+')">'
|
||||||
+'Add<i class="fa fa-plus"></i></button></label>'
|
+'Add<i class="fa fa-plus"></i></button></label>'
|
||||||
+'<div class="col-sm-10"><table class="table table-bordered" id="storage_mapping_' + task_number + '">'
|
+'<div class="col-sm-10"><table class="table table-bordered" id="storage_mapping_' + task_number + '">'
|
||||||
+'<thead>'
|
+'<thead>'
|
||||||
|
|
Loading…
Reference in New Issue