In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
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.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.