107 cmd = ['/usr/sbin/ipadm', 'create-addr', '-T', 'static', '-a', |
107 cmd = ['/usr/sbin/ipadm', 'create-addr', '-T', 'static', '-a', |
108 ipaddr, self._ifname] |
108 ipaddr, self._ifname] |
109 if temp: |
109 if temp: |
110 cmd.append('-t') |
110 cmd.append('-t') |
111 |
111 |
112 return self.execute_with_pfexec(cmd) |
112 self.execute_with_pfexec(cmd) |
113 |
113 |
114 def delete_address(self, ipaddr): |
114 def delete_address(self, ipaddr): |
115 if not self.ipaddr_exists(self._ifname, ipaddr): |
115 if not self.ipaddr_exists(self._ifname, ipaddr): |
116 return |
116 return |
117 |
117 |
185 cmd = ['/usr/sbin/dladm', 'create-vnic', '-l', lower_link, |
185 cmd = ['/usr/sbin/dladm', 'create-vnic', '-l', lower_link, |
186 '-m', mac_address, '-v', vid, self._dlname] |
186 '-m', mac_address, '-v', vid, self._dlname] |
187 if temp: |
187 if temp: |
188 cmd.append('-t') |
188 cmd.append('-t') |
189 |
189 |
190 return self.execute_with_pfexec(cmd) |
190 self.execute_with_pfexec(cmd) |
191 |
191 |
192 def delete_vnic(self): |
192 def delete_vnic(self): |
193 if not self.datalink_exists(self._dlname): |
193 if not self.datalink_exists(self._dlname): |
194 return |
194 return |
195 |
195 |
196 cmd = ['/usr/sbin/dladm', 'delete-vnic', self._dlname] |
196 cmd = ['/usr/sbin/dladm', 'delete-vnic', self._dlname] |
197 return self.execute_with_pfexec(cmd) |
197 self.execute_with_pfexec(cmd) |
198 |
198 |
199 |
199 |
200 class IPpoolCommand(CommandBase): |
200 class IPpoolCommand(CommandBase): |
201 '''Wrapper around Solaris ippool(1m) command''' |
201 '''Wrapper around Solaris ippool(1m) command''' |
202 |
202 |
278 |
278 |
279 return existing_rules, non_existing_rules |
279 return existing_rules, non_existing_rules |
280 |
280 |
281 def add_rules(self, rules, version=4): |
281 def add_rules(self, rules, version=4): |
282 rules = self._split_rules(rules, version)[1] |
282 rules = self._split_rules(rules, version)[1] |
283 process_input = '\n'.join(rules) |
283 if not rules: |
|
284 return |
|
285 process_input = '\n'.join(rules) + '\n' |
284 cmd = ['/usr/sbin/ipf', '-f', '-'] |
286 cmd = ['/usr/sbin/ipf', '-f', '-'] |
285 if version == 6: |
287 if version == 6: |
286 cmd.insert(1, '-6') |
288 cmd.insert(1, '-6') |
287 return self.execute_with_pfexec(cmd, process_input=process_input) |
289 self.execute_with_pfexec(cmd, process_input=process_input) |
288 |
290 |
289 def remove_rules(self, rules, version=4): |
291 def remove_rules(self, rules, version=4): |
290 rules = self._split_rules(rules, version)[0] |
292 rules = self._split_rules(rules, version)[0] |
291 process_input = '\n'.join(rules) |
293 if not rules: |
|
294 return |
|
295 process_input = '\n'.join(rules) + '\n' |
292 cmd = ['/usr/sbin/ipf', '-r', '-f', '-'] |
296 cmd = ['/usr/sbin/ipf', '-r', '-f', '-'] |
293 if version == 6: |
297 if version == 6: |
294 cmd.insert(1, '-6') |
298 cmd.insert(1, '-6') |
295 return self.execute_with_pfexec(cmd, process_input=process_input) |
299 self.execute_with_pfexec(cmd, process_input=process_input) |
296 |
300 |
297 |
301 |
298 class IPnatCommand(CommandBase): |
302 class IPnatCommand(CommandBase): |
299 '''Wrapper around Solaris ipnat(1m) command''' |
303 '''Wrapper around Solaris ipnat(1m) command''' |
300 |
304 |
301 def add_rules(self, rules): |
305 def add_rules(self, rules): |
302 process_input = '\n'.join(rules) |
306 if not rules: |
|
307 return |
|
308 process_input = '\n'.join(rules) + '\n' |
303 cmd = ['/usr/sbin/ipnat', '-f', '-'] |
309 cmd = ['/usr/sbin/ipnat', '-f', '-'] |
304 return self.execute_with_pfexec(cmd, process_input=process_input) |
310 self.execute_with_pfexec(cmd, process_input=process_input) |
305 |
311 |
306 def remove_rules(self, rules): |
312 def remove_rules(self, rules): |
307 process_input = '\n'.join(rules) |
313 if not rules: |
|
314 return |
|
315 process_input = '\n'.join(rules) + '\n' |
308 cmd = ['/usr/sbin/ipnat', '-r', '-f', '-'] |
316 cmd = ['/usr/sbin/ipnat', '-r', '-f', '-'] |
309 return self.execute_with_pfexec(cmd, process_input=process_input) |
317 self.execute_with_pfexec(cmd, process_input=process_input) |