Solvik / netbox-agent

Netbox agent to run on your infrastructure's servers
Apache License 2.0
287 stars 74 forks source link

Project dependencies may have API risk issues #245

Closed PyDeps closed 1 year ago

PyDeps commented 1 year ago

Hi, In netbox-agent, inappropriate dependency versioning constraints can cause risks.

Below are the dependencies and version constraints that the project is using

pynetbox==6.1.2
netaddr==0.8.0
netifaces==0.10.9
pyyaml==5.4.1
jsonargparse==3.11.2
python-slugify==5.0.2
packaging==20.9
distro==1.7.0

The version constraint == will introduce the risk of dependency conflicts because the scope of dependencies is too strict. The version constraint No Upper Bound and * will introduce the risk of the missing API Error because the latest version of the dependencies may remove some APIs.

After further analysis, in this project, The version constraint of dependency python-slugify can be changed to >=0.0.1,<=0.0.7. The version constraint of dependency packaging can be changed to >=14.1,<=21.3. The version constraint of dependency distro can be changed to >=0.5.0,<=1.0.1.

The above modification suggestions can reduce the dependency conflicts as much as possible, and introduce the latest version as much as possible without calling Error in the projects.

The invocation of the current project includes all the following methods.

The calling methods from the python-slugify
slugify.slugify
The calling methods from the packaging
packaging.version.parse
The calling methods from the distro
distro.linux_distribution
The calling methods from the all methods
self.nb_net.interfaces.filter
re.compile
subprocess.getoutput.splitlines
format.get
netbox_agent.lshw.LSHW
x.strip
netbox_agent.config.netbox_instance.dcim.interfaces.get
self._netbox_create_blade_expansion.save
self.create_netbox_raid_card
next.save
x.copy
motherboard.get
os.path.realpath
StorcliControllerError
jsonargparse.ArgumentParser
OmreportController
power_supply.append
self.HPHost.super.__init__
self.walk_bridge
netbox_agent.vendors.generic.GenericHost
netbox_agent.virtualmachine.VirtualMachine
os.path.isfile
psu.get.split
self.create_netbox_nic.split
v.strip
self._netbox_create_server.delete
os.sysconf
self.QCTHost.super.__init__
self.lldp.get_switch_vlan
self.do_netbox_motherboard
nb_gpu_models.setdefault
re.compile.search
self.power.create_or_update_power_supply
self.own_gpu_expansion_slot
print
d.get.get
self.nb_net.interfaces.create
self.server.get_netbox_vm
self._get_logical_drives
list.remove
socket.gethostname
x.IPAddress.netmask_bits
vd_identifier.split
self._netbox_create_chassis
interface.self.data.get
self.get_hostname
gpus.append
logging.info
self.reset_vlan_on_interface
netbox_agent.config.netbox_instance.dcim.device_types.get
pd_dev_attr.get.strip
self.cpus.append
slave_int.save
omreport.setdefault
nb_interface.delete
self.do_netbox_cpus
self.is_blade
open.read
tests.conftest.parametrize_with_fixtures
_parse_pd_output.items
netbox_agent.vendors.supermicro.SupermicroHost
netifaces.ifaddresses
self.nb_net.interfaces.get
json.dumps
self.get_netbox_network_card
self.lldp.get_switch_vlan.items
self.power.report_power_consumption
pynetbox.api
self.get_netbox_power_supply
HPRaidController
getattr
set
get_config
line.split.join.strip
netbox_agent.config.netbox_instance.dcim.sites.get
netbox_agent.config.netbox_instance.ipam.ip_addresses.choices
p.stdout.read.decode.split
self.get_hw_disks.extend
self.create_netbox_inventory_item
next
self.baseboard.strip
logging.error
self.get_datacenter.get
setuptools.setup
re.compile.findall
self._parse_ethtool_output
self.product.startswith
netbox_agent.dmidecode.get_by_type.endswith
path.endswith
line.rstrip.find
netbox_agent.misc.get_device_platform
pprint.pprint
self.scan
netbox_agent.config.netbox_instance.dcim.manufacturers.create
line.startswith
os.path.islink
netbox_agent.ethtool.Ethtool
self.get_chassis_service_tag
ssacli
self.find_gpus
setuptools.find_packages
netbox_agent.virtualmachine.is_vm
self.find_storage
Exception
netbox_agent.location.Slot.get
name.upper
val.strip.strip
self.lldp.get_switch_ip
netbox_agent.config.config.datacenter_location.driver.split
netbox_agent.ipmi.IPMI
netbox_agent.vendors.hp.HPHost.is_blade
self._netbox_deduplicate_server
netbox_agent.config.netbox_instance.ipam.vlans.get
line.rstrip.strip
dimm.get
subprocess.getoutput
INVENTORY_TAG.items
self.memories.append
re.search
self._netbox_create_blade_expansion
psu.get
current_section.res.setdefault.append
actual_device_bay.save
self._netbox_create_blade_expansion.delete
importlib.import_module
addr.replace
self._get_physical_disks.values
netbox_agent.network.ServerNetwork
netbox_agent.inventory.Inventory.create_or_update
netbox_agent.config.netbox_instance.ipam.ip_addresses.filter
record.splitlines
nb_mgmt_ip.address.split
self.server.own_gpu_expansion_slot
device.get
netbox_agent.config.netbox_instance.dcim.inventory_items.create
line.rstrip.rstrip
attrs.update
self.do_netbox_raid_cards
storecli.items
self.get_product_name.startswith
self.get_netbox_inventory
self.create_netbox_gpus
netbox_agent.config.netbox_instance.virtualization.virtual_machines.get
_parse_ctrl_output.items
vd_identifier.split.lstrip
obj.get
value.replace
command.append
netbox_agent.inventory.Inventory.get_raid_cards
self.get_netbox_rack
_parse_pd_output
self.get_netbox_tenant.get
self._set_bonding_interfaces
self.create_netbox_nic
raid_class
netbox_agent.config.netbox_instance.dcim.racks.get
self.own_disk_expansion_slot
r.startswith
self.get_memory
netbox_agent.config.netbox_instance.ipam.vlans.create
entry.strip.split
netbox_agent.vendors.hp.HPHost.get_chassis_service_tag
self.hw_info.get
netbox_agent.config.netbox_instance.dcim.power_ports.create.delete
interface.netifaces.ifaddresses.get.append
json.loads
f.strip
netbox_agent.power.PowerSupply
self.DellHost.super.__init__
r.line.strip
psu.get.strip
self.GenericHost.super.__init__
self.get_hw_motherboards.append
netbox_agent.logging.logging.debug
vendors.items
dmi.dmidecode.get_by_type.get
attr.strip.strip
netbox_agent.vendors.hp.HPHost.own_expansion_slot
netbox_agent.config.netbox_instance.dcim.cables.get.delete
self.update_netbox_expansion_location
int
self.find_cpus
netbox_agent.config.netbox_instance.dcim.platforms.get
subprocess.check_output
self.do_netbox_gpus
netbox_agent.config.netbox_instance.dcim.inventory_items.filter
self.output.split
gpu.startswith
os.cpu_count
self.gpus.append
set.add
gpu_models.setdefault
raid_card.get_physical_disks
self.get_netbox_rack.get
value.strip.strip
os.path.isdir
_parse
vlans.get
importlib.machinery.SourceFileLoader.load_module
disk.get
interface.Ethtool.parse
filter
data.values
self.get_netbox_type_for_nic
re.sub
netbox_agent.misc.get_vendor.setdefault
self.get_vcpus
netbox_agent.vendors.generic.GenericHost.netbox_create_or_update
pd_re.search.group
jsonargparse.ArgumentParser.add_argument
self.dmi.dmidecode.get_by_type.get
self.baseboard.get
range
subprocess.Popen
self.get_netbox_datacenter
self.product.endswith
traceback.format_exc
netbox_agent.misc.is_tool
super
self.interfaces.append
len
_parse_ld_output
self.ldrives.get
StorcliController
raid_card.is_external
dict.update
line.split.strip
str
omreport.values
isinstance
storecli
self.create_netbox_nic.save
command.extend
ret.append
netbox_agent.config.netbox_instance.extras.tags.get
self.system.strip
result.append
netbox_agent.lldp.LLDP
self.get_hw_motherboards
self.network.get_network_cards
self.parse
netbox_agent.config.config.device.custom_fields.split
netbox_agent.lldp.LLDP.get_switch_port
self._parse_ethtool_module_output
netbox_agent.config.netbox_instance.dcim.device_bays.filter
logging.getLogger.setLevel
self.get_or_create_vlan
self._get_virtual_drives_map.items
netbox_agent.config.netbox_instance.dcim.cables.get
netbox_agent.config.netbox_instance.extras.tags.create
self.server.get_power_consumption
urllib3.disable_warnings
re.match
netbox_agent.misc.get_vendor
name.upper.startswith
disk.get.lower
subprocess.getstatusoutput
line.strip.split
netbox_agent.misc.get_device_type
jsonargparse.ArgumentParser.parse_args
netbox_agent.config.netbox_instance.dcim.power_feeds.filter
self.get_blade_expansion_slot
self.network.create_or_update_netbox_network_cards
line.strip.strip
self.get_power_supply
self._parse_ethtool_output.split
netbox_agent.config.netbox_instance.dcim.power_ports.create.save
run
self.create_netbox_memory
os.listdir
open.write
self.get_expansion_service_tag
platform.linux_distribution
self.dump_disks_map
logging.debug
importlib.machinery.SourceFileLoader
addr.split
x.delete
netbox_agent.misc.get_mount_points
_parse_ctrl_output
raid_card.get_serial_number
netbox_agent.config.netbox_instance.ipam.ip_addresses.create.save
line.strip.startswith
logging.getLogger
netbox_agent.dmidecode.get_by_type.strip
self.get_hw_disks.append
r.split
netbox_agent.vendors.hp.HPHost.get_product_name
self._netbox_create_server.save
k.strip
slugify.slugify
self.server.own_expansion_slot
self.VirtualNetwork.super.__init__
path.split
self.baseboard.keys
self._netbox_create_blade
self.server.is_blade
netaddr.IPAddress
self.lshw.get_hw_linux
interface.Ethtool.parse.delete
line.split.split
netbox_agent.inventory.Inventory
_str2type.get
netbox_agent.config.config.slot_location.driver.split
self.get_netbox_cluster
interface.format.open.read.split
attrs.get.strip.split
self._get_virtual_drives_map
attrs.get.strip.startswith
hasattr
netbox_agent.misc.get_mount_points.get
netbox_agent.config.netbox_instance.ipam.ip_addresses.get
netbox_agent.misc.get_hostname
i.startswith
netbox_agent.server.ServerBase
self.get_chassis
pd_attr.get
join
buffer.decode.split
value.append
self.get_expansion_product
_type2str.items
self.get_blade_slot
self.SupermicroHost.super.__init__
self.get_netbox_vm
interface.Ethtool.parse.get
self.server.get_netbox_tenant
netbox_agent.config.netbox_instance.virtualization.virtual_machines.create.save
netbox_agent.config.netbox_instance.dcim.manufacturers.get
netbox_agent.config.netbox_instance.dcim.platforms.create
self.update_netbox_location
self.output.splitlines
drives.setdefault
open
memory.get
self._netbox_set_or_update_blade_slot
self.find_network
netbox_agent.vendors.hp.HPHost
self.do_netbox_interfaces
self.create_or_update_cable
main
x.get_serial_number
self.custom_fields.update
entry.strip
netbox_agent.config.netbox_instance.dcim.power_ports.filter
os.path.join
netbox_agent.vendors.hp.HPHost.get_service_tag
self.get_product_name.endswith
self.get_datacenter
current_dict.get
pd_info.items
line.strip
device.mount_points.setdefault.append
netbox_agent.config.config.tenant.driver.split
raid_card.get_product_name
re.search.groups
name.re.sub.lower
netbox_agent.network.VirtualNetwork
p.stdout.read
self.do_netbox_memories
sys.exit
enumerate
ParseError
packaging.version.parse
pd_identifier.pds.setdefault
sub_command.split
attrs.get
netbox_agent.dmidecode.parse
REGEXP_CONTROLLER_HP.search.group
self.get_hw_disks
d.get
iface.get
OmreportControllerError
self.disks.append
netbox_agent.misc.create_netbox_tags
mount_points.setdefault
pd_identifier.pds.setdefault.update
ImportError
interface.format.open.read.strip
netbox_agent.config.netbox_instance.dcim.devices.get
vd_info.items
netbox_agent.config.netbox_instance.dcim.inventory_items.create.delete
os.path.dirname
HPRaidControllerError
self.ServerNetwork.super.__init__
self._get_physical_disks
super.__init__
netbox_agent.location.Rack
self._find_rack_locator
netbox_agent.location.Datacenter
netbox_agent.config.netbox_instance.dcim.devices.create
distro.linux_distribution
self.get_service_tag
netbox_agent.config.netbox_instance.dcim.cables.create
format
self.get_netbox_network_cards
type
_parse_ld_output.items
subprocess.Popen.wait
sorted
attrs.get.strip
self.pdrives.values
self.get_netbox_tenant
dict
c.is_external
self.find_or_create_manufacturer
self.get_raid_cards
nb_motherboard.delete
netbox_agent.config.config.device.tags.split
self.pdrives.items
self.raid.get_controllers
self.chassis.strip
self.create_netbox_interface
netbox_agent.dmidecode.get_by_type
itertools.chain.from_iterable
self.connect_interface_to_switch
self.controllers.append
get_requirements
get_netbox_instance
netbox_agent.config.config.log_level.lower
self.get_tenant
self.get_rack
x.copy.update
requests.Session
interface.format.open.read
netbox_agent.location.Slot
pd_attr.get.strip
netbox_agent.misc.get_device_role
self._netbox_create_server
pkg_resources.get_distribution
self.server.get_netbox_server
self.get_network_type
netbox_agent.ipmi.IPMI.parse
netbox_agent.config.netbox_instance.virtualization.interfaces.choices
self.create_or_update_netbox_ip_on_interface
list
self.create_netbox_tags
self._netbox_set_or_update_blade_expansion_slot
netaddr.IPNetwork
self.is_external_gpu
netbox_agent.vendors.generic.GenericHost.print_debug
self.get_chassis_name
self.system.strip.startswith
self.do_netbox_disks
self.nics.append
open.close
self.is_virtual_disk
buffer.decode.decode
self.power.append
self.inventory.create_or_update
interface.netifaces.ifaddresses.get
nb_disk.delete
nics.append
self.hp_rack_locator.strip
self.get_ipmi
vlans.items
netbox_agent.config.netbox_instance.dcim.power_ports.create
netbox_agent.location.Tenant
subprocess.getoutput.split
netbox_agent.vendors.hp.HPHost.get_chassis
self.own_expansion_slot
vd_identifier.startswith
in_block_list.append
netbox_agent.config.netbox_instance.ipam.ip_addresses.create
_execute_cmd
omreport
interface.vlans.get
dmi.dmidecode.get_by_type.get.MANUFACTURERS
netbox_agent.config.netbox_instance.virtualization.clusters.get
netbox_agent.config.netbox_instance.tenancy.tenants.get
netbox_agent.config.netbox_instance.dcim.interfaces.choices
self.lldp.get_switch_port
self.get_product_name
shutil.which
netbox_agent.config.config.rack_location.driver.split
self.convert_to_dict
line.split
netbox_agent.vendors.qct.QCTHost
self.find_memories
netbox_agent.config.netbox_instance.dcim.device_roles.get
self.driver.getattr
self._parse_ethtool_output.update
self.baseboard.get.strip
self.data.get
self.create_netbox_disk
netbox_agent.config.netbox_instance.virtualization.virtual_machines.create
float
netbox_agent.vendors.hp.HPHost.get_expansion_service_tag
p.stdout.read.decode
r.strip
interface.netifaces.ifaddresses.get.pop
self.create_netbox_cpus
vlan_infos.get
raid_card.get_manufacturer
f.split

@developer Could please help me check this issue? May I pull a request to fix it? Thank you very much.

cynici commented 1 year ago

pyyaml==5.4.1 is causing pip install to fail. Please see details here: https://github.com/yaml/pyyaml/issues/724

Collecting pyyaml==5.4.1
  Using cached PyYAML-5.4.1.tar.gz (175 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [43 lines of output]
      running egg_info
      Traceback (most recent call last):
        File "/opt/netbox_agent/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/opt/netbox_agent/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/opt/netbox_agent/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 130, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 162, in get_requires_for_build_wheel
          return self._get_build_requires(
        File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 143, in _get_build_requires
          self.run_setup()
        File "/usr/lib/python3/dist-packages/setuptools/build_meta.py", line 158, in run_setup
          exec(compile(code, __file__, 'exec'), locals())
        File "setup.py", line 271, in <module>
          setup(
        File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup
          return distutils.core.setup(**attrs)
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 148, in setup
          return run_commands(dist)
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 163, in run_commands
          dist.run_commands()
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 967, in run_commands
          self.run_command(cmd)
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 986, in run_command
          cmd_obj.run()
        File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 299, in run
          self.find_sources()
        File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 306, in find_sources
          mm.run()
        File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 541, in run
          self.add_defaults()
        File "/usr/lib/python3/dist-packages/setuptools/command/egg_info.py", line 578, in add_defaults
          sdist.add_defaults(self)
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/command/sdist.py", line 228, in add_defaults
          self._add_defaults_ext()
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/command/sdist.py", line 312, in _add_defaults_ext
          self.filelist.extend(build_ext.get_source_files())
        File "setup.py", line 201, in get_source_files
          self.cython_sources(ext.sources, ext)
        File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 103, in __getattr__
          raise AttributeError(attr)
      AttributeError: cython_sources
      [end of output]
cynici commented 1 year ago

Answering my own issue FWIW.

Using git commit 7ab7bbb9e1d3e8616b818e2c76b4d31596b45e95 which pins PyYAML 6.0.1 resolves my issue.

Solvik commented 1 year ago

I'll close this issue since it's fixed I'm not so keen to have large dependency constraints since some of the libraries used by the project already broke stuff between minor versions