openstack neutron -- 概念,表结构及代码目录结构

本文介绍了OpenStack Neutron的基本概念,包括network、subnet和port等核心组件的定义及作用。同时详细展示了Neutron数据库中这些组件的属性、约束条件及默认值等信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

声明:

本博客欢迎转发,但请保留原作者信息!

博客地址:http://blog.youkuaiyun.com/llg8212

内容系本人学习、研究和总结,如有雷同,不胜荣幸!

  1. Neutron概念

network:隔离的虚拟2层域,network也可以看作是一个虚拟(或逻辑)交换机。对应物理交换机

subnet:IPv4IPv6的地址段。表示在指定的network中,哪些IP地址可以被分配给虚拟机。相当于IP

port:就是网络上的虚拟(或逻辑)交换机的端口。对应物理交换机的端口

2. Neutron表结构

  • C- the attribute can be used increateoperations;

  • R- the attribute is returned in the response forshow orlistoperations;

  • U- the value of attribute can be updated;

  • D- the value of the attribute can be removed;

    1. network

只能被创建的租户使用,除非被创建成shared

Attribute

Type

Required

CRUD

DefaultValue

Validation

Constraints

描述

id

uuid-str

N/A

CR

Generated

UUID_PATTERN


name

String

No

CRU

None

N/A

网络名,可以重复

admin_state_up

Bool

No

CRU

True

{True | False }

管理状态,默认为True如果为False,整个网络不可用

status

String

N/A

R

N/A

N/A

网络的状态。ACTIVE可用状态BUILD创建中DOWN不可用状态,该网络上所有的port也不可用ERROR错误

subnets

list(uuid-str)

No

R

EmptyList

N/A


shared

Bool

No

CRU

False

{True | False }

是否设置成共享,如果为True,其它租户也可以访问

tenant_id

uuid-str

No*

CR

N/A

N/A


    1. subnet

     subnet代表了可用于分配给虚拟机的IP地址集合。每个subnet必须有一个cidr,并且必须与network相关联。Ip地址可以从整个subnetcidr或“allocation_pools”中任选,这可以由用户来指定。

subnet也可以有一个网关,DNS名称服务器的列表,以及主机路由。所有这些信息将被应用到和该subnet关联的虚拟机网口上。

Attribute

Type

Requ

ired

CRUD

Default

ValidationConstraints

描述

id

uuid-str

N/A

CR

Generated

UUID_PATTERN


name

String

No

CRU

None

N/A

子网名,可以重复

network_id

uuid-str

Yes

CR

Generated

Existingnetwork identifier.


ip_version

int

Yes

CR

4

{4 | 6 }


cidr

string

Yes

CR

N/A

ValidCIDR in the form <network_address>/

<prefix>

子网IP的集合。例:"192.168.199.0/24"

表示从192.168.199.2192.168.199.254

的集合(192.168.199.1默认是网关)

gateway_ip

stringor null

No

CRUD

First

address inCIDR

ValidIP address or null

网关,不指定默认为cidr中的第一个IP

dns_

nameservers

list(str)

No

CRU

None

Configurablemaximum amount of nameservers per subnet. The default is 5.


allocation_

pools

list(dict)

No

CR

Every

address

in CIDR, excluding

gateway

IP if configured

Start/endof range must be valid IP

自动根据cidr创建,cidr中的所有IP和网关IP(如果指定)

如果指定cidr为格式为192.168.199.0/24

(不指定网关ip),其

allocation_pools的值为[{"end":

   "192.168.199.254",

"start":

   "192.168.199.2"}]

host_routes

list(dict)

No

CRU

Defaultroute to gateway_ip

{'destination':<CIDR>, "nexthop": <valid IP address>}.Configurable maximum amount of routes per subnet. The default is20.

默认路由,其格式为cidr,有效的ip。例:192.168.70.0/24,

192.168.70.1

enable_dhcp

Bool

No

CRU

True

{True | False }


tenant_id

uuid-str

No*

CR

N/A

N/A

如果不使用keystone认证,该字段是必须的

    1. port

   port表示一个逻辑网络交换机虚拟交换机端口。虚拟机将其interface关联到port。虚拟机interface被注入通过逻辑端口还定义的MAC地址和IP地址(允许多个)。当IP地址关联到一个port,这也意味着该portsubnet相关联,因为IP地址是从特定子网的allocation_pools中分配的。

Attribute

Type

Required

CRUD

Default

Validation

Constraints

描述

id

uuid-str

N/A

CR

Generated

UUID_PATTERN

子网名,可以重复

name

String

No

CRU

None

N/A


network_id

uuid-str

Yes

CR

N/A

Existing

network identifier.


admin_state_

up

bool

No

CRU

True

{True | False }

管理状态,默认为True

如果为False

整个端口不可用

status

string

N/A

R

N/A

N/A

端口的状态,和network

status含义一致。

ACTIVE可用状态

BUILD创建中

DOWN不可用状态,

该网络上所有的port也不可用

ERROR错误

mac_address

string

No

CR

Generated

ValidMAC in 6-octet form separated by colons.

端口的MAC地址,自动生成。

fixed_ips

list(dict)

No

CRU

Automatically

allocated from pool.

ValidIP address and existing subnet identifier.


device_id

str

No

CRUD

None

Noconstraint


device_owner

str

No

CRUD

None

Noconstraint


tenant_id

uuid-str

No*

CR

N/A

N/A

如果不使用keystone认证,

该字段是必须的(和subnet一致)

  1. neutron的代码结构

|--agent:部署在Network Node上。为整个网络提供公共服务,包括如:l3-agent(实现3层网络路由的配置),dhcp-agent(提供dhcp服务)

|--api:对外提供RestAPI访问。在neutron-server服务中提供。

|--cmd:用于发出哪些network,subnet,port,router,floatingip已经存在

|--commonneutron模块的公共

|--db:数据库

|--debug:用于测试neutron功能

|--extensionsneutron的扩展模块,如:vpnaasl3lbaas

|--locale:多语言支持

|--openstackopenstack的公共模块,来源于olso-incubator

|--plugin:实现网络功能的插件。如:linuxbridgeml2

   |--agent:部署在Compute Node节点(真正干活的)。使vm能通过网络通信,如openvswitch中的agent是通过ovs-ofctl命令修改流规则。

|--schedulerneutron的调度模块,负载均衡功能时使用。包含:dhcp-agentl3-agent调度

|--server:启动NeutronApiService服务

|--service

|--tests:


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值