Created
April 30, 2015 14:46
-
-
Save otherwiseguy/f7e21ece51813469cc1d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddLogicalPortCommand(BaseCommand): | |
# required values or values that need processing enumerated, optional | |
# columns as kwargs | |
def __init__(self, api, lswitch_name, lport_name, may_exist, **columns): | |
super(AddLogicalPortCommand, self).__init__(api) | |
self.lswitch_name = lswitch_name | |
self.lport_name = lport_name | |
self.may_exist = may_exist | |
self.columns == columns | |
def run_idl(self, txn): | |
try: | |
lswitch = idlutils.row_by_value(self.api.idl, 'Logical_Switch', | |
'name', self.lswitch) | |
except: | |
... | |
if self.may_exist: | |
... | |
port = txn.insert(self.api._tables['Logical_Port']) | |
port.name = self.lport_name | |
port.lswitch = lswitch | |
for col, val in self.columns: | |
setattr(port, col, val) | |
def create_lport(self, lport_name, lswitch_name, may_exist=True, **columns) | |
return AddLogicalPortCommand(self, lswitch_name, lport_name, may_exist, | |
**columns) | |
create_port(lport_name=port['id'], | |
lswitch_name=utils.ovn_name(port['network_id']), | |
macs=[mac], | |
lport_name=get_port_name(port), | |
**self._binding_from_profile(port)).execute() | |
# Same with SetLogicalPortCommand |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment