def authenticate_juju(self): if not len(self.config.juju_env['state-servers']) > 0: state_server = 'localhost:17070' else: state_server = self.config.juju_env['state-servers'][0] self.juju = JujuClient(url=path.join('wss://', state_server), password=self.config.juju_api_password) self.juju.login() self.juju_state = JujuState(self.juju) log.debug('Authenticated against juju api.')
#!/usr/bin/env python import sys sys.path.insert(0, '../cloudinstall') from macumba import JujuClient from pprint import pprint JUJU_PASS = '******' JUJU_URL = 'wss://localhost:17070/' if __name__ == '__main__': ws = JujuClient(url=JUJU_URL, password=JUJU_PASS) ws.login() t = ws.status() pprint(t) #ws.add_machine() # ws.deploy('mysql') # ws.deploy('wordpress', dict(charm_url='cs:precise/wordpress-24')) # ws.deploy('juju-gui') # # ws.add_relation('mysql', 'wordpress') # ws.add_unit('mysql') ws.close()
import threading juju_home = os.getenv("JUJU_HOME", "~/.juju") jenv_pat = os.path.expanduser(os.path.join(juju_home, "environments/*.jenv")) jenv_files = glob(jenv_pat) if len(jenv_files) == 0 or len(jenv_files) > 1: print("found 0 or >1 .jenv files, will ask for IP and password") wss_ip = input("juju api IP (with port):") jpass = getpass("juju password : "******"{} starting: {}".format(i, threading.current_thread().name)) if i == 0: time.sleep(3) print("*" * 80) print("{} RECONNECT {}\n".format(i, threading.current_thread().name)) j.reconnect() time.sleep(5) j.reconnect() print("*" * 80) print("{} RECONNECT {}\n".format(i, threading.current_thread().name))