Browse files

logging path changes

SliceUtil building
  • Loading branch information...
1 parent 1e884ab commit c1177493a21ad744403a006d1029d6c844404340 @lynxbat lynxbat committed Mar 2, 2012
View
1 bin/razor
@@ -7,7 +7,6 @@
# Modules are dynamically loaded and accessed through corresponding namespace
# Format will be 'project_razor [module namespace] [module args{}]'
#
-# This adds ProjectRazor Common lib path to the load path for this child proc
$lib_path = File.dirname(__FILE__).sub(/\/bin$/,"/lib")
View
1 lib/project_razor.rb
@@ -4,6 +4,7 @@
$config_server_path = "#{File.dirname(__FILE__).sub(/\/lib$/,"/conf")}/razor_server.conf"
$img_svc_path = File.dirname(__FILE__).sub(/\/lib$/,"/image")
+$logging_path = "#{File.dirname(__FILE__).sub(/\/lib$/,"/conf")}/project_razor.log"
require "project_razor/object"
require "project_razor/data"
View
2 lib/project_razor/logging.rb
@@ -30,7 +30,7 @@ class << self
def get_log_path
if ENV['RAZOR_LOG_PATH'] == nil
- return "#{ENV['RAZOR_HOME']}/log/project_razor.log"
+ return $logging_path
end
"#{ENV['RAZOR_LOG_PATH']}/project_razor.log"
end
View
4 lib/project_razor/slice.rb
@@ -1,11 +1,15 @@
# EMC Confidential Information, protected under EMC Bilateral Non-Disclosure Agreement.
# Copyright © 2012 EMC Corporation, All Rights Reserved
+require "project_razor/slice_util/common"
+require "project_razor/slice_util/filtering"
require "project_razor/slice/base"
require "project_razor/slice/boot"
require "project_razor/slice/config"
require "project_razor/slice/model"
require "project_razor/slice/node"
+require "project_razor/slice/tag"
+
module Slice
# To change this template use File | Settings | File Templates.
View
2 lib/project_razor/slice/base.rb
@@ -13,6 +13,8 @@ module Slice
# @author Nicholas Weaver
class Base
include(ProjectRazor::Logging)
+ include(ProjectRazor::SliceUtil::Common)
+ include(ProjectRazor::SliceUtil::Filtering)
# Bool for indicating whether this was driven from Node.js
attr_accessor :web_command
View
49 lib/project_razor/slice/tag.rb
@@ -0,0 +1,49 @@
+# EMC Confidential Information, protected under EMC Bilateral Non-Disclosure Agreement.
+# Copyright © 2012 EMC Corporation, All Rights Reserved
+
+require "json"
+
+module ProjectRazor
+ module Slice
+ # ProjectRazor Tag Slice
+ # Tag
+ # @author Nicholas Weaver
+ class Tag < ProjectRazor::Slice::Base
+
+ # init
+ # @param [Array] args
+ def initialize(args)
+ super(args)
+ # Define your commands and help text
+ @slice_commands = {:rules => "get_tagpolicy",
+ :default => "get_tagpolicy"}
+ @slice_commands_help = {:rules => "tag [rules]"}
+ @slice_name = "Tag"
+ end
+
+ # Reads the ProjectRazor config
+ def get_tagpolicy
+ setup_data
+ if @web_command
+
+
+
+ else
+ slice_error("NotImplemented")
+ end
+ end
+
+ def add_tag_rule
+
+ end
+
+ def delete_tag_rule
+
+ end
+
+ def update_tag_rule
+
+ end
+ end
+ end
+end
View
14 lib/project_razor/slice/utility.rb
@@ -0,0 +1,14 @@
+# EMC Confidential Information, protected under EMC Bilateral Non-Disclosure Agreement.
+# Copyright © 2012 EMC Corporation, All Rights Reserved
+
+require "project_razor/slice/utility/common"
+require "project_razor/slice/utility/filtering"
+
+module ProjectRazor
+ module Slice
+ module Utility
+ #
+ end
+ end
+end
+
View
73 lib/project_razor/slice_util/common.rb
@@ -0,0 +1,73 @@
+# EMC Confidential Information, protected under EMC Bilateral Non-Disclosure Agreement.
+# Copyright © 2012 EMC Corporation, All Rights Reserved
+
+require "json"
+
+module ProjectRazor
+ module SliceUtil
+ module Common
+ #include(ProjectRazor::Slice::Utility::Filtering)
+
+
+ # Gets a selection of objects for slice
+ # @param noun [String] name of the object for logging
+ # @param collection [Symbol] collection for object
+
+ def get_object(noun, collection)
+ logger.debug "Query #{nodes} called"
+
+ # Check if REST-driven request
+ if @web_command
+
+ # Get request filter JSON string
+ @filter_json_string = @command_array.shift
+
+ # Check if we were passed a filter string
+ # TODO - make this more than just a uuid filter
+ if @filter_json_string != "{}" && @filter_json_string != nil
+ @command = "query_with_filter"
+ begin
+ # Render our JSON to a Hash
+ filter = JSON.parse(@filter_json_string)
+ logger.debug "Filter: #{filter["uuid"]}"
+
+ # Check is filter contains a valid field, in this case only uuid is implemented right now
+ if filter["uuid"] != nil
+ # Get objects based on filter
+ return_object_using_filter(filter)
+ else
+ # Return error signifying filter is invalid
+ slice_error("InvalidFilter")
+ end
+ rescue StandardError => e
+ # We caught an error / likely JSON. We return the error text as a Slice error.
+ slice_error(e.message)
+ end
+ else
+ @command = "query_all"
+ return_objects
+ end
+ # Is CLI driven
+ else
+ return_objects
+ end
+ end
+
+ # Return objects using a filter
+ # @param filter [Hash] contains key/values used for filtering
+ def return_object_using_filter(filter)
+
+
+ end
+
+ # Return all objects (no filtering)
+ def return_objects
+
+ end
+
+
+
+
+ end
+ end
+end
View
43 lib/project_razor/slice_util/filtering.rb
@@ -0,0 +1,43 @@
+# EMC Confidential Information, protected under EMC Bilateral Non-Disclosure Agreement.
+# Copyright © 2012 EMC Corporation, All Rights Reserved
+
+require "json"
+
+module ProjectRazor
+ module SliceUtil
+ module Filtering
+
+ def check_filter_vs_hash(filter_hash, object_hash)
+ # Iterate over each key/value checking if there is a match within the object_hash level
+ # if we run into a key/value that is a hash we check for a matching hash and call this same method
+
+ filter_hash.each_pair do
+ |filter_key, filter_value|
+
+ # Find a matching key / return false if there is none
+ return false if (object_key = find_key_match(filter_key, object_hash)) == nil
+
+ # If our
+ check_filter_vs_hash(filter_hash[filter_key],object_hash[object_key]) if
+ filter_hash[filter_key] == Hash && object_hash[object_key].class == Hash
+
+
+
+
+
+
+ end
+
+ true
+ end
+
+ def find_key_match(filter_key, object_hash)
+ object_hash.each_pair do
+ |object_key, object_value|
+
+ end
+ end
+
+ end
+ end
+end
View
12 project_razor.gemspec
@@ -0,0 +1,12 @@
+Gem::Specification.new do |s|
+ s.name = 'project_razor'
+ s.version = '0.0.0.1'
+ s.date = '2012-3-2'
+ s.summary = "Project Razor"
+ s.description = ""
+ s.authors = ["Nicholas Weaver","Tom McSweeney"]
+ s.email = ['nicholas.weaver@emc.com','tom.mcweeney@emc.com']
+ s.files = ["lib/project_razor.rb"]
+ s.homepage =
+ 'http://nickapedia.com/project-razor'
+end

0 comments on commit c117749

Please sign in to comment.