Skip to content

Ui refactor #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions unifiedstack/codebase/UnifiedStack/config/Config_Parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ def get_systems_data():
sys_node.port = other_fields[2]
sys_node.interface = other_fields[3]
sys_node.profile_name = other_fields[4]
sys_node.power_user = other_fields[5]
sys_node.power_password = other_fields[6]
sys_node.power_address = other_fields[7]
sys_node.power_type = Config.get_cobbler_field("power_type")
sys_node.power_proxy = Config.get_cobbler_field("http_proxy_ip")
#sys_node.power_user = other_fields[5]
#sys_node.power_password = other_fields[6]
#sys_node.power_address = other_fields[7]
#sys_node.power_type = Config.get_cobbler_field("power_type")
#sys_node.power_proxy = Config.get_cobbler_field("http_proxy_ip")
sys_nodes.append(sys_node)

str_nodes = Config.get_field("Cobbler-Configuration", "network-hosts")
Expand All @@ -126,11 +126,11 @@ def get_systems_data():
sys_node.port = other_fields[2]
sys_node.interface = other_fields[3]
sys_node.profile_name = other_fields[4]
sys_node.power_user = other_fields[5]
sys_node.power_password = other_fields[6]
sys_node.power_address = other_fields[7]
sys_node.power_type = Config.get_cobbler_field("power_type")
sys_node.power_proxy = Config.get_cobbler_field("http_proxy_ip")
#sys_node.power_user = other_fields[5]
#sys_node.power_password = other_fields[6]
#sys_node.power_address = other_fields[7]
#sys_node.power_type = Config.get_cobbler_field("power_type")
#sys_node.power_proxy = Config.get_cobbler_field("http_proxy_ip")
sys_nodes.append(sys_node)
return sys_nodes

Expand Down
107 changes: 46 additions & 61 deletions unifiedstack/codebase/UnifiedStack/data_static/unified_stack.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,95 +6,80 @@ pool-id:
hostname-port-mapping-1:
hostname-port-mapping-2:
hostname-port-mapping-3:
rhel-image-url:192.168.211.131:8000/rhel-server-7.0-x86_64-dvd.iso
rhel-image-url:http://192.168.24.9:8000/RHEL1.iso


[Authentication]

[Cobbler-Configuration]
compute-hosts: crhel1(19.19.150.2;88:5a:92:f6:e1:9e;ethernet1/3;enp1s0f0;prof1;admin;Cisco12345;19.19.100.1)
network-hosts: nrhel1(19.19.150.3;78:da:6e:98:60:3a;ethernet1/4;enp1s0f0;prof2;admin;password;19.19.100.2)
compute-hosts: crhel1(192.168.131.201;00:25:B5:6A:00:00;ethernet1/1;enp6s0;prof1)
network-hosts: nrhel1(192.168.131.202;00:25:B5:6A:00:06;ethernet1/1;enp6s0;prof2)
profiles: prof1(RHELx86_64), prof2(RHELx86_64)
distro_name=RHELx86_64
cobbler_interface= eno16777736
cobbler_interface= enp6s0
cobbler_netmask= 255.255.255.0
cobbler_server = 192.168.211.131
cobbler_next_server = 192.168.211.131
cobbler_subnet = 192.168.211.0
cobbler_option_router = 192.168.211.2
cobbler_DNS = 192.168.211.131
cobbler_server = 192.168.131.200
cobbler_next_server = 192.168.131.200
cobbler_subnet = 192.168.131.0
cobbler_option_router = 192.168.131.254
cobbler_DNS = 72.163.128.140
cobbler_hostname= buildserver
cobbler_web_username= cobbler
cobbler_web_password= cobbler
redhat_username= rahuupad2
redhat_password= iso*help123
redhat_pool= 8a85f98444de1da50144e5c4aeae67d0
http_proxy_ip=19.19.0.253
https_proxy_ip=19.19.0.253
https_port=80
http_proxy_ip=""
https_proxy_ip=""
https_port=""
power_type=ipmilan

[FI-Configuration]
fi-cluster-ip-address = 19.19.102.10
fi-cluster-username = fun
fi-cluster-password = Cisco12345
fi-server-ports:15, 16
fi-uplink-ports: 20
fi-slot-id: 1
fi-slot-1-ports: 15, 16
fi-uuid-pool-name: UUID-Test
fi-uuid-pool-start: 0000-000000000001
fi-uuid-pool-end: 0000-0000000003E8
fi-mac-pool-name: MAC_A
fi-mac-pool-start: 00:25:B5:6A:00:00
fi-mac-pool-end: 00:25:B5:6A:03:E7
fi-vnic-1-name:tenant
fi-vnic-1-vlan-range: 2-10
fi-vnic-2-name: internal
fi-vnic-2-vlan-range: 172
fi-vnic-3-name: management
fi-vnic-3-vlan-range: 19
fi-service-profile-name: demoLS
fi-cluster-ip-address = 192.168.131.65
fi-cluster-username = satroutr
fi-cluster-password = S6T8UB1i
fi-server-ports = 1,2
fi-uplink-ports = 20
fi-slot-id = 1
fi-slot-1-ports = 1,2
fi-uuid-pool-name = UUID-Test
fi-uuid-pool-start = 0000-000000000001
fi-uuid-pool-end = 0000-0000000003E8
fi-mac-pool-name = MAC_A
fi-mac-pool-start = 00:25:B5:6A:00:00
fi-mac-pool-end = 00:25:B5:6A:03:E7
fi-vnic-1-name = tenant
fi-vnic-1-vlan-range = 1000-1010
fi-vnic-2-name = internal
fi-vnic-2-vlan-range = 172
fi-vnic-3-name = management
fi-vnic-3-vlan-range = 131
fi-service-profile-name = demoLS



[Switch-Configuration]
Available-Switches: 3750, 9K
3750-ip-address:10.106.16.253
3750-password:1@#$sDu%^7
3750-username:sdu
9k-ip-address: 19.19.0.3
9k-username: admin
9k-password: Cisco123

[Switch-3750]
hostname: SDU-3750-1
username: sdu
password: 1@#$sDu%^7
# vlan(ip; subnet)
vlans: 19(19.19.0.1; 255.255.0.0), 172(172.16.10.1; 255.255.0.0), 300(10.106.16.253; 255.255.255.224)
# Interface(description; vlan)
access-interfaces: Gi1/0/3(to 19.19.100.1; 19), Gi1/0/4(to 19.19.100.2; 19), Gi1/0/5(to 19.19.100.3; 19), Gi1/0/6(to 19.19.100.4; 19), Gi1/0/7(to 19.19.100.5; 19), Gi1/0/8(to 19.19.100.6; 19), Gi1/0/14(<<==Connected to 2960-1==>>; 300), Gi1/0/48(<<==Connected to uplink==>>; 300),
trunk-interfaces: Gi1/0/13(<<==Connected to 3750-2==>>), Port-channel1
portchannel-labels: 1
portchannel-1-interfaces: Gi1/0/35, Gi1/0/36, Gi1/0/37, Gi1/0/38
default-route: 10.106.16.225
Available-Switches: 9K
9k-ip-address: 192.168.131.225
9k-username: satroutr
9k-password: S6T8UB1i

[Switch-9K]
hostname: sdu-n9396
username: admin
password: Cisco123
trunk-interfaces: Ethernet1/1, Ethernet1/2, Ethernet1/3, Ethernet1/4, Ethernet1/5, Ethernet1/6, Ethernet1/7
hostname: cvf13-leaf-2
username: satroutr
password: S6T8UB1i
trunk-interfaces: Ethernet1/41, Ethernet1/42, Ethernet1/43, Ethernet1/44, Ethernet1/45, Ethernet1/46, Ethernet1/47, Ethernet1/48
vrf: management
vlan: 19, 50-100
vlan: 1,131,1001,1500
# interface(ip/subnet)
management-interface: mgmt0(19.19.0.3; 255.255.0.0)
management-interface: mgmt0(192.168.131.225; 255.255.0.0)

[Packstack-Configuration]
compute-hosts: 19.19.150.2
network-hosts:19.19.150.3
compute-hosts: 192.168.131.201
network-hosts:192.168.131.202
keystone-admin-pw: Cisco12345
enable-openvswitch: True
enable-cisconexus: True
vlan-mapping-ranges: physnet:2100:2999
vlan-mapping-ranges: physnet:1000:1500


4 changes: 2 additions & 2 deletions unifiedstack/codebase/UnifiedStack/fi/FI_Config_Parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

class FIConfig:
config = ConfigParser.ConfigParser()
config.read(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + '\..\config\unified_stack.cfg')

config.read(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) + '/../data_static/unified_stack.cfg')
#config.read("//root/UnifiedStack/UnifiedStack/fi/unified_stack.cfg")

@staticmethod
def get_field(field):
Expand Down
18 changes: 9 additions & 9 deletions unifiedstack/codebase/UnifiedStack/integrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import inspect
import time

root_path = os.path.abspath(r"..")
root_path = os.path.abspath(r"../..")
sys.path.append(root_path)

# Hardcoded Values
Expand All @@ -27,12 +27,12 @@
MAX_TRIES = 5

#from UnifiedStack.cimc import CIMC_Setup as cimc
from UnifiedStack.masternode import cobbler_integrator as cobb
from UnifiedStack.packstack import Packstack_Setup as pst
from UnifiedStack.cli import Shell_Interpretter as shi
from UnifiedStack.cli import Console_Output as cli
from UnifiedStack.config import Config_Parser
from UnifiedStack.fi import FI_Configurator
from codebase.UnifiedStack.masternode import cobbler_integrator as cobb
from codebase.UnifiedStack.packstack import Packstack_Setup as pst
from codebase.UnifiedStack.cli import Shell_Interpretter as shi
from codebase.UnifiedStack.cli import Console_Output as cli
from codebase.UnifiedStack.config import Config_Parser
from codebase.UnifiedStack.fi import FI_Configurator
# To Add
#name, purpose(networker, compute), os -> name of system
#system, rhel img (access.redhat)(http server), hostname port
Expand Down Expand Up @@ -76,7 +76,7 @@ def configure_packstack(self, shell, console):
packstack_config.configure_packstack(console)

def configure_switch(self, shell, console):
from UnifiedStack.netswitch import Switch_Setup as sw
from codebase.UnifiedStack.netswitch import Switch_Setup as sw
sw_config = sw.SwitchConfigurator()
sw_config.configure_switch(console)

Expand All @@ -98,7 +98,7 @@ def configure_unifiedstack(self):
# self.configure_cobbler_preboot(shell, console)
#if(runstatus <= 1):

ficonfig = FIConfigurator()
ficonfig = FI_Configurator.FIConfigurator()
ficonfig.configure_fi_components()

shell.execute_command("yum install python-devel python-paramiko -y")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import os
import sys

root_path = os.path.abspath(r"../..")
sys.path.append(root_path)
#root_path = os.path.abspath(r"../../../..")
#sys.path.append(root_path)

from UnifiedStack.config.Config_Parser import Config
from codebase.UnifiedStack.config.Config_Parser import Config


class Build_Server():
Expand Down Expand Up @@ -43,12 +43,12 @@ def create_system(self,systems):
ipaddress = system.ip_address
interface = system.interface
profile = system.profile_name
proxy=system.http_proxy_ip + '80'
proxy=None #system.http_proxy_ip + '80'
#power_id= system.power_id
power_type=system.power_type
power_user=system.power_user
power_pass=system.power_password
power_addr=system.power_address
power_type=None #system.power_type
power_user=None #system.power_user
power_pass=None #system.power_password
power_addr=None #system.power_address
name = '' + hostname + "-" + purpose

handle = syst.New_system(name=name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
root_path = os.path.abspath(r"../..")
sys.path.append(root_path)

from UnifiedStack.config.Config_Parser import Config
from codebase.UnifiedStack.config.Config_Parser import Config
from general_utils import shell_command

class Cobbler_Integrator():
Expand Down Expand Up @@ -57,6 +57,7 @@ def cobbler_preInstall(self,console,redhat_username,redhat_password,redhat_pool,
cobbler_preInstall.enable_repos(console,redhat_username,redhat_password,redhat_pool)
cobbler_preInstall.install_prerequistes()
cobbler_preInstall.disable_SELinux(console)
shell_command("reboot")
#cobbler_preInstall.enable_networking(console)
#cobbler_preInstall.add_name_server(console)

Expand Down Expand Up @@ -85,8 +86,9 @@ def cobbler_postInstall(self,console,cobbler_interface,cobbler_netmask,cobbler_s
continue
towrite.append(line)
if '%post' in line:
towrite.append(
"subscription-manager config --server.proxy_hostname=" + http_proxy_ip + " --server.proxy_port=80 \n")
if http_proxy_ip!='':
towrite.append(
"subscription-manager config --server.proxy_hostname=" + http_proxy_ip + " --server.proxy_port=80 \n")
towrite.append(
"subscription-manager register --username=" +
redhat_username +
Expand All @@ -96,9 +98,12 @@ def cobbler_postInstall(self,console,cobbler_interface,cobbler_netmask,cobbler_s
"\nsubscription-manager subscribe --pool=" +
redhat_pool + "\n")
#TO DO REMOVE HARD CODING
towrite.append("/usr/bin/echo 'export http_proxy=http://" + http_proxy_ip + ":80' >> /etc/bashrc\n")
towrite.append("/usr/bin/echo 'export https_proxy=https://" + https_proxy_ip + ":" + https_port + "' >> /etc/bashrc\n")
towrite.append("/usr/bin/echo \"export no_proxy=`echo " + get_no_proxy_string(cobbler_subnet,cobbler_netmask) + " | sed 's/ /,/g'`\" >> /etc/bashrc\n")
if http_proxy_ip!='':
towrite.append("/usr/bin/echo 'export http_proxy=http://" + http_proxy_ip + ":80' >> /etc/bashrc\n")
if https_proxy_ip!='':
towrite.append("/usr/bin/echo 'export https_proxy=https://" + https_proxy_ip + ":" + https_port + "' >> /etc/bashrc\n")
if http_proxy_ip!='':
towrite.append("/usr/bin/echo \"export no_proxy=`echo " + get_no_proxy_string(cobbler_subnet,cobbler_netmask) + " | sed 's/ /,/g'`\" >> /etc/bashrc\n")
#towrite.append("/usr/bin/echo 'printf -v no_proxy '%s,' 19.19.{0..255}.{0..255}' >> /etc/bashrc\n")
#towrite.append("/usr/bin/echo 'export no_proxy=${no_proxy%,}' >> /etc/bashrc\n")
towrite.append("/usr/bin/echo 'nameserver " + nameserver + "' >> /etc/resolv.conf\n")
Expand All @@ -121,7 +126,10 @@ def cobbler_postInstall(self,console,cobbler_interface,cobbler_netmask,cobbler_s
shell_command("cobbler sync")
time.sleep(5)
shell_command("systemctl restart xinetd.service")
result=handle.power_cycle_systems(systems=systems)
#If C-series the this
#result=handle.power_cycle_systems(systems=systems)
#else if B-series
#call fi- module to power cycle
time.sleep(400)
handle.disable_netboot_systems(systems=systems)
console.cprint_progress_bar("Task Completed",100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

root_path = os.path.abspath(r"../..")
sys.path.append(root_path)
from UnifiedStack.config.Config_Parser import Config
from codebase.UnifiedStack.config.Config_Parser import Config


def enable_repos(console,redhat_username,redhat_password,redhat_pool):
Expand Down Expand Up @@ -51,9 +51,10 @@ def install_prerequistes():
shell_command("pushd /root/pip-1.2.1; python setup.py install; popd")
shell_command("pip install django==1.7")
shell_command("pip install djangorestframework")
shell_command("wget https://communities.cisco.com/servlet/JiveServlet/download/36899-13-76835/UcsSdk-0.8.3.tar.gz -O /root/UcsSdk-0.8.3.tar.gz")
shell_command("tar -zxvf /root/UcsSdk-0.8.3.tar.gz -C /root/")
shell_command("pushd /root/UcsSdk-0.8.3; python setup.py install; popd")
shell_command("wget https://communities.cisco.com/servlet/JiveServlet/download/36899-13-76835/UcsSdk-0.8.2.tar.gz -O /root/UcsSdk-0.8.3.tar.gz")
shell_command("tar -zxvf /root/UcsSdk-0.8.2.tar.gz -C /root/")
shell_command("pushd /root/UcsSdk-0.8.2; python setup.py install; popd")



def disable_SELinux(console):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
sys.path.append(root_path)


from UnifiedStack.config.Config_Parser import Config
from codebase.UnifiedStack.config.Config_Parser import Config


def cobbler_setup(console,cobbler_interface,cobbler_netmask,cobbler_server,cobbler_next_server,\
Expand Down Expand Up @@ -137,7 +137,7 @@ def mount(console,rhel_image_url):
"""Here goes the code to wget the rhel image in the /root directory"""
shell_command("mkdir -p /var/www/cobbler/images/RHEL")
#console.cprint_progress_bar("Downloading the rhel-image Mounting the RHEL iso to /root/rhel_mount ",85)
shell_command("wget " + rhel_image_url + " -O /root/rhel-server-7.0-x86_64-dvd.iso ")
#shell_command("wget " + rhel_image_url + " -O /root/rhel-server-7.0-x86_64-dvd.iso ")
shell_command(
"mount -t iso9660 /root/rhel-server-7.0-x86_64-dvd.iso /var/www/cobbler/images/RHEL")
shell_command("cp -rf /var/www/cobbler/images/RHEL/images/pxeboot /var/lib/tftpboot/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import sys
root_path = os.path.abspath(r"../..")
sys.path.append(root_path)
from UnifiedStack.cli import Shell_Interpretter as shi
from codebase.UnifiedStack.cli import Shell_Interpretter as shi

class bcolors:
HEADER = '\033[95m'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
root_path = os.path.abspath(r"../..")
sys.path.append(root_path)

from UnifiedStack.config import Config_Parser
from codebase.UnifiedStack.config import Config_Parser
# Alias for simple usage of Config parser
Config = Config_Parser.Config

Expand Down
4 changes: 2 additions & 2 deletions unifiedstack/codebase/UnifiedStack/netswitch/Switch_Setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
root_path = os.path.abspath(r"../..")
sys.path.append(root_path)

from UnifiedStack.cli import Console_Output as con
from codebase.UnifiedStack.cli import Console_Output as con
from Switch_Config_Generator import SwitchConfigGenerator
from UnifiedStack.config import Config_Parser as cfg
from codebase.UnifiedStack.config import Config_Parser as cfg
import paramiko
# Alias for config parser
Config = cfg.Config
Expand Down
Loading