Class: OpenNebula::System

Inherits:
Object
  • Object
show all
Defined in:
lib/opennebula/system.rb

Constant Summary collapse

SYSTEM_METHODS =

Constants and Class attribute accessors

{
    :userquotainfo      => "userquota.info",
    :userquotaupdate    => "userquota.update",
    :groupquotainfo     => "groupquota.info",
    :groupquotaupdate   => "groupquota.update",
    :version            => "system.version",
    :config             => "system.config",
    :sql                => "system.sql",
    :sqlquery           => "system.sqlquery"
}

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ System

Constructor

@param [Client] client that represents a XML-RPC connection


43
44
45
# File 'lib/opennebula/system.rb', line 43

def initialize(client)
    @client = client
end

Instance Method Details

#compatible_versiontrue, ...

Returns whether of not the oned version is the same as the OCA version

Returns:



90
91
92
93
94
95
96
97
98
99
# File 'lib/opennebula/system.rb', line 90

def compatible_version()
    no_revision = VERSION[/^\d+\.\d+\./]
    oned_v = get_oned_version

    if OpenNebula.is_error?(oned_v)
        return oned_v
    end

    return (oned_v =~ /#{no_revision}/) != nil
end

#get_configurationXMLElement, OpenNebula::Error

Gets the oned configuration

Returns:



105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/opennebula/system.rb', line 105

def get_configuration()
    rc = @client.call(SYSTEM_METHODS[:config])

    if OpenNebula.is_error?(rc)
        return rc
    end

    config = XMLElement.new
    config.initialize_xml(rc, 'OPENNEBULA_CONFIGURATION')

    return config
end

#get_group_quotasXMLElement, OpenNebula::Error

Gets the default group quota limits

Returns:



148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/opennebula/system.rb', line 148

def get_group_quotas()
    rc = @client.call(SYSTEM_METHODS[:groupquotainfo])

    if OpenNebula.is_error?(rc)
        return rc
    end

    default_quotas = XMLElement.new
    default_quotas.initialize_xml(rc, 'DEFAULT_GROUP_QUOTAS')

    return default_quotas
end

#get_oned_versionString, OpenNebula::Error

Gets the oned version

Returns:

  • (String, OpenNebula::Error)

    the oned version in case of success, Error otherwise



82
83
84
# File 'lib/opennebula/system.rb', line 82

def get_oned_version()
    return @client.call("system.version")
end

#get_user_quotasXMLElement, OpenNebula::Error

Gets the default user quota limits

Returns:



122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/opennebula/system.rb', line 122

def get_user_quotas()
    rc = @client.call(SYSTEM_METHODS[:userquotainfo])

    if OpenNebula.is_error?(rc)
        return rc
    end

    default_quotas = XMLElement.new
    default_quotas.initialize_xml(rc, 'DEFAULT_USER_QUOTAS')

    return default_quotas
end

#set_group_quotas(quota) ⇒ nil, OpenNebula::Error

Sets the default group quota limits

Parameters:

  • quota (String)

    a template (XML or txt) with the new quota limits

Returns:



166
167
168
# File 'lib/opennebula/system.rb', line 166

def set_group_quotas(quota)
    return @client.call(SYSTEM_METHODS[:groupquotaupdate], quota)
end

#set_user_quotas(quota) ⇒ nil, OpenNebula::Error

Sets the default user quota limits

Parameters:

  • quota (String)

    a template (XML or txt) with the new quota limits

Returns:



140
141
142
# File 'lib/opennebula/system.rb', line 140

def set_user_quotas(quota)
    return @client.call(SYSTEM_METHODS[:userquotaupdate], quota)
end

#sql_command(sql, federate) ⇒ Object

Executes and replicates SQL commands on OpenNebula DB

@param [String] Sql string
@param [Boolean] True to replicate command on a federation. To
operate on federated tables
@return [Integer, OpenNebula::Error] Sql execution result in case
of success, Error otherwise


57
58
59
# File 'lib/opennebula/system.rb', line 57

def sql_command(sql, federate)
    return @client.call(SYSTEM_METHODS[:sql], sql, federate)
end

#sql_query_command(sql) ⇒ Object

Executes a SQL query command on OpenNebula DB

@param [String] Sql string
@return [String, OpenNebula::Error] Sql execution result in XML
format in case of success, Error otherwise
<QUERY>
  the query sent to oned
</QUERY>
<RESULT>
  <ROW>
    <column_name>column_value</column_name>
    ...
  </ROW>
</RESULT>


74
75
76
# File 'lib/opennebula/system.rb', line 74

def sql_query_command(sql)
    return @client.call(SYSTEM_METHODS[:sqlquery], sql)
end