Revision e1fab40f snf-cyclades-app/synnefo/api/ports.py
b/snf-cyclades-app/synnefo/api/ports.py | ||
---|---|---|
107 | 107 |
port_dict = api.utils.get_attribute(req, "port") |
108 | 108 |
net_id = api.utils.get_attribute(port_dict, "network_id") |
109 | 109 |
|
110 |
network = util.get_network(net_id, user_id, non_deleted=True, |
|
111 |
for_update=True) |
|
110 |
device_id = api.utils.get_attribute(port_dict, "device_id", required=False) |
|
111 |
vm = None |
|
112 |
if device_id is not None: |
|
113 |
vm = util.get_vm(device_id, user_id, for_update=True, non_deleted=True, |
|
114 |
non_suspended=True) |
|
112 | 115 |
|
113 | 116 |
# Check if the request contains a valid IPv4 address |
114 | 117 |
fixed_ips = api.utils.get_attribute(port_dict, "fixed_ips", required=False) |
... | ... | |
129 | 132 |
else: |
130 | 133 |
fixed_ip_address = None |
131 | 134 |
|
135 |
network = util.get_network(net_id, user_id, non_deleted=True, |
|
136 |
for_update=True) |
|
137 |
|
|
132 | 138 |
ipaddress = None |
133 | 139 |
if network.public: |
134 | 140 |
# Creating a port to a public network is only allowed if the user has |
... | ... | |
144 | 150 |
ipaddress = ips.allocate_ip(network, user_id, |
145 | 151 |
address=fixed_ip_address) |
146 | 152 |
|
147 |
device_id = api.utils.get_attribute(port_dict, "device_id", required=False) |
|
148 |
vm = None |
|
149 |
if device_id is not None: |
|
150 |
vm = util.get_vm(device_id, user_id, for_update=True, non_deleted=True, |
|
151 |
non_suspended=True) |
|
152 |
|
|
153 | 153 |
name = api.utils.get_attribute(port_dict, "name", required=False) |
154 | 154 |
if name is None: |
155 | 155 |
name = "" |
Also available in: Unified diff