class Org
Attributes
id[R]
name[R]
Public Class Methods
new(org)
click to toggle source
# File lib/satops/operator.rb, line 814 def initialize(org) @id=org['id'] @name=org['name'] @active_users=org['active_users'] # Number of active users in the organization. @systems=org['systems'] # Number of systems in the organization. # API doesn't return trusts info wigh getDetails # @trusts=org['trusts'] # Number of trusted organizations. @users=org['users'] @system_groups=org['system_groups'] # Number of system groups in the organization. (optional) @activation_keys=org['activation_keys'] # Number of activation keys in the organization. (optional) @kickstart_profiles=org['kickstart_profiles'] # Number of kickstart profiles in the organization. (optional) @configuration_channels=org['configuration_channels'] # Number of configuration channels in the organization. (optional) @system_entitlements=org['system_entitlements'] @software_entitlements=org['software_entitlements'] end
reader(sat, id)
click to toggle source
# File lib/satops/operator.rb, line 795 def self.reader(sat, id) org={} org.merge!(sat.org.getDetails(id)) org.merge!({'users'=>sat.org.listUsers(id)}) if Orgs.entitlements org.merge!({'system_entitlements'=>sat.org.listSystemEntitlementsForOrg(id)}) # Filter out empty software entitlements software_entitlements=sat.org.listSoftwareEntitlementsForOrg(id) if software_entitlements software_entitlements.delete_if do |entitlement| entitlement['allocated'] == 0 && entitlement['allocated_flex'] == 0 end org.merge!({'software_entitlements'=>software_entitlements}) end end org end
Public Instance Methods
create(sat)
click to toggle source
# File lib/satops/operator.rb, line 830 def create(sat) # Create org from the first user with admin privileges # Never handle default org (id=1) if @id != 1 && @active_users >= 1 admin=get_admin if admin # Try to find that Org org=sat.org.getDetails(@name) unless org # Create Org if doesn't exit org=sat.org.create(@name, admin['login'], admin['login'], 'Mr.', admin['name'].split(',')[1], admin['name'].split(',')[0], admin['email'], false) end # Entitlements option activated if Orgs.entitlements unless org # case org already exist! org=sat.org.getDetails(@name) end if org # Systems Entitlements @system_entitlements.each do |system_entitlement| sat.org.setSystemEntitlements(org['id'], system_entitlement['label'], system_entitlement['allocated']) end # Software Entitlements @software_entitlements.each do |software_entitlement| sat.org.setSoftwareEntitlements(org['id'], software_entitlement['label'], software_entitlement['allocated']) sat.org.setSoftwareFlexEntitlements(org['id'], software_entitlement['label'], software_entitlement['allocated_flex']) end end end end end end
delete(sat)
click to toggle source
# File lib/satops/operator.rb, line 868 def delete(sat) sat.org.delete(@id) unless @id == 1 end
get_admin()
click to toggle source
# File lib/satops/operator.rb, line 872 def get_admin @users.each do |user| return user if user['is_org_admin'] end end
update(sat)
click to toggle source
# File lib/satops/operator.rb, line 878 def update(sat) self.create(sat) end