FloodLight開發者文檔二(譯文)

用戶文檔

控制器

Floodlight不僅僅是一個支持OpenFLow協議的控制器(FloodlightCOntroller),也是一個基於Floodlight控制器的應用集。

當用戶在OpenFLow網絡上運行各種應用程序的時候,Floodlight控制器實現了對OpenFLow網絡的監控和查詢功能。圖0.0顯示了Floodlight不同模塊之間的關係,這些應用程序構建成java模塊,和Floodlight一起編譯。同時這些應用程序都是基於REST API的。

當運行floodlight時,控制器和一組java應用模塊(這些會在floodlight屬性文件中載入)開始運行。REST API通過REST端口(默認8080)對所有的運行中的模塊開放。

Configuration HOWTO

選擇加載模塊

Floodlight可以配置載入不同的模塊以適應不停地應用。配置不同的載入模塊之後必須重啓生效。目前對於Floodlight模塊的配置都是通過需在啓動時加載的一個配置文件的修改實現的。

簡單的說,用戶可以通過以下步驟,找到或控制Floodlight當前的配置:

l 打開 src/main/resources/META-INF/services/net.floodlightcontroller.core.module.IFloodlightModule文件,就可以查看所有在floodlight.jar二進制編譯中的模塊編譯。

l 打開src/main/resources/floodlightdefault.properties文件或者其他自定義屬性文件,查看文件中選擇加載/運行模塊。這些文件時是配置某些啓動時參數的地方,例如:REST  API服務和WEB UI端口(8080)、交換機連接OpenFlow端口(6633)、默認的超時值等。

n 如果在Eclipse或命令行(java -jar floodlight.jar)運行Floodlight,默認情況下加載默認屬性文件。詳細情況可以查看程序參數包括 -cf  some_properties_file文件。

n 如果在Floodlight-vm上運行的Floodlightfloodlight.jar是按照 /opt/floodlight/floodlight/configuration/floodlight.properties instead of floodlightdefault.properties文件,作爲服務載入

n 如果需要修改默認值,停止Floodlight,更新以上所說的屬性文件並重啓。

l 如果自定義新的模塊更新上述的兩個文件並重啓生效。

雖然大多數的應用都是按照默認屬性配置運行,但是下面的應用程序需要一組特定的模塊,因此需要一個特定的配置文件(由於某些模塊之間不兼容)來運行。

l OpenStack Quantum plugin:需要和src/main/resources/quantum.properties文件一起運行

l ForwardingStaticFlowEntryPusher:這兩個模塊都是默認加載的

,但有時你只需要加載其中的一個來實現應用程序的功能。例如,你想要一個完全自動配置的網絡並且不會有轉發反應,因此只需要StaticFlowEntryPusher模塊而禁止Forwarding模塊。

 

控制日誌級別

在控制檯顯示的調試信息有時是很有幫助的,但有時又會顯得十分繁雜。Floodlight使用org.slf4j.Logger模塊,將日誌信息劃分不同的等級。同時,日誌等級是可控的。在默認情況下,Floodlight顯示了所有的日誌等級。爲了控制日誌等級,可以向JVM傳遞以下參數:

java -Dlogback.configurationFile=logback.xml -jar floodlight.jar

如果實在Eclipse下運行的Floodlight,點擊運行->運行/調試配置->參數->VM參數,在這裏添加 -Dlogback.configurationFile=logback.xml

Xml文件已經包含在Floodlight根目錄中。

<configuration scan="true">

  <appender name="STDOUT">

    <encoder>

      <pattern>%level [%logger:%thread] %msg%n</pattern>

    </encoder>

  </appender>

  <root level="INFO">

    <appender-ref ref="STDOUT" />

  </root>

  <logger name="org" level="WARN"/>

  <logger name="LogService" level="WARN"/> <!-- Restlet access logging -->

  <logger name="net.floodlightcontroller" level="INFO"/>

  <logger name="net.floodlightcontroller.logging" level="WARN"/> 

</configuration>

 

在這個例子中,net,floodlightcontroller包含了所有的floodlight模塊,並且具有日誌記錄級別的信息,因此調試信息並不會出現在控制檯中。你可以在logxml文件中指定INFOWARNDEBUG的級別。

監聽地址和端口配置

爲了改變主機地址或監聽特定服務的端口號,可以在屬性配置文件中使用以下的配置參數:

net.floodlightcontroller.restserver.RestApiServer.host

net.floodlightcontroller.restserver.RestApiServer.port

net.floodlightcontroller.core.internal.FloodlightProvider.openflowhost

net.floodlightcontroller.core.internal.FloodlightProvider.openflowport

net.floodlightcontroller.jython.JythonDebugInterface.host

net.floodlightcontroller.jython.JythonDebugInterface.port

默認的屬性配置文件(例如:floodlightdefault.properties

 

 

 

Floodlight REST API

 

虛擬網絡過濾器的REST API

 

URI

方法

URI 參數

數據

數據作用域

描述

/networkService/v1.1/tenants/{tenant}/networks/{network}

PUT/

POST/

DELETE

Tenant:暫時忽略Network:網絡ID(非網絡名)

{"network": { "gateway": "<IP>", "name": "<Name>" }}\

IP:點分十進制的網關IP,可以爲空  
Name:字符串形式的網絡名

創建一個新的虛擬網絡,IDname是必須的但是網關是可選的。

/networkService/v1.1/tenants/{tenant}/networks/{network}/ports/{port}/attachment

PUT/

DELETE

Tenant: Currently ignored  
Network: The ID (not name) of the network
Port: Logical port name

{"attachment": {"id": "<Network ID>", "mac": "<MAC>"}}  

Network ID: 字符串形式的剛剛創建的網絡的ID  
MAC:點分十進制的MAC地址

給虛擬網絡添加主機

/networkService/v1.1/tenants/{tenant}/networks 

GET

Tenant: Currently ignored

None

None

json形式顯示所有的網絡的網絡名、ID、網關,所有主機的MAC地址

 

Curl使用樣例

創建一個名字是“VirtualNetwork1”的虛擬網絡,ID是“Networkid1”,網關是“10.0.0.7”,tenant是“默認”(目前是忽略的):

curl -X PUT -d '{ "network": { "gateway": "10.0.0.7", "name": "virtualNetwork1" } }' http://localhost:8080/networkService/v1.1/tenants/default/networks/NetworkId1

 

添加一個主機到VirtualNetwork1MAC地址爲“00:00:00:00:00:08”端口爲“port1

curl -X PUT -d '{"attachment": {"id": "NetworkId1", "mac": "00:00:00:00:00:08"}}' http://localhost:8080/networkService/v1.1/tenants/default/networks/NetworkId1/ports/port1/attachment

 

 

 

 

 

StaticFlow Pusher API(新)

 

什麼是Static Flow Pusher

Static Flow PusherFloodlight的一個模塊,通過REST API形式向外曝露,這個接口允許用戶手動向OpenFlow網絡中插入流表。

 

主動和被動流插入

OpenFlow支持兩種流插入方式:主動式和被動式。當數據包到達OpenFlow交換機但未成功匹配流表時發生被動式流表插入。這個數據包將會被髮送到控制器,控制器對數據包進行分析評估,添加相應的流表並允許交換機繼續該數據包的轉發。另外,也可以在數據包到達交換機之前,控制器可以主動地插入相應流表。

Floodlight支持這兩種的流表插入方式。Static Flow Pusher對於主動插入流表的方式很有幫助。

注意,在默認情況下,Floodlight載入的轉發模塊是被動插入流表模式的。如果只使用靜態流表,就必須將Forwarding模塊從floodlight.properties文件中刪除。

 

使用方法

 

API總結

URI  

Description  

Arguments  

/wm/staticflowentrypusher/json

Add/Delete static flow

HTTP POST data (add flow), HTTP DELETE (for deletion)

/wm/staticflowentrypusher/list/<switch>/json

List static flows for a switch or all switches

switch: Valid Switch DPID (XX:XX:XX:XX:XX:XX:XX:XX) or "all"

/wm/staticflowentrypusher/clear/<switch>/json

Clear static flows for a switch or all switches

switch: Valid Switch DPID (XX:XX:XX:XX:XX:XX:XX:XX) or "all"

 

添加一個靜態流表

Static Flow Pusher是通過REST API方式接入,所以有很多訪問方式。例如:要在switch1中插入一個流表,使得port1進入的數據包從port2轉發出去。這一操作可以通過使用簡單的curl命令實現。第二個命令將顯示流表設置。

curl -d '{"switch": "00:00:00:00:00:00:00:01", "name":"flow-mod-1", "priority":"32768", "ingress-port":"1","active":"true","actions":"output=2"}' http://<controller_ip>:8080/wm/staticflowentrypusher/json

curl http://<controller_ip>:8080/wm/core/switch/1/flow/json;

 

 

 

刪除靜態流表

通過發送包含流表名稱的HTTP  DELETE來刪除靜態流表

curl -X DELETE -d '{"name":"flow-mod-1"}' http://<controller_ip>:8080/wm/staticflowentrypusher/json

 

 

 

 

流表項屬性

Key  

Value  

Notes  

switch

<switch ID>

ID of the switch (data path) that this rule should be added to  
xx:xx:xx:xx:xx:xx:xx:xx

name

<string>

Name of the flow entry, this is the primary key, it MUST be unique

actions

<key>=<value>

See table of actions below  
Specify multiple actions using a comma-separated list  
Specifying no actions will cause the packets to be dropped

priority

<number>

D默認值爲 32767  
最大值爲 32767

active

<boolean>

 

wildcards

 

 

ingress-port

<number>

switch port on which the packet is received  
Can be hexadecimal (with leading 0x) or decimal

src-mac

<mac address>

xx:xx:xx:xx:xx:xx

dst-mac

<mac address>

xx:xx:xx:xx:xx:xx

vlan-id

<number>

可以使16進制(以0X開頭)或者是10進制

vlan-priority

<number>

可以使16進制(以0X開頭)或者是10進制

ether-type

<number>

可以使16進制(以0X開頭)或者是10進制

tos-bits

<number>

可以使16進制(以0X開頭)或者是10進制

protocol

<number>

可以使16進制(以0X開頭)或者是10進制

src-ip

<ip address>

xx.xx.xx.xx

dst-ip

<ip address>

xx.xx.xx.xx

src-port

<number>

可以使16進制(以0X開頭)或者是10進制

dst-port

<number>

可以使16進制(以0X開頭)或者是10進制

 

操作域的操作選項

Key  

Value

Notes

output

<number> all controller local  
ingress-port normal flood

沒有丟棄選項
(但可以不指定操作從而丟棄數據包)  

enqueue

<number>:<number>

第一個數字是端口號,第二個是隊列ID
可以是16進制(0x開頭)或者10進制

strip-vlan

 

 

set-vlan-id

<number>

可以是16進制(0x開頭)或者10進制

set-vlan-priority

<number>

可以是16進制(0x開頭)或者10進制

set-src-mac

<mac address>

xx:xx:xx:xx:xx:xx

set-dst-mac

<mac address>

xx:xx:xx:xx:xx:xx

set-tos-bits

<number>

 

set-src-ip

<ip address>

xx.xx.xx.xx

set-dst-ip

<ip address>

xx.xx.xx.xx

set-src-port

<number>

可以是16進制(0x開頭)或者10進制

set-dst-port

<number>

可以是16進制(0x開頭)或者10進制

 

在主動插入方式中使用Static Flow Pusher

Static Flow Pusher可以通過編寫簡單的python代碼腳本來控制。例如,在運行floodlight之後配置mininet虛擬機。默認的拓撲結構式一個交換機(s1)和兩個連接到交換機的主機(h2h3)。

sudo mn --controller=remote  --ip=<controller ip> --port=6633

以下代碼是插入從h2發送到h3h3發送到h2的流表

import httplib

import json

 

class StaticFlowPusher(object):

 

    def __init__(self, server):

        self.server = server

 

    def get(self, data):

        ret = self.rest_call({}, 'GET')

        return json.loads(ret[2])

 

    def set(self, data):

        ret = self.rest_call(data, 'POST')

        return ret[0] == 200

 

    def remove(self, objtype, data):

        ret = self.rest_call(data, 'DELETE')

        return ret[0] == 200

 

    def rest_call(self, data, action):

        path = '/wm/staticflowentrypusher/json'

        headers = {

            'Content-type': 'application/json',

            'Accept': 'application/json',

            }

        body = json.dumps(data)

        conn = httplib.HTTPConnection(self.server, 8080)

        conn.request(action, path, body, headers)

        response = conn.getresponse()

        ret = (response.status, response.reason, response.read())

        print ret

        conn.close()

        return ret

 

pusher = StaticFlowPusher('<insert_controller_ip')

 

flow1 = {

    'switch':"00:00:00:00:00:00:00:01",

    "name":"flow-mod-1",

    "cookie":"0",

    "priority":"32768",

    "ingress-port":"1",

    "active":"true",

    "actions":"output=flood"

    }

 

flow2 = {

    'switch':"00:00:00:00:00:00:00:01",

    "name":"flow-mod-2",

    "cookie":"0",

    "priority":"32768",

    "ingress-port":"2",

    "active":"true",

    "actions":"output=flood"

    }

 

pusher.set(flow1)

pusher.set(flow2)

爲了測試這個例子,可以再mininet虛擬機上運行pingall(注意:必須禁用交換機的學習功能和其他路由代碼以確保交換機按照靜態流表工作)

Mininet> h2 ping h3

 

 

 

Firewall REST API

 

Firewall REST接口

防火牆模塊提供REST接口服務,該接口實現了採用REST API服務形式的RestletRoutable接口。以下是REST方法的列表:

URI

Method

URI Arguments

Data

Data Fields

Description

/wm/firewall/module/<op>/json

GET

選項:

status,enable,disable

存儲規則,子網掩碼

None

None

查詢防火牆狀態,啓用、停止防火牆

/wm/firewall/rules/json 

GET

None

None

None

json格式理出所有的規則

 

POST

None

{"<field 1>":"<value 1>", "<field 2>":"<value 2>", ...}

"field":"value" 所有的序列組合: 
"switchid":"<xx:xx:xx:xx:xx:xx:xx:xx>", "src-inport":"<short>",  
"src-mac": "<xx:xx:xx:xx:xx:xx>", "dst-mac": "<xx:xx:xx:xx:xx:xx>",  
"dl-type": "<ARP or IPv4>", "src-ip": "<A.B.C.D/M>", "dst-ip": "<A.B.C.D/M>",  
"nw-proto": "<TCP or UDP or ICMP>", "tp-src": "<short>", "tp-dst": "<short>",  
"priority": "<int>", "action": "<ALLOW or DENY>"

Note: specifying src-ip/dst-ip without specifying dl-type as ARP, or specifying any IP-based nw-proto will automatically set dl-type to match IPv4. 

創建新的防火牆規則

 

DELETE

None

{"<ruleid>":"<int>"}

"ruleid": "<int>" 
注意:rule id是成功創建規則是以json形式生成並返回的隨機數

根據rule id刪除規則

 

Curl使用樣例

假設控制器在本機上運行,顯示防火牆運行還是禁用

curl http://localhost:8080/wm/firewall/module/status/json

 

啓用防火牆。默認情況下防火牆禁用所有的流量除非創建新的明確允許的規則

curl http://localhost:8080/wm/firewall/module/enable/json

 

添加了允許所有流通過交換機00:00:00:00:00:00:00:01的規則

curl -X POST -d '{"switchid""00:00:00:00:00:00:00:01"}' http://localhost:8080/wm/firewall/rules/json

 

添加允許所有IP10.0.0.3的主機到IP10.0.0.5的主機的流的規則。不指定動作就是允許的規則

curl -X POST -d '{"src-ip""10.0.0.3/32""dst-ip""10.0.0.7/32"}' http://localhost:8080/wm/firewall/rules/json

curl -X POST -d '{"src-ip""10.0.0.7/32""dst-ip""10.0.0.3/32"}' http://localhost:8080/wm/firewall/rules/json

 

添加允許所有MAC地址爲00:00:00:00:00:00:00:0b的主機到MAC地址爲00:00:00:00:00:00:00:0c的主機的流的規則

curl -X POST -d '{"src-mac""00:00:00:00:00:0a""dst-mac""00:00:00:00:00:0a"}' http://localhost:8080/wm/firewall/rules/json

curl -X POST -d '{"src-mac""00:00:00:00:00:0b""dst-mac""00:00:00:00:00:0b"}' http://localhost:8080/wm/firewall/rules/json

 

添加允許IP10.0.0.3的主機到IP10.0.0.5的主機ping測試的規則。

curl -X POST -d '{"src-ip""10.0.0.3/32""dst-ip""10.0.0.7/32""dl-type":"ARP" }'   http://localhost:8080/wm/firewall/rules/json

curl -X POST -d '{"src-ip""10.0.0.7/32""dst-ip""10.0.0.3/32""dl-type":"ARP" }' http://localhost:8080/wm/firewall/rules/json

 

curl -X POST -d '{"src-ip""10.0.0.3/32""dst-ip""10.0.0.7/32""nw-proto":"ICMP" }' http://localhost:8080/wm/firewall/rules/json

curl -X POST -d '{"dst-ip""10.0.0.7/32""dst-ip""10.0.0.3/32""nw-proto":"ICMP" }' http://localhost:8080/wm/firewall/rules/json

 

添加允許IP爲難10.0.0.4IP10.0.0.10主機的UDP轉發(如iperf)規則,並禁止5010端口。

curl -X POST -d '{"src-ip""10.0.0.4/32""dst-ip""10.0.0.10/32""dl-type":"ARP" }' http://localhost:8080/wm/firewall/rules/json

curl -X POST -d '{"dst-ip""10.0.0.10/32""dst-ip""10.0.0.4/32""dl-type":"ARP" }' http://localhost:8080/wm/firewall/rules/json

 

curl -X POST -d '{"src-ip""10.0.0.4/32""dst-ip""10.0.0.10/32""nw-proto":"UDP" }' http://localhost:8080/wm/firewall/rules/json

curl -X POST -d '{"src-ip""10.0.0.10/32""dst-ip""10.0.0.4/32""nw-proto":"UDP" }' http://localhost:8080/wm/firewall/rules/json

 

curl -X POST -d '{"src-ip""10.0.0.4/32""dst-ip""10.0.0.10/32""nw-proto":"UDP""tp-src":"5010""action":"DENY" }' http://localhost:8080/wm/firewall/rules/json

curl -X POST -d '{"src-ip""10.0.0.10/32""dst-ip""10.0.0.4/32""nw-proto":"UDP""tp-src":"5010""actio

 

 

 

應用

 

REST應用

 

Circuit Pusher

Circuit Pusher採用floodlight REST API在所有交換機上創建基於IP地址與指定的優先級兩個設備之間路由的一個雙向電路即永久性的流表項。

 

注意
1. Circuit Pusher 現在只能創建兩個IP主機之間的,雖然只是簡單的擴展以創建基於CIDR格式的IP前綴(例如:192.168.0.0/16)電路,但是支持Static Flow Pusher

2. 在向Circuit Pusher發送restAPIRequest之前,控制器必須已經檢測到終端設備的存在(即終端設備已經在網絡中發送過數據,最簡單的辦法就是用網絡中任意兩臺主機ping一下),只有這樣控制器才知道這些網絡終端設備的接入點從而計算他們的路由。

3.當前支持的命令格式語法爲:

a) circuitpusher.py --controller={IP}:{rest port} --type ip --src {IP} --dst {IP} --add --name {circuit-name}

 

在目前IP鏈路允許的情況之下在目的和源設備之間新建一個鏈路。ARP自動支持。

目前,由工作目錄中的一個文本文件circuits.json提供一個簡單的鏈路記錄存儲。

這個文件沒有設置任何保護,並且在控制器重啓時也不會重置。這個文件需要正確的操作。

用戶也應該確保當floodlight控制器重啓時刪除該文件。

 

b) circuitpusher.py --controller={IP}:{rest port} --delete --name {circuit-name}

 

通過之前創建鏈路時定義的鏈接名刪除已創建的鏈路(即3circuits.json文件中的一條記錄

 

 

 

應用模塊

 

 

Firewall

 

簡介

Firewall應用已經作爲floodlight模塊實現,防火牆模塊在OpenFlow網絡之中強制執行ACL規則(接入控制列表)以確保在網絡中的交換機使用的是在packet-in監控行爲之下的流。

ACL規則就是一組交換機入口permitallow或者deny數據流的條件。

每個數據流的第一個數據包與交換機已存在的防火牆規則匹配從而決定是否允許通過交換機。

防火牆規則會按照已分配的優先級排序並且匹配OFMatchOpenFlow 標準1.0)中定義的Packet-in數據包包頭域

匹配防火牆規則的高優先權決定了對流執行什麼操作(允許/拒絕)。

OPMatch定義中可以使用通配符。

 

防火牆策略

防火牆工作在被動模式中。

防火牆規則在創建時按照優先級排序(通過REST API)。

每個進入交換機的packet-in數據包都會從列表中的最高優先級開始比較,直到匹配成功或者將列表中的全部比較完畢。

如果匹配成功,規則中的操作(允許/拒絕)將會被存儲在IPoutingDecision對象中,然後傳遞到其他packet-in數據包處理管道之中。

這一結果將會最終到達Forwarding或者其他被選擇的包轉發應用(如LearingSwitch

)中。

如果結果是允許,Forwarding模塊將會發送一個常規的轉發流表項;如果結果是拒絕,Forwarding將會丟棄流表項。

在這兩種情況之下,被髮送到交換機的流表項都必須完全映射匹配防火牆規則的匹配

屬性(包括通配符)。

防火牆實現允許規則會產生部分的重疊留空間,這通過判斷優先級決定。在下面的簡單的例子中,所有送達192.168.1.0/24子網的流除了進入的HTTPTCP端口80)都被禁止。

protocol

destination IP

destination port

action

priority*

TCP

192.168.1.0/24

80

ALLOW

1

TCP

192.168.1.0/24

wildcard

DENY

2

*數字越小優先級越高

需要特別注意的是在有通配符的情況。如果一個流表不與第一個流表(最高優先級)但和第二個流表(較低優先級)匹配成功,這個流表將通過Forwawrding轉發到交換機,但這個流表不會通配目的端口;然而,在這個流中的特定端口會被指定到流表項中從而使得通過80端口的數據包將不會被交換機丟棄也不會像控制器發送packet-in數據包。

 

REST API

防火牆模塊通過REST接口實現,採用REST API服務形式的RestletRoutable接口。(REST方法見P14-P15防火牆REST方法列表

 

Curl使用樣例

(詳情請見P15防火牆curl樣例

 

問題和限制

防火牆模塊的DELETE REST API的調用並不會刪除交換機上的流表項。規則只會刪除控制器中的存儲而交換機內的流表項則會按照標準超時行爲自動丟棄。這意味着刪除規則之後的一定時間之內,被刪除的規則仍然有效。

在最初的提案中,TCP/UDP的所有端口都在防火牆規則支持範圍內。然而,由於OpenFlow的流匹配機制不允許指定端口範圍,這個功能並沒有實現。

 

 

負載均衡

一個簡單的pingtcpudp流的負載均衡。這個模塊是通過REST API訪問的,類似於OpenStatck Quantum LBbaasLoad-baloance-as-a-Servicev1.0API方案。詳情見http://wiki.openstack.org/Quantum/LBaaS。由於該提案尚未完善,所有兼容新並未得到明確的證明。

代碼並不完整但支持基本的爲icmp,tcp,udp服務創建和使用負載均衡

 

侷限性:

客戶端不會再使用之後清除靜態流表記錄,長時間之後會造成交換機流表用盡;

基於連接的服務器輪叫策略,而不是基於流量;

狀態檢測功能尚未實現。

 

歡迎從Floodlight社區獲得幫助來改善運行情況

 

嘗試以下基本特徵:

1、下載2012/12/12發佈的floodlihgt-master

確認 net.floodlightcontroller.loadbalancer.LoadBanancerfloodlight.defaultpeoperties

啓動floodlight

啓動mininet,創建至少8臺主機的網絡。如:

$sudo mn --controller=rmote --ip=<controller_ip> --mac --topo=tree,3

mininet中執行pingall命令

在任意linux終端中設置負載均衡vips,poolsmembers。使用以下腳本:

#!/bin/sh

curl -X POST -d '{"id":"1","name":"vip1","protocol":"icmp","address":"10.0.0.100","port":"8"}' http://localhost:8080/quantum/v1.0/vips/

curl -X POST -d '{"id":"1","name":"pool1","protocol":"icmp","vip_id":"1"}' http://localhost:8080/quantum/v1.0/pools/

curl -X POST -d '{"id":"1","address":"10.0.0.3","port":"8","pool_id":"1"}' http://localhost:8080/quantum/v1.0/members/

curl -X POST -d '{"id":"2","address":"10.0.0.4","port":"8","pool_id":"1"}' http://localhost:8080/quantum/v1.0/members/

 

curl -X POST -d '{"id":"2","name":"vip2","protocol":"tcp","address":"10.0.0.200","port":"100"}' http://localhost:8080/quantum/v1.0/vips/

curl -X POST -d '{"id":"2","name":"pool2","protocol":"tcp","vip_id":"2"}' http://localhost:8080/quantum/v1.0/pools/

curl -X POST -d '{"id":"3","address":"10.0.0.5","port":"100","pool_id":"2"}' http://localhost:8080/quantum/v1.0/members/

curl -X POST -d '{"id":"4","address":"10.0.0.6","port":"100","pool_id":"2"}' http://localhost:8080/quantum/v1.0/members/

 

curl -X POST -d '{"id":"3","name":"vip3","protocol":"udp","address":"10.0.0.150","port":"200"}' http://localhost:8080/quantum/v1.0/vips/

curl -X POST -d '{"id":"3","name":"pool3","protocol":"udp","vip_id":"3"}' http://localhost:8080/quantum/v1.0/pools/

curl -X POST -d '{"id":"5","address":"10.0.0.7","port":"200","pool_id":"3"}' http://localhost:8080/quantum/v1.0/members/

curl -X POST -d '{"id":"6","address":"10.0.0.8","port":"200","pool_id":"3"}' http://localhost:8080/quantum/v1.0/members/

7、在mininet中,執行’h1 ping -c1 10.0.0.100’,然後執行’h2 ping -c1 10.0.0.100’。這兩次的ping都會成功的輪換調用兩臺不同的真實主機執行。

 

 

OpenStack

 

安裝FloodlightOpenStatic

概述

以下介紹的是在ubuntu虛擬機上使用BigSwitch開發的decstack腳本安裝(last build)和OpenStackGrizzy)。

 

條件

l Ubuntu12.04.1服務器版即以上

l 至少2GB RAM(擴展應用需要更多)

l 至少30GB存儲空間

 

安裝floodlight

需要運行一個flooflight控制器來支持OpenStack Neutron網絡。Floodlight控制器可以運行在一個特定的floodlight虛擬機中(floodlight官網上下載floodlight-vm虛擬機鏡像文件).或者你可以下載floodlight.zip源代碼壓縮文件解壓後進行編譯運行。只需要在你的ubuntu虛擬機中進行以下幾步簡單的操作:

確保你有正常的網絡連接

$ sudo apt-get update

$ sudo apt-get install zip default-jdk ant

$ wget --no-check-certificate https://github.com/floodlight/floodlight/archive/master.zip

$ unzip master.zip

$ cd floodlight-master; ant

$ java -jar target/floodlight.jar -cf src/main/resources/neutron.properties

你可以通過以下步驟確保你的VirtualNetworkFilter成功激活:

$ curl 127.0.0.1:8080/networkService/v1.1

{"status":"ok"}

通過RestProxy Neutron Plugin使用Devstatck安裝OpenStatic

一旦Floodlight控制器運行之後,我們就準備使用安裝腳本安裝OpenStack。下面的步驟1在虛擬機上配置OVS監聽Floodlight,步驟2在虛擬機上安裝OpenStaticBigSwitch REST procy插件。

OpenStack Grizzly

$ wget https://github.com/openstack-dev/devstack/archive/stable/grizzly.zip

$ unzip grizzly.zip

$ cd devstack-stable-grizzly

OpenStack Folsom

$ wget https://github.com/bigswitch/devstack/archive/floodlight/folsom.zip

$ unzip folsom.zip

$ cd devstack-floodlight-folsom

 

使用編輯器創建一個”localrc”文件並且填在下面。記住,用你選擇的密碼替換下面的<passward>並更新'BS_FL_CONTROLLERS_PORT=<floodlight IP address>:8080'。如果在同一臺虛擬機上啓動的floodlight,可以使用127.0.0.1替換控制器的IP地址;否則使用遠程控制器所在主機的正確IP地址。

disable_service n-net

enable_service q-svc

enable_service q-dhcp

enable_service neutron

enable_service bigswitch_floodlight

Q_PLUGIN=bigswitch_floodlight

Q_USE_NAMESPACE=False

NOVA_USE_NEUTRON_API=v2

SCHEDULER=nova.scheduler.simple.SimpleScheduler

MYSQL_PASSWORD=<password>

RABBIT_PASSWORD=<password>

ADMIN_PASSWORD=<password>

SERVICE_PASSWORD=<password>

SERVICE_TOKEN=tokentoken

DEST=/opt/stack

SCREEN_LOGDIR=$DEST/logs/screen

SYSLOG=True

#IP:Port for the BSN controller

#if more than one, separate with commas

BS_FL_CONTROLLERS_PORT=<ip_address:port>

BS_FL_CONTROLLER_TIMEOUT=10

然後:

$ ./stack.sh

需要注意的是安裝OpenStack時間比較長並且不能中斷。任何中斷和網絡連接失敗都會導致錯誤並無法恢復。建議你在安裝之前使用VirtualBox的“快照功能”進行保存。這樣就可以很方便的保存後中斷安裝也不會影響到以後繼續安裝。

 

安裝完成

如果安裝成功完成就會顯示:

Horizon is now available at http://10.10.2.15/

Keystone is serving at http://10.10.2.15:5000/v2.0/

Examples on using novaclient command line is in exercise.sh

The default users are: admin and demo

The password: nova

This is your host ip: 10.10.2.15

stack.sh completed in 102 seconds.

 

 

 

驗證OpenStackFloodlight安裝

下面顯示的是一個會話的安裝devstack後的快照:

~/quantum-restproxy$ source openrc demo demo
~/quantum-restproxy$ quantum net-list

~/quantum-restproxy$ quantum net-create net1

 

創建一個新的網絡:

Field

Value

admin_state_up

True

id

9c1cca24-3b7c-456d-afdd-55bc178b1c83

name

net1

shared

False

status

ACTIVE

subnets

 

tenant_id

4fafea2aac994c13a5f3034a35e583f4

~/quantum-restproxy$ quantum subnet-create 9c1cca24-3b7c-456d-afdd-55bc178b1c83 10.2.2.0/24

 

創建一個新的子網:

Field

Value

allocation_pools

{"start": "10.2.2.2", "end": "10.2.2.254"}

cidr

10.2.2.0/24

dns_nameservers

 

enable_dhcp

True

gateway_ip

10.2.2.1

host_routes

 

id

7f03b14a-c15e-4d7b-81a0-8e9e6c6bbd88

ip_version

4

name

 

network_id

9c1cca24-3b7c-456d-afdd-55bc178b1c83

tenant_id

4fafea2aac994c13a5f3034a35e583f4

~/devstack$ IMG_ID=`nova image-list | grep cirros | grep -v kernel | grep -v ram | awk -F "|" '{print $2}'`
~/devstack$ nova boot --image $IMG_ID --flavor 1 --nic net-id=9c1cca24-3b7c-456d-afdd-55bc178b1c83 vm1

 

Property

Value

OS-DCF:diskConfig

MANUAL

OS-EXT-STS:power_state

0

OS-EXT-STS:task_state

scheduling

OS-EXT-STS:vm_state

building

accessIPv4

 

accessIPv6

 

adminPass

ZTYnQ7PB3Z7M

config_drive

 

created

2012-11-01T06:23:32Z

flavor

m1.tiny

hostId

 

id

fe362118-77e3-441d-bb68-608394256259

image

cirros-0.3.0-x86_64-uec

key_name

None

metadata

{}

name

vm1

progress

0

security_groups

[{u'name': u'default'}]

status

BUILD

tenant_id

4fafea2aac994c13a5f3034a35e583f4

updated

2012-11-01T06:23:32Z

user_id

69c5935b290543278fb3c4037b44fe8e

~/devstack$ nova list

 

ID

Name

Status

Networks

fe362118-77e3-441d-bb68-608394256259

vm1

ACTIVE

net1=10.2.2.3

~/quantum-restproxy$ ping 10.2.2.3

PING 10.2.2.3 (10.2.2.3) 56(84) bytes of data.
64 bytes from 10.2.2.3: icmp_req=1 ttl=64 time=15.9 ms
64 bytes from 10.2.2.3: icmp_req=2 ttl=64 time=0.684 ms
64 bytes from 10.2.2.3: icmp_req=3 ttl=64 time=0.433 ms
^C
~/quantum-restproxy$ ssh [email protected]
The authenticity of host '10.2.2.3 (10.2.2.3)' can't be established.
RSA key fingerprint is cf:b0:bb:0f:a6:00:0c:87:00:fd:c5:ac:1d:41:03:77.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.2.2.3' (RSA) to the list of known hosts.
[email protected]'s password:
$ ifconfig
eth0 Link encap:Ethernet HWaddr FA:16:3E:51:2F:27
inet addr:10.2.2.3 Bcast:10.2.2.255 Mask:255.255.255.0
inet6 addr: fe80::f816:3eff:fe51:2f27/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:353 errors:0 dropped:95 overruns:0 frame:0
TX packets:236 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:34830 (34.0 KiB) TX bytes:28414 (27.7 KiB)
Interrupt:11

 

另一個例子(基於Essex版本,一些命令格式發生改變)

 

創建網絡、租戶、虛擬機

下載我們擁有了一個正在工作的OpenStack服務器,我們可以在其上啓動多個虛擬機並通過Quantum API關聯到不同的虛擬網絡

odd_even_essex.sh創建兩個網絡每個網絡中有兩個虛擬機。如果節點創建成功,將會有許多表格被打印,但是確保節點的WAIT PATIENTALY完成了了引導過程。四個虛擬機嵌套在一個虛擬機中,執行都會變得緩慢。

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章