Class: JSS::Computer

Inherits:
APIObject show all
Extended by:
Matchable
Includes:
Extendable, Locatable, Purchasable, Updatable, Uploadable
Defined in:
lib/jss/api_object/computer.rb,
lib/jss.rb

Overview

This class represents a Computer in the JSS.

Adding Computers to the JSS

This class cannot be used to add new Computers to the JSS. Please use other Casper methods (like the Recon App or QuickAdd package)


Editing values

Any data that arrives in the JSS via an “inventory update” (a.k.a. ‘recon’) cannot be modified through this class, or the API.

Data that can be modified are:

  • Management Account (see #set_management_to)

  • asset_tag

  • barcodes 1 and 2

  • ip_address

  • udid

  • mac_addresses

  • location data via the Locatable module

  • purchasing data via the Purchasable module

  • Extension Attribute values via the Extendable module Note: as with other ‘recon’ generated values, Ext. Attrs. populated by scripts cannot be modified via the API. (the change would be overwritten the next time the machine did a recon)

After making any changes, you must call #update to send those changes to the server.


MDM Commands

MDM Commands are Not Yet Supported!

*Hopefully they will be soon*

The following methods will be used to send an APNS command to the computer represented by an instance of JSS::Computer, equivalent to clicking one of the buttons on the Management Commands section of the Management tab of the Computer details page in the JSS UI.

The methods supported will be:

  • #blank_push (aliases blank, noop, send_blank_push)

  • #device_lock (aliases lock, lock_device)

  • #erase_device (aliases wipe)

To send an MDM command without making an instance, use the class method send_mdm_command

Each returns true if the command as sent.


Other Methods

Constant Summary collapse

RSRC_BASE =

The base for REST resources of this class

"computers"
LIST_RSRC =

The (temporary?) list-resource

"#{RSRC_BASE}/subset/basic"
RSRC_LIST_KEY =

the hash key used for the JSON list output of all objects in the JSS

:computers
RSRC_OBJECT_KEY =

The hash key used for the JSON object output. It’s also used in various error messages

:computer
VALID_DATA_KEYS =

these keys, as well as :id and :name, are present in valid API JSON data for this class

[:sus, :distribution_point, :alt_mac_address ]
SEARCH_CLASS =

This class lets us seach for computers

JSS::AdvancedComputerSearch
EXT_ATTRIB_CLASS =

This is the class for relevant Extension Attributes

JSS::ComputerExtensionAttribute
BOOT_FLAG =

Boot partitions are noted with the string “(Boot Partition)” at the end

" (Boot Partition)"
UPLOAD_TYPES =

file uploads can send attachments to the JSS using :computers as the sub-resource.

{ :attachment => :computers}
COMPUTER_MDM_COMMANDS =

A mapping of Symbols available to the send_mdm_command class method, to the String commands actuallly sent via the API.

{
  :blank_push => "BlankPush",
  :send_blank_push => "BlankPush",
  :blank => "BlankPush",
  :noop => "BlankPush",
  :device_lock => "DeviceLock",
  :lock => "DeviceLock",
  :lock_device => "DeviceLock",
  :erase_device => "EraseDevice",
  :erase => "EraseDevice",
  :wipe => "EraseDevice",
  :unmanage_device => "UnmanageDevice",
  :unmanage => "UnmanageDevice"
}
@@all_computers =

Class Variables

nil

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Computer

As well as :id and :name, computers can be queried using :udid, :serialnumber, and :mac_address

Parameters:

  • args (Hash) (defaults to: {})

    the data for looking up, or constructing, a new object.

  • other_lookup_keys (Array<Symbol>)

    Hash keys other than :id and :name, by which an API lookup may be performed.



546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
# File 'lib/jss/api_object/computer.rb', line 546

def initialize (args = {})

  super args, [:udid, :serialnumber, :mac_address]

  ### now we have raw @init_data with something in it, so fill out the instance vars
  @alt_mac_address = @init_data[:general][:alt_mac_address]
  @asset_tag = @init_data[:general][:asset_tag]
  @barcode_1 = @init_data[:general][:barcode_1]
  @barcode_2 = @init_data[:general][:barcode_2]
  @distribution_point = @init_data[:general][:distribution_point]
  @initial_entry_date = JSS.epoch_to_time @init_data[:general][:initial_entry_date_epoch]
  @ip_address = @init_data[:general][:ip_address]
  @jamf_version = @init_data[:general][:jamf_version]
  @last_contact_time = JSS.epoch_to_time @init_data[:general][:last_contact_time_epoch]
  @mac_address = @init_data[:general][:mac_address]
  @managed = @init_data[:general][:remote_management][:managed]
  @management_username = @init_data[:general][:remote_management][:management_username]
  @mdm_capable = @init_data[:general][:mdm_capable]
  @netboot_server = @init_data[:general][:netboot_server]
  @platform = @init_data[:general][:platform]
  @report_date = JSS.epoch_to_time @init_data[:general][:report_date_epoch]
  @serial_number = @init_data[:general][:serial_number]
  @site =  JSS::APIObject.get_name( @init_data[:general][:site])
  @sus = @init_data[:general][:sus]
  @udid = @init_data[:general][:udid]

  parse_location
  parse_purchasing
  parse_ext_attrs

  @configuration_profiles = @init_data[:configuration_profiles]
  @extension_attributes = @init_data[:extension_attributes]
  @groups_accounts = @init_data[:groups_accounts]
  @hardware = @init_data[:hardware]
  @peripherals = @init_data[:peripherals]
  @software = @init_data[:software]

  @management_password = nil

end

Instance Attribute Details

#alt_mac_addressString (readonly) Also known as: alt_macaddress

Returns the secondary mac address.

Returns:

  • (String)

    the secondary mac address



321
322
323
# File 'lib/jss/api_object/computer.rb', line 321

def alt_mac_address
  @alt_mac_address
end

#applecare_idString Originally defined in module Purchasable

Returns:

#asset_tagString

Returns the asset tag.

Returns:



324
325
326
# File 'lib/jss/api_object/computer.rb', line 324

def asset_tag
  @asset_tag
end

#barcode_1String Also known as: bar_code_1

Returns the barcodes.

Returns:



327
328
329
# File 'lib/jss/api_object/computer.rb', line 327

def barcode_1
  @barcode_1
end

#barcode_2String Also known as: bar_code_2

Returns the barcodes.

Returns:



327
328
329
# File 'lib/jss/api_object/computer.rb', line 327

def barcode_2
  @barcode_2
end

#buildingString Originally defined in module Locatable

Returns:

#configuration_profilesArray<Hash> (readonly)

A Hash for each ConfigurationProfile on the computer

The Hash keys are:

  • :id => the ConfigurationProfile id in the JSS

  • :name => the username to whom this user-level profile has been applied (if it’s a user-level profile)

  • :uuid => the ConfigurationProfile uuid

Returns:



393
394
395
# File 'lib/jss/api_object/computer.rb', line 393

def configuration_profiles
  @configuration_profiles
end

#departmentString Originally defined in module Locatable

Returns:

#distribution_pointString (readonly)

Returns The name of the distribution point for this computer.

Returns:

  • (String)

    The name of the distribution point for this computer



331
332
333
# File 'lib/jss/api_object/computer.rb', line 331

def distribution_point
  @distribution_point
end

#email_addressString Originally defined in module Locatable

Returns:

#ext_attrsHash (readonly) Originally defined in module Extendable

Returns A mapping of Ext Attrib names to their values.

Returns:

  • (Hash)

    A mapping of Ext Attrib names to their values

#extension_attributesArray<Hash> (readonly) Originally defined in module Extendable

Returns The extension attribute values for the object.

Returns:

  • (Array<Hash>)

    The extension attribute values for the object

#groups_accountsHash (readonly)

Info about the local accts and ComputerGroups to which this machine beloings

The Hash keys are:

  • :computer_group_memberships => An Array of names of ComputerGroups to which this computer belongs

  • :local_accounts => An Array of Hashes for each local user acct on this computer. Each hash has these keys:

    • :name => String, the login name of the acct

    • :realname => the real name of the acct

    • :uid => String, the uid of the acct

    • :home => String, the path to the home folder

    • :home_size => String, the size of the homedir as a string like “53245MB”

    • :home_size_mb => Integer, the size of the homedir as an integer like 53245

    • :administrator => Boolean

    • :filevault_enabled => Boolean

Returns:



411
412
413
# File 'lib/jss/api_object/computer.rb', line 411

def groups_accounts
  @groups_accounts
end

#hardwareHash (readonly)

A Hash with info about the hardware of this cmoputer.

These are the keys & sample data

  • :number_processors=>2,

  • :processor_speed_mhz=>2530,

  • :make=>“Apple”,

  • :cache_size=>3072,

  • :processor_type=>“Intel Core i5”,

  • :total_ram_mb=>8192,

  • :model=>“15-inch MacBook Pro (Mid 2010)”,

  • :available_ram_slots=>0,

  • :processor_architecture=>“i386”,

  • :bus_speed_mhz=>0,

  • :total_ram=>8192,

  • :os_name=>“Mac OS X”,

  • :optical_drive=>“HL-DT-ST DVDRW GS23N”,

  • :model_identifier=>“MacBookPro6,2”,

  • :cache_size_kb=>3072,

  • :boot_rom=>“MBP61.0057.B0F”,

  • :os_version=>“10.9.3”,

  • :mapped_printers=> An Array of Hashes, one per printer, with these keys

    • :name => the name of the printer

    • :location => the location of the printer

    • :type => the printer model

    • :uri => the uri to reach the printer on the network

  • :nic_speed=>“10/100/1000”,

  • :processor_speed=>2530,

  • :active_directory_status=>“Not Bound”,

  • :bus_speed=>0,

  • :os_build=>“13D65”,

  • :smc_version=>“1.58f17”,

  • :service_pack=>“”,

  • :battery_capacity=>87

  • :storage=> An Array of Hashes, one per Drive, with these keys

    • :smart_status=>“Verified”,

    • :connection_type=>“NO”,

    • :model=>“M4-CT256M4SSD2”,

    • :revision=>“040H”,

    • :serial_number=>“00000000130709JH7GhhC”,

    • :size=>262205,

    • :disk=>“disk0”,

    • :drive_capacity_mb=>262205}],

    • :partition=> A Hash with these keys

      • :filevault2_status=>“Encrypted”,

      • :type=>“boot”,

      • :filevault2_percent=>100,

      • :partition_capacity_mb=>38014,

      • :lvgUUID=>“C4883AF5-3E58-4F76-A56C-094D4CEC7E9F”,

      • :percentage_full=>61,

      • :lvUUID=>“745A262E-AEA6-4608-8A3A-6CDC225B4DE6”,

      • :filevault_status=>“Encrypted”,

      • :size=>38014,

      • :pvUUID=>“C38051CF-5066-442F-A442-1035060ED462”,

      • :name=>“KimDrive40 (Boot Partition)”,

      • :filevault_percent=>100

Returns:



471
472
473
# File 'lib/jss/api_object/computer.rb', line 471

def hardware
  @hardware
end

#initial_entry_dateTime (readonly)

Returns when was it added to the JSS.

Returns:

  • (Time)

    when was it added to the JSS



334
335
336
# File 'lib/jss/api_object/computer.rb', line 334

def 
  @initial_entry_date
end

#ip_addressIPAddr

Returns the last known IP address.

Returns:

  • (IPAddr)

    the last known IP address



337
338
339
# File 'lib/jss/api_object/computer.rb', line 337

def ip_address
  @ip_address
end

#is_leasedBoolean Also known as: leased? Originally defined in module Purchasable

Returns:

  • (Boolean)

#is_purchasedBoolean Also known as: purchased? Originally defined in module Purchasable

Returns:

  • (Boolean)

#jamf_versionString (readonly)

Returns the version of the jamf binary.

Returns:

  • (String)

    the version of the jamf binary



340
341
342
# File 'lib/jss/api_object/computer.rb', line 340

def jamf_version
  @jamf_version
end

#last_contact_timeTime (readonly)

Returns the last contact time.

Returns:

  • (Time)

    the last contact time



343
344
345
# File 'lib/jss/api_object/computer.rb', line 343

def last_contact_time
  @last_contact_time
end

#lease_expiresTime Originally defined in module Purchasable

Returns:

#life_expectancyInteger Originally defined in module Purchasable

Returns:

  • (Integer)

#mac_addressString (readonly)

Returns the primary macaddress.

Returns:

  • (String)

    the primary macaddress



346
347
348
# File 'lib/jss/api_object/computer.rb', line 346

def mac_address
  @mac_address
end

#managedBoolean (readonly) Also known as: managed?

Returns is this machine “managed” by Casper?.

Returns:

  • (Boolean)

    is this machine “managed” by Casper?



349
350
351
# File 'lib/jss/api_object/computer.rb', line 349

def managed
  @managed
end

#management_usernameString (readonly)

Returns the name of the management account.

Returns:

  • (String)

    the name of the management account



352
353
354
# File 'lib/jss/api_object/computer.rb', line 352

def management_username
  @management_username
end

#mdm_capableBoolean (readonly) Also known as: mdm?

Returns doesit support MDM?.

Returns:

  • (Boolean)

    doesit support MDM?



355
356
357
# File 'lib/jss/api_object/computer.rb', line 355

def mdm_capable
  @mdm_capable
end

#need_to_updateBoolean (readonly) Originally defined in module Updatable

Returns do we have unsaved changes?.

Returns:

  • (Boolean)

    do we have unsaved changes?

#netboot_serverString (readonly)

Returns the name of the netboot server for this machine.

Returns:

  • (String)

    the name of the netboot server for this machine



358
359
360
# File 'lib/jss/api_object/computer.rb', line 358

def netboot_server
  @netboot_server
end

#peripheralsArray<Hash> (readonly)

A Hash per peripheral

Each hash has these keys & sample data:

  • :id=>286,

  • :type=>“Display”,

  • :field_0=>“HP”,

  • :field_1=>“HP LP2480zx”,

  • :field_2=>“DreamColor”,

  • :field_3=>“3CM10800F4”,

  • :field_4=>“”,

  • :field_5=>“”

  • :field_6=>“”,

  • :bar_code_1=>“”,

  • :bar_code_2=>“”,

  • :purchasing=> A hash with these keys:

    • :warranty_expires_utc=>“”,

    • :is_leased=>false,

    • :po_date=>“”,

    • :lease_expires=>“”,

    • :po_number=>“”,

    • :po_date_epoch=>0,

    • :lease_expires_epoch=>0,

    • :vendor=>“”,

    • :attachments=>[],

    • :po_date_utc=>“”,

    • :lease_expires_utc=>“”,

    • :applecare_id=>“”,

    • :warranty_expires=>“”,

    • :life_expectancy=>0,

    • :purchase_price=>“”,

    • :warranty_expires_epoch=>0,

    • :is_purchased=>true,

    • :purchasing_contact=>“”,

    • :purchasing_account=>“”

Returns:



513
514
515
# File 'lib/jss/api_object/computer.rb', line 513

def peripherals
  @peripherals
end

#phoneString Originally defined in module Locatable

Returns:

#platformString (readonly)

Returns what kind of computer?.

Returns:

  • (String)

    what kind of computer?



361
362
363
# File 'lib/jss/api_object/computer.rb', line 361

def platform
  @platform
end

#po_dateTime Originally defined in module Purchasable

Returns:

#po_numberString Originally defined in module Purchasable

Returns:

#positionString Originally defined in module Locatable

Returns:

#purchase_priceFloat Originally defined in module Purchasable

Returns:

  • (Float)

#purchasing_accountString Originally defined in module Purchasable

Returns:

#purchasing_contactString Originally defined in module Purchasable

Returns:

#real_nameString Originally defined in module Locatable

Returns:

#report_dateTime (readonly) Also known as: last_recon

Returns the last recon time.

Returns:

  • (Time)

    the last recon time



364
365
366
# File 'lib/jss/api_object/computer.rb', line 364

def report_date
  @report_date
end

#roomString Originally defined in module Locatable

Returns:

#serial_numberString (readonly) Also known as: sn, serialnumber

Returns the serial number.

Returns:

  • (String)

    the serial number



367
368
369
# File 'lib/jss/api_object/computer.rb', line 367

def serial_number
  @serial_number
end

#siteHash (readonly)

Returns the :name and :id of the site for this machine.

Returns:

  • (Hash)

    the :name and :id of the site for this machine



371
372
373
# File 'lib/jss/api_object/computer.rb', line 371

def site
  @site
end

#softwareHash (readonly)

A Hash of software data

The Hash has these keys:

  • :running_services => An Array of services running on the computer (if gathered) TODO - is each item a hash?

  • :installed_by_casper => An Array of Package names unstalled on this computer by Casper

  • :fonts => An Array of fonts on this computer (if gathered) TODO - is each item a hash?

  • :installed_by_installer_swu => An Array of pkg IDs for pkgs installed by SoftwareUpdate or the Apple Installer

  • :applications => An Array of Hashes, one per Application on the computer, with these keys:

    • :path => String, the path to the app

    • :name => String, the name of the app, including the .app suffix

    • :version => String, the version of the app at that path.

  • :cached_by_casper => An Array of Casper Package names cached on the machine, awaiting installation

  • :available_software_updates => An Array of available SoftwareUpdate (if gathered) TODO - is each item a hash?

  • :plugins => An Array of plugins installed on the machine (if gathered) TODO - is each item a hash?

  • :available_updates => A Hash - Deprecated?

  • :licensed_software => An Array, the names of Licenced Software (as defined in Casper) on this machine

  • :unix_executables => DEPRECATED

Returns:



535
536
537
# File 'lib/jss/api_object/computer.rb', line 535

def software
  @software
end

#susString (readonly)

Returns the name of the Software Update Server assigned to this machine.

Returns:

  • (String)

    the name of the Software Update Server assigned to this machine.



374
375
376
# File 'lib/jss/api_object/computer.rb', line 374

def sus
  @sus
end

#udidString (readonly)

Returns the UDID of the computer.

Returns:

  • (String)

    the UDID of the computer



377
378
379
# File 'lib/jss/api_object/computer.rb', line 377

def udid
  @udid
end

#usernameString Also known as: user Originally defined in module Locatable

Returns:

#vendorString Originally defined in module Purchasable

Returns:

#warranty_expiresTime Originally defined in module Purchasable

Returns:

Class Method Details

.all(refresh = false) ⇒ Array<Hash{:name=>String, :id=> Integer}>

A larger set of info about the computers in the JSS.

Casper 9.4 introduced the API Resource /computers/subset/basic that returns an array of hashes with more data than just /computers/ (which was just :name and :id). Similar to /mobildevices/, this new list includes :udid, :serial_number, and :mac_address, as well as :model, :managed, :building, :department, :username, and :report_date

Because this requires a different, unusual, resource path, we’re completely re-defining APIObject.all for JSS::Computer. Hopefully some day the original /computers/ resource will be updated to return this data.

Parameters:

  • refresh (Boolean) (defaults to: false)

    should the data be re-queried from the API?

Returns:



153
154
155
156
157
# File 'lib/jss/api_object/computer.rb', line 153

def self.all(refresh = false)
  @@all_computers = nil if refresh
  return @@all_computers if @@all_computers
  @@all_computers = JSS::API.get_rsrc(self::LIST_RSRC)[self::RSRC_LIST_KEY]
end

.all_desktops(refresh = false) ⇒ Array<Hash>

Returns all desktop macs in the jss.

Returns:

  • (Array<Hash>)

    all desktop macs in the jss



210
211
212
# File 'lib/jss/api_object/computer.rb', line 210

def self.all_desktops(refresh = false)
  self.all(refresh).select{|d| d[:model] !~ /serve|book/i  }
end

.all_imacs(refresh = false) ⇒ Array<Hash>

Returns all imacs in the jss.

Returns:



215
216
217
# File 'lib/jss/api_object/computer.rb', line 215

def self.all_imacs(refresh = false)
  self.all(refresh).select{|d| d[:model] =~ /^imac/i  }
end

.all_laptops(refresh = false) ⇒ Array<Hash>

Returns all laptop computers in the jss.

Returns:

  • (Array<Hash>)

    all laptop computers in the jss



185
186
187
# File 'lib/jss/api_object/computer.rb', line 185

def self.all_laptops(refresh = false)
  self.all(refresh).select{|d| d[:model] =~ /book/i }
end

.all_mac_addresses(refresh = false) ⇒ Array<String>

Returns all computer mac_addresses in the jss.

Returns:

  • (Array<String>)

    all computer mac_addresses in the jss



165
166
167
# File 'lib/jss/api_object/computer.rb', line 165

def self.all_mac_addresses(refresh = false)
  self.all(refresh).map{|i| i[:mac_address]}
end

.all_macbookairs(refresh = false) ⇒ Array<Hash>

Returns all macbookairs in the jss.

Returns:

  • (Array<Hash>)

    all macbookairs in the jss



200
201
202
# File 'lib/jss/api_object/computer.rb', line 200

def self.all_macbookairs(refresh = false)
  self.all(refresh).select{|d| d[:model] =~ /^macbookair\d/i  }
end

.all_macbookpros(refresh = false) ⇒ Array<Hash>

Returns all macbookpros in the jss.

Returns:

  • (Array<Hash>)

    all macbookpros in the jss



195
196
197
# File 'lib/jss/api_object/computer.rb', line 195

def self.all_macbookpros(refresh = false)
  self.all(refresh).select{|d| d[:model] =~ /^macbookpro\d/i  }
end

.all_macbooks(refresh = false) ⇒ Array<Hash>

Returns all macbooks in the jss.

Returns:



190
191
192
# File 'lib/jss/api_object/computer.rb', line 190

def self.all_macbooks(refresh = false)
  self.all(refresh).select{|d| d[:model] =~ /^macbook\d/i  }
end

.all_macpros(refresh = false) ⇒ Array<Hash>

Returns all macpros in the jss.

Returns:



225
226
227
# File 'lib/jss/api_object/computer.rb', line 225

def self.all_macpros(refresh = false)
  self.all(refresh).select{|d| d[:model] =~ /^macpro/i  }
end

.all_managed(refresh = false) ⇒ Array<Hash>

Returns all managed computers in the jss.

Returns:

  • (Array<Hash>)

    all managed computers in the jss



175
176
177
# File 'lib/jss/api_object/computer.rb', line 175

def self.all_managed(refresh = false)
  self.all(refresh).select{|d| d[:managed] }
end

.all_minis(refresh = false) ⇒ Array<Hash>

Returns all mac minis in the jss.

Returns:



220
221
222
# File 'lib/jss/api_object/computer.rb', line 220

def self.all_minis(refresh = false)
  self.all(refresh).select{|d| d[:model] =~ /^macmini/i  }
end

.all_serial_numbers(refresh = false) ⇒ Array<String>

Returns all computer serial numbers in the jss.

Returns:

  • (Array<String>)

    all computer serial numbers in the jss



160
161
162
# File 'lib/jss/api_object/computer.rb', line 160

def self.all_serial_numbers(refresh = false)
  self.all(refresh).map{|i| i[:serial_number]}
end

.all_udids(refresh = false) ⇒ Array<String>

Returns all computer udids in the jss.

Returns:



170
171
172
# File 'lib/jss/api_object/computer.rb', line 170

def self.all_udids(refresh = false)
  self.all(refresh).map{|i| i[:udid]}
end

.all_unmanaged(refresh = false) ⇒ Array<Hash>

Returns all unmanaged computers in the jss.

Returns:

  • (Array<Hash>)

    all unmanaged computers in the jss



180
181
182
# File 'lib/jss/api_object/computer.rb', line 180

def self.all_unmanaged(refresh = false)
  self.all(refresh).select{|d| not d[:managed] }
end

.all_xserves(refresh = false) ⇒ Array<Hash>

Returns all xserves in the jss.

Returns:



205
206
207
# File 'lib/jss/api_object/computer.rb', line 205

def self.all_xserves(refresh = false)
  self.all(refresh).select{|d| d[:model] =~ /serve/i  }
end

.match(term) ⇒ Array<Hash> Originally defined in module Matchable

Perform a match, returning an Array of Hashes, one for each item matched

At the moment, it appears the search is an “exact match” search regardless of the prefs of the user connected to the API.

Parameters:

  • term (String)

    the term to match.

Returns:

Raises:

Instance Method Details

#appsArray<Hash>

Returns all apps installed on this machine. Hash keys are :name, :path, and :version.

Returns:

  • (Array<Hash>)

    all apps installed on this machine. Hash keys are :name, :path, and :version



641
# File 'lib/jss/api_object/computer.rb', line 641

def apps ; @software[:applications] ; end

#boot_driveHash?

Returns The hardware hash of the boot drive.

Returns:



625
626
627
628
# File 'lib/jss/api_object/computer.rb', line 625

def boot_drive
  drives.each{ |d| return d if d[:partition][:type] == "boot" }
  return nil
end

#clear_locationvoid Originally defined in module Locatable

This method returns an undefined value.

Clear all location data

#computer_groupsArray

Returns the JSS groups to which thismachine belongs (smart and static).

Returns:

  • (Array)

    the JSS groups to which thismachine belongs (smart and static)



590
591
592
# File 'lib/jss/api_object/computer.rb', line 590

def computer_groups
  @groups_accounts[:computer_group_memberships]
end

#deletevoid

This method returns an undefined value.

Delete this computer from the JSS



742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
# File 'lib/jss/api_object/computer.rb', line 742

def delete
  super
  @alt_mac_address = nil
  @asset_tag = nil
  @barcode_1 = nil
  @barcode_2 = nil
  @distribution_point = nil
  @initial_entry_date = nil
  @ip_address = nil
  @jamf_version = nil
  @last_contact_time = nil
  @macaddress = nil
  @managed = nil
  @management_username = nil
  @mdm_capable = nil
  @netboot_server = nil
  @platform = nil
  @report_date = nil
  @serial_number = nil
  @site = nil
  @sus = nil
  @udid = nil

  @building = nil
  @department = nil
  @email_address = nil
  @phone = nil
  @position = nil
  @real_name = nil
  @room = nil
  @username = nil

  @configuration_profiles = nil
  @extension_attributes = nil
  @groups_accounts = nil
  @hardware = nil
  @peripherals = nil
  @purchasing = nil
  @software = nil
end

#drivesArray<Hash>

Returns each storage device.

Returns:



619
620
621
# File 'lib/jss/api_object/computer.rb', line 619

def drives
  @hardware[:storage]
end

#ext_attr_xmlREXML::Element Originally defined in module Extendable

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns An <extension_attribute> element to be included in the rest_xml of objects that mix-in this module.

Returns:

  • (REXML::Element)

    An <extension_attribute> element to be included in the rest_xml of objects that mix-in this module.

#filevault1_accountsArray<Hash>

Returns The local_accounts Array that have Legacy FV enabled.

Returns:

  • (Array<Hash>)

    The local_accounts Array that have Legacy FV enabled



612
613
614
615
# File 'lib/jss/api_object/computer.rb', line 612

def filevault1_accounts
  return [] if filevault2_enabled?
  local_accounts.select{ |a| a[:filevault_enabled] }
end

#filevault2_enabled?Boolean

Returns is FileVault2 enabled?.

Returns:

  • (Boolean)

    is FileVault2 enabled?



606
607
608
# File 'lib/jss/api_object/computer.rb', line 606

def filevault2_enabled?
  boot_drive[:partition][:filevault2_status] != "Not Encrypted"
end

#has_location?Boolean Originally defined in module Locatable

Returns Does this item have location data?.

Returns:

  • (Boolean)

    Does this item have location data?

#has_purchasing?Boolean Originally defined in module Purchasable

Returns does this item have any purchasing info?.

Returns:

  • (Boolean)

    does this item have any purchasing info?

#licensed_swArray<String>

Returns the JSS-defined “licensed software” titles installed on this machine.

Returns:

  • (Array<String>)

    the JSS-defined “licensed software” titles installed on this machine.



647
# File 'lib/jss/api_object/computer.rb', line 647

def licensed_sw ; @software[:licensed_software] ; end

#local_accountsArray<Hash> Also known as: accounts, accts

Each item has keys :name, :realname, :uid, :home, :home_size, :administrator, :filevault_enabled

Returns:

  • (Array<Hash>)

    all the local accts on the machine.



599
600
601
# File 'lib/jss/api_object/computer.rb', line 599

def local_accounts
  @groups_accounts[:local_accounts]
end

#locationHash<String> Originally defined in module Locatable

All the location data in a Hash, as it comes from the API.

The reason it isn’t stored this way is to prevent editing of the hash directly.

Returns:

#location_xmlREXML::Element Originally defined in module Locatable

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return a REXML <location> element to be included in the rest_xml of objects that have a Location subset

Returns:

  • (REXML::Element)

#make_unmanagedvoid

This method returns an undefined value.

Make the machine unmanaged.

The same as

#set_management_to nil, nil

followed by

JSS::Computer.send_mdm_command @id, :unmanage_device

which currently isn’t working



683
684
685
686
687
688
689
690
# File 'lib/jss/api_object/computer.rb', line 683

def make_unmanaged
  return nil unless managed?
  set_management_to(nil, nil)
  begin
    self.class.send_mdm_command(@id, :unmanage_device)
  rescue
  end
end

#name=(newname) ⇒ void Originally defined in module Updatable

This method returns an undefined value.

Change the name of this item Remember to #update to push changes to the server.

Parameters:

  • newname (String)

    the new name

Raises:

#parse_ext_attrsvoid Originally defined in module Extendable

This method returns an undefined value.

Populate @extension_attributes (the Array of Hashes that comes from the API) and @ext_attr_names, which is a Hash mapping the EA names to their index in the @extension_attributes Array.

Classes including this module should call this in #initialize

#parse_locationvoid Originally defined in module Locatable

This method returns an undefined value.

Call this during initialization of objects that have a Location subset and the location attributes will be populated (as primary attributes) from @init_data

#parse_purchasingObject Originally defined in module Purchasable

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Call this during initialization of objects that have a Purchasing subset and the purchasing attribute will be populated from @init_data

#printersArray<Hash>

Returns each printer on this computer Keys are :name, :uri, :type, :location.

Returns:

  • (Array<Hash>)

    each printer on this computer Keys are :name, :uri, :type, :location



633
634
635
# File 'lib/jss/api_object/computer.rb', line 633

def printers
  @hardware[:mapped_printers]
end

#purchasingHash<String> Originally defined in module Purchasable

All the purchasing data in a Hash, as it comes from the API.

The reason it isn’t stored this way is to prevent editing of the hash directly.

Returns:

#purchasing_xmlREXML::Element Originally defined in module Purchasable

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns A <purchasing> element to be included in the rest_xml of objects that mix-in this module.

Returns:

  • (REXML::Element)

    A <purchasing> element to be included in the rest_xml of objects that mix-in this module.

#set_ext_attr(name, value) ⇒ void Originally defined in module Extendable

This method returns an undefined value.

Set the value of an extension attribute

If the extension attribute is defined as a popup menu, the value must be one of the defined popup choices.

If the ext. attrib. is defined with a data type of Integer, the value must be an Integer.

If the ext. attrib. is defined with a data type of Date, the value will be converted to a Time

Parameters:

  • name (String)

    the name of the extension attribute to set

  • value (String, Time, Time, Integer)

    the new value for the extension attribute for this user

#set_management_to(name, password) ⇒ void Also known as: make_managed

This method returns an undefined value.

Set or unset management acct and password for this computer

The changes will need to be pushed to the server with #update before they take effect.

CAUTION: this does nothing to confirm the name and password will work on the machine!

Parameters:

  • name (String)

    the name of the management acct.

  • password (String)

    the password of the management acct



664
665
666
667
668
669
670
# File 'lib/jss/api_object/computer.rb', line 664

def set_management_to (name, password)
  password = nil unless name
  @management_username = name
  @management_password = password
  @managed = name ? true : false
  @need_to_update = true
end

#updatevoid

This method returns an undefined value.

Send changes to the API



731
732
733
734
735
# File 'lib/jss/api_object/computer.rb', line 731

def update
  id = super
  @management_password = nil
  id
end

#upload(type, local_file) ⇒ String Originally defined in module Uploadable

Upload a file to the JSS via the REST Resource of the object to which this module is mixed in.

Parameters:

  • type (Symbol)

    the type of upload happening. Must be one of the keys defined in the class’s UPLOAD_TYPES Hash.

  • local_file (String, Pathname)

    String or Pathname pointing to the locally-readable file to be uploaded.

Returns:

  • (String)

    The xml response from the server.

Raises: