def load_data(contents, org_name = nil)
      org_name ||= options[:single_org]
      if org_name.nil? && contents.keys != [ "users" ]
        raise "Must pass an org name to load_data or run in single_org mode"
      end

      %w{clients containers environments groups nodes roles sandboxes}.each do |data_type|
        if contents[data_type]
          dejsonize_children(contents[data_type]).each_pair do |name, data|
            data_store.set(["organizations", org_name, data_type, name], data, :create)
          end
        end
      end

      if contents["users"]
        dejsonize_children(contents["users"]).each_pair do |name, data|
          if options[:osc_compat]
            data_store.set(["organizations", org_name, "users", name], data, :create)
          else
            # Create the user and put them in the org
            data_store.set(["users", name], data, :create)
            if org_name
              data_store.set(["organizations", org_name, "users", name], "{}", :create)
            end
          end
        end
      end

      if contents["members"]
        contents["members"].each do |name|
          data_store.set(["organizations", org_name, "users", name], "{}", :create)
        end
      end

      if contents["invites"]
        contents["invites"].each do |name|
          data_store.set(["organizations", org_name, "association_requests", name], "{}", :create)
        end
      end

      if contents["acls"]
        dejsonize_children(contents["acls"]).each do |path, acl|
          path = [ "organizations", org_name ] + path.split("/")
          path = ChefData::AclPath.get_acl_data_path(path)
          ChefZero::RSpec.server.data_store.set(path, acl)
        end
      end

      if contents["data"]
        contents["data"].each_pair do |key, data_bag|
          data_store.create_dir(["organizations", org_name, "data"], key, :recursive)
          dejsonize_children(data_bag).each do |item_name, item|
            data_store.set(["organizations", org_name, "data", key, item_name], item, :create)
          end
        end
      end

      if contents["policies"]
        contents["policies"].each_pair do |policy_name, policy_struct|
          # data_store.create_dir(['organizations', org_name, 'policies', policy_name], "revisions", :recursive)
          dejsonize_children(policy_struct).each do |revision, policy_data|
            data_store.set(["organizations", org_name, "policies", policy_name,
                            "revisions", revision], policy_data, :create, :create_dir)
          end
        end
      end

      if contents["policy_groups"]
        contents["policy_groups"].each_pair do |group_name, group|
          group["policies"].each do |policy_name, policy_revision|
            data_store.set(["organizations", org_name, "policy_groups", group_name, "policies", policy_name], FFI_Yajl::Encoder.encode(policy_revision["revision_id"], pretty: true), :create, :create_dir)
          end
        end
      end

      %w{cookbooks cookbook_artifacts}.each do |cookbook_type|
        if contents[cookbook_type]
          contents[cookbook_type].each_pair do |name_version, cookbook|
            if cookbook_type == "cookbook_artifacts"
              name, _, identifier = name_version.rpartition("-")
              cookbook_data = ChefData::CookbookData.to_hash(cookbook, name, identifier)
            elsif name_version =~ /(.+)-(\d+\.\d+\.\d+)$/
              cookbook_data = ChefData::CookbookData.to_hash(cookbook, $1, $2)
            else
              cookbook_data = ChefData::CookbookData.to_hash(cookbook, name_version)
            end
            raise "No version specified" if !cookbook_data[:version]
            data_store.create_dir(["organizations", org_name, cookbook_type], cookbook_data[:cookbook_name], :recursive)
            data_store.set(["organizations", org_name, cookbook_type, cookbook_data[:cookbook_name], cookbook_data[:version]], FFI_Yajl::Encoder.encode(cookbook_data, pretty: true), :create)
            cookbook_data.values.each do |files|
              next unless files.is_a? Array
              files.each do |file|
                data_store.set(["organizations", org_name, "file_store", "checksums", file[:checksum]], get_file(cookbook, file[:path]), :create)
              end
            end
          end
        end
      end
    end
def load_data(contents, org_name = nil)
      org_name ||= options[:single_org]
      if org_name.nil? && contents.keys != [ "users" ]
        raise "Must pass an org name to load_data or run in single_org mode"
      end

      %w{clients containers environments groups nodes roles sandboxes}.each do |data_type|
        if contents[data_type]
          dejsonize_children(contents[data_type]).each_pair do |name, data|
            data_store.set(["organizations", org_name, data_type, name], data, :create)
          end
        end
      end

      if contents["users"]
        dejsonize_children(contents["users"]).each_pair do |name, data|
          if options[:osc_compat]
            data_store.set(["organizations", org_name, "users", name], data, :create)
          else
            # Create the user and put them in the org
            data_store.set(["users", name], data, :create)
            if org_name
              data_store.set(["organizations", org_name, "users", name], "{}", :create)
            end
          end
        end
      end

      if contents["members"]
        contents["members"].each do |name|
          data_store.set(["organizations", org_name, "users", name], "{}", :create)
        end
      end

      if contents["invites"]
        contents["invites"].each do |name|
          data_store.set(["organizations", org_name, "association_requests", name], "{}", :create)
        end
      end

      if contents["acls"]
        dejsonize_children(contents["acls"]).each do |path, acl|
          path = [ "organizations", org_name ] + path.split("/")
          path = ChefData::AclPath.get_acl_data_path(path)
          ChefZero::RSpec.server.data_store.set(path, acl)
        end
      end

      if contents["data"]
        contents["data"].each_pair do |key, data_bag|
          data_store.create_dir(["organizations", org_name, "data"], key, :recursive)
          dejsonize_children(data_bag).each do |item_name, item|
            data_store.set(["organizations", org_name, "data", key, item_name], item, :create)
          end
        end
      end

      if contents["policies"]
        contents["policies"].each_pair do |policy_name, policy_struct|
          # data_store.create_dir(['organizations', org_name, 'policies', policy_name], "revisions", :recursive)
          dejsonize_children(policy_struct).each do |revision, policy_data|
            data_store.set(["organizations", org_name, "policies", policy_name,
                            "revisions", revision], policy_data, :create, :create_dir)
          end
        end
      end

      if contents["policy_groups"]
        contents["policy_groups"].each_pair do |group_name, group|
          group["policies"].each do |policy_name, policy_revision|
            data_store.set(["organizations", org_name, "policy_groups", group_name, "policies", policy_name], FFI_Yajl::Encoder.encode(policy_revision["revision_id"], pretty: true), :create, :create_dir)
          end
        end
      end

      %w{cookbooks cookbook_artifacts}.each do |cookbook_type|
        if contents[cookbook_type]
          contents[cookbook_type].each_pair do |name_version, cookbook|
            if cookbook_type == "cookbook_artifacts"
              name, _, identifier = name_version.rpartition("-")
              cookbook_data = ChefData::CookbookData.to_hash(cookbook, name, identifier)
            elsif name_version =~ /(.+)-(\d+\.\d+\.\d+)$/
              cookbook_data = ChefData::CookbookData.to_hash(cookbook, $1, $2)
            else
              cookbook_data = ChefData::CookbookData.to_hash(cookbook, name_version)
            end
            raise "No version specified" if !cookbook_data[:version]
            data_store.create_dir(["organizations", org_name, cookbook_type], cookbook_data[:cookbook_name], :recursive)
            data_store.set(["organizations", org_name, cookbook_type, cookbook_data[:cookbook_name], cookbook_data[:version]], FFI_Yajl::Encoder.encode(cookbook_data, pretty: true), :create)
            cookbook_data.values.each do |files|
              next unless files.is_a? Array
              files.each do |file|
                data_store.set(["organizations", org_name, "file_store", "checksums", file[:checksum]], get_file(cookbook, file[:path]), :create)
              end
            end
          end
        end
      end
    end
Load data in a nice, friendly form:
 {
   'roles' => {
     'desert' => '{ "description": "Hot and dry"' },
     'rainforest' => { "description" => 'Wet and humid' }
   },
   'cookbooks' => {
     'apache2-1.0.1' => {
       'templates' => { 'default' => { 'blah.txt' => 'hi' }}
       'recipes' => { 'default.rb' => 'template "blah.txt"' }
       'metadata.rb' => 'depends "mysql"'
     },
     'apache2-1.2.0' => {
       'templates' => { 'default' => { 'blah.txt' => 'lo' }}
       'recipes' => { 'default.rb' => 'template "blah.txt"' }
       'metadata.rb' => 'depends "mysql"'
     },
     'mysql' => {
       'recipes' => { 'default.rb' => 'file { contents "hi" }' },
       'metadata.rb' => 'version "1.0.0"'
     }
   }
 }