Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to obtain the number of available fixed_ip of network

Shulou Source: shulou.com Published: 2022-05-31 17:12:39 09月21日 Update

Today, I will talk to you about how to obtain the number of available fixed_ip of network. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

Get the number of available fixed_ip of network-openstackE version

About:blank

Method 1: add the fixed_ip_count field directly to the bottom layer of nova:

Method 2: directly encapsulate the api from dashboard to the underlying layer:

Where api is published as follows:

The following are the details:

1. Dashboard page:

Dashboards/nova/zones_and_networks/views.py

Network_id = networks [0] ['id']

Count = api.nova.get_available_count_ips (self.request, network_id)

Api/nova.py

Def get_available_count_ips (request,network_id):

Return novaclient (request) networks.get_available_count_ips (network_id)

2. Novaclient layer

V1_1/networks.py

Def get_available_count_ips (self, network_id):

"

Get a specific flavor.

: param flavor: The ID of the: class: `Flavor` to get.

: rtype:: class: `Flavor`

"

Return self._list ("/ os-networks/get_available_count_ips/%s"% network_id, "count")

3. Nova layer

Api/openstack/compute/contrib/networks.py

Def get_available_count_ips (self, req, id):

Context = req.environ ['nova.context']

Authorize (context)

LOG.debug (_ ("Showing network_fixed_count with id s") id)

Try:

Count = self.network_api.get_available_count_ips (context, id)

Except exception.NetworkNotFound:

Raise exc.HTTPNotFound (_ (Network not found))

Return {'count': count}

Collection_actions = {'list_limit':' POST','get_available_count_ips': 'POST'}

Vi network/api.py

Def get_available_count_ips (self, context,network_id):

Return rpc.call (context

FLAGS.network_topic

{'method':' get_available_count_ips'

'args': {' network_id': network_id}})

Vi network/manager.py

@ wrap_check_policy

Def get_available_count_ips (self, context, network_id):

Count = db.network_available_count_ips (context, network_id)

Return count

Db/api.py

Def network_available_count_ips (context, network_id):

"Return the number of reserved ips in the network."

Return IMPL.network_available_count_ips (context, network_id)

Db/sqlalchemy/api.py

@ require_admin_context

Def network_available_count_ips (context, network_id):

Return _ network_ips_query (context, network_id).\

Filter_by (reserved=False).\

Filter_by (host='').\

Filter_by (instance_id='').\

Filter_by (allocated=False).\

Count ()

Note: be sure to follow the base.py to see how to pass parameters to _ list:

After reading the above, do you have any further understanding of how to obtain the number of fixed_ip available for network? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Number content method information fields bottom layer way more comments knowledge articles industry information information channels pages channels enter one package support related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Tech Info vpn MySQL MariaDB