def post_proc(self): """ post processing for nova-cloud-controller """ svc = self.juju_state.service(self.charm_name) unit = svc.unit(self.charm_name) k_svc = self.juju_state.service('keystone') keystone = k_svc.unit('keystone') openstack_password = self.config.getopt('openstack_password') public_address = keystone.public_address if is_ipv6(public_address): public_address = "[%s]".format(public_address) log.debug("Found ipv6 address, {}".format(public_address)) if unit.machine_id == '-1': return True for u in ['admin', 'ubuntu']: env = self._openstack_env(u, openstack_password, u, public_address) self._openstack_env_save(u, env) utils.remote_cp( unit.machine_id, src=self._openstack_env_path(u), dst='/tmp/openstack-{u}-rc'.format(u=u), juju_home=self.config.juju_home(use_expansion=True)) setup_script_path = self.render_setup_script() remote_setup_script_path = "/tmp/nova-controller-setup.sh" utils.remote_cp( unit.machine_id, src=setup_script_path, dst=remote_setup_script_path, juju_home=self.config.juju_home(use_expansion=True)) utils.remote_run( unit.machine_id, cmds="chmod +x {}".format(remote_setup_script_path), juju_home=self.config.juju_home(use_expansion=True)) utils.remote_cp( unit.machine_id, src=utils.ssh_pubkey(), dst="/tmp/id_rsa.pub", juju_home=self.config.juju_home(use_expansion=True)) err = utils.remote_run( unit.machine_id, cmds="/tmp/nova-controller-setup.sh " "\"{p}\" \"{install_type}\"".format( p=openstack_password, install_type=self.config.getopt('install_type')), juju_home=self.config.juju_home(use_expansion=True)) if err['status'] != 0: # something happened during nova setup, re-run return True return False
def post_proc(self): """ post processing for nova-cloud-controller """ svc = self.juju_state.service(self.charm_name) unit = svc.unit(self.charm_name) k_svc = self.juju_state.service("keystone") keystone = k_svc.unit("keystone") openstack_password = self.config.getopt("openstack_password") if unit.machine_id == "-1": return True for u in ["admin", "ubuntu"]: env = self._openstack_env(u, openstack_password, u, keystone.public_address) self._openstack_env_save(u, env) utils.remote_cp( unit.machine_id, src=self._openstack_env_path(u), dst="/tmp/openstack-{u}-rc".format(u=u), juju_home=self.config.juju_home(use_expansion=True), ) setup_script_path = self.render_setup_script() remote_setup_script_path = "/tmp/nova-controller-setup.sh" utils.remote_cp( unit.machine_id, src=setup_script_path, dst=remote_setup_script_path, juju_home=self.config.juju_home(use_expansion=True), ) utils.remote_run( unit.machine_id, cmds="chmod +x {}".format(remote_setup_script_path), juju_home=self.config.juju_home(use_expansion=True), ) utils.remote_cp( unit.machine_id, src=utils.ssh_pubkey(), dst="/tmp/id_rsa.pub", juju_home=self.config.juju_home(use_expansion=True), ) err = utils.remote_run( unit.machine_id, cmds="/tmp/nova-controller-setup.sh " "{p} {install_type}".format(p=openstack_password, install_type=self.config.getopt("install_type")), juju_home=self.config.juju_home(use_expansion=True), ) if err["status"] != 0: # something happened during nova setup, re-run return True return False