Class: ResourceRoles
- Inherits:
-
Object
- Object
- ResourceRoles
- Defined in:
- lib/HMC/ResourceRoles.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
Instance Method Summary collapse
- #decode(string) ⇒ Object
- #has_lpar?(role_names, model_type_serial, lpar_id) ⇒ Boolean
-
#initialize(string = '') ⇒ ResourceRoles
constructor
name=L2support,“resources=cec:root/ibmhscS1_0|9131-52A*6535CCG|IBMHSC_ComputerSystem,lpar:root/ibmhscS1_0|ALL_PARTITIONS*9131-52A*6535CCG|IBMHSC_Partition”.
- #lpar_add_to_role_cmd(role_name, type_model_serial, lpar_id) ⇒ Object
- #lpar_has_roles(model_type_serial, lpar_id) ⇒ Object
- #lpar_remove_from_role_cmd(role_name, type_model_serial, lpar_id) ⇒ Object
- #role_create_cmd(role_name) ⇒ Object
- #role_delete(role_name) ⇒ Object
- #role_delete_cmd(role_name) ⇒ Object
- #role_exist?(role_name) ⇒ Boolean
- #role_list_cmd ⇒ Object
- #roles_has_all_partitions(model_type_serial) ⇒ Object
Constructor Details
#initialize(string = '') ⇒ ResourceRoles
name=L2support,“resources=cec:root/ibmhscS1_0|9131-52A*6535CCG|IBMHSC_ComputerSystem,lpar:root/ibmhscS1_0|ALL_PARTITIONS*9131-52A*6535CCG|IBMHSC_Partition”
14 15 16 17 18 19 20 21 |
# File 'lib/HMC/ResourceRoles.rb', line 14 def initialize string='' @roles = Hash.new() if string.length > 0 self.decode string end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/HMC/ResourceRoles.rb', line 10 def name @name end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
11 12 13 |
# File 'lib/HMC/ResourceRoles.rb', line 11 def roles @roles end |
Instance Method Details
#decode(string) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/HMC/ResourceRoles.rb', line 23 def decode(string) string.split("\n").each { |resourceroleString| role = ResourceRole.new(resourceroleString) @roles[role.name] = role } end |
#has_lpar?(role_names, model_type_serial, lpar_id) ⇒ Boolean
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/HMC/ResourceRoles.rb', line 32 def has_lpar?(role_names, model_type_serial, lpar_id) role_names.split(',').each { |role_name| if @roles.include?(role_name) if @roles[role_name].has_lpar?(model_type_serial, lpar_id) return true end end } false end |
#lpar_add_to_role_cmd(role_name, type_model_serial, lpar_id) ⇒ Object
82 83 84 |
# File 'lib/HMC/ResourceRoles.rb', line 82 def lpar_add_to_role_cmd(role_name, type_model_serial, lpar_id) "chaccft -t resourcerole -i \"name=#{role_name},resources+=lpar:root/ibmhsc01_0|#{lpar_id}*#{type_model_serial}|IBMHSC_Partition\"" end |
#lpar_has_roles(model_type_serial, lpar_id) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/HMC/ResourceRoles.rb', line 45 def lpar_has_roles(model_type_serial, lpar_id) result = Array.new @roles.each_value { |role| result.push(role.name) if role.has_lpar?(model_type_serial, lpar_id) } result.sort end |
#lpar_remove_from_role_cmd(role_name, type_model_serial, lpar_id) ⇒ Object
86 87 88 |
# File 'lib/HMC/ResourceRoles.rb', line 86 def lpar_remove_from_role_cmd(role_name , type_model_serial, lpar_id) "chaccft -t resourcerole -i \"name=#{role_name},resources-=lpar:root/ibmhsc01_0|#{lpar_id}*#{type_model_serial}|IBMHSC_Partition\"" end |
#role_create_cmd(role_name) ⇒ Object
74 75 76 |
# File 'lib/HMC/ResourceRoles.rb', line 74 def role_create_cmd(role_name) "mkaccfg -t resourcerole -i \"name=#{role_name},resources=\"" end |
#role_delete(role_name) ⇒ Object
57 58 59 |
# File 'lib/HMC/ResourceRoles.rb', line 57 def role_delete(role_name) @roles.delete(role_name) end |
#role_delete_cmd(role_name) ⇒ Object
70 71 72 |
# File 'lib/HMC/ResourceRoles.rb', line 70 def role_delete_cmd(role_name) "rmaccfg -t resourcerole -n #{role_name}" end |
#role_exist?(role_name) ⇒ Boolean
53 54 55 |
# File 'lib/HMC/ResourceRoles.rb', line 53 def role_exist?(role_name) @roles.include?(role_name) end |
#role_list_cmd ⇒ Object
78 79 80 |
# File 'lib/HMC/ResourceRoles.rb', line 78 def role_list_cmd 'lsaccfg -t resourcerole' end |
#roles_has_all_partitions(model_type_serial) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/HMC/ResourceRoles.rb', line 61 def roles_has_all_partitions(model_type_serial) result = Array.new @roles.each_value { |role| result.push(role.name) if role.has_all_partitions?(model_type_serial) } result.sort end |