Skip to content

Commit b394ec7

Browse files
committed
changed intersection to just look for name since it was allowing devices with no name to enter post, fixed yaml load warning by safe loading insted of deprecated method, debug message change
1 parent df122e3 commit b394ec7

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

device42.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ def _log(self, message, level="DEBUG"):
7474
def update_device(self, **kwargs):
7575
""" See http://api.device42.com/#create/update-device-by-name """
7676
path = 'devices'
77-
atleast_fields = "name serial_no uuid".split()
77+
atleast_fields = ["name"] # this is the only required field to create/update a device, serial and uuid opt
7878
known_fields = "new_name asset_no manufacturer hardware new_hardware is_it_switch"
7979
known_fields += " is_it_virtual_host is_it_blade_host in_service type service_level virtual_host"
80+
known_fields += " serial_no uuid"
8081
known_fields += " blade_host slot_no storage_room_id storage_room os osver osverno memory cpucount cpupower cpucore"
8182
known_fields += " hddcount hddsize hddraid hddraid_type macaddress devices_in_cluster appcomps"
8283
known_fields += " customer contract_id contract"

puppetexplore.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def get_config(cfgpath):
4040
raise ValueError("Config file %s is not found!" % cfgpath)
4141
cfgpath = os.path.join(CUR_DIR, cfgpath)
4242
with open(cfgpath, 'r') as cfgf:
43-
config = yaml.load(cfgf.read())
43+
config = yaml.safe_load(cfgf.read())
4444
return config
4545

4646

@@ -60,7 +60,8 @@ def d42_update(dev42, nodes, options, static_opt, mapping, from_version='3', pup
6060
if customer_name and cst['name'] == customer_name:
6161
customer_id = str(cst['id'])
6262
break
63-
logger.debug("Customer %s: '%s'" % (customer_id, customer_name))
63+
64+
logger.debug("Static: Customer ID: %s, Customer Name: '%s'" % (customer_id, customer_name))
6465

6566
# processing all nodes
6667
for node in nodes:
@@ -74,6 +75,9 @@ def d42_update(dev42, nodes, options, static_opt, mapping, from_version='3', pup
7475

7576
node_name = node['hostname']
7677

78+
if node_name == '' or node_name is None:
79+
continue
80+
7781
if options.get('as_node_name').upper() == 'FQDN':
7882
node_name = node.get('fqdn', node_name)
7983

@@ -136,7 +140,6 @@ def d42_update(dev42, nodes, options, static_opt, mapping, from_version='3', pup
136140

137141
data = {
138142
'name': node_name,
139-
'new_name': node_name,
140143
'type': nodetype,
141144
'virtual_subtype': virtual_subtype,
142145
'os': node['operatingsystem'] if 'operatingsystem' in node else '',

0 commit comments

Comments
 (0)