Example #1
0
def get_usb_mount(lsscsi_id):
    cmd = "lsscsi | grep '{id}'".format(id=lsscsi_id.strip('[]'))
    dev_path = get_cmd(cmd).split(' ')[-2]
    current_app.logger.info("get usb dev path: {}".format(dev_path))
    # 如果挂在则能拿到路径、否则去挂载
    mount_num = 0
    u_path = get_cmd('mount | grep {}'.format(dev_path))
    if u_path:
        current_app.logger.info({'code': 1, 'message': '该U盘已被挂载'})
        current_app.logger.info('当前u盘挂在路径----{}'.format(u_path.split(' ')[2]))
        model.update_or_create('u_path', u_path.split(' ')[2])
        current_app.logger.info('-----model U盘地址-----{}'.format(model.get_params('u_path')))
        return True
    else:
        mount_num += 1
        get_cmd('sudo mount {usb}1 /mnt{num}'.format(usb=dev_path, num=mount_num))
        model.update_or_create('u_path', '/mnt{}'.format(mount_num))
        current_app.logger.info('-----model U盘地址-----{}'.format(model.get_params('u_path')))
        return True
Example #2
0
 def get_auth_header():
     data = model.get_params('get_auth_header')
     if data:
         return data
     from app_projects.tools.get_awcloud_img import AWCloudManage
     model.update_or_create('username', 'admin')
     model.update_or_create('password', 'P@ssw0rd')
     manager = AWCloudManage()
     manager._login()
     model.update_or_create('get_auth_header', manager.get_auth_header())
     return GetModel.get_auth_header()
Example #3
0
 def auto_project():
     return '{u_path}/auto_project'.format(
         u_path=model.get_params('u_path'))
Example #4
0
 def dev_abs_path():
     return model.get_params('dev_path')
Example #5
0
 def u():
     return model.get_params('u_path')
Example #6
0
 def deploy_type():
     return model.get_params('type')
Example #7
0
 def get_panaocs():
     return model.get_params('panaocs')
Example #8
0
 def get_node():
     try:
         return json.loads(model.get_params('node'))
     except:
         return model.get_params('node')
Example #9
0
 def get_privkey():
     return model.get_params('privkey')
Example #10
0
 def cpu_count():
     return int(model.get_params('count_cpu'))
Example #11
0
 def account():
     username, password = model.get_params('username'), model.get_params(
         'password')
     return username, password
Example #12
0
 def image_id(_type='storage'):
     if _type == 'storage':
         return model.get_params('storage_img_id')
     return model.get_params('panacube_img_id')
Example #13
0
 def network_id():
     return model.get_params('network_id')
Example #14
0
 def kvm_ip():
     return model.get_params('kvm_ip')