共計(jì) 2160 個(gè)字符,預(yù)計(jì)需要花費(fèi) 6 分鐘才能閱讀完成。
今天就跟大家聊聊有關(guān) 如何獲得 network 的可用 fixed_ip 個(gè)數(shù),可能很多人都不太了解,為了讓大家更加了解,丸趣 TV 小編給大家總結(jié)了以下內(nèi)容,希望大家根據(jù)這篇文章可以有所收獲。
獲得 network 的可用 fixed_ip 個(gè)數(shù) -openstackE 版
about:blank
方法一:直接在 nova 底層增加 fixed_ip_count 字段:
方法二:直接從 dashboard 封裝 api 到底層:
其中 api 發(fā)布為:
以下為詳細(xì)信息:
1、dashboard 頁(yè)面:
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 層
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 層
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()
注釋:一定要跟到 base.py 里面看_list 的傳參方式:
看完上述內(nèi)容,你們對(duì) 如何獲得 network 的可用 fixed_ip 個(gè)數(shù)有進(jìn)一步的了解嗎?如果還想了解更多知識(shí)或者相關(guān)內(nèi)容,請(qǐng)關(guān)注丸趣 TV 行業(yè)資訊頻道,感謝大家的支持。