作为个人学习笔记分享,有任何问题欢迎交流!
适应版本:E
使用方法:
如下图所示,若要分配指定的floatingIP,可在里输入指定IP;若不要分配指定的floating IP,“IP地址”栏为空,直接点“分配IP”按钮。
修改过程
1./usr/share/pyshared/horizon/dashboards/nova/access_and_security/floating_ips/forms.py:FloatingIpAllocate中添加一个变量address,address从horizon的页面上接受用户输入的floating ip的值;并在api函数中添加该变量。
class FloatingIpAllocate(forms.SelfHandlingForm):
tenant_name = forms.CharField(widget=forms.HiddenInput())
pool = forms.ChoiceField(label=_("Pool"))
address = forms.CharField(required=False,label=_("IP Address"))
def __init__(self, *args, **kwargs):
super(FloatingIpAllocate, self).__init__(*args, **kwargs)
floating_pool_list = kwargs.get('initial', {}).get('pool_list', [])
self.fields['pool'].choices = floating_pool_list
#self.fields['address'].choices = None
def handle(self, request, data):
try:
fip = api.tenant_floating_ip_allocate(request,
pool=data.get('pool', N