Remove needless files

master3.3
Mike Hiretsky 12 years ago
parent 06a1931560
commit 868aa84ca9

@ -1,373 +0,0 @@
#!/usr/bin/python
#-*- coding: utf-8 -*-
# Copyright 2012 Calculate Ltd. http://www.calculate-linux.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from suds.client import Client
from suds import WebFault
import traceback as tb
from getpass import getpass
import time, logging
import glob, os
from OpenSSL.crypto import load_certificate, FILETYPE_PEM
import re, threading
from calculate.core.client.function import *
from calculate.core.client.pid_information import *
from calculate.core.client.cert_func import *
from calculate.core.client.sid_func import *
from calculate.lib.datavars import DataVars
from calculate.api.client.client_class import HTTPSClientAuthHandler, \
HTTPSClientCertTransport
VERSION = 0.1
class Client_suds(Client):
def set_parameters (self, path_to_cert):
self.CERT_FILE = path_to_cert + 'client.crt'
self.CERT_PEM = path_to_cert + 'client.pem'
self.REQ_FILE = path_to_cert + 'client.csr'
self.PKEY_FILE = path_to_cert + 'client.key'
self.SID_FILE = path_to_cert + 'sid.int'
t = time
help_ = '''
useradd, cl-unix-useradd - add unix user
say, say_hello - server function
halt, server_shutdown - shutdown server
run, server_start - start server
---- process methods ----
lsp, list-pid - listing all pids for this session
pi, pid-info - get information about select pid (0 for all)
kill, pid-kill - kill select pid
---- sessions methods ----
lss, list-session - listing all sessions in server
si, session-info - get information about select session (sid)
lsr, list-method - listing all accessible methods
q, quit - exit
h, help - display this help and exit
v, version - output version information and exit'''
#class NewType:
#def __init__ (self, a, b):
#self.a = int(a)
#self.b = str(b)
def client_say_hello(client):
#try:
name2 = raw_input ("Enter your name: ")
times = raw_input ("Enter number repeating (1-100): ")
if (not name2.isalpha()):
print "Name input Error!"
return 2
try:
times = int(times)
except:
print "Number repeating input Error!"
return 2
if times < 1 or times > 100:
print "Number repeating must be > 0 and < 100"
return 2
#get cert & sid
#try:
c_s = get_cert_sid(client.CERT_FILE, client.SID_FILE)
#name = client.factory.create('s1:NewType')
#name4 = client.factory.create('s1:UserInfoValue')
#name.helper = 4
#name4.table.name = name2
#name4.table.surname = "fadf"
#name.value = name4
#a = 3
name = client.factory.create('s0:stringArray')
name['string'] = [name2,"BBBBBBB"]
s = client.service.say_hello(c_s[0], c_s[1], name, times)
#print s.helper
#print dir (s.value)
#print s.value.data.name
#except:
#print "Connection error! "
#return 1
try:
if s[1][0] == "Permission denied":
print s[1][0], s[1][1]
return 3
except:
return 0
def client_login (client):
login = raw_input ("Login: ")
password = raw_input ("password: ")
try:
name_re = re.compile("[^a-zA-Z_]")
if name_re.findall(login):
print "input error"
return 2
param = ""
print login, password
print client.service.cl_login(login = login, password = password)
except:
print "create error"
def client_useradd (client):
user_name = raw_input ("User name: ")
try:
name_re = re.compile("[^a-zA-Z_]")
if name_re.findall(user_name):
print "input error"
return 2
param = ""
print client.service.cl_unix_useradd(param = user_name)
except:
print "create error"
def client_userdel (client):
user_name = raw_input ("User name: ")
try:
name_re = re.compile("[^a-zA-Z_]")
if name_re.findall(user_name):
print "input error"
return 2
param = ""
print client.service.cl_unix_userdel(param = user_name)
except:
print "deleted error"
def client_shut (client):
import soaplib
try:
temp = client.service.server_shutdown()
if ( temp == 1):
print "Server shutting down..."
except:
print "Connection error! "
return 1
def client_signal(client):
while True:
time.sleep(5)
if os.path.exists(client.SID_FILE) :
fi = open(client.SID_FILE, 'r')
temp = fi.read()
fi.close()
sid = int(temp)
else:
sid = 0
reply = client.service.active_client(sid)
import argparse
def parse():
parser = argparse.ArgumentParser()
parser.add_argument(
'-p', '--port', type=int, default = '8888', dest='port',
help='port number')
parser.add_argument(
'--script', type=str, default = '/Server', dest='script_name',
help='name script in server')
parser.add_argument(
'--host', type=str, default = 'localhost', dest='host',
help='host destination')
parser.add_argument(
'--cert-path', type=str,
default = '~/.calculate/client_cert/',
nargs ='?', dest='path_to_cert',
help='path to cert and key file')
return parser.parse_args()
#url = 'http://localhost:8888/TestService/?wsdl'
def https_server(client, signaling):
global url
client_post_auth(client)
signaling.start()
client_list_methods(client)
sid = get_sid(client.SID_FILE)[1]
print client.service.install_system_view(sid ,0)
installInfo = create_obj(client,"install_system")
for params in [
# ("cl-install -d /dev/sda3:/:reiserfs:format -d /dev/sda5:/var/calculate:ext4:noformat",
# listToArrayArray(client,
# [["/dev/sda3","/","reiserfs","format"],
# ["/dev/sda5","/var/calculate","ext4","noformat"]])),
# ("cl-install -d /dev/sda3:swap -d /dev/sda5:/var/calculate:ext4:noformat",
# listToArrayArray(client,
# [["/dev/sda3","swap"],
# ["/dev/sda5","/var/calculate","ext4","noformat"]])),
# ("cl-install -d /var/calculate/home:/home -d /dev/sda5:/var/calculate:ext4:noformat",
# listToArrayArray(client,
# [["/var/calculate/home","/home"],
# ["/dev/sda5","/var/calculate","ext4","noformat"]])),
# ("cl-install -d /dev/sda10:/ -d /var/calculate/home:/home -d /dev/sda5:/var/calculate:ext4:noformat",
# listToArrayArray(client,
# [["/dev/sda10","/"],
# ["/var/calculate/home","/home"],
# ["/dev/sda5","/var/calculate","ext4","noformat"]])),
# ("cl-install -d /dev/sda4:/ -d /var/calculate/home:/home -d /dev/sda5:/var/calculate:ext4:noformat",
# listToArrayArray(client,
# [["/dev/sda4","/"],
# ["/var/calculate/home","/home"],
# ["/dev/sda5","/var/calculate","ext4","noformat"]])),
# ("cl-install -d /dev/sr0:/ -d /var/calculate/home:/home -d /dev/sda5:/var/calculate:ext4:noformat",
# listToArrayArray(client,
# [["/dev/sr0","/"],
# ["/var/calculate/home","/home"],
# ["/dev/sda5","/var/calculate","ext4","noformat"]])),
# ("cl-install -d /var/calculate/home:/home -d /home:/test",
# listToArrayArray(client,
# [["/var/calculate/home","/home"],
# ["/home","/test"]])),
# ("cl-install -d var/calculate/home:/home -d /home2:test",
# listToArrayArray(client,
# [["var/calculate/home","/home"],
# ["/home2","test"]])),
# ("cl-install -d /dev/sda2:/ -d /dev/sda2:/var/calculate",
# listToArrayArray(client,
# [["/dev/sda2","/"],
# ["/dev/sda2","/var/calculate"]])),
# ("cl-install -d /dev/sda2:/ -d /dev/sda2:/var/calculate",
# listToArrayArray(client,
# [["/dev/sda2","/"],
# ["/dev/sda3","/"]])),
# ("cl-install -d /dev/sda2:/ -d /dev/sda5:/var/calculate",
# listToArrayArray(client,
# [["/dev/sda2","/"],
# ["/dev/sda5","/var/calculate"]])),
# ("cl-install -d /dev/sda3:/:vfat -d /dev/sda5:/var/calculate",
# listToArrayArray(client,
# [["/dev/sda3","/","vfat"],
# ["/dev/sda5","/var/calculate"]])),
# ("cl-install -d /dev/sda3:/:ntfs -d /dev/sda2:/var/calculate:ext3",
# listToArrayArray(client,
# [["/dev/sda3","/","ntfs"],
# ["/dev/sda2","/var/calculate","ext3"]])),
# ("cl-install -d /dev/sda3:/:flaksjdf -d /dev/sda5:/var/calculate",
# listToArrayArray(client,
# [["/dev/sda3","/","flaksjdf"],
# ["/dev/sda5","/var/calculate"]])),
("cl-install -d /dev/sda3:/ -d /dev/sda5:/var/calculate",
listToArrayArray(client,
[["/dev/sda3","/"],
["/dev/sda5","/var/calculate"]]),
listToArray(client,["falksdjflkasd"])),
("cl-install -d /dev/sda3:/:flaksjdf -d /dev/sda5:/var/calculate",
listToArrayArray(client,
[["/dev/sda3","/","flaksjdf"],
["/dev/sda5","/var/calculate"]]),
listToArray(client,["/dev/sda"])),
]:
print params[0]
installInfo.disk = params[1]
if len(params) > 2:
installInfo.mbr = params[2]
errs = client.service.install_system(sid,installInfo,True)
if errs:
for err in errs[0]:
print "Wrong value for '%s':%s"%(err.name,err.message)
def main():
clear()
#password = getpass(prompt="Password: ")
logging.basicConfig(level=logging.FATAL)
logging.getLogger('suds.client').setLevel(logging.FATAL)
logging.getLogger('suds.transport').setLevel(logging.FATAL)
logging.getLogger('suds.transport.http').setLevel(logging.FATAL)
#fmt = '%(asctime)s [%(levelname)s] %(funcName)s() @%(filename)s:%(lineno)d\n%(message)s\n'
#logging.basicConfig(level=logging.INFO, format=fmt)
logging.getLogger('suds.umx.typed').setLevel(logging.ERROR)
clVars = DataVars()
clVars.flIniFile()
homePath = clVars.Get('ur_home_path')
args = parse()
port = args.port
host = args.host
path_to_cert = args.path_to_cert
path_to_cert = path_to_cert.replace("~",homePath)
script_name = args.script_name
print "wsdl is at: https://%s:%d%s/?wsdl" %(host, port, script_name)
url = "https://%s:%d%s/?wsdl" %(host, port, script_name)
try:
# client_start()
CERT_FILE = path_to_cert + 'client.crt'
CERT_PEM = path_to_cert + 'client.pem'
CERT_KEY = path_to_cert + 'client.key'
#If the certificate file is created
if os.path.exists(CERT_KEY) and \
os.path.exists(CERT_FILE):
client = Client_suds(url,\
transport = HTTPSClientCertTransport(CERT_KEY, CERT_FILE,\
path_to_cert))
#If the certificate file misses
else:
CERT_FILE = None
CERT_KEY = None
CERT_PEM = None
client = Client_suds(url,\
transport = HTTPSClientCertTransport(CERT_KEY, CERT_FILE,\
path_to_cert))
#print CERT_PEM
#print "#######################################"
#print dir (client)
#print "#######################################"
#threads = []
client.set_parameters (path_to_cert.replace("~",homePath))
signaling = threading.Thread(target=client_signal, args = (client, ))
#threads.append(signaling)
signaling.setDaemon(True)
https_server(client, signaling)
#----------------------------------------------------
except WebFault, f:
print f
print f.fault
except Exception, e:
#signaling.killed = True
print e
tb.print_exc()
if __name__=='__main__':
main()

@ -176,7 +176,7 @@ setup(
package_dir = {'calculate.install': "install"},
packages = ['calculate.install','calculate.install.variables'],
data_files = data_files,
scripts=['scripts/cl-install3'],
scripts=[],
cmdclass={'install_data': cl_install_data,
'build':build,'build_man':build_man,
'install':install,'install_man':install_man},

Loading…
Cancel
Save