def update(contxt, appnode_id, ssh_status=None, log_info=None, ip=None): """update app node ssh status, log info or deleted""" if contxt is None: contxt = context.get_admin_context() id = utils.int_from_str(appnode_id) LOG.debug('app node id: %s ' % id) kargs = {} if ip: kargs['ip'] = ip if ssh_status: utils.check_string_length(ssh_status, 'ssh_status', 1, 50) kargs['ssh_status'] = ssh_status if log_info: utils.check_string_length(log_info, 'log_info', 1, 65535) kargs['log_info'] = log_info if kargs: try: return db.appnodes_update(contxt, id, kargs) except db_exc.DBError as e: LOG.exception(_("DB Error on updating Appnodes %s" % e)) raise exception.AppNodeFailure()
def update(contxt, appnode_id, appnode): """update app node ssh status, log info or deleted""" if contxt is None: contxt = context.get_admin_context() id = utils.int_from_str(appnode_id) LOG.debug('app node id: %s ' % id) os_tenant_name = appnode['os_tenant_name'] os_username = appnode['os_username'] os_password = appnode['os_password'] os_auth_url = appnode['os_auth_url'] os_region_name = appnode['os_region_name'] """validate openstack access info""" try: token_url_id = _get_token(os_tenant_name, os_username, os_password, os_auth_url, os_region_name) if token_url_id != None: appnode['ssh_status'] = "reachable" else: appnode['ssh_status'] = "no cinder-volume" except: LOG.exception(_("Error to access to openstack")) appnode['ssh_status'] = "unreachable" try: return db.appnodes_update(contxt, id, appnode) except db_exc.DBError as e: LOG.exception(_("DB Error on updating Appnodes %s" % e)) raise exception.AppNodeFailure()
def update(contxt, appnode_id, appnode): """update app node ssh status, log info or deleted""" if contxt is None: contxt = context.get_admin_context() id = utils.int_from_str(appnode_id) LOG.debug("app node id: %s " % id) os_tenant_name = appnode["os_tenant_name"] os_username = appnode["os_username"] os_password = appnode["os_password"] os_auth_url = appnode["os_auth_url"] os_region_name = appnode["os_region_name"] xtrust_user = appnode["xtrust_user"] novaclient = nc.Client(os_username, os_password, os_tenant_name, os_auth_url, region_name=os_region_name) nova_services = novaclient.services.list() nova_compute_hosts = [] for nova_service in nova_services: if nova_service.binary == "nova-compute": nova_compute_hosts.append(nova_service.host) cinderclient = cc.Client(os_username, os_password, os_tenant_name, os_auth_url, region_name=os_region_name) cinder_services = cinderclient.services.list() cinder_volume_hosts = [] for cinder_service in cinder_services: if cinder_service.binary == "cinder-volume": cinder_volume_hosts.append(cinder_service.host) hosts = list(set(nova_compute_hosts + cinder_volume_hosts)) print hosts for host in hosts: result, err = utils.execute("check_xtrust_crudini", xtrust_user, host, run_as_root=True) LOG.info("==============result: %s" % result) LOG.info("==============result: %s" % err) if "command not found" in err: raise Exception("Command not found on %s" % host) if "Permission denied" in err: raise Exception("Please check the mutual trust between vsm nodes and openstack nodes") """validate openstack access info""" try: token_url_id = _get_token(os_tenant_name, os_username, os_password, os_auth_url, os_region_name) if token_url_id != None: appnode["ssh_status"] = "reachable" else: appnode["ssh_status"] = "no cinder-volume" except: LOG.exception(_("Error to access to openstack")) appnode["ssh_status"] = "unreachable" try: return db.appnodes_update(contxt, id, appnode) except db_exc.DBError as e: LOG.exception(_("DB Error on updating Appnodes %s" % e)) raise exception.AppNodeFailure()
def update(contxt, appnode_id, appnode): """update app node ssh status, log info or deleted""" if contxt is None: contxt = context.get_admin_context() auth_url = appnode['os_auth_url'].strip("/") ssh_user = appnode['ssh_user'] tenant_name = appnode['os_tenant_name'] username = appnode['os_username'] password = appnode['os_password'] region_name = appnode['os_region_name'] id = utils.int_from_str(appnode_id) LOG.debug('app node id: %s ' % id) os_controller_host = auth_url.split(":")[1][2:] result, err = utils.execute('check_xtrust_crudini', ssh_user, os_controller_host, run_as_root=True) LOG.info("==============result: %s" % result) LOG.info("==============err: %s" % err) if "command not found" in err: raise Exception("Command not found on %s" % os_controller_host) if "Permission denied" in err: raise Exception( "Please check the mutual trust between vsm controller node " "and openstack controller node") if "No passwd entry" in err: raise Exception("Please check the trust user") # support keystone v3 ad v2.0 keystone_version = auth_url.split("/")[-1] try: if keystone_version == "v3": result = _check_v3(tenant_name, username, password, auth_url, region_name) elif keystone_version == "v2.0": result = _check_v2(tenant_name, username, password, auth_url, region_name) else: raise Exception("Only support keystone v3 and v2.0 now.") if result: appnode['ssh_status'] = "reachable" else: appnode['ssh_status'] = "no cinder-volume" except: LOG.exception(_("Error to access to openstack")) appnode['ssh_status'] = "unreachable" try: return db.appnodes_update(contxt, id, appnode) except db_exc.DBError as e: LOG.exception(_("DB Error on updating Appnodes %s" % e)) raise exception.AppNodeFailure()
def update(contxt, appnode_id, appnode): """update app node ssh status, log info or deleted""" if contxt is None: contxt = context.get_admin_context() id = utils.int_from_str(appnode_id) LOG.debug('app node id: %s ' % id) os_controller_host = appnode['os_auth_url'].split(":")[1][2:] result, err = utils.execute( 'check_xtrust_crudini', appnode['ssh_user'], os_controller_host, run_as_root = True ) LOG.info("==============result: %s" % result) LOG.info("==============err: %s" % err) if "command not found" in err: raise Exception("Command not found on %s" % os_controller_host) if "Permission denied" in err: raise Exception("Please check the mutual trust between vsm controller node " "and openstack controller node") if "No passwd entry" in err: raise Exception("Please check the trust user") """validate openstack access info""" try: token_url_id = _get_token( appnode['os_tenant_name'], appnode['os_username'], appnode['os_password'], appnode['os_auth_url'], appnode['os_region_name'] ) if token_url_id != None: appnode['ssh_status'] = "reachable" else: appnode['ssh_status'] = "no cinder-volume" except: LOG.exception(_("Error to access to openstack")) appnode['ssh_status'] = "unreachable" try: return db.appnodes_update(contxt, id, appnode) except db_exc.DBError as e: LOG.exception(_("DB Error on updating Appnodes %s" % e)) raise exception.AppNodeFailure()
def update(contxt, appnode_id, appnode): """update app node ssh status, log info or deleted""" if contxt is None: contxt = context.get_admin_context() id = utils.int_from_str(appnode_id) LOG.debug('app node id: %s ' % id) os_controller_host = appnode['os_auth_url'].split(":")[1][2:] result, err = utils.execute('check_xtrust_crudini', appnode['ssh_user'], os_controller_host, run_as_root=True) LOG.info("==============result: %s" % result) LOG.info("==============err: %s" % err) if "command not found" in err: raise Exception("Command not found on %s" % os_controller_host) if "Permission denied" in err: raise Exception( "Please check the mutual trust between vsm controller node " "and openstack controller node") if "No passwd entry" in err: raise Exception("Please check the trust user") """validate openstack access info""" try: token_url_id = _get_token(appnode['os_tenant_name'], appnode['os_username'], appnode['os_password'], appnode['os_auth_url'], appnode['os_region_name']) if token_url_id != None: appnode['ssh_status'] = "reachable" else: appnode['ssh_status'] = "no cinder-volume" except: LOG.exception(_("Error to access to openstack")) appnode['ssh_status'] = "unreachable" try: return db.appnodes_update(contxt, id, appnode) except db_exc.DBError as e: LOG.exception(_("DB Error on updating Appnodes %s" % e)) raise exception.AppNodeFailure()
def update(contxt, appnode_id, appnode): """update app node ssh status, log info or deleted""" if contxt is None: contxt = context.get_admin_context() auth_url = appnode['os_auth_url'].strip("/") ssh_user = appnode['ssh_user'] tenant_name = appnode['os_tenant_name'] username = appnode['os_username'] password = appnode['os_password'] region_name = appnode['os_region_name'] id = utils.int_from_str(appnode_id) LOG.debug('app node id: %s ' % id) os_controller_host = auth_url.split(":")[1][2:] result, err = utils.execute( 'check_xtrust_crudini', ssh_user, os_controller_host, run_as_root = True ) LOG.info("==============result: %s" % result) LOG.info("==============err: %s" % err) if "command not found" in err: raise Exception("Command not found on %s" % os_controller_host) if "Permission denied" in err: raise Exception("Please check the mutual trust between vsm controller node " "and openstack controller node") if "No passwd entry" in err: raise Exception("Please check the trust user") # support keystone v3 ad v2.0 keystone_version = auth_url.split("/")[-1] try: if keystone_version == "v3": result = _check_v3(tenant_name, username, password, auth_url, region_name) elif keystone_version == "v2.0": result = _check_v2(tenant_name, username, password, auth_url, region_name) else: raise Exception("Only support keystone v3 and v2.0 now.") if result: appnode['ssh_status'] = "reachable" else: appnode['ssh_status'] = "no cinder-volume" except: LOG.exception(_("Error to access to openstack")) appnode['ssh_status'] = "unreachable" try: return db.appnodes_update(contxt, id, appnode) except db_exc.DBError as e: LOG.exception(_("DB Error on updating Appnodes %s" % e)) raise exception.AppNodeFailure()