Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
contego / home / tvault / .virtenv / lib / python2.7 / site-packages / nova / virt / netutils.pyc
Size: Mime:
ó
±EYc@s¼dZddlZddlZddlZddlZddlmZejj	Z	d„Z
d„Zd„Zd„Z
dddd„Zdd	„Zd
„Zd„Zd„Zd
„ZdS(sANetwork-related utilities for supporting libvirt connection code.iÿÿÿÿN(tmodelcCs+tj|ƒ}t|jƒt|jƒfS(N(tnetaddrt	IPNetworktstrtiptnetmask(tcidrtnet((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/netutils.pytget_net_and_mask!scCs+tj|ƒ}t|jƒt|jƒfS(N(RRRRt
_prefixlen(RR((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/netutils.pytget_net_and_prefixlen&scCstj|ƒ}t|jƒS(N(RRtinttversion(RR((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/netutils.pytget_ip_version+scs:y"t‡fd†|dDƒƒSWntk
r5nXdS(Nc3s%|]}|dˆkr|VqdS(RN((t.0ti(R(sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/netutils.pys	<genexpr>5stsubnets(tnextt
StopIteration(tnetworkR((RsG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/netutils.pyt_get_first_network0s"
c"	CsÇ|dkrtj}n|s*tj}n|o3|s:dSg}d}t}x|D]ü}|dsS|ddryqSn|d}t|dƒ}	t|dƒ}
|d7}|jdƒsÀqSn|jd	ƒ}d}d}
d
}d}d}g}|	r|	jdƒdk	rqSn|	dr|	dd
}|d	}tj	||	ƒ}
|	drc|	dd	}nt
|	jƒjƒ}dj
g|	dD]}|d	^q‰ƒ}xr|	dD]c}t|dƒ\}}it
|dd	ƒd6t
|dƒd6|d6|d6}|j|ƒq­Wqnd}d
}d}d}|o;|
}|rä|
jdƒdk	r_qSn|
drät}|
dd
}|d	}tj	||
ƒ}|
dr´|
dd	}ndj
g|
dD]}|d	^qŃ}qänid|d6|d6|d	6|
d6|d6|d6|d6|d6|d6|d6|d6|d6}|j|ƒqSW|s]dStjj|ƒ\}} tjdtj|ƒdtƒ}!|!j| ƒ}|ji|d6|d6|d 6ƒS(!sÎReturns a rendered network template for the given network_info.

    :param network_info:
        :py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
    :param use_ipv6: If False, do not return IPv6 template information
        even if an IPv6 subnet is present in network_info.
    :param template: Path to the interfaces template file.
    :param libvirt_virt_type: The Libvirt `virt_type`, will be `None` for
        other hypervisors..
    NiÿÿÿÿRRiiitinjectedtaddressttdhcp_servertipsitgatewayt tdnstroutesRRseth%dtnamet	hwaddresst	broadcastt
address_v6t
gateway_v6t
netmask_v6tdns_v6tloaderttrim_blockst
interfacestuse_ipv6tlibvirt_virt_type(tNonetCONFR(tinjected_network_templatetFalseRtget_metatgetRtget_netmaskRt
as_netaddrR tjoinRtappendtTruetostpathtsplittjinja2tEnvironmenttFileSystemLoadertget_templatetrender("tnetwork_infoR(ttemplateR)tnetstifc_numtipv6_is_availabletvifRt	subnet_v4t	subnet_v6RRRRR RRRRt	route_refRtmasktrouteR!R"R#R$t	have_ipv6tip_v6tnet_infot	tmpl_patht	tmpl_filetenv((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/netutils.pytget_injected_network_template;s¢





*



0
	c
Cså|s
dS|dkr"tj}ng}g}g}d}d}x‰|D]}|jdƒsG|djdƒrwqGn|d}t|dƒ}	t|dƒ}
|d7}d}|	s»|
rÚt||ƒ}|j|ƒn|	rN|	jdƒrN|d7}|jt||	d||d	ƒƒ|gt|	ƒD]}||kr,|^q,7}n|rG|
rG|
jdƒrG|d7}|jt||
d||d	ƒƒ|gt|
ƒD]}||kr¦|^q¦7}qGqGWi|d
6|d6|d6S(
sÇGets a more complete representation of the instance network information.

    This data is exposed as network_data.json in the metadata service and
    the config drive.

    :param network_info: `nova.network.models.NetworkInfo` object describing
        the network metadata.
    :param use_ipv6: If False, do not return IPv6 template information
        even if an IPv6 subnet is present in network_info. Defaults to
        nova.netconf.use_ipv6.
    NiÿÿÿÿRRiiiRtidtlinkstnetworkstservices(	R*R+R(R/Rt
_get_eth_linkR3t	_get_netst_get_dns_services(
R=R(R?RPRRR@tnet_numRBRRCRDtlinkR((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/netutils.pytget_network_metadata¬sD
$


#
# cCsš|jdƒ}|s"d|}n|jdƒdkr@d}n|jdƒ}i|d6|dd6|d6|dd	jd
ƒd
6|jdƒd6}|S(
sGet a VIF or physical NIC representation.

    :param vif: Neutron VIF
    :param ifc_num: Interface index for generating name if the VIF's
        'devname' isn't defined.
    :return: A dict with 'id', 'vif_id', 'type', 'mtu' and
        'ethernet_mac_address' as keys
    tdevnamesinterface%dttypetethernettphyROtvif_idRtmetatmtuRtethernet_mac_address(R/(RBR@tlink_idtnic_typeRW((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/netutils.pyRSís	
	cCsj|jdƒdk	rKid|d6d|d6|d6|ddd6}|S|d	d
}|d}|dkr„tj||ƒ}n$|d
kr¨t|jƒjƒ}nid|d6d|d6|d6|d6|d6t||ƒd6|ddd6}xk|dD]_}	tj	|	dƒ}
it|
j
ƒd6t|
jƒd6|	ddd6}|dj|ƒqW|S(sJGet networks for the given VIF and subnet

    :param vif: Neutron VIF
    :param subnet: Neutron subnet
    :param version: IP version as an int, either '4' or '6'
    :param net_num: Network index for generating name of each network
    :param link_id: Arbitrary identifier for the link the networks are
        attached to
    Rs	network%dROs
ipv%d_dhcpRZRWRt
network_idRiRiisipv%dt
ip_addressRRRRN(R.R*RR0RR1Rt_get_default_routeRRRR3(RBtsubnetRRVRaRJRRRRGt
route_addrt	new_route((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/netutils.pyRT
s:

cCs‹|jdƒr3|djdƒr3|dd}ngS|dkr_idd6dd6|d6gS|dkr‡idd6dd6|d6gSd	S(
s…Get a default route for a network

    :param version: IP version as an int, either '4' or '6'
    :param subnet: Neutron subnet
    RRis0.0.0.0RRis::N(R/(RRfR((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/netutils.pyRe;s"cCsKg}|jdƒs|Sg|dD]#}idd6|jdƒd6^q$S(s#Get the DNS servers for the subnet.RRZR(R/(RfRRR((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/netutils.pyRUTs
(t__doc__R5R8Rt	nova.conftnovatnova.networkRtconfR+RR
R
RR*RNRXRSRTReRU(((sG/home/tvault/.virtenv/lib/python2.7/site-packages/nova/virt/netutils.pyt<module>s"				pA		1