SmartState analysis scheme, restrictions, extensions
Scheme of Smart State Analysis
The intent of Smart State Analysis is to collect information from Virtual machine and save it in models.
These Models are:
-
-
-
-
-
-
Smart State Analysis system generates a few xml-files with information from VM. Then data is saved using the function These Models are:
-
Nerwork -
OperatingSystem -
Account -
SystemService -
GuestApplication -
Patch add_elements. And these xml-files are saved in
/var/www/miq/vmdb/data/metadata/*.( Also, these xml-files are stored one day and if VM is scanned several times per day, file will be replaced).It is necessary to say about modules,which collects information and group into following categories.
There are five categories:
-
system-
services-
accounts-
software-
ntevents-
vmconfigUsed module depends on OS:
| Collection category | Source module (Windows) | Source module (Linux) |
|---|---|---|
system | MiqWin32::System | MiqLinux::System |
services |
MiqWin32::Services |
MiqLinux::InitProcs |
accounts |
MiqWin32::Accounts |
MiqLinux::Users |
software |
MiqWin32::Software |
MiqLinux::Packages |
ntevents |
Win32EventLog |
- |
vmconfig |
MIQExtract |
MIQExtract |
Some restrictions of Smart State Analysis
After exploring Smart State Analysis, restrictions were found, and these restrictions are not documented. More about them:
1. System of Smart State Analysis supports scanning of files with network configuration in OS:
Redhat, Ubuntu and Fedora and emulator Herkules.2. System of Smart State Analysis checks only network interface(
ifcfg-eth0).3. If in configuration file parameters are with
'', System of Smart State Analysis won't parse it correctly.The solution of required tasks is creation of extensions of standart functions. Look at new custom functions, which are based on function
networking_redhat:-
networking_custom-
dhcp_configuration---
SUSEIFCFGFILE = "/etc/sysconfig/network/"
SUSEDHCLIENTFILE = "/var/lib/dhcpcd/"
REDHATIFCFGFILE = "/etc/sysconfig/network-scripts/"
REDHATDHCLIENTFILE = "/var/lib/dhclient/"
def self.dhcp_configuration(ifcfg, attrs, fs)
dhcpcfg = "dhcpcd-eth" + ifcfg.delete("ifcfgeth-") +".info"
self.read_file(fs,File.join(SUSEDHCLIENTFILE, dhcpcfg)) do |line|
case line
when /^\s*IPADDR\s*=\s*(.*)$/ then attrs[:ipaddress] = $1
when /^\s*NETMASK\s*=\s*(.*)$/ then attrs[:subnet_mask] = $1
when /^\s*BROADCAST\s*=\s*(.*)$/ then attrs[:broadcast] = $1
when /^\s*NETWORK\s*=\s*(.*)$/ then attrs[:network] = $1
when /^\s*GATEWAYS\s*=\s*(.*)$/ then attrs[:default_gateway] = $1
when /^\s*DNSDOMAIN\s*=\s*(.*)$/ then attrs[:domain] = $1
when /^\s*DNSSERVERS\s*=\s*(.*)$/ then attrs[:dns_server] = $1
when /^\s*DHCPSIADDR\s*=\s*(.*)$/ then attrs[:dhcp_server] = $1
end
end
if (attrs.has_key?(:dhcp_server)==false)
self.read_file(fs,File.join(REDHATDHCLIENTFILE, "dhclient.leases")) do |line|
case line
when /^\s*fixed-address\s*(.*)\;$/ then attrs[:ipaddress] = $1
when /^\s*option subnet-mask\s*(.*)\;$/ then attrs[:subnet_mask] = $1
when /^\s*option routers\s*(.*)\;$/ then attrs[:default_gateway] = $1
when /^\s*option domain-name-servers\s*(.*)\;$/ then attrs[:dns_server] = $1
when /^\s*option dhcp-server-identifier\s*(.*)\;$/ then attrs[:dhcp_server] = $1
when /^\s*option domain-name\s*"*(.*)"\;$/ then attrs[:domain] = $1
when /^\s*expire\s*[0-9]?\s*(.*)\;$/ then attrs[:lease_expires] = $1
when /^\s*renew\s*[0-9]?\s*(.*)\;$/ then attrs[:lease_obtained] = $1
end
end
end
attrs
end
def self.networking_custom(fs,attrs,os)
ifcfg = "ifcfg-eth"
if (os.eql?("suse"))
ifcfgfile = SUSEIFCFGFILE
elsif (os.eql?("redhat") || os.eql?("fedora"))
ifcfgfile = REDHATIFCFGFILE
end
for i in 0..20
ifcfg_i = ifcfg + i.to_s
self.read_file(fs,File.join(ifcfgfile, ifcfg_i)) do |line|
case line
when /^\s*BOOTPROTO='?dhcp'?\s*(.*)$/ then attrs[:dhcp_enabled] = 1
when /^\s*BOOTPROTO='?static'?\s*(.*)$/ then attrs[:dhcp_enabled] = 0
when /^\s*DEVICE\s*=\s*(.*)$/ then attrs[:device] = $1
when /^\s*HWADDR\s*=\s*(.*)$/ then attrs[:hwaddr] = $1
when /^\s*IPADDR\s*=\s*(.*)$/ then attrs[:ipaddress] = $1
when /^\s*NETMASK\s*=\s*(.*)$/ then attrs[:subnet_mask] = $1
when /^\s*BROADCAST\s*=\s*(.*)$/ then attrs[:broadcast] = $1
when /^\s*NETWORK\s*=\s*(.*)$/ then attrs[:network] = $1
end
end
if (attrs.has_key?(:dhcp_enabled)==true) then
break
end
end
if (attrs[:dhcp_enabled] == 1)
attrs = self.dhcp_configuration(ifcfg, attrs,fs)
end
self.fix_attr_values(attrs)
attrs
end
- Function
self.networking_custom finds first network interface with BOOTPROTO value (first configured interface)- If
BOOTPROTO=dhcp, then discover DHCP configuration with dhcp_configuration function, currently dhcpd and dhclient supported..png)
1 comments: