add datacenter location awareness with pseudo-driver (cmd and file) #4

Merged
Solvik merged 10 commits from feature/datacenter into master 2019-08-04 20:09:29 +02:00
Solvik commented 2019-08-03 17:16:52 +02:00 (Migrated from github.com)

This PR is fixes issue #1 by letting the users choose how they want to create datacenter awareness

This PR is fixes issue #1 by letting the users choose how they want to create datacenter awareness
blotus (Migrated from github.com) reviewed 2019-08-04 18:53:11 +02:00
blotus (Migrated from github.com) commented 2019-08-04 18:53:11 +02:00

Might cause issue with existing data in netbox if the name isn't in uppercase ?
I think we should use whatever value is returned by the driver without modification.

Might cause issue with existing data in netbox if the name isn't in uppercase ? I think we should use whatever value is returned by the driver without modification.
blotus (Migrated from github.com) reviewed 2019-08-04 18:58:28 +02:00
@ -0,0 +13,4 @@
DATACENTER_LOCATION_DRIVER_FILE = config.get('datacenter_location').get('driver_file')
DATACENTER_LOCATION = config.get('datacenter_location').get('driver')
DATACENTER_LOCATION_REGEX = config.get('datacenter_location').get('regex')
blotus (Migrated from github.com) commented 2019-08-04 18:58:28 +02:00

Probably need some sanity check as the drivers (for now) require the regex to have a datacenter named group.
I think there is 3 solutions :

  • Check if the regex has a datacenter named group (not a big fan)
  • Remove the requirement of the named capture group, and just grab whatever is in the first capturing group of the regex.
  • Allow user to configure the name of group or the position in the configuration file (and defaulting to the 1st capturing group)
Probably need some sanity check as the drivers (for now) require the regex to have a `datacenter` named group. I think there is 3 solutions : - Check if the regex has a `datacenter` named group (not a big fan) - Remove the requirement of the named capture group, and just grab whatever is in the first capturing group of the regex. - Allow user to configure the name of group or the position in the configuration file (and defaulting to the 1st capturing group)
blotus (Migrated from github.com) reviewed 2019-08-04 19:00:16 +02:00
@ -0,0 +43,4 @@
raise Exception(
"Your driver {} doesn't have a get() function, please fix it".format(self.driver)
)
return getattr(self.driver, 'get')(self.driver_value, DATACENTER_LOCATION_REGEX)
blotus (Migrated from github.com) commented 2019-08-04 19:00:16 +02:00

We should properly check if the module has a get method to output a proper error message if a custom driver is not compliant instead of an ugly stacktrace.

We should properly check if the module has a `get` method to output a proper error message if a custom driver is not compliant instead of an ugly stacktrace.
Solvik (Migrated from github.com) reviewed 2019-08-04 19:19:14 +02:00
@ -0,0 +43,4 @@
raise Exception(
"Your driver {} doesn't have a get() function, please fix it".format(self.driver)
)
return getattr(self.driver, 'get')(self.driver_value, DATACENTER_LOCATION_REGEX)
Solvik (Migrated from github.com) commented 2019-08-04 19:19:14 +02:00

Fixed in last commit

Fixed in last commit
Solvik (Migrated from github.com) reviewed 2019-08-04 19:33:46 +02:00
Solvik (Migrated from github.com) commented 2019-08-04 19:33:46 +02:00

fixed in d90eac3fe6

fixed in d90eac3fe6cb59d06ca4afb3fffb4ecee8e87ece
Solvik (Migrated from github.com) reviewed 2019-08-04 19:52:31 +02:00
@ -0,0 +13,4 @@
DATACENTER_LOCATION_DRIVER_FILE = config.get('datacenter_location').get('driver_file')
DATACENTER_LOCATION = config.get('datacenter_location').get('driver')
DATACENTER_LOCATION_REGEX = config.get('datacenter_location').get('regex')
Solvik (Migrated from github.com) commented 2019-08-04 19:52:31 +02:00

fixed in 9f0db28
for the sanity check, will address that in a PR around configuration file

fixed in 9f0db28 for the sanity check, will address that in a PR around configuration file
Sign in to join this conversation.
No description provided.