- 浏览: 1478437 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (691)
- linux (207)
- shell (33)
- java (42)
- 其他 (22)
- javascript (33)
- cloud (16)
- python (33)
- c (48)
- sql (12)
- 工具 (6)
- 缓存 (16)
- ubuntu (7)
- perl (3)
- lua (2)
- 超级有用 (2)
- 服务器 (2)
- mac (22)
- nginx (34)
- php (2)
- 内核 (2)
- gdb (13)
- ICTCLAS (2)
- mac android (0)
- unix (1)
- android (1)
- vim (1)
- epoll (1)
- ios (21)
- mysql (3)
- systemtap (1)
- 算法 (2)
- 汇编 (2)
- arm (3)
- 我的数据结构 (8)
- websocket (12)
- hadoop (5)
- thrift (2)
- hbase (1)
- graphviz (1)
- redis (1)
- raspberry (2)
- qemu (31)
- opencv (4)
- socket (1)
- opengl (1)
- ibeacons (1)
- emacs (6)
- openstack (24)
- docker (1)
- webrtc (11)
- angularjs (2)
- neutron (23)
- jslinux (18)
- 网络 (13)
- tap (9)
- tensorflow (8)
- nlu (4)
- asm.js (5)
- sip (3)
- xl2tp (5)
- conda (1)
- emscripten (6)
- ffmpeg (10)
- srt (1)
- wasm (5)
- bert (3)
- kaldi (4)
- 知识图谱 (1)
最新评论
-
wahahachuang8:
我喜欢代码简洁易读,服务稳定的推送服务,前段时间研究了一下go ...
websocket的helloworld -
q114687576:
http://www.blue-zero.com/WebSoc ...
websocket的helloworld -
zhaoyanzimm:
感谢您的分享,给我提供了很大的帮助,在使用过程中发现了一个问题 ...
nginx的helloworld模块的helloworld -
haoningabc:
leebyte 写道太NB了,期待早日用上Killinux!么 ...
qemu+emacs+gdb调试内核 -
leebyte:
太NB了,期待早日用上Killinux!
qemu+emacs+gdb调试内核
http://haoningabc.iteye.com/blog/2317951装完openstack
http://haoningabc.iteye.com/blog/2322169做完neutron的试验
复杂的网络关系还是无法获取,
做个topo图
写个脚本查看nova和neutron的表的结构
mysql_openstack.sh:
./mysql_openstack.sh neutron
./mysql_openstack.sh nova
观察得到 nova库的instance
neutron库的,networks,routers,subnets,ports
这几个表看明白就理解neutron的基础概念了
网络,子网,路由器,端口
其实就是linux的
veth pair,tap,桥,vxlan
等概念的组合
如果使用openstack命令
简单写个java的demo,
生成固定格式的json,
传给noflo显示成topo图
http://haoningabc.iteye.com/blog/2322169做完neutron的试验
复杂的网络关系还是无法获取,
做个topo图
写个脚本查看nova和neutron的表的结构
mysql_openstack.sh:
#!/bin/sh #for i in `awk ' {if(NR>4 && NR<40)print $2};' a.log ` mysql_user=root mysql_password=haoning mysql_host=mcon if [ "$1" = "" ] then echo "please use ./mysql_openstack.sh [dbname], for example: ./mysql_openstack.sh keystone"; echo "this will exit." exit 0; fi echo "use db " $1 for i in ` mysql -u$mysql_user -h$mysql_host -p$mysql_password $1 -e "show tables" |awk ' {if(NR>1)print $1};'` do if [ $i != "ml2_vxlan_allocations" ] then echo "mysql -u$mysql_user -h$mysql_host -p$mysql_password $1 -e \"select * from \`$i\`\""; mysql -u$mysql_user -h$mysql_host -p$mysql_password $1 -e "select * from \`$i\`"; fi done
./mysql_openstack.sh neutron
./mysql_openstack.sh nova
观察得到 nova库的instance
neutron库的,networks,routers,subnets,ports
这几个表看明白就理解neutron的基础概念了
网络,子网,路由器,端口
其实就是linux的
brctl show ip netns bridge fdb ip neigh
veth pair,tap,桥,vxlan
等概念的组合
如果使用openstack命令
nova list neutron net-list neutron subnet-list neutron router-list neutron port-list
简单写个java的demo,
生成固定格式的json,
传给noflo显示成topo图
package openstacktopo; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.ResultSetMetaData; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import net.sf.json.JSONArray; import net.sf.json.JSONObject; //import net.sf.json.JSONObject; //https://sourceforge.net/projects/json-lib/files/json-lib/json-lib-2.4/ public class Topo { static { try { Class.forName("com.mysql.jdbc.Driver"); } catch (Exception e) { e.printStackTrace(); } } public static Connection getConnection(String db) { String url = "jdbc:mysql://192.168.139.251:3306/"+db; String username = "root"; String password = "haoning"; Connection con = null; try { con = DriverManager.getConnection(url, username, password); } catch (Exception e) { e.printStackTrace(); } return con; } public Map getInstances() {//获取实例 Map vm_processes=new HashMap(); ResultSet rs = null; Connection con = null; try { con = getConnection("nova"); PreparedStatement ps = null; String sql = "select i.uuid,i.display_name,i.launched_on,i.vm_state from instances i where deleted =0 "; ps = (PreparedStatement) con.prepareStatement(sql); if (ps.execute()) { rs = ps.getResultSet(); StringBuffer b = new StringBuffer(); while (rs.next()) { JSONObject instance=new JSONObject(); JSONObject metadata=new JSONObject(); //System.out.println(rs.getString("uuid")+"\t"); //System.out.println(rs.getString("display_name")+"\t"); instance.put("component", "vm/"+rs.getString("uuid")); metadata.put("type", "vm"); metadata.put("vm_id", rs.getString("uuid")); metadata.put("vm_status", rs.getString("vm_state")); metadata.put("label", rs.getString("display_name")); instance.put("metadata", metadata); //System.out.println(instance); vm_processes.put("vm/"+rs.getString("uuid"), instance); } } else { int i = ps.getUpdateCount(); } } catch (Exception e) { e.printStackTrace(); }finally{ try { rs.close(); con.close(); } catch (Exception e2) {} } return vm_processes; } public List<JSONObject> get_instance_net() {//获取vm和网络的关系 List list_i_net=new ArrayList(); ResultSet rs = null; Connection con = null; try { con = getConnection("nova"); PreparedStatement ps = null; String sql = "select iic.network_info,i.uuid,i.display_name,i.launched_on from instance_info_caches iic , instances i where i.id=iic.id and i.deleted = 0"; ps = (PreparedStatement) con.prepareStatement(sql); if (ps.execute()) { rs = ps.getResultSet(); StringBuffer b = new StringBuffer(); while (rs.next()) { //System.out.println(rs.getString("uuid")+"\t");//vm-id //System.out.println(rs.getString("display_name")+"\t");//vm-name String network_info = rs.getString("network_info"); //System.out.println(rs.getString("network_info")); JSONArray ja = new JSONArray().fromObject(network_info); for(int i=0;i<ja.size();i++){ JSONObject jo= (JSONObject) ja.get(i); //System.out.println(jo.get("id"));//port-id ★★★★★ JSONObject network= (JSONObject) jo.get("network"); //System.out.println("---------"); //System.out.println(((JSONObject)((JSONArray)((JSONObject)((JSONArray)(network.get("subnets"))).get(0)).get("ips")).get(0)).get("address")); //System.out.println(((JSONObject)(((JSONObject)((JSONArray)(network.get("subnets"))).get(0)).get("meta"))).get("dhcp_server")); String dhcp_server = (String) ((JSONObject)(((JSONObject)((JSONArray)(network.get("subnets"))).get(0)).get("meta"))).get("dhcp_server"); String vm_address = (String) ((JSONObject)((JSONArray)((JSONObject)((JSONArray)(network.get("subnets"))).get(0)).get("ips")).get(0)).get("address"); //System.out.println(network.get("id"));//network-id //System.out.println(network.get("label"));//network-name //System.out.println(network); JSONObject one_connection=new JSONObject(); one_connection.put("src", new JSONObject().fromObject("{\"process\":\"switch/"+network.get("id")+"\",\"port\":\""+dhcp_server+"\"}"));//有port one_connection.put("tgt", new JSONObject().fromObject("{\"process\":\"vm/"+rs.getString("uuid")+"\",\"port\":\""+vm_address+"\"}")); // System.out.println(one_connection); list_i_net.add(one_connection); } //System.out.println(); } } else { int i = ps.getUpdateCount(); } } catch (Exception e) { e.printStackTrace(); }finally{ try { rs.close(); con.close(); } catch (Exception e2) {} } return list_i_net; } public List<JSONObject> get_router_net() {//获取router和网络的关系 List list_router_net=new ArrayList(); ResultSet rs = null; Connection con = null; try { con = getConnection("neutron"); PreparedStatement ps = null; String sql = "select * from routerports rp ,ports p,ipallocations i where rp.port_id=p.id and i.port_id=p.id"; ps = (PreparedStatement) con.prepareStatement(sql); if (ps.execute()) { rs = ps.getResultSet(); StringBuffer b = new StringBuffer(); while (rs.next()) { JSONObject one_connection=new JSONObject(); String ip_address = rs.getString("ip_address"); if("network:router_interface".equals(rs.getString("port_type"))){ one_connection.put("src", new JSONObject().fromObject("{\"process\":\"router/"+rs.getString("router_id")+"\",\"port\":\""+ip_address+"\"}")); one_connection.put("tgt", new JSONObject().fromObject("{\"process\":\"switch/"+rs.getString("network_id")+"\",\"port\":\""+"in"+"\"}")); }else{//network:router_gateway //one_connection.put("src", new JSONObject().fromObject("{\"process\":\"router/"+rs.getString("router_id")+"\",\"port\":\""+jo.get("port_id")+"\"}")); one_connection.put("src", new JSONObject().fromObject("{\"process\":\"switch/"+rs.getString("network_id")+"\",\"port\":\""+"out"+"\"}")); one_connection.put("tgt", new JSONObject().fromObject("{\"process\":\"router/"+rs.getString("router_id")+"\",\"port\":\""+ip_address+"\"}")); } //System.out.println(one_connection); list_router_net.add(one_connection); //System.out.println(); } } else { int i = ps.getUpdateCount(); } } catch (Exception e) { e.printStackTrace(); }finally{ try { rs.close(); con.close(); } catch (Exception e2) {} } return list_router_net; } public Map<String,JSONObject> getRouters() { Map<String,JSONObject> routers=new HashMap<String,JSONObject>(); Connection con = null; ResultSet rs = null; try { con = getConnection("neutron"); PreparedStatement ps = null; String sql = "select * from routers"; ps = (PreparedStatement) con.prepareStatement(sql); if (ps.execute()) { rs = ps.getResultSet(); StringBuffer b = new StringBuffer(); while (rs.next()) { JSONObject instance=new JSONObject(); JSONObject metadata=new JSONObject(); instance.put("component", "router/"+rs.getString("id")); metadata.put("type", "router"); metadata.put("router_id", rs.getString("id")); metadata.put("router_status", rs.getString("status")); metadata.put("label", rs.getString("name")); instance.put("metadata", metadata); //System.out.println(instance); routers.put("router/"+rs.getString("id"), instance); } } else { int i = ps.getUpdateCount(); } } catch (Exception e) { e.printStackTrace(); }finally{ try { rs.close(); con.close(); } catch (Exception e2) {} } return routers; } public Map getNetworkExternal() {//获取网络是外部网络的集合 Map external_map = new HashMap(); Connection con = null; ResultSet rs = null; try { con = getConnection("neutron"); PreparedStatement ps = null; String sql = "select * from networkrbacs where action='access_as_external'";//where tenant_id= scsssdfs; ps = (PreparedStatement) con.prepareStatement(sql); if (ps.execute()) { rs = ps.getResultSet(); StringBuffer b = new StringBuffer(); while (rs.next()) { external_map.put(rs.getString("object_id"),"access_as_external"); } } else { int i = ps.getUpdateCount(); } } catch (Exception e) { e.printStackTrace(); }finally{ try { rs.close(); con.close(); } catch (Exception e2) {} } //System.out.println(external_map.size()); return external_map; } public Map getNetworkShared() {//获取网络是共享网络的集合 Map shared_map = new HashMap(); Connection con = null; ResultSet rs = null; try { con = getConnection("neutron"); PreparedStatement ps = null; String sql = "select * from networkrbacs where action='access_as_shared'";//where tenant_id= scsssdfs; ps = (PreparedStatement) con.prepareStatement(sql); if (ps.execute()) { rs = ps.getResultSet(); StringBuffer b = new StringBuffer(); while (rs.next()) { shared_map.put(rs.getString("object_id"), "access_as_shared"); } } else { int i = ps.getUpdateCount(); } } catch (Exception e) { e.printStackTrace(); }finally{ try { rs.close(); con.close(); } catch (Exception e2) {} } //System.out.println(shared_map.size()); return shared_map; } public Map getSwitchs() { Map<String,JSONObject> switchs=new HashMap<String,JSONObject>(); Connection con = null; ResultSet rs = null; Map shared_map = getNetworkShared(); Map external_map = getNetworkExternal(); try { con = getConnection("neutron"); PreparedStatement ps = null; String sql = "select * from networks";//where tenant_id= scsssdfs; ps = (PreparedStatement) con.prepareStatement(sql); if (ps.execute()) { rs = ps.getResultSet(); StringBuffer b = new StringBuffer(); while (rs.next()) { JSONObject instance=new JSONObject(); JSONObject metadata=new JSONObject(); instance.put("component", "switch/"+rs.getString("id")); metadata.put("type", "switch"); metadata.put("switch_id", rs.getString("id")); metadata.put("switch_status", rs.getString("status")); metadata.put("label", rs.getString("name")); if(shared_map.get(rs.getString("id"))!=null){ metadata.put("shared", "true"); } if(external_map.get(rs.getString("id"))!=null){ metadata.put("router_external", "true"); } instance.put("metadata", metadata); //System.out.println(instance); switchs.put("switch/"+rs.getString("id"), instance); } } else { int i = ps.getUpdateCount(); } } catch (Exception e) { e.printStackTrace(); }finally{ try { rs.close(); con.close(); } catch (Exception e2) {} } return switchs; } public JSONObject getTopo(){ JSONObject topojson = new JSONObject(); JSONObject processes = new JSONObject(); Map ins =getInstances(); Iterator<Map.Entry<String, JSONObject>> it = ins.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, JSONObject> entry = it.next(); processes.put(entry.getKey(), entry.getValue()); } Map routers= getRouters(); Iterator<Map.Entry<String, JSONObject>> router = routers.entrySet().iterator(); while (router.hasNext()) { Map.Entry<String, JSONObject> entry = router.next(); processes.put(entry.getKey(), entry.getValue()); } Map switchs= getSwitchs(); Iterator<Map.Entry<String, JSONObject>> switcher = switchs.entrySet().iterator(); while (switcher.hasNext()) { Map.Entry<String, JSONObject> entry = switcher.next(); processes.put(entry.getKey(), entry.getValue()); } topojson.put("processes", processes); List<JSONObject> lin = get_instance_net(); List<JSONObject> lrn = get_router_net(); for(int i=0;i<lin.size();i++){ lrn.add(lin.get(i)); } topojson.put("connections", lrn); System.out.println(topojson); return topojson; } public static void main(String[] args) { JSONObject jo = new JSONObject(); //get_instance_net(); //getInstances(); //getRouters(); //getSwitchs(); //get_router_net(); Topo topo=new Topo(); topo.getTopo(); } }
发表评论
-
br0和tap0的互相影响
2019-01-02 19:17 815转载 http://www.cnblogs.com/wlei/ ... -
M版openstack(ovs,dvr,动态迁移)
2017-06-09 10:30 1789主要内容 1.先搭建三个节点的环境,dvr模式 2.建一个vm ... -
M版本的openstack的例子(linuxbridge)
2017-05-23 15:05 558做两个节点控制节点和计算节点 mcontroller521 ... -
openstack的M版本的neutron的实验
2016-09-01 20:00 3135试验步骤: 1.创建内部 ... -
openstack的M版本安装
2016-08-17 13:33 1059参考 http://docs.openstack.org/mi ... -
linux下TUN/TAP虚拟网卡的使用
2016-03-31 18:46 4882tun在网络层 tap在二层 ls ... -
openstack L版本(openvswitch的安装和应用)
2016-03-24 15:04 3021参考L版本的linuxbridge的安装方式 和k版本的ov ... -
openstack试验(linux vxlan)
2016-03-22 22:27 2728yum install centos-release-open ... -
backup a libvirt xml
2016-03-18 21:23 570<domain type='kvm' id='2'> ... -
neutron router试验
2016-03-17 20:41 966上接 http://haoningabc.iteye.com/ ... -
openstack L版本(使用linux bridge的vxlan)
2016-03-12 23:35 2379参考 http://docs.openstack.org/li ... -
openstack的L版本安装(flat网络)
2016-03-07 17:55 981参考http://docs.openstack.org ... -
openstack调试 数据库跟踪
2016-03-04 18:07 719查看openstack代码 openstack每个命令之后,数 ... -
使用devstack安装magnum
2015-11-18 21:22 1431在redhat6.5上建立个centos7的虚拟机,使用cen ... -
openstack 快速安装笔记
2015-07-19 15:21 1300前提是要配置好yum源 版本icehouse,操作系统redh ... -
openstack安装笔记 nova (未完成)(七)
2015-02-05 18:15 1162编辑 /etc/sysconfig/iptables ... -
openstack安装笔记 Neutron(未完成)(六)
2015-02-05 18:10 810验证 keystone role-list keysto ... -
openstack安装笔记 Horizon(五)
2015-02-04 16:08 2032适用的django 导入key cd /var/www/ht ... -
openstack安装笔记 swift(四)
2015-02-04 14:54 3041所有的安装都是yum 改配置 在keystone库中写serv ... -
openstack安装笔记 环境(零)
2015-02-04 12:18 1056在mac上用vmware rhel6.5 搭建openstac ...
相关推荐
o p e n s t a c k 拓扑图
最终经过夜以继日的尝试和配置,终于在某一天的深夜,安装成功了,我把安装成功的过程和配置以及图片都一步一步的记录下来,希望能报道大家。 ps: 安装过程中,需要注意的地方均以使用红色高亮字体标出, 切记一定...
《OpenStack从零开始学》是一本面向初学者的指南,旨在帮助读者全面理解并掌握OpenStack这一开源云操作系统的基础知识和实践技能。OpenStack是一个庞大且复杂的项目,由多个组件构成,为云计算提供了基础设施即服务...
《Open Stack设计与实现》是一本介绍OpenStack设计与实现原理的书。《Open Stack设计与实现》以Juno版本为基础,覆盖了OpenStack的学习方法到设计与实现等各个方面内容,致力于帮助读者形成OpenStack及其各个主要...
### OpenStack管理员参考文档知识点概览 #### 一、OpenStack简介 OpenStack是一个开源的云计算平台,适用于公共云和私有云环境。它由一系列相互关联的项目组成,共同提供了一个全面的云基础设施解决方案。这份...
### OpenStack架构详解 #### 一、OpenStack概述 OpenStack是一个开源的云计算管理平台项目,旨在为企业提供一套部署和管理私有云、公有云的解决方案。它不仅是一个技术平台,更是一个活跃的社区,汇聚了全球众多...
在OpenStack环境中,管理和操作云基础设施涉及众多组件的安装与卸载。OpenStack是一个开源的云计算平台,由多个服务组成,如计算(Nova)、对象存储(Swift)、块存储(Cinder)、网络(Neutron)等。了解如何正确...
在OpenStack书籍《OpenStack部署实践.pdf》和《OpenStack Operations Guide.pdf》中,读者可以深入理解OpenStack的核心概念、架构以及如何在实际环境中部署和运维OpenStack云。 《OpenStack部署实践》可能涵盖了...
在IT行业中,虚拟化技术是云计算服务的基础,OpenStack作为一款开源的云计算平台,广泛用于构建私有云和公有云。在OpenStack环境中,虚拟机的稳定运行至关重要,但难免会出现故障或需要进行灾难恢复的情况。这时,...
- **功能**:Swift提供了高可用性的对象存储服务,能够存储大量的非结构化数据,如图片、视频等。 - **应用场景**:适合于大规模的数据存储场景,例如备份、归档和内容分发网络(CDN)等。 3. **区块存储(Block ...
openstack 计费模块设计与SSH实现
《OpenStack云平台实战》课程测试试卷涉及到OpenStack的基础概念、组件功能以及使用方法等多个方面的知识点。OpenStack是一个开源的云计算管理平台,旨在提供可扩展的弹性的私有云和公有云服务。它由NASA和Rackspace...
"openstack安装图解" OpenStack 是一个云平台管理项目,主要由 NASA 和 Rackspace2010 年 6 月合作成立,使用 Apache 许可证授权。OpenStack 项目整合了多种开源软件,使用 Python 编程语言编写,整合 Tornado 网页...
OpenStack is today’s leading technology for building and integrating public and private clouds. Common OpenStack Deployments is a complete, practical guide to deploying OpenStack and understanding ...
### OpenStack Essex 版本安装指南 #### 一、OpenStack Essex 概览 OpenStack Essex 是 OpenStack 发展过程中的一个里程碑版本,发布于2012年4月5日,它标志着 OpenStack 从早期阶段步入了一个相对成熟的阶段。...
Openstack
通过分析这些数据,调查试图为OpenStack项目组提供一个全面的社区视角,并为2013年的战略优先事项制定一个路线图。其中一些关键发现包括了用户对于简化安装和配置流程的需求,对于更高安全性的渴望,以及对于...