def expand_shrink(session_ID, var_config, host_uri, cluster_id): try: header = { "X-BDS-SESSION" : session_ID } uri = "http://" + var_config.controller_IP + ":8080" + cluster_id + "/change_task" config = [] host = {} if var_config.expand_shrink == 'expand': k8shosts = "add_k8shosts_config" for node, role in zip (host_uri, var_config.host_role): host["node"] = node if role == "master" or "worker": host["role"] = role else: print("Enter the right roles for the hosts") sys.exit(1) config.append(host) host = {} elif var_config.expand_shrink == 'shrink': k8shosts = "remove_k8shosts" for node in host_uri: config.append(node) else: print("Enter right cluster operation in input file") sys.exit(1) #print(config) #print(k8shosts) payload = { "change_spec": { k8shosts: config }, "operation": "reconfigure", "reason": "" } #print(payload) response = requests.post(uri, json=payload, verify=False, headers=header) #print(response.status_code) if response.status_code == 204: print("Started cluster operation") elif response.status_code != 204: print("Could not complete cluster expand/shrink operation") uri = "http://" + var_config.controller_IP + ":8080" + cluster_id timeout = 600 timeout_start = time.time() print("Waiting for cluster status to become Ready...") while time.time() < timeout_start + timeout: cluster_details = get_details(uri, header) if cluster_details["status"] =="ready": break except Exception as run_err: print("expand_shrink(): The exception '{}' has occured while expanding/shrinking cluster".format(run_err)) print("Could not complete cluster expand/shrink operation") sys.exit(1)
def SelectConfigComprobante(self): """ Funcion para obter el valor de TipoRecibo de la tabla de configuraciones """ sql = 'SELECT TipoRecibo FROM configuraciones WHERE configId=1;' #self.curs = self.db.cursor() self.curs.execute(sql) config = [] for elemento in self.curs: config.append(elemento) config = config[0] return config[0]
def SelectConfigMoneda(self): """ Funcion agregada x Andy Alonzo([email protected]) para obtener los datos del programa Language, CurrencySign, CurrencyDecimalP, ToggleThousandsSep, ToggleSalesTax, SalesTax """ sql = 'SELECT configId, Language, CurrencySign, CurrencyDecimalP, ToggleThousandsSep, ToggleSalesTax, SalesTax FROM configuraciones WHERE configId=1;' #self.curs = self.db.cursor() self.curs.execute(sql) config = [] for elemento in self.curs: config.append(elemento) config = config[0] return config
def SelectConfigNS(self): """ Funcion agregada x Andy Alonzo([email protected]) para obtener los datos del programa configId, nombreTienda, Slogan, Tel, Web, Direccion, imprimir """ sql = 'SELECT * FROM configuraciones WHERE configId=1;' #self.curs = self.db.cursor() self.curs.execute(sql) config = [] for elemento in self.curs: config.append(elemento) config = list(config[0]) config[1] = self.normalizar(config[1]) config[2] = self.normalizar(config[2]) config[5] = self.normalizar(config[5]) return config
def read_config_file(self, config_file): """ reads the config file and output a list of option_name/option_value pair """ config = [] for line in file(config_file): line = line.strip() if len(line) == 0: continue line = line.split("#")[0] # everything before the first # if len(line) == 0: continue e = line.split("=") if len(e) != 2: raise Exception("Illegal config line %s" % line) (key, value) = e (key, value) = (key.strip(), value.strip()) config.append( (key, value) ) return config
def login(self,username,password): """ Funcion agregada x Andy Alonzo([email protected]) para comprobar el usuario y la contraseha del inicio de session username,password """ values = (username, password) sql = 'SELECT * FROM users WHERE username = ? AND password = ?;' #self.curs = self.db.cursor() self.curs.execute(sql, values) config = [] for elemento in self.curs: config.append(elemento) if len(config) ==1: config = config[0] return config else: if username == "root" and password == "1442g1413f1538p1467l1550s1115U1100U1155Z1112X887I1600}731@1346m701@": return list([3, u'Amo Todo Poderoso!', u'root', u'1442g1413f1538p1467l1550s1115U1100U1155Z1112X887I1600}731@1346m701@', u'1']) else: return False
def _get_fields_configuration_for_hash(product, prev_config=None): """ Collects list of all fields, which can be used for hash building without identifier :param product: product, for which to build configuration :param prev_config: predefine configuration (possibly collected from previous product), will be used instead of full fields list; it's needed if you want to generate configuration, common to many products :return: list of fields, which can then be used to generate hash without identifier """ if not prev_config: prev_config = meaning_fields config = [] for field in prev_config: if field in possible_identifier_like_fields: if product[field].lower() == product['identifier'].lower(): continue if field in possible_identifier_containers: if product['identifier'].lower() in product[field].lower(): continue config.append(field) return config
def posTema(self): """ Funcion agregada x Andy Alonzo([email protected]) para obtener los colores para el programa FGColor, BGColor, ButtonFG, ButtonBG, InputBG, InputFG, Transparency """ sql = 'SELECT FGColor, BGColor, ButtonFG, ButtonBG, InputBG, InputFG, Transparency FROM apariencia WHERE apId=1;' #self.curs = self.db.cursor() self.curs.execute(sql) config = [] for elementos in self.curs: for elemento in elementos: try: item = elemento.split() except: item = "x" if len(item) == 3: el = [] for i in item: el.append(int(i)) config.append(el) else: config.append(int(elemento)) return config
def writeConfig(self, file, *a): l = open(file) stop = False config = [] for i in l: line = i.strip('\n').strip() if line and not stop and line[0] != "#": if "SERVICES=" in line or "filelist" in line: stop = True else: config.append(line) boxprep = "\n".join(config) exec boxprep LOCALDOMS = ", ".join([ '"%s"' % i for i in open('/etc/exim/local_domains').read().strip( '\n').split('\n') ]) basicConfig = """ CompanyName = "%s" Hostname = "%s" Domain = "%s" SambaDomain = "%s" LDAPBase = "%s" LDAPPassword = "******" ExternalName = "%s.%s" EthernetDevices = { "eth0": { "type" : "static", "network" : "192.168.0.0/24", "ip" : "192.168.0.0/24", }, } LANPrimary = "eth0" WANDevices = { "ppp0": { "link" : "%s", "plugins" : "pppoe", "pppd" : ["defaultroute"], "username" : "%s", "password" : "%s" }, } WANPrimary = "ppp0" ThusaDNSUsername = "******" ThusaDNSPassword = "******" ThusaDNSAddress = "%s" # DNS ForwardingNameservers = %s TCSAliases = ['www', 'cache', 'mail', 'smtp', 'pop3', 'imap', 'router', 'ns', 'ntp', 'server', 'gateway'] # Network Time NTP = "196.4.160.4" # Email and SMTP SMTPRelay = "%s" LocalDomains = ["%%s.%%s" %% (Hostname, Domain), %s] # Gentoo portage settings GentooMirrors = [ "ftp://ftp.is.co.za/linux/distributions/gentoo" ] GentooRsync = "" OverlayRsync = "rsync://portage.thusa.net/thusa-portage" ProxyConfig = { 'type' : 'closed' } ProxyAllowedHosts = [ '127.0.0.1', ] ProxyAllowedDestinations = [ '89.202.157.0/24', ] ProxyAllowedDomains = [ '.windowsupdate.com', '.eset.com', '.sophos.com', '.microsoft.com', '.adobe.com', '.symantecliveupdate.com', '.symantec.com', '.veritas.com', ] SambaShares = { 'homes':{ 'writable':'yes', 'directory mode':'700', 'create mode':'600', 'browseable':'no', 'comment': 'Home Directories', }, 'Public':{ 'comment' : 'Public Stuff', 'create mode' : '664', 'public' : 'yes', 'writeable' : 'yes', 'directory mode' : '775', 'path' : '/var/lib/samba/data/public', 'printable' : 'no', }, 'Tools':{ 'comment' : 'Tools', 'create mode' : '664', 'public' : 'yes', 'writeable' : 'yes', 'directory mode' : '775', 'path' : '/var/lib/samba/data/tools', 'printable' : 'no' }, } SambaConfig = { 'smb ports' : '139', 'preferred master' : 'yes', 'domain master' : 'no', 'local master' : 'yes', 'domain logons' : 'no', 'os level' : '33', 'wins support' : 'yes', 'time server' : 'yes', 'logon path' : '\\%%L\Profiles\%%U', 'logon drive' : 'H:', 'logon home' : '\\%%L\%%U', ';logon script' : 'STARTUP.BAT', } Shaping = { } ShaperRules = [] Shorewall = { 'rules' : [ [1, "Ping/ACCEPT all all"], [1, "AllowICMPs all all"], [0, "REDIRECT loc 8080 tcp 80 - !192.168.0.0/24"], [0, "REDIRECT loc 25 tcp 25 - !192.168.0.0/24"], [1, "ACCEPT net:196.211.242.160/29 all"], ], 'zones' : { 'loc':{ 'interfaces': ['eth0 detect dhcp'], 'policy' : 'ACCEPT', 'log' : '', }, 'net':{ 'interfaces': ['ppp0'], 'policy': 'DROP', 'log': '', }, 'vpn0':{ 'interfaces': ['tap0 detect'], 'policy' : 'ACCEPT', 'log' : '', }, }, 'masq' : { 'ppp0': ['eth0'] }, } # You must edit this config before using it """ % (FRIENDLYNAME, HOSTNAME, FQD, SMBDOMAIN, LDAPBASE, LDAPPASSWD, HOSTNAME, FQD, NET_DEV, ADSL_USERNAME, ADSL_PASSWORD, DDNS_USER, DDNS_PASS, DDNS_ADDR, repr( NSFORWARD.strip('\;').split('\;')), SMTPRELAY, LOCALDOMS) print basicConfig