def handle_list(self, storage=None, *args, **options): if not storage: st = ExtStorage.objects.filter(type="beef") else: st = [self.get_storage(storage)] r = ["UUID,Profile,Vendor,Platform,Version,SpecUUID,Changed,Path"] for storage in st: self.print("\n%sStorage: %s%s\n" % ("=" * 20, storage.name, "=" * 20)) st_fs = storage.open_fs() for step in st_fs.walk(''): if not step.files: continue for file in step.files: beef = Beef.load(storage, file.make_path(step.path)) r += [",".join([ beef.uuid, beef.box.profile, beef.box.vendor, beef.box.platform, beef.box.version, beef.spec, beef.changed, file.make_path(step.path) ])] # Dump output self.stdout.write("\n".join(r) + "\n") return
def handle_list(self, storage=None, *args, **options): r = ["GUID,Profile,Vendor,Platform,Version,SpecUUID,Changed,Path"] for storage in self.iter_storage(name=storage, beef=True): self.print("\n%sStorage: %s%s\n" % ("=" * 20, storage.name, "=" * 20)) st_fs = storage.open_fs() for step in st_fs.walk(""): if not step.files: continue for file in step.files: beef = Beef.load(storage, file.make_path(step.path)) r += [ ",".join([ beef.uuid, beef.box.profile, beef.box.vendor, beef.box.platform, beef.box.version, beef.spec, beef.changed, file.make_path(step.path), ]) ] # Dump output self.stdout.write("\n".join(r) + "\n") return
def get_beef(self, storage, path): """ Get beef :param storage: Storage instance :param path: Beef path :return: """ try: return Beef.load(storage, path) except IOError as e: self.die("Failed to load beef: %s" % e)
def handle_list(self, storage=None, *args, **options): if storage: storages = [self.get_storage(name=storage)] else: connect() storages = ExtStorage.objects.filter(type="beef") for storage in storages: self.print("\n%sStorage: %s%s\n" % ("=" * 20, storage.name, "=" * 20)) r = [ "GUID,Profile,Vendor,Platform,Version,Description,SpecUUID,Changed,Path" ] st_fs = storage.open_fs() for step in st_fs.walk("", exclude=["*.yml"]): if not step.files: continue for file in step.files: try: beef = Beef.load(storage, file.make_path(step.path)) except ValueError: self.print("Error when loading beef file %s" % file.make_path(step.path)) continue r += [ ",".join([ beef.uuid, beef.box.profile, beef.box.vendor, beef.box.platform, beef.box.version, beef.description, beef.spec or "", # For ad-hoc specs beef.changed, file.make_path(step.path), ]) ] # Dump output self.stdout.write("\n".join(r) + "\n") return
def discovery_object(request): global _configs name, address, pool_name, beef_storage_url, beef_path, data = request.param beef = Beef.load(beef_storage_url, beef_path) mo = ManagedObject(name=name, is_managed=True, administrative_domain=get_ad(pool_name), segment=get_segment(pool_name), pool=get_pool(pool_name), profile=get_profile(beef.box.profile), object_profile=get_managedobjectprofile(), scheme=BEEF, address=name) mo.save() # Store beef path mo._beef_storage = beef_storage_url mo._beef_path = beef_path # Shortcut scripts to beef mo.set_scripts_caller(BeefCallWrapper) # _configs[mo.id] = data return mo