Skip to content

Instantly share code, notes, and snippets.

@chewmanfoo
Created April 19, 2011 18:42
Show Gist options
  • Save chewmanfoo/929215 to your computer and use it in GitHub Desktop.
Save chewmanfoo/929215 to your computer and use it in GitHub Desktop.
builder and rendered xml
class CompleteConfigurationController < ApplicationController
def index
@carrier = Carrier.find(params[:id])
@hosts = @carrier.net_profile.network_hosts
respond_to do |wants|
wants.html
wants.xml {
render :layout => false;
response.headers["Content-Type"] = "application/xml; charset=utf-8"
}
end
end
end
====================================================================
xml.instruct!(:xml, :encoding => "UTF-8")
xml.title "PT Smart Complete Configuration V1.1"
xml.url url_for :only_path => false, :controller => 'complete_configuration'
xml.description "PT Smart OTAF Configuration Description"
xml.hosts do
@hosts.each do |host|
xml.host do
xml.name host.name
xml.dell_service_tag host.service_tag
xml.make_model host.server.name if host.server
xml.os do
xml.os_name host.os.name if host.os
xml.os_version host.os.version if host.os
end
xml.location do
xml.site host.location.name if host.location
xml.rack host.rack
xml.space host.space
end
xml.ip_addresses do
host.ip_addresses.each do |ip|
xml.ip do
xml.ip_name ip.name
xml.mac ip.mac
xml.logical_interface_name ip.logical_interface_name.name
end
end
end
xml.functions do
host.functions.each do |f|
xml.function_name f.name
end
end
end
end
end
====================================================================
<?xml version="1.0" encoding="UTF-8"?>
<title>PT Smart Complete Configuration V1.1</title>
<url>http://url.com/complete_configuration/11</url>
<description>Customer OTAF Configuration Description</description>
<hosts>
<host>
<name>ota-db1</name>
<dell_service_tag>ASDVB</dell_service_tag>
<make_model>Dell PowerEdge R610</make_model>
<os>
<os_name>CentOS x86_64</os_name>
<os_version>5.2</os_version>
</os>
<location>
<site>Data Center</site>
<rack>1</rack>
<space>16</space>
</location>
<ip_addresses>
<ip>
<ip_name>192.168.11.013</ip_name>
<mac></mac>
<logical_interface_name>bond0</logical_interface_name>
</ip>
<ip>
<ip_name>10.168.11.013</ip_name>
<mac></mac>
<logical_interface_name>drac</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.161</ip_name>
<mac></mac>
<logical_interface_name>bond0:0</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.213</ip_name>
<mac></mac>
<logical_interface_name>bond0:1</logical_interface_name>
</ip>
</ip_addresses>
<functions>
<function_name>database - reader Side A</function_name>
<function_name>database - writer Side A</function_name>
<function_name>ota database</function_name>
<function_name>support database Side A</function_name>
</functions>
</host>
<host>
<name>ota-db2</name>
<dell_service_tag>ALSOY</dell_service_tag>
<make_model>Dell PowerEdge R610</make_model>
<os>
<os_name>CentOS x86_64</os_name>
<os_version>5.2</os_version>
</os>
<location>
<site>Data Center</site>
<rack>1</rack>
<space>17</space>
</location>
<ip_addresses>
<ip>
<ip_name>192.168.11.014</ip_name>
<mac></mac>
<logical_interface_name>bond0</logical_interface_name>
</ip>
<ip>
<ip_name>10.168.11.014</ip_name>
<mac></mac>
<logical_interface_name>drac</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.162</ip_name>
<mac></mac>
<logical_interface_name>bond0:0</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.213</ip_name>
<mac></mac>
<logical_interface_name>bond0:1</logical_interface_name>
</ip>
</ip_addresses>
<functions>
<function_name>database - writer Side B</function_name>
<function_name>database - reader Side B</function_name>
<function_name>ota database</function_name>
<function_name>support database Side B</function_name>
</functions>
</host>
<host>
<name>ota-app1</name>
<dell_service_tag>QUKEIT</dell_service_tag>
<make_model>Dell PowerEdge R610</make_model>
<os>
<os_name>CentOS i386</os_name>
<os_version>5.2</os_version>
</os>
<location>
<site>Data Center</site>
<rack>1</rack>
<space>13</space>
</location>
<ip_addresses>
<ip>
<ip_name>192.168.11.011</ip_name>
<mac></mac>
<logical_interface_name>bond0</logical_interface_name>
</ip>
<ip>
<ip_name>10.168.11.011</ip_name>
<mac></mac>
<logical_interface_name>drac</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.131</ip_name>
<mac></mac>
<logical_interface_name>bond0:0</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.211</ip_name>
<mac></mac>
<logical_interface_name>bond0:1</logical_interface_name>
</ip>
</ip_addresses>
<functions>
<function_name>app server</function_name>
<function_name>control center Side A</function_name>
<function_name>otapa server</function_name>
<function_name>otasp server</function_name>
</functions>
</host>
<host>
<name>ota-app2</name>
<dell_service_tag>OKSIER</dell_service_tag>
<make_model>Dell PowerEdge R610</make_model>
<os>
<os_name>CentOS i386</os_name>
<os_version>5.2</os_version>
</os>
<location>
<site>Data Center</site>
<rack>1</rack>
<space>14</space>
</location>
<ip_addresses>
<ip>
<ip_name>192.168.11.012</ip_name>
<mac></mac>
<logical_interface_name>bond0</logical_interface_name>
</ip>
<ip>
<ip_name>10.168.11.012</ip_name>
<mac></mac>
<logical_interface_name>drac</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.132</ip_name>
<mac></mac>
<logical_interface_name>bond0:0</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.211</ip_name>
<mac></mac>
<logical_interface_name>bond0:1</logical_interface_name>
</ip>
</ip_addresses>
<functions>
<function_name>app server</function_name>
<function_name>control center Side B</function_name>
<function_name>ota app server</function_name>
</functions>
</host>
<host>
<name>fw1</name>
<dell_service_tag>HSLOER</dell_service_tag>
<make_model>Dell PowerEdge R610</make_model>
<os>
<os_name>CentOS x86_64</os_name>
<os_version>5.2</os_version>
</os>
<location>
<site>Data Center</site>
<rack>1</rack>
<space>9</space>
</location>
<ip_addresses>
<ip>
<ip_name>192.168.11.101</ip_name>
<mac></mac>
<logical_interface_name>bond1</logical_interface_name>
</ip>
<ip>
<ip_name>10.168.11.101</ip_name>
<mac></mac>
<logical_interface_name>drac</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.73.242</ip_name>
<mac></mac>
<logical_interface_name>eth2</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.70.242</ip_name>
<mac></mac>
<logical_interface_name>eth0</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.1</ip_name>
<mac></mac>
<logical_interface_name>bond1:0</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.70.241</ip_name>
<mac></mac>
<logical_interface_name>eth0:0</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.73.241</ip_name>
<mac></mac>
<logical_interface_name>eth2:0</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.70.245</ip_name>
<mac></mac>
<logical_interface_name>eth0:1</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.73.245</ip_name>
<mac></mac>
<logical_interface_name>eth2:1</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.73.247</ip_name>
<mac></mac>
<logical_interface_name>eth2</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.70.247</ip_name>
<mac></mac>
<logical_interface_name>eth0</logical_interface_name>
</ip>
</ip_addresses>
<functions>
<function_name>firewall Side A</function_name>
<function_name>app server</function_name>
<function_name>sshd port 1022</function_name>
</functions>
</host>
<host>
<name>fw2</name>
<dell_service_tag>QJIER</dell_service_tag>
<make_model>Dell PowerEdge R610</make_model>
<os>
<os_name>CentOS x86_64</os_name>
<os_version>5.2</os_version>
</os>
<location>
<site>Data Center</site>
<rack>1</rack>
<space>10</space>
</location>
<ip_addresses>
<ip>
<ip_name>192.168.11.102</ip_name>
<mac></mac>
<logical_interface_name>bond1</logical_interface_name>
</ip>
<ip>
<ip_name>10.168.11.102</ip_name>
<mac></mac>
<logical_interface_name>drac</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.73.243</ip_name>
<mac></mac>
<logical_interface_name>eth2</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.70.243</ip_name>
<mac></mac>
<logical_interface_name>eth0</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.70.241</ip_name>
<mac></mac>
<logical_interface_name>eth0:0</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.73.241</ip_name>
<mac></mac>
<logical_interface_name>eth2:0</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.1</ip_name>
<mac></mac>
<logical_interface_name>bond1:0</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.70.245</ip_name>
<mac></mac>
<logical_interface_name>eth0:1</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.73.245</ip_name>
<mac></mac>
<logical_interface_name>eth2:1</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.70.247</ip_name>
<mac></mac>
<logical_interface_name>eth0</logical_interface_name>
</ip>
<ip>
<ip_name>10.17.73.247</ip_name>
<mac></mac>
<logical_interface_name>eth2</logical_interface_name>
</ip>
</ip_addresses>
<functions>
<function_name>app server</function_name>
<function_name>firewall Side B</function_name>
<function_name>sshd port 1022</function_name>
</functions>
</host>
<host>
<name>ivr</name>
<dell_service_tag>POSLIE</dell_service_tag>
<make_model>Dell PowerEdge R610</make_model>
<os>
<os_name>CentOS i386</os_name>
<os_version>5.2</os_version>
</os>
<location>
<site>Data Center</site>
<rack>1</rack>
<space>15</space>
</location>
<ip_addresses>
<ip>
<ip_name>192.168.11.043</ip_name>
<mac></mac>
<logical_interface_name>bond0</logical_interface_name>
</ip>
</ip_addresses>
<functions>
<function_name>app server</function_name>
<function_name>ivr</function_name>
<function_name>http to https proxy</function_name>
<function_name>httpd</function_name>
</functions>
</host>
<host>
<name>spare-db</name>
<dell_service_tag>OSPOER</dell_service_tag>
<make_model>Dell PowerEdge R610</make_model>
<os>
<os_name>CentOS x86_64</os_name>
<os_version>5.2</os_version>
</os>
<location>
<site>PT Smart Billing Address</site>
<rack>1</rack>
<space>18</space>
</location>
<ip_addresses>
<ip>
<ip_name>192.168.11.250</ip_name>
<mac></mac>
<logical_interface_name>bond0</logical_interface_name>
</ip>
</ip_addresses>
<functions>
<function_name>database - reader Side A</function_name>
<function_name>database - writer Side A</function_name>
</functions>
</host>
<host>
<name>lb1</name>
<dell_service_tag>POLSUE</dell_service_tag>
<make_model>Dell PowerEdge R610</make_model>
<os>
<os_name>CentOS x86_64</os_name>
<os_version>5.2</os_version>
</os>
<location>
<site>Data Center</site>
<rack>1</rack>
<space>11</space>
</location>
<ip_addresses>
<ip>
<ip_name>192.168.11.103</ip_name>
<mac></mac>
<logical_interface_name>bond0</logical_interface_name>
</ip>
<ip>
<ip_name>10.168.11.103</ip_name>
<mac></mac>
<logical_interface_name>drac</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.230</ip_name>
<mac></mac>
<logical_interface_name>bond0:0</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.222</ip_name>
<mac></mac>
<logical_interface_name>bond0:1</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.213</ip_name>
<mac></mac>
<logical_interface_name>bond0:2</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.191</ip_name>
<mac></mac>
<logical_interface_name>bond0:3</logical_interface_name>
</ip>
<ip>
<ip_name>192.168.11.216</ip_name>
<mac></mac>
<logical_interface_name>bond0:4</logical_interface_name>
</ip>
</ip_addresses>
<functions>
<function_name>load balancer Side A</function_name>
<function_name>nagios server</function_name>
</functions>
</host>
<host>
<name>lb2</name>
<dell_service_tag>PWUEHR</dell_service_tag>
<make_model>Dell PowerEdge R610</make_model>
<os>
<os_name>CentOS x86_64</os_name>
<os_version>5.2</os_version>
</os>
<location>
<site>Data Center</site>
<rack>1</rack>
<space>12</space>
</location>
<ip_addresses>
<ip>
<ip_name>192.168.11.104</ip_name>
<mac></mac>
<logical_interface_name>bond0</logical_interface_name>
</ip>
<ip>
<ip_name>10.168.11.104</ip_name>
<mac></mac>
<logical_interface_name>drac</logical_interface_name>
</ip>
</ip_addresses>
<functions>
<function_name>load balancer Side B</function_name>
<function_name>nagios server</function_name>
</functions>
</host>
<host>
<name>tb640-a</name>
<dell_service_tag></dell_service_tag>
<make_model>TelcoBridges TB640</make_model>
<os>
<os_name>TelcoBridges</os_name>
<os_version></os_version>
</os>
<location>
<site>PT Smart Billing Address</site>
<rack>1</rack>
<space>1</space>
</location>
<ip_addresses>
<ip>
<ip_name>192.168.11.201</ip_name>
<mac></mac>
<logical_interface_name>eth0</logical_interface_name>
</ip>
</ip_addresses>
<functions>
</functions>
</host>
<host>
<name>tb640-b</name>
<dell_service_tag></dell_service_tag>
<make_model>TelcoBridges TB640</make_model>
<os>
<os_name>TelcoBridges</os_name>
<os_version></os_version>
</os>
<location>
<site>PT Smart Billing Address</site>
<rack>1</rack>
<space>3</space>
</location>
<ip_addresses>
<ip>
<ip_name>192.168.11.202</ip_name>
<mac></mac>
<logical_interface_name>eth0</logical_interface_name>
</ip>
</ip_addresses>
<functions>
</functions>
</host>
<host>
<name>siu-a</name>
<dell_service_tag></dell_service_tag>
<make_model>Dialogic</make_model>
<os>
<os_name>Dialogic SIU</os_name>
<os_version></os_version>
</os>
<location>
<site>PT Smart Billing Address</site>
<rack>1</rack>
<space>7</space>
</location>
<ip_addresses>
<ip>
<ip_name>192.168.11.241</ip_name>
<mac></mac>
<logical_interface_name>eth0</logical_interface_name>
</ip>
</ip_addresses>
<functions>
</functions>
</host>
<host>
<name>siu-b</name>
<dell_service_tag></dell_service_tag>
<make_model>Dialogic</make_model>
<os>
<os_name>Dialogic SIU</os_name>
<os_version></os_version>
</os>
<location>
<site>PT Smart Billing Address</site>
<rack>1</rack>
<space>8</space>
</location>
<ip_addresses>
<ip>
<ip_name>192.168.11.242</ip_name>
<mac></mac>
<logical_interface_name>eth0</logical_interface_name>
</ip>
</ip_addresses>
<functions>
</functions>
</host>
<host>
<name>net-swa-1</name>
<dell_service_tag></dell_service_tag>
<make_model>Juniper 24 Port TOR Switch</make_model>
<os>
<os_name>JunOS</os_name>
<os_version>10.1</os_version>
</os>
<location>
<site>PT Smart Billing Address</site>
<rack>1</rack>
<space>1</space>
</location>
<ip_addresses>
<ip>
<ip_name>10.168.11.4</ip_name>
<mac></mac>
<logical_interface_name>eth0</logical_interface_name>
</ip>
</ip_addresses>
<functions>
</functions>
</host>
<host>
<name>net-swb-1</name>
<dell_service_tag></dell_service_tag>
<make_model>Juniper 24 Port TOR Switch</make_model>
<os>
<os_name>JunOS</os_name>
<os_version>10.1</os_version>
</os>
<location>
<site>PT Smart Billing Address</site>
<rack>1</rack>
<space>2</space>
</location>
<ip_addresses>
<ip>
<ip_name>10.168.11.5</ip_name>
<mac></mac>
<logical_interface_name>eth0</logical_interface_name>
</ip>
</ip_addresses>
<functions>
</functions>
</host>
<host>
<name>PDUa</name>
<dell_service_tag></dell_service_tag>
<make_model>APC Metered PDU</make_model>
<os>
</os>
<location>
<site>PT Smart Billing Address</site>
<rack>1</rack>
<space>1</space>
</location>
<ip_addresses>
<ip>
<ip_name>10.168.11.7</ip_name>
<mac></mac>
<logical_interface_name>eth0</logical_interface_name>
</ip>
</ip_addresses>
<functions>
</functions>
</host>
<host>
<name>PDUb</name>
<dell_service_tag></dell_service_tag>
<make_model>APC Metered PDU</make_model>
<os>
</os>
<location>
<site>PT Smart Billing Address</site>
<rack>1</rack>
<space>1</space>
</location>
<ip_addresses>
<ip>
<ip_name>10.168.11.8</ip_name>
<mac></mac>
<logical_interface_name>eth0</logical_interface_name>
</ip>
</ip_addresses>
<functions>
</functions>
</host>
</hosts>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment