next up previous contents
Next: 刪除 keypair Up: 其他及問題解決 Previous: 問題:無法刪除 network   Contents

刪除 network

  1. 要刪除網路 selfservice 是用戶 demo 創建,所以先載入用戶 demo 的環境變數。
    [root@controller ~]# . demo.token
    
  2. 要刪除網路是 selfservice。
    [root@controller ~]# openstack network list
    +--------------------------------------+-------------+--------------------------------------+
    | ID                                   | Name        | Subnets                              |
    +--------------------------------------+-------------+--------------------------------------+
    | 3d2fe8f3-6871-4072-8688-4c83f597cda1 | selfservice | 37adab37-d710-406f-bdfa-66c2a4d13203 |
    +--------------------------------------+-------------+--------------------------------------+
    \end{enumerate}
    \item 列出 ports,兩個 ports 於 subnet 37adab37-d710-406f-bdfa-66c2a4d13203,這是 selfservice 的 subnet。
    \begin{myverbatim}
    [root@controller ~]# openstack port list
    +--------------------------------------+------+-------------------+-------------------------
    | ID                                   | Name | MAC Address       | Fixed IP Addresses      
    +--------------------------------------+------+-------------------+-------------------------
    | 92485f50-e5c0-471a-9f24-ba1355d0f36c |      | fa:16:3e:de:db:25 | ip_address='172.16.1.2',
    | b1ba39ec-4646-46b6-850c-13ab5cfd9c3f |      | fa:16:3e:ea:66:23 | ip_address='172.16.1.1',
    +--------------------------------------+------+-------------------+-------------------------
    --------------------------------------------------+--------+
                                                      | Status |
    --------------------------------------------------+--------+
     subnet_id='37adab37-d710-406f-bdfa-66c2a4d13203' | ACTIVE |
     subnet_id='37adab37-d710-406f-bdfa-66c2a4d13203' | ACTIVE |
    --------------------------------------------------+--------+
    \end{enumerate}
    \item 以 port delete 刪除 port,port b1ba39ec-4646-46b6-850c-13ab5cfd9c3f 無法刪除,原於是其為 router 的 gateway。
    \begin{myverbatim}
    [root@controller ~]# openstack port delete 92485f50-e5c0-471a-9f24-ba1355d0f36c
    [root@controller ~]# openstack port delete b1ba39ec-4646-46b6-850c-13ab5cfd9c3f
    Failed to delete port with name or ID 'b1ba39ec-4646-46b6-850c-13ab5cfd9c3f': 
    Unable to delete Port for openstack.network.v2.port.Port(status=BUILD, 
    created_at=2018-05-25T12:29:00Z, description=, allowed_address_pairs=[], tags=[], 
    network_id=3d2fe8f3-6871-4072-8688-4c83f597cda1, tenant_id=92d1ec3e04384ad599c1a8f5aed73663, 
    extra_dhcp_opts=[], admin_state_up=True, updated_at=2018-05-26T04:23:50Z, name=, 
    device_owner=network:router_interface, revision_number=15, mac_address=fa:16:3e:ea:66:23, 
    port_security_enabled=False, binding:vnic_type=normal, fixed_ips=[{u'subnet_id': 
    u'37adab37-d710-406f-bdfa-66c2a4d13203', u'ip_address': u'172.16.1.1'}], 
    id=b1ba39ec-4646-46b6-850c-13ab5cfd9c3f, security_groups=[], 
    device_id=53bc7576-bcee-4ad4-ae06-d18d9be372a2)
    1 of 1 ports failed to delete.
    \end{enumerate}
    \item router list 列出 router,但一樣無法刪除。
    \begin{myverbatim}
    [root@controller ~]# openstack router list
    +--------------------------------------+--------+--------+-------+-------------+-------+----------------------------------+
    | ID                                   | Name   | Status | State | Distributed | HA    | Project                          |
    +--------------------------------------+--------+--------+-------+-------------+-------+----------------------------------+
    | 53bc7576-bcee-4ad4-ae06-d18d9be372a2 | router | ACTIVE | UP    | False       | False | 92d1ec3e04384ad599c1a8f5aed73663 |
    +--------------------------------------+--------+--------+-------+-------------+-------+----------------------------------+
    [root@controller ~]# openstack router delete 53bc7576-bcee-4ad4-ae06-d18d9be372a2
    Failed to delete router with name or ID '53bc7576-bcee-4ad4-ae06-d18d9be372a2': 
    Unable to delete Router for openstack.network.v2.router.Router(status=ACTIVE, 
    external_gateway_info=None, availability_zone_hints=[], availability_zones=[u'nova'], 
    description=, tags=[], tenant_id=92d1ec3e04384ad599c1a8f5aed73663, 
    created_at=2018-05-25T12:28:46Z, admin_state_up=True, updated_at=2018-05-26T01:37:32Z, 
    flavor_id=None, routes=[], revision=7, id=53bc7576-bcee-4ad4-ae06-d18d9be372a2, name=router)
    1 of 1 routers failed to delete.
    \end{enumerate}
    \item router 先 unset gateway。
    \begin{myverbatim}
    [root@controller ~]# openstack router unset --external-gateway 53bc7576-bcee-4ad4-ae06-d18d9be372a2
    \end{enumerate}
    \item 再查一下 ports,除原無法刪除的 b1ba39ec-4646-46b6-850c-13ab5cfd9c3f,又自動生成 e34033f0-dfef-40d5-933d-b7a5584cca94。
    \begin{myverbatim}
    [root@controller ~]# openstack port list
    +--------------------------------------+------+-------------------+-------------------------
    | ID                                   | Name | MAC Address       | Fixed IP Addresses      
    +--------------------------------------+------+-------------------+-------------------------
    | b1ba39ec-4646-46b6-850c-13ab5cfd9c3f |      | fa:16:3e:ea:66:23 | ip_address='172.16.1.1',
    | e34033f0-dfef-40d5-933d-b7a5584cca94 |      | fa:16:3e:68:a3:d2 | ip_address='172.16.1.2',
    +--------------------------------------+------+-------------------+-------------------------
    --------------------------------------------------+--------+
                                                      | Status |
    --------------------------------------------------+--------+
     subnet_id='37adab37-d710-406f-bdfa-66c2a4d13203' | BUILD  |
     subnet_id='37adab37-d710-406f-bdfa-66c2a4d13203' | BUILD  |
    --------------------------------------------------+--------+
    \end{enumerate}
    \item 將 port b1ba39ec-4646-46b6-850c-13ab5cfd9c3f 從 router b1ba39ec-4646-46b6-850c-13ab5cfd9c3f 中移除。
    \begin{myverbatim}
    [root@controller ~]# openstack router remove port 53bc7576-bcee-4ad4-ae06-d18d9be372a2 b1ba39ec-4646-46b6-850c-13ab5cfd9c3f
    \end{enumerate}
    \item 再查一下 ports,只剩剛剛生成 e34033f0-dfef-40d5-933d-b7a5584cca94。
    \begin{myverbatim}
    [root@controller ~]# openstack port list
    +--------------------------------------+------+-------------------+-------------------------
    | ID                                   | Name | MAC Address       | Fixed IP Addresses      
    +--------------------------------------+------+-------------------+-------------------------
    | e34033f0-dfef-40d5-933d-b7a5584cca94 |      | fa:16:3e:68:a3:d2 | ip_address='172.16.1.2',
    +--------------------------------------+------+-------------------+-------------------------
    --------------------------------------------------+--------+
                                                      | Status |
    --------------------------------------------------+--------+
     subnet_id='37adab37-d710-406f-bdfa-66c2a4d13203' | BUILD  |
    --------------------------------------------------+--------+
    \end{enumerate}
    \item port e34033f0-dfef-40d5-933d-b7a5584cca94 不是 gateway,直接以 port delete 刪除,直到沒有列出 port。
    \begin{myverbatim}
    [root@controller ~]# openstack port delete e34033f0-dfef-40d5-933d-b7a5584cca94
    [root@controller ~]# openstack port list
    \end{enumerate}
    \item 查詢 subnet id 37adab37-d710-406f-bdfa-66c2a4d13203。
    \begin{myverbatim}
    [root@controller ~]# openstack subnet list
    +--------------------------------------+-------------+--------------------------------------+---------------+
    | ID                                   | Name        | Network                              | Subnet        |
    +--------------------------------------+-------------+--------------------------------------+---------------+
    | 37adab37-d710-406f-bdfa-66c2a4d13203 | selfservice | 3d2fe8f3-6871-4072-8688-4c83f597cda1 | 172.16.1.0/24 |
    +--------------------------------------+-------------+--------------------------------------+---------------+
    \end{enumerate}
    \item 刪除 subnet 37adab37-d710-406f-bdfa-66c2a4d13203。
    \begin{myverbatim}
    [root@controller ~]# openstack subnet delete 37adab37-d710-406f-bdfa-66c2a4d13203
    \end{enumerate}
    \item 查詢 network id 是 3d2fe8f3-6871-4072-8688-4c83f597cda1。
    \begin{myverbatim}
    [root@controller ~]# openstack network list
    +--------------------------------------+-------------+---------+
    | ID                                   | Name        | Subnets |
    +--------------------------------------+-------------+---------+
    | 3d2fe8f3-6871-4072-8688-4c83f597cda1 | selfservice |         |
    +--------------------------------------+-------------+---------+
    \end{enumerate}
    \item 刪除 network 3d2fe8f3-6871-4072-8688-4c83f597cda1。
    \begin{myverbatim}
    [root@controller ~]# openstack network delete 3d2fe8f3-6871-4072-8688-4c83f597cda1
    \end{enumerate}
    \item 再查 network 已是空的。
    \begin{myverbatim}
    [root@controller ~]# openstack network list
    



2018-09-19