def run(self, inv): rv = inv.systemrack_read(self.opts.systemrack) util.handle_error(rv) data = rv['data'] util.generic_output(data)
def run(self, inv): criteria = {} has_search = False if self.opts.asset_tag: has_search = True criteria["asset_tag"] = self.opts.asset_tag if self.opts.serial: has_search = True criteria["serial"] = self.opts.serial if self.opts.system_rack_id: has_search = True criteria["system_rack_id"] = self.opts.system_rack_id if self.opts.rack_order: has_search = True criteria["rack_order"] = self.opts.rack_order if self.opts.oob_ip: has_search = True criteria["oob_ip"] = self.opts.oob_ip if has_search: rv = inv.system_search(criteria) util.handle_error(rv) if has_search: data = rv["data"] if not data: print >> sys.stderr, "not found." sys.exit(1) else: data = [rv["data"]] keys = dict( serial="serial", asset_tag="asset_tag", rack_order="rack_order", patch_panel_port="patch_panel_port", oob_ip="oob_ip", # allocation = 'allocation', -- bug 688627 switch_ports="switch_ports", oob_switch_port="oob_switch_port", notes="notes", ) for host in data: print "-- %s --" % host["hostname"] for key, name in sorted(keys.items()): if key in host and host[key]: print "%s=%s" % (name, host[key])
def run(self, inv): rv = inv.system_create(self.opts.hostname) util.handle_error(rv) id = rv["data"]["id"] data = {} for k in "serial asset_tag location oob_ip notes".split(): if hasattr(self.opts, k) and getattr(self.opts, k) is not None: data[k] = getattr(self.opts, k) rv = inv.system_update(id, data) util.handle_error(rv) print "Created; system ID is %d" % (id,)
def run(self, inv): criteria = {} use_search = False if self.opts.asset_tag: use_search = True criteria["asset_tag"] = self.opts.asset_tag if self.opts.serial: use_search = True criteria["serial"] = self.opts.serial if self.opts.system_rack_id: use_search = True criteria["system_rack_id"] = self.opts.system_rack_id if self.opts.rack_order: use_search = True criteria["rack_order"] = self.opts.rack_order if self.opts.oob_ip: use_search = True criteria["oob_ip"] = self.opts.oob_ip if use_search: rv = inv.system_search(criteria) else: rv = inv.system_hostname_search(self.opts.hostname_fragment) util.handle_error(rv) data = rv["data"] # if we used system_search, but had a hostname fragment, filter # that client-side if use_search and self.opts.hostname_fragment: frag = self.opts.hostname_fragment data = [h for h in data if frag in h["hostname"]] if not data: print >> sys.stderr, "not found." sys.exit(1) self.display_hosts(data)
def run(self, inv): rv = inv.system_read(self.opts.hostname) util.handle_error(rv) self.display_hosts([rv["data"]])