@@ -46,19 +46,21 @@ class OptiondefException(Exception):
4646
4747
4848class Network (object ):
49- def __init__ (self , config , name = None , id = None ):
49+ def __init__ (self , config , name = None , id = None , tags = None ):
5050 """
5151 Create a new high level Network object
5252
5353 :param ns1.config.Config config: config object
5454 :param str name: network name
5555 :param int id: id of an existing Network
56+ :param dict tags: tags of the reservation
5657 """
5758 self ._rest = Networks (config )
5859 self .config = config
5960 self .name = name
6061 self .id = id
6162 self .report = {}
63+ self .tags = tags
6264 self .data = None
6365
6466 def __repr__ (self ):
@@ -88,6 +90,9 @@ def success(result, *args):
8890 self .name = result ["name" ]
8991 self .report = self ._rest .report (self .id )
9092
93+ if "tags" in result :
94+ self .tags = result ["tags" ]
95+
9196 if callback :
9297 return callback (self )
9398 else :
@@ -161,7 +166,7 @@ def success(result, *args):
161166 )
162167
163168 def new_address (
164- self , prefix , status , callback = None , errback = None , ** kwargs
169+ self , prefix , status , callback = None , errback = None , ** kwargs
165170 ):
166171 """
167172 Create a new address space in this Network
@@ -179,13 +184,14 @@ def new_address(
179184
180185class Address (object ):
181186 def __init__ (
182- self ,
183- config ,
184- prefix = None ,
185- status = None ,
186- network = None ,
187- scope_group = None ,
188- id = None ,
187+ self ,
188+ config ,
189+ prefix = None ,
190+ status = None ,
191+ network = None ,
192+ scope_group = None ,
193+ id = None ,
194+ tags = None
189195 ):
190196 """
191197 Create a new high level Address object
@@ -195,6 +201,7 @@ def __init__(
195201 :param str status: planned, assigned
196202 :param Network network: Network Object the address will be part of
197203 :param Scopegroup scope_group: Scopegroup Object that will be associated with the address
204+ :param dict tags: tags of the reservation
198205 """
199206 self ._rest = Addresses (config )
200207 self .config = config
@@ -206,6 +213,7 @@ def __init__(
206213 self .children = []
207214 self .report = {}
208215 self .data = None
216+ self .tags = tags
209217
210218 def __repr__ (self ):
211219 return "<Address address=%s>" % self .prefix
@@ -237,6 +245,10 @@ def success(result, *args):
237245 # self.scope_group = Scopegroup(config=self.config, id=result['scope_group_id']) NYI
238246 self .report = self ._rest .report (self .id )
239247 children = self ._rest .retrieve_children (self .id )
248+
249+ if "tags" in result :
250+ self .tags = result ["tags" ]
251+
240252 self .children = [
241253 Address (self .config , id = child ["id" ])
242254 for child in children
@@ -255,9 +267,9 @@ def success(result, *args):
255267
256268 if self .id is None :
257269 if (
258- self .prefix is None
259- or self .status is None
260- or self .network is None
270+ self .prefix is None
271+ or self .status is None
272+ or self .network is None
261273 ):
262274 raise AddressException (
263275 "Must at least specify an id or prefix, status, and network"
@@ -269,8 +281,8 @@ def success(result, *args):
269281 address
270282 for address in self ._rest .list ()
271283 if address ["prefix" ] == self .prefix
272- and address ["status" ] == self .status
273- and address ["network_id" ] == network_id
284+ and address ["status" ] == self .status
285+ and address ["network_id" ] == network_id
274286 ][0 ]["id" ]
275287 except IndexError :
276288 raise AddressException (
@@ -326,7 +338,7 @@ def success(result, *args):
326338 )
327339
328340 def reserve (
329- self , scopegroup_id , mac , options = None , callback = None , errback = None
341+ self , scopegroup_id , mac , options = None , callback = None , errback = None
330342 ):
331343 """
332344 Add scope group reservation. Pass a single Address object and a MAC address as a string
@@ -390,14 +402,15 @@ def success(result, *args):
390402
391403
392404class Scopegroup (object ):
393- def __init__ (self , config , name = None , service_def_id = None , id = None ):
405+ def __init__ (self , config , name = None , service_def_id = None , id = None , tags = None ):
394406 """
395407 Create a new high level Scopegroup object
396408
397409 :param ns1.config.Config config: config object
398410 :param str name: Name of the scope group
399411 :param int service_group_id: id of the service group the scope group is associated with
400412 :param int id: id of the scope group
413+ :param dict tags: tags of the reservation
401414 """
402415 self ._rest = Scopegroups (config )
403416 self .config = config
@@ -407,6 +420,7 @@ def __init__(self, config, name=None, service_def_id=None, id=None):
407420 self .name = name
408421 self .dhcp_service_id = service_def_id
409422 self .data = None
423+ self .tags = tags
410424
411425 def __repr__ (self ):
412426 return "<Scopegroup scope_group=%s>" % self .name
@@ -435,6 +449,9 @@ def success(result, *args):
435449 self .dhcp4 = result ["dhcpv4" ]
436450 self .dhcp6 = result ["dhcpv6" ]
437451 self .dhcp_service_id = result .get ("dhcp_service_id" )
452+
453+ if "tags" in result :
454+ self .tags = result ["tags" ]
438455
439456 if callback :
440457 return callback (self )
@@ -522,7 +539,7 @@ def success(result, *args):
522539 )
523540
524541 def reserve (
525- self , address_id , mac , options = None , callback = None , errback = None
542+ self , address_id , mac , options = None , callback = None , errback = None
526543 ):
527544 """
528545 :param int address_id: id of the Address to reserve
@@ -576,14 +593,14 @@ def scopes(self, callback=None, errback=None):
576593
577594class Reservation (object ):
578595 def __init__ (
579- self ,
580- config ,
581- scopegroup_id ,
582- address_id ,
583- tags = None ,
584- reservation_id = None ,
585- options = None ,
586- mac = None ,
596+ self ,
597+ config ,
598+ scopegroup_id ,
599+ address_id ,
600+ reservation_id = None ,
601+ options = None ,
602+ mac = None ,
603+ tags = None
587604 ):
588605 """
589606 Create a new high level Reservation object
@@ -595,15 +612,16 @@ def __init__(
595612 :param int reservation_id: id of the reservation
596613 :param list options: dhcp options of the reservation
597614 :param str mac: mac address of the reservation
615+ :param dict tags: tags of the reservation
598616 """
599617 self ._rest = Reservations (config )
600618 self .config = config
601619 self .id = reservation_id
602620 self .scopegroup_id = scopegroup_id
603- self .tags = tags
604621 self .address_id = address_id
605622 self .mac = mac
606623 self .data = None
624+ self .tags = tags
607625
608626 if options is None :
609627 options = DHCPOptions ("dhcpv4" , {})
@@ -698,7 +716,7 @@ def success(result, *args):
698716 )
699717
700718 def update (
701- self , options , callback = None , errback = None , parent = True , ** kwargs
719+ self , options , callback = None , errback = None , parent = True , ** kwargs
702720 ):
703721 """
704722 Update reservation configuration. Pass a list of keywords and their values to
@@ -825,7 +843,7 @@ def success(result, *args):
825843
826844class Scope (object ):
827845 def __init__ (
828- self , config , scopegroup_id , address_id , scope_id = None , options = None
846+ self , config , scopegroup_id , address_id , scope_id = None , options = None , tags = None
829847 ):
830848 """
831849 Create a new high level Scope object
@@ -835,12 +853,14 @@ def __init__(
835853 :param int address_id: id of the address the scope is associated with
836854 :param int scope_id: id of the scope
837855 :param DHCPOptions options: DHCPOptions object that contains the settings for the scope
856+ :param dict tags: tags of the reservation
838857 """
839858 self ._rest = Scopes (config )
840859 self .config = config
841860 self .scopegroup_id = scopegroup_id
842861 self .address_id = address_id
843862 self .id = scope_id
863+ self .tags = tags
844864
845865 if options is None :
846866 options = DHCPOptions ("dhcpv4" , {})
@@ -883,6 +903,9 @@ def success(result, *args):
883903 self .address_id = result ["address_id" ]
884904 self .options = result ["options" ]
885905
906+ if "tags" in result :
907+ self .tags = result ["tags" ]
908+
886909 if callback :
887910 return callback (self )
888911 else :
@@ -930,7 +953,7 @@ def success(result, *args):
930953 )
931954
932955 def update (
933- self , address_id , options , callback = None , errback = None , ** kwargs
956+ self , address_id , options , callback = None , errback = None , ** kwargs
934957 ):
935958 """
936959 Update Scope configuration. Pass a list of keywords and their values to
@@ -984,14 +1007,14 @@ def reload(self, callback=None, errback=None):
9841007 return self .load (reload = True , callback = callback , errback = errback )
9851008
9861009 def load (
987- self ,
988- scope_group_id = None ,
989- scope_id = None ,
990- limit = None ,
991- offset = None ,
992- callback = None ,
993- errback = None ,
994- reload = False ,
1010+ self ,
1011+ scope_group_id = None ,
1012+ scope_id = None ,
1013+ limit = None ,
1014+ offset = None ,
1015+ callback = None ,
1016+ errback = None ,
1017+ reload = False ,
9951018 ):
9961019 """
9971020 Load Lease data from the API.
0 commit comments