Commit b2bf7691 by Csók Tamás

client: linux version is made up to date

parent 3dca7160
......@@ -7,5 +7,5 @@ Comment=Tool to use IK Cloud
Exec=cloud2 %u
Icon=/usr/share/icons/cloud.svg
Terminal=true
MimeType=x-scheme-handler/rdp;x-scheme-handler/nx;x-scheme-handler/ssh;
MimeType=x-scheme-handler/circle;
Categories=Utility;Application;
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# A cloudban létrehozott virtuális gépekhez történő kapcsolódást segítő program
##
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import platform, argparse, sys, time
##
# Paraméterek átadására használt struktúra
# state A virtuális gép állapota, azt figyeljük, hogy fut-e
# protocol SSH, NX és RDP lehetséges
# host A virtuális gép címe
# port Ezen a porton csatlakozunk a virtuális géphez
# user Csatlakozáshoz használt név
# password Csatlakozáshoz használt jelszó
"""
Main program of the Client written for CIRCLE Cloud.
The Client job is to help the ease of use of the cloud system.
"""
import platform
import argparse
try:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
except ImportError:
pass
class Struct:
"""
A struct used for parameter passing
Keyword arguments:
state -- State of the Virtual Computer (running, etc..)
protocol -- SSH, NX and RDP possible
host -- Address of the Virtual Computer
port -- The port where we can access the Virtual Computer
user -- Username used for the connection
password -- Password used for the connection
"""
pass
##
# Argument parser, argparse modulon alapszik
# @return args
#
def pars_arguments():
parser = argparse.ArgumentParser();
parser.add_argument("uri", type=str, help="Specific schema handler", nargs='?', default=None)
def parse_arguments():
"""
Argument parser, based on the argparse module
Keyword arguments:
@return args -- arguments given by console
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"uri", type=str, help="Specific schema handler", nargs='?',
default=None)
parser.add_argument("-u", "--username", type=str)
parser.add_argument("-p", "--password", type=str)
parser.add_argument("-d", "--driver", help="Select webdriver. Aside from Firefox, you have to install first the proper driver.", \
type=str, choices=['firefox', 'chrome', 'ie', 'opera', 'safari'], default="firefox")
parser.add_argument("-o", "--old", help="Use old interface", action="store_true")
args = parser.parse_args();
parser.add_argument(
"-d", "--driver",
help="Select webdriver. Aside from Firefox, you have to install "
+ "first the proper driver.", type=str,
choices=['firefox', 'chrome', 'ie', 'opera'],
default="firefox")
args = parser.parse_args()
return args
class Browser:
##
# Browser inicializálás
# @param args Az args.driver paraméterrel meghatározhatjuk, melyik böngészőt akarjuk használni.
#
"""
Browser initialisation
Keyword arguments:
@param args -- args.driver tells us which installed browser
we want to use with selenium.
"""
def __init__(self, args):
self.args = args
if args.driver == "firefox":
......@@ -54,14 +73,12 @@ class Browser:
self.driver = webdriver.Ie()
elif args.driver == "opera":
self.driver = webdriver.Opera()
elif args.driver == "safari":
self.driver = webdriver.Safari()
self.driver.implicitly_wait(10)
##
# Címtáras beléptetés a parancssorban megadott paraméterek alapján
#
def login(self):
"""
Eduid login based on the given console arguments
"""
driver = self.driver
args = self.args
if args.username is not None:
......@@ -71,51 +88,36 @@ class Browser:
driver.find_element_by_name("j_password").clear()
driver.find_element_by_name("j_password").send_keys(args.password)
if args.username is not None and args.password is not None:
driver.find_element_by_css_selector("input[type='submit']").click()
driver.find_element_by_css_selector(
"input[type='submit']").click()
##
# A régi webes felület használata
# @return vm Virtuális gép csatlakozásához szükséges paraméterek
#
def old_main(self):
vm = Struct()
driver = self.driver
driver.maximize_window()
driver.get("https://cloud.ik.bme.hu/info/")
driver.find_element_by_css_selector("a[href*='/login/']").click()
self.login()
vm.state, vm.protocol = "", "NONE"
try:
while vm.state.upper()[:3] not in ("FUT", "RUN"):
element = WebDriverWait(driver, 7200).until(EC.presence_of_element_located((By.CSS_SELECTOR, "input.hidden-password.shown[type='text']")))
vm.password = element.get_attribute("value")
vm.state = driver.find_element_by_css_selector("#state > div > p").text
vm.protocol = driver.find_element_by_css_selector("#vm-credentials > div > table > tbody > tr:nth-child(1) > td").text
vm.host,vm.port = driver.find_element_by_css_selector("#vm-credentials > div > table > tbody > tr:nth-child(2) > td").text.split(':')
vm.user = driver.find_element_by_css_selector("#vm-credentials > div > table > tbody > tr:nth-child(4) > td").text
driver.find_element_by_css_selector("a[href*='/logout/']").click()
except:
print "Browser session timed out!"
return vm
##
# Az új webes felület használata
# @return vm Virtuális gép csatlakozásához szükséges paraméterek
#
def main(self):
"""
Use of the https://cloud.bme.hu/
Keyword arguments:
@return vm -- Necessarily parameters to connect
to the Virtual Machine
"""
vm = Struct()
driver = self.driver
driver.maximize_window()
driver.get("https://pc3.szgt.uni-miskolc.hu/")
#driver.find_element_by_css_selector("a[href*='/login/']").click()
#self.login()
driver.get("https://cloud.bme.hu/")
# driver.find_element_by_css_selector("a[href*='/login/']").click()
# self.login()
vm.state, vm.protocol = "", "NONE"
try:
while vm.state.upper()[:3] not in ("FUT", "RUN"):
element = WebDriverWait(driver,7200).until(EC.presence_of_element_located((By.CSS_SELECTOR, "#vm-details-pw-eye.icon-eye-close")))
vm.state = driver.find_element_by_css_selector("#vm-details-state > span").text
#cl: connection string converted to list
cl = driver.find_element_by_css_selector("#vm-details-connection-string").get_attribute("value").split()
WebDriverWait(driver, 7200).until(
EC.presence_of_element_located((
By.CSS_SELECTOR,
"#vm-details-pw-eye.fa.fa-eye-slash")))
vm.state = driver.find_element_by_css_selector(
"#vm-details-state > span").text
# cl: connection string converted to list
cl = driver.find_element_by_css_selector(
"#vm-details-connection-string").get_attribute(
"value").split()
if cl[0] == "sshpass":
vm.protocol = "SSH"
vm.user, vm.host = cl[6].split("@")
......@@ -127,36 +129,35 @@ class Browser:
driver.find_element_by_css_selector("a[href*='/logout/']").click()
except:
print "Browser session timed out!"
raise
return vm
##
# Főprogram
# beolvassuk a paramétereket
# megnyitjuk a kiválasztott böngészőben a weboldalt
# bejelentkezünk a címtárba
# kiválasztjuk a futtatni kívánt klienst
# kapcsolódunk a klienshez
def main():
args = pars_arguments()
if args.uri is not None:
vm = Struct()
vm.protocol, vm.user, vm.password, vm.host, vm.port = args.uri.split(':',4)
vm.protocol = vm.protocol.upper()
vm.state = "RUN"
else:
browser = Browser(args)
if args.old:
vm = browser.old_main()
"""
Main program
"""
try:
args = parse_arguments()
if args.uri is not None:
vm = Struct()
x, vm.protocol, vm.user, vm.password, vm.host, vm.port = \
args.uri.split(':', 5)
vm.protocol = vm.protocol.upper()
vm.state = "RUN"
else:
browser = Browser(args)
vm = browser.main()
browser.driver.quit()
if platform.system() == "Linux":
from cloud_connect_from_linux import connect
elif platform.system() == "Windows":
from cloud_connect_from_windows import connect
if vm.state.upper()[:3] in ("FUT", "RUN"):
connect(vm)
browser.driver.quit()
if platform.system() == "Linux":
from cloud_connect_from_linux import connect
elif platform.system() == "Windows":
from cloud_connect_from_windows import connect
if vm.state.upper()[:3] in ("FUT", "RUN"):
connect(vm)
except:
print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__":
main()
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import cloud
......@@ -7,4 +8,3 @@ if __name__ == '__main__':
cloud.main()
finally:
pass
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# Távoli klienshez csatlakozás linux OS alól
##
"""
Configuration of the Linux specific tools to enhance the ease of use
of the CIRCLE cloud. Handles the auto launch and auto configuration
of these specific connectivity programs.
"""
import time
import os
import subprocess
import glob
import sys, os, time, subprocess, glob
##
# A távoli klienshez csatlakozás valósítja meg
# NX és RDP esetén a remmina programot hívja meg. Ha a remmina-ban még nem szerepel
# a kliens, a program elkészíti az indításhoz szükséges profilt.
# @param vm Paraméterek a csatlakozáshoz
# vm.protocol SSH, NX és RDP lehetséges
# vm.host A virtuális gép címe
# vm.port Ezen a porton csatlakozunk a virtuális géphez
# vm.user Csatlakozáshoz használt név
# vm.password Csatlakozáshoz használt jelszó
#
def connect(vm):
"""
Handles to connection to the Virtual Machines from the local
machine
Keyword arguments:
vm.protocol -- SSH, NX and RDP possible
vm.host -- Address of the Virtual Computer
vm.port -- The port where we can access the Virtual Computer
vm.user -- Username used for the connection
vm.password -- Password used for the connection
"""
if vm.protocol == "SSH":
command = "sshpass -p %s ssh -p %s -o StrictHostKeyChecking=no %s@%s" % (vm.password, vm.port, vm.user, vm.host)
subprocess.call(command, shell=True)
......@@ -42,18 +49,12 @@ def connect(vm):
f.close()
subprocess.call(["remmina", "-c", config_file])
NX_template = """[remmina]
ssh_auth=0
quality=2
disableencryption=0
ssh_charset=
ssh_privatekey=
resolution=
group=
ssh_loopback=0
exec=
ssh_username=
ssh_server=
ssh_enabled=0
nx_privatekey=
showcursor=0
......@@ -65,24 +66,12 @@ viewmode=4
RDP_template = """[remmina]
disableclipboard=0
ssh_auth=0
clientname=
quality=2
ssh_charset=
ssh_privatekey=
console=0
resolution=
group=
ssh_loopback=0
shareprinter=0
ssh_username=
ssh_server=
security=
execpath=
sound=off
exec=
ssh_enabled=0
sharefolder=
domain=
colordepth=24
window_maximize=1
viewmode=4
......
# -*- coding: utf-8 -*-
##
# Távoli klienshez csatlakozás windows OS alól
##
##
# A távoli klienshez csatlakozás valósítja majd meg windows alól
# @param vm Paraméterek a csatlakozáshoz
# vm.protocol SSH, NX és RDP lehetséges
# vm.host A virtuális gép címe
# vm.port Ezen a porton csatlakozunk a virtuális géphez
# vm.user Csatlakozáshoz használt név
# vm.password Csatlakozáshoz használt jelszó
#
def connect(vm):
pass
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# A cloudban létrehozott virtuális gépekhez történő kapcsolódást segítő program
##
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import platform, argparse, sys, time
##
# Paraméterek átadására használt struktúra
# state A virtuális gép állapota, azt figyeljük, hogy fut-e
# protocol SSH, NX és RDP lehetséges
# host A virtuális gép címe
# port Ezen a porton csatlakozunk a virtuális géphez
# user Csatlakozáshoz használt név
# password Csatlakozáshoz használt jelszó
"""
Main program of the Client written for CIRCLE Cloud.
The Client job is to help the ease of use of the cloud system.
"""
import platform
import argparse
try:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
except ImportError:
pass
class Struct:
"""
A struct used for parameter passing
Keyword arguments:
state -- State of the Virtual Computer (running, etc..)
protocol -- SSH, NX and RDP possible
host -- Address of the Virtual Computer
port -- The port where we can access the Virtual Computer
user -- Username used for the connection
password -- Password used for the connection
"""
pass
##
# Argument parser, argparse modulon alapszik
# @return args
#
def pars_arguments():
parser = argparse.ArgumentParser();
parser.add_argument("uri", type=str, help="Specific schema handler", nargs='?', default=None)
def parse_arguments():
"""
Argument parser, based on the argparse module
Keyword arguments:
@return args -- arguments given by console
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"uri", type=str, help="Specific schema handler", nargs='?',
default=None)
parser.add_argument("-u", "--username", type=str)
parser.add_argument("-p", "--password", type=str)
parser.add_argument("-d", "--driver", help="Select webdriver. Aside from Firefox, you have to install first the proper driver.", \
type=str, choices=['firefox', 'chrome', 'ie', 'opera', 'safari'], default="firefox")
parser.add_argument("-o", "--old", help="Use old interface", action="store_true")
args = parser.parse_args();
parser.add_argument(
"-d", "--driver",
help="Select webdriver. Aside from Firefox, you have to install "
+ "first the proper driver.", type=str,
choices=['firefox', 'chrome', 'ie', 'opera'],
default="firefox")
args = parser.parse_args()
return args
class Browser:
##
# Browser inicializálás
# @param args Az args.driver paraméterrel meghatározhatjuk, melyik böngészőt akarjuk használni.
#
"""
Browser initialisation
Keyword arguments:
@param args -- args.driver tells us which installed browser
we want to use with selenium.
"""
def __init__(self, args):
self.args = args
if args.driver == "firefox":
......@@ -54,14 +73,12 @@ class Browser:
self.driver = webdriver.Ie()
elif args.driver == "opera":
self.driver = webdriver.Opera()
elif args.driver == "safari":
self.driver = webdriver.Safari()
self.driver.implicitly_wait(10)
##
# Címtáras beléptetés a parancssorban megadott paraméterek alapján
#
def login(self):
"""
Eduid login based on the given console arguments
"""
driver = self.driver
args = self.args
if args.username is not None:
......@@ -71,51 +88,36 @@ class Browser:
driver.find_element_by_name("j_password").clear()
driver.find_element_by_name("j_password").send_keys(args.password)
if args.username is not None and args.password is not None:
driver.find_element_by_css_selector("input[type='submit']").click()
driver.find_element_by_css_selector(
"input[type='submit']").click()
##
# A régi webes felület használata
# @return vm Virtuális gép csatlakozásához szükséges paraméterek
#
def old_main(self):
vm = Struct()
driver = self.driver
driver.maximize_window()
driver.get("https://cloud.ik.bme.hu/info/")
driver.find_element_by_css_selector("a[href*='/login/']").click()
self.login()
vm.state, vm.protocol = "", "NONE"
try:
while vm.state.upper()[:3] not in ("FUT", "RUN"):
element = WebDriverWait(driver, 7200).until(EC.presence_of_element_located((By.CSS_SELECTOR, "input.hidden-password.shown[type='text']")))
vm.password = element.get_attribute("value")
vm.state = driver.find_element_by_css_selector("#state > div > p").text
vm.protocol = driver.find_element_by_css_selector("#vm-credentials > div > table > tbody > tr:nth-child(1) > td").text
vm.host,vm.port = driver.find_element_by_css_selector("#vm-credentials > div > table > tbody > tr:nth-child(2) > td").text.split(':')
vm.user = driver.find_element_by_css_selector("#vm-credentials > div > table > tbody > tr:nth-child(4) > td").text
driver.find_element_by_css_selector("a[href*='/logout/']").click()
except:
print "Browser session timed out!"
return vm
##
# Az új webes felület használata
# @return vm Virtuális gép csatlakozásához szükséges paraméterek
#
def main(self):
"""
Use of the https://cloud.bme.hu/
Keyword arguments:
@return vm -- Necessarily parameters to connect
to the Virtual Machine
"""
vm = Struct()
driver = self.driver
driver.maximize_window()
driver.get("https://pc3.szgt.uni-miskolc.hu/")
#driver.find_element_by_css_selector("a[href*='/login/']").click()
#self.login()
driver.get("https://cloud.bme.hu/")
# driver.find_element_by_css_selector("a[href*='/login/']").click()
# self.login()
vm.state, vm.protocol = "", "NONE"
try:
while vm.state.upper()[:3] not in ("FUT", "RUN"):
element = WebDriverWait(driver,7200).until(EC.presence_of_element_located((By.CSS_SELECTOR, "#vm-details-pw-eye.icon-eye-close")))
vm.state = driver.find_element_by_css_selector("#vm-details-state > span").text
#cl: connection string converted to list
cl = driver.find_element_by_css_selector("#vm-details-connection-string").get_attribute("value").split()
WebDriverWait(driver, 7200).until(
EC.presence_of_element_located((
By.CSS_SELECTOR,
"#vm-details-pw-eye.fa.fa-eye-slash")))
vm.state = driver.find_element_by_css_selector(
"#vm-details-state > span").text
# cl: connection string converted to list
cl = driver.find_element_by_css_selector(
"#vm-details-connection-string").get_attribute(
"value").split()
if cl[0] == "sshpass":
vm.protocol = "SSH"
vm.user, vm.host = cl[6].split("@")
......@@ -127,36 +129,35 @@ class Browser:
driver.find_element_by_css_selector("a[href*='/logout/']").click()
except:
print "Browser session timed out!"
raise
return vm
##
# Főprogram
# beolvassuk a paramétereket
# megnyitjuk a kiválasztott böngészőben a weboldalt
# bejelentkezünk a címtárba
# kiválasztjuk a futtatni kívánt klienst
# kapcsolódunk a klienshez
def main():
args = pars_arguments()
if args.uri is not None:
vm = Struct()
vm.protocol, vm.user, vm.password, vm.host, vm.port = args.uri.split(':',4)
vm.protocol = vm.protocol.upper()
vm.state = "RUN"
else:
browser = Browser(args)
if args.old:
vm = browser.old_main()
"""
Main program
"""
try:
args = parse_arguments()
if args.uri is not None:
vm = Struct()
x, vm.protocol, vm.user, vm.password, vm.host, vm.port = \
args.uri.split(':', 5)
vm.protocol = vm.protocol.upper()
vm.state = "RUN"
else:
browser = Browser(args)
vm = browser.main()
browser.driver.quit()
if platform.system() == "Linux":
from cloud_connect_from_linux import connect
elif platform.system() == "Windows":
from cloud_connect_from_windows import connect
if vm.state.upper()[:3] in ("FUT", "RUN"):
connect(vm)
browser.driver.quit()
if platform.system() == "Linux":
from cloud_connect_from_linux import connect
elif platform.system() == "Windows":
from cloud_connect_from_windows import connect
if vm.state.upper()[:3] in ("FUT", "RUN"):
connect(vm)
except:
print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__":
main()
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import cloud
......@@ -7,4 +8,3 @@ if __name__ == '__main__':
cloud.main()
finally:
pass
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# Távoli klienshez csatlakozás linux OS alól
##
"""
Configuration of the Linux specific tools to enhance the ease of use
of the CIRCLE cloud. Handles the auto launch and auto configuration
of these specific connectivity programs.
"""
import time
import os
import subprocess
import glob
import sys, os, time, subprocess, glob
##
# A távoli klienshez csatlakozás valósítja meg
# NX és RDP esetén a remmina programot hívja meg. Ha a remmina-ban még nem szerepel
# a kliens, a program elkészíti az indításhoz szükséges profilt.
# @param vm Paraméterek a csatlakozáshoz
# vm.protocol SSH, NX és RDP lehetséges
# vm.host A virtuális gép címe
# vm.port Ezen a porton csatlakozunk a virtuális géphez
# vm.user Csatlakozáshoz használt név
# vm.password Csatlakozáshoz használt jelszó
#
def connect(vm):
"""
Handles to connection to the Virtual Machines from the local
machine
Keyword arguments:
vm.protocol -- SSH, NX and RDP possible
vm.host -- Address of the Virtual Computer
vm.port -- The port where we can access the Virtual Computer
vm.user -- Username used for the connection
vm.password -- Password used for the connection
"""
if vm.protocol == "SSH":
command = "sshpass -p %s ssh -p %s -o StrictHostKeyChecking=no %s@%s" % (vm.password, vm.port, vm.user, vm.host)
subprocess.call(command, shell=True)
......@@ -42,18 +49,12 @@ def connect(vm):
f.close()
subprocess.call(["remmina", "-c", config_file])
NX_template = """[remmina]
ssh_auth=0
quality=2
disableencryption=0
ssh_charset=
ssh_privatekey=
resolution=
group=
ssh_loopback=0
exec=
ssh_username=
ssh_server=
ssh_enabled=0
nx_privatekey=
showcursor=0
......@@ -65,24 +66,12 @@ viewmode=4
RDP_template = """[remmina]
disableclipboard=0
ssh_auth=0
clientname=
quality=2
ssh_charset=
ssh_privatekey=
console=0
resolution=
group=
ssh_loopback=0
shareprinter=0
ssh_username=
ssh_server=
security=
execpath=
sound=off
exec=
ssh_enabled=0
sharefolder=
domain=
colordepth=24
window_maximize=1
viewmode=4
......
# -*- coding: utf-8 -*-
##
# Távoli klienshez csatlakozás windows OS alól
##
##
# A távoli klienshez csatlakozás valósítja majd meg windows alól
# @param vm Paraméterek a csatlakozáshoz
# vm.protocol SSH, NX és RDP lehetséges
# vm.host A virtuális gép címe
# vm.port Ezen a porton csatlakozunk a virtuális géphez
# vm.user Csatlakozáshoz használt név
# vm.password Csatlakozáshoz használt jelszó
#
def connect(vm):
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment