def test_removes_users(self): # Given sync_ssh_users.add_user('foo') # When sync_ssh_users.main() # Then with raises(ErrorReturnCode): id_('foo') assert 'foo' not in getent('group', 'users') assert 'foo' not in getent('group', 'wheel') assert not os.path.isdir('/home/foo')
def make_ip_window(): H, W = screen.getmaxyx() ip_win = screen.subwin(H / 2, W, H / 2 - HINT_WIDTH, 0) ip_win.box() try: ip = sh.head(sh.awk(sh.getent("ahosts", sh.hostname().strip()), "{print $1}"), n="1").strip() if ip == "127.0.0.1": raise DHCPMisconfiguration() except sh.ErrorReturnCode: ip_win.addstr(1, 2, "===================================") ip_win.addstr(2, 2, "Connectivity issues detected!") ip_win.addstr(3, 2, "===================================") ip_win.addstr(4, 2, "Check VM setup instructions") ip_win.addstr(6, 2, "For details, see VM setup instructions") except DHCPMisconfiguration: ip_win.addstr(1, 2, "===================================") ip_win.addstr(2, 2, "Connectivity issues detected!") ip_win.addstr(3, 2, "===================================") ip_win.addstr(4, 2, "Check connection of Host-only interface") ip_win.addstr(5, 2, "and check DHCP is enabled for it") ip_win.addstr(7, 2, "For details, see VM setup instructions") else: ip_win.addstr(1, 2, "To initiate your Hortonworks Sandbox session,") ip_win.addstr(2, 2, "please open a browser and enter this address ") ip_win.addstr(3, 2, "in the browser's address field: ") ip_win.addstr(4, 2, "http://%s/" % ip)
def make_ip_window(): H, W = screen.getmaxyx() ip_win = screen.subwin(H / 2, W, H / 2 - HINT_WIDTH, 0) ip_win.box() try: ip = sh.head( sh.awk( sh.getent("ahosts", sh.hostname().strip()), "{print $1}"), n="1").strip() if ip == "127.0.0.1": raise DHCPMisconfiguration() except sh.ErrorReturnCode: ip_win.addstr(1,2,"===================================") ip_win.addstr(2,2,"Connectivity issues detected!") ip_win.addstr(3,2,"===================================") ip_win.addstr(4,2,"Check VM setup instructions") ip_win.addstr(6,2,"For details, see VM setup instructions") except DHCPMisconfiguration: ip_win.addstr(1,2,"===================================") ip_win.addstr(2,2,"Connectivity issues detected!") ip_win.addstr(3,2,"===================================") ip_win.addstr(4,2,"Check connection of Host-only interface") ip_win.addstr(5,2,"and check DHCP is enabled for it") ip_win.addstr(7,2,"For details, see VM setup instructions") else: ip_win.addstr(1,2,"To initiate your Hortonworks Sandbox session,") ip_win.addstr(2,2,"please open a browser and enter this address ") ip_win.addstr(3,2,"in the browser's address field: ") ip_win.addstr(4,2,"http://%s/" % ip)
def make_status_window(): Height, Width = screen.getmaxyx() status_win = screen.subwin(Height / 4 - Width_Factor / 2 , Width, Height / 4 , 0) status_win.box() try: ip = sh.head(sh.awk(sh.getent("ahosts", sh.hostname().strip()),"{print $1}"),n="1").strip() if ip == "127.0.0.1": raise NetworkMisconfiguredException() except sh.ErrorReturnCode: status_win.addstr(1,2,"MapR-Platfora-Sandbox-For-Hadoop setup did not succseed.") raise ServiceFailedtoStartException() make_error_window() except NetworkMisconfiguredException: make_error_window() else: status_win.addstr(1,2,"MapR Services failed to start.", curses.A_BOLD) make_error_window()
def test_adds_users(self): # When sync_ssh_users.main() # Then assert 'groups' in id_('aad') assert 'groups' in id_('bbe') assert 'groups' in id_('ccf') assert 'aad' in getent('group', 'users') assert 'bbe' in getent('group', 'users') assert 'ccf' in getent('group', 'users') assert 'aad' in getent('group', 'wheel') assert 'bbe' in getent('group', 'wheel') assert 'ccf' in getent('group', 'wheel')
def make_status_window(): Height, Width = screen.getmaxyx() status_win = screen.subwin(Height / 4 - Width_Factor / 2, Width, Height / 4, 0) status_win.box() try: ip = sh.head(sh.awk(sh.getent("ahosts", sh.hostname().strip()), "{print $1}"), n="1").strip() if ip == "127.0.0.1": raise NetworkMisconfiguredException() except sh.ErrorReturnCode: status_win.addstr(1, 2, "_MAPR_BANNER_NAME_ setup did not succseed.") raise ServiceFailedtoStartException() make_error_window() except NetworkMisconfiguredException: make_error_window() else: status_win.addstr(1, 2, "MapR Services failed to start.", curses.A_BOLD) make_error_window()
# All Rights Reserved MapR import curses import sh import subprocess import os screen = None Width_Factor = 4 ip = sh.head(sh.awk(sh.getent("ahosts", sh.hostname().strip()), "{print $1}"), n="1").strip() if not os.path.exists("/vmware"): ip = "127.0.0.1" ssh_cmd = "" if ip == "127.0.0.1": ssh_cmd = "ssh mapr@localhost -p 2222" else: ssh_cmd = "ssh mapr@%s" % (ip) class NetworkMisconfiguredException(Exception): pass class ServiceFailedtoStartException(Exception): pass def make_welcome_window(): Height, Width = screen.getmaxyx() welcome_win = screen.subwin(Height / 2 - Width_Factor - 2, Width, 0, 0)
#All Rights Reserved MapR import curses import sh import subprocess import os screen = None Width_Factor = 4 ip = sh.head(sh.awk(sh.getent("ahosts", sh.hostname().strip()), "{print $1}"), n="1").strip() if not os.path.exists("/vmware"): ip = "127.0.0.1" ssh_cmd = "" if ip == "127.0.0.1": ssh_cmd = "ssh mapr@localhost -p 2222" else: ssh_cmd = "ssh mapr@%s" % (ip) class NetworkMisconfiguredException(Exception): pass class ServiceFailedtoStartException(Exception): pass def make_welcome_window():
def find_users_to_remove(valid_users: Sequence[str]) -> Sequence[str]: existing_users = getent('group', USERS_GROUP).split(':')[3].strip() users_to_remove = set(existing_users.split(',')) - set(valid_users) return list(users_to_remove)