Class: Vagrant::Smartos::Zones::Util::ZoneUser
- Inherits:
-
Object
- Object
- Vagrant::Smartos::Zones::Util::ZoneUser
- Includes:
- GlobalZone::Helper
- Defined in:
- lib/vagrant/smartos/zones/util/zone_user.rb
Instance Attribute Summary collapse
-
#machine ⇒ Object
readonly
Returns the value of attribute machine.
-
#zone ⇒ Object
readonly
Returns the value of attribute zone.
Instance Method Summary collapse
- #create(username, group, role = nil) ⇒ Object
- #exists?(username) ⇒ Boolean
- #find(username) ⇒ Object
-
#initialize(machine, zone) ⇒ ZoneUser
constructor
A new instance of ZoneUser.
Methods included from GlobalZone::Helper
Constructor Details
#initialize(machine, zone) ⇒ ZoneUser
Returns a new instance of ZoneUser.
14 15 16 17 |
# File 'lib/vagrant/smartos/zones/util/zone_user.rb', line 14 def initialize(machine, zone) @machine = machine @zone = zone end |
Instance Attribute Details
#machine ⇒ Object (readonly)
Returns the value of attribute machine.
12 13 14 |
# File 'lib/vagrant/smartos/zones/util/zone_user.rb', line 12 def machine @machine end |
#zone ⇒ Object (readonly)
Returns the value of attribute zone.
12 13 14 |
# File 'lib/vagrant/smartos/zones/util/zone_user.rb', line 12 def zone @zone end |
Instance Method Details
#create(username, group, role = nil) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/vagrant/smartos/zones/util/zone_user.rb', line 32 def create(username, group, role = nil) return if exists?(username) zone.zlogin("useradd #{flags(group)} #{username}") grant_role(username, role) install_public_key(group) end |
#exists?(username) ⇒ Boolean
28 29 30 |
# File 'lib/vagrant/smartos/zones/util/zone_user.rb', line 28 def exists?(username) machine.communicate.gz_test("#{sudo} zlogin #{zone.uuid} id -u #{username}") end |