Skip to content

Commit

Permalink
update module.neutron to work with all options that create-network ha…
Browse files Browse the repository at this point in the history
…s in the neutron client.
  • Loading branch information
Thomas Phipps committed Jun 13, 2015
1 parent b869823 commit 2b105ef
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
13 changes: 9 additions & 4 deletions salt/modules/neutron.py
Expand Up @@ -373,7 +373,7 @@ def show_network(network, profile=None):
return conn.show_network(network)


def create_network(name, router_ext=False, profile=None):
def create_network(name, router_ext=None, admin_state_up=True, network_type=None, physical_network=None, segmentation_id=None, shared=None, profile=None):
'''
Creates a new network
Expand All @@ -385,13 +385,18 @@ def create_network(name, router_ext=False, profile=None):
salt '*' neutron.create_network network-name profile=openstack1
:param name: Name of network to create
:param router_ext: True then if create the external network,
default: False (Optional)
:param admin_state_up: should the state of the network be up?
default: True (Optional)
:param router_ext: True then if create the external network (Optional)
:param network_type: the Type of network that the provider is such as GRE, VXLAN, VLAN, FLAT, or LOCAL (Optional)
:param physical_network: the name of the physical network as neutron knows it (Optional)
:param segmentation_id: the vlan id or GRE id (Optional)
:param shared: is the network shared or not (Optional)
:param profile: Profile to build on (Optional)
:return: Created network information
'''
conn = _auth(profile)
return conn.create_network(name, router_ext)
return conn.create_network(name, admin_state_up, router_ext, network_type, physical_network, segmentation_id, shared)


def update_network(network, name, profile=None):
Expand Down
17 changes: 14 additions & 3 deletions salt/utils/openstack/neutron.py
Expand Up @@ -272,13 +272,24 @@ def show_network(self, network):
'''
return self._fetch_network(network)

def create_network(self, name, router_ext=False):
def create_network(self, name, admin_state_up=True, router_ext=None, network_type=None, physical_network=None, segmentation_id=None, shared=None, vlan_transparent=None):
'''
Creates a new network
'''
body = {'name': name,
'admin_state_up': True,
'router:external': router_ext}
'admin_state_up': admin_state_up}
if router_ext:
body['router:external'] = router_ext
if network_type:
body['provider:network_type'] = network_type
if physical_network:
body['provider:physical_network'] = physical_network
if segmentation_id:
body['provider:segmentation_id'] = segmentation_id
if shared:
body['shared'] = shared
if vlan_transparent:
body['vlan_transparent'] = vlan_transparent
return self.network_conn.create_network(body={'network': body})

def update_network(self, network, name):
Expand Down

0 comments on commit 2b105ef

Please sign in to comment.