Class: OsCtl::Image::Operations::Builder::GetRootUgid
- Inherits:
-
OsCtl::Image::Operations::Base
- Object
- OsCtl::Image::Operations::Base
- OsCtl::Image::Operations::Builder::GetRootUgid
- Defined in:
- lib/osctl/image/operations/builder/get_root_ugid.rb
Instance Attribute Summary collapse
- #builder ⇒ Builder readonly
Instance Method Summary collapse
-
#execute ⇒ Array(Integer, Integer)
Ugid, gid.
- #find_root(idmap, type) ⇒ Object protected
-
#initialize(builder) ⇒ GetRootUgid
constructor
A new instance of GetRootUgid.
Methods inherited from OsCtl::Image::Operations::Base
Constructor Details
#initialize(builder) ⇒ GetRootUgid
Returns a new instance of GetRootUgid.
9 10 11 12 |
# File 'lib/osctl/image/operations/builder/get_root_ugid.rb', line 9 def initialize(builder) super() @builder = builder end |
Instance Attribute Details
#builder ⇒ Builder (readonly)
6 7 8 |
# File 'lib/osctl/image/operations/builder/get_root_ugid.rb', line 6 def builder @builder end |
Instance Method Details
#execute ⇒ Array(Integer, Integer)
Returns ugid, gid.
15 16 17 18 19 20 21 |
# File 'lib/osctl/image/operations/builder/get_root_ugid.rb', line 15 def execute OsCtldClient.new.batch do |client| ct = client.find_container(builder.ctid) idmap = client.user_idmap(ct[:user]) [find_root(idmap, 'uid'), find_root(idmap, 'gid')] end end |
#find_root(idmap, type) ⇒ Object (protected)
25 26 27 28 29 30 31 32 33 |
# File 'lib/osctl/image/operations/builder/get_root_ugid.rb', line 25 def find_root(idmap, type) idmap.each do |entry| if entry[:type] == type && entry[:ns_id] == 0 return entry[:host_id] end end raise OperationError, "unable to find root #{type} in id map" end |