mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Add network create function
This commit is contained in:
parent
31cbff6954
commit
7542fba756
@ -960,7 +960,14 @@ def volume_list(**kwargs):
|
||||
|
||||
def network_list(call=None, **kwargs):
|
||||
'''
|
||||
Attach block volume
|
||||
List private networks
|
||||
'''
|
||||
conn = get_conn()
|
||||
return conn.network_list()
|
||||
|
||||
def network_create(name, **kwargs):
|
||||
'''
|
||||
Create private networks
|
||||
'''
|
||||
conn = get_conn()
|
||||
return conn.network_create(name, **kwargs)
|
||||
|
@ -284,6 +284,18 @@ def volume_detach(provider, names, **kwargs):
|
||||
info = client.volume_action(provider, names, action='detach', **kwargs)
|
||||
return info
|
||||
|
||||
|
||||
def network_list(provider):
|
||||
'''
|
||||
List private networks
|
||||
'''
|
||||
client = _get_client()
|
||||
return action(fun='network_list', provider=provider)
|
||||
|
||||
|
||||
def network_create(provider, names, **kwargs):
|
||||
'''
|
||||
Create private network
|
||||
'''
|
||||
client = _get_client()
|
||||
return action(fun='network_create', provider=provider, names=names)
|
||||
|
@ -728,6 +728,33 @@ class SaltNova(object):
|
||||
nt_ks = self.compute_conn
|
||||
return [network.__dict__ for network in nt_ks.networks.list()]
|
||||
|
||||
def _sanatize_network_params(kwargs):
|
||||
'''
|
||||
Sanatize novaclient network parameters
|
||||
'''
|
||||
params = [
|
||||
'label', 'bridge', 'bridge_interface', 'cidr', 'cidr_v6', 'dns1',
|
||||
'dns2', 'fixed_cidr', 'gateway', 'gateway_v6', 'multi_host',
|
||||
'priority', 'project_id', 'vlan_start', 'vpn_start'
|
||||
]
|
||||
|
||||
for variable in kwargs.keys():
|
||||
if variable not in params:
|
||||
del kwargs[variable]
|
||||
return kwargs
|
||||
|
||||
|
||||
def network_create(self, name, **kwargs):
|
||||
'''
|
||||
Create extra private network
|
||||
'''
|
||||
nt_ks = self.compute_conn
|
||||
kwargs['label'] = name
|
||||
kwargs = _sanatize_network_params(kwargs)
|
||||
net = nt_ks.networks.create(**kwargs)
|
||||
log.debug('Network: \n{0}'.format(net))
|
||||
return net
|
||||
|
||||
#The following is a list of functions that need to be incorporated in the
|
||||
#nova module. This list should be updated as functions are added.
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user