Esempio n. 1
0
    def execute(self):
        headers = ["ID", "Name", "Status", "Created", "Updated"]

        set_file = self.args["--file"]
        default_file = orch.check_manifest_file()

        if set_file:
            if os.path.exists(set_file):
                default_file = set_file
            else:
                utils.log_err("{} file is not exists!".format(set_file))
                exit()

        if not default_file:
            utils.log_err("Can't find neo.yml manifest file!")
            exit()

        deploy_init = orch.initialize(default_file)
        try:
            orch.do_update(deploy_init)
        except:
            utils.log_err("Update Stack failed...")
            exit()

        projects = utils.get_project(default_file)

        project_list = list()
        for project in projects:
            proj = orch.get_stack(project)
            if proj:
                project_list.append(proj)

        if len(project_list) > 0:
            print(tabulate(project_list, headers=headers, tablefmt="grid"))
Esempio n. 2
0
 def execute(self):
     if self.args["vm"]:
         instance_id = self.args["<VM_ID>"]
         limit = self.args['--limit']
         if not instance_id:
             default_file = orch.check_manifest_file()
             if default_file:
                 keys = utils.get_key(default_file)
                 instances = keys['stack']['instances']
                 if len(instances) > 0:
                     vms = vm_lib.get_list()
                     for vm in vms:
                         if vm.name == instances[0]:
                             instance_id = vm.id
                             break
                 else:
                     utils.log_err('VM not found')
             else:
                 utils.log_err("Can't find neo.yml manifest file!")
         else:
             vm_data = vm_lib.get_list()
             for vm in vm_data:
                 if (instance_id == vm.name) or (instance_id == vm.id):
                     instance_id = vm.id
         try:
             utils.log_info(
                 vm_lib.get_console_logs(instance_id, length=limit))
         except Exception as err:
             utils.log_err(err.message)
     exit()
Esempio n. 3
0
 def test_get_project(self):
     os.chdir("tests")
     default_file = orch.check_manifest_file()
     os.chdir(os.pardir)
     assert utils.get_project(default_file) == [
         'unittest-network', 'unittest-vm', 'unittest-key'
     ]
Esempio n. 4
0
    def execute(self):

        set_file = self.args["--file"]
        default_file = orch.check_manifest_file()

        if self.args["vm"]:
            instance_id = self.args["<VM_ID>"]
            try:
                q_vm = utils.question(
                    "Are you sure to delete this virtual machines ? ")

                if q_vm:
                    vm_lib.do_delete(instance_id)
                    utils.log_info("VM has been deleted")
            except Exception as e:
                utils.log_err(e)
            else:
                pass
            finally:
                pass
            exit()

        if self.args["network"]:
            network_id = self.args["<NETWORK_ID>"]
            try:
                q_net = utils.question("Are you sure to delete this network ?")

                if q_net:
                    network_lib.do_delete(network_id)
                    utils.log_info("network has been deleted")
            except Exception as e:
                utils.log_err(e)
            else:
                pass
            finally:
                pass
            exit()

        if self.args["stack"]:
            stack_name = self.args["<STACK_NAME>"]
            try:
                q_stack = utils.question(
                    'Are you sure to delete "{}" stack ? '.format(stack_name))

                if q_stack:
                    proj = orch.do_delete(stack_name)
                    if proj:
                        utils.log_info(
                            "Stack {} has been deleted".format(stack_name))
                    else:
                        utils.log_err(
                            "Stack {} is not exists".format(stack_name))
            except Exception as e:
                utils.log_err(e)
            else:
                pass
            finally:
                pass
            exit()

        if set_file:
            if os.path.exists(set_file):
                default_file = "{}".format(set_file)
            else:
                utils.log_err("{} file is not exists!".format(set_file))
                print(self.__doc__)
                exit()

        if not default_file:
            utils.log_err("Can't find neo.yml manifest file!")
            print(self.__doc__)
            exit()

        projects = utils.get_project(default_file)
        project_answer = ",".join(projects)
        q_project = utils.question(
            "Are you sure to delete {} ? ".format(project_answer))

        if q_project:
            for project in projects:
                proj = orch.do_delete(project)
                if proj:
                    utils.log_info("Stack {} has been deleted".format(project))
                else:
                    utils.log_err("Stack {} is not exists".format(project))
Esempio n. 5
0
    def execute(self):
        """
            Remote client over SSH
        """

        if self.args["ssh"]:
            cridential = self.args["<USER@HOSTS>"].split("@")
            if len(cridential) != 2:
                print(self.__doc__)
                exit(0)

            user = cridential[0]
            hostname = cridential[1]
            utils.ssh_shell(hostname, user)
            exit(0)
        """
            Remote VM over SSH
        """
        if self.args["vm"]:
            vm_id = self.args["<VM_ID>"]
            """
                cek vm metadata from stack
            """
            utils.log_info("Check your key pairs")
            vm_detail = vm_lib.detail(vm_id).to_dict()
            key_pair_temp = tempfile.NamedTemporaryFile(delete=True)

            try:
                key_name = vm_detail["key_name"]
                out = orch.get_private_key(key_name)
                if out:
                    with open(key_pair_temp.name, 'w') as pkey:
                        pkey.write(out)
                        os.chmod(key_pair_temp.name, 0o600)
                        utils.log_info("Done...")
                else:
                    utils.log_err(
                        "Can't find key pairs on your Virtual Machine!")
                    exit()

            except Exception as e:
                utils.log_err("Can't find key pairs on your Virtual Machine!")
                exit()

            # Address
            addr = list()
            addr_objs = utils.get_index(vm_detail["addresses"])
            if len(addr_objs) > 0:
                for addr_obj in addr_objs:
                    for addr_ip in vm_detail["addresses"][addr_obj]:
                        if addr_ip["OS-EXT-IPS:type"] == "floating":
                            addr_meta = addr_ip["addr"]
                            addr.append(addr_meta)

            if not (len(addr) > 0):
                utils.log_err("Can't find floating IP Address!")
                exit()

            utils.log_info("Check username")
            user = orch.get_metadata(vm_detail["name"], "user")
            if not user:
                user = ""
                while user == "":
                    user = input("Username : "******"Login with {}".format(user))
            utils.ssh_shell(addr[0], user, key_file=key_pair_temp.name)
            exit(0)
        """
            Remote by manifest file neo.yaml
        """
        set_file = self.args["--file"]
        default_file = orch.check_manifest_file()
        deploy_file = ".deploy/deploy.yml"

        if set_file:
            if os.path.exists(set_file):
                default_file = set_file
            else:
                utils.log_err("{} file is not exists!".format(set_file))
                exit()

        if not default_file:
            utils.log_err("Can't find neo.yml manifest file!")
            exit()

        if os.path.exists(deploy_file):
            deploy_init = utils.yaml_parser(deploy_file)
            deploy_init = [
                d_init for d_init in deploy_init
                if d_init["stack"] in ["instances", "clusters", "databases"]
            ]
        else:
            deploy_init = orch.initialize(default_file)
            deploy_init = [
                d_init for d_init in deploy_init
                if d_init["stack"] in ["instances", "clusters", "databases"]
            ]

        meta = None
        if len(deploy_init) == 1:
            meta = deploy_init[0]

        if len(deploy_init) > 1:
            meta_project = [pra_meta["project"] for pra_meta in deploy_init]
            meta_field = [{
                "type": "TitleSelectOne",
                "name": "Select Project",
                "key": "project",
                "values": meta_project
            }]
            meta_field = utils.prompt_generator("Select project...",
                                                meta_field)
            meta = [
                pra_meta for pra_meta in deploy_init
                if pra_meta in [meta_field["project"]]
            ][0]

        if meta:
            project_name = meta["project"]
            project_dir = meta["dir"]
            private_key_file = "{}/private_key.pem".format(project_dir)
            project_hostname = None
            project_user = None

            if not os.path.exists(private_key_file):
                utils.log_info(
                    "Generate {} private key...".format(project_name))
                wait_key = True
                while wait_key:
                    out = orch.get_pkey_from_stack(project_name)
                    if out:
                        with open(private_key_file, "w") as pkey:
                            pkey.write(out)
                            os.chmod(private_key_file, 0o600)
                            utils.log_info("Done...")
                        wait_key = False
                    else:
                        pkeys = orch.get_private_key(project_name)
                        if pkeys:
                            with open(private_key_file, "w") as pkey:
                                pkey.write(pkeys)
                                os.chmod(private_key_file, 0o600)
                                utils.log_info("Done...")
                            wait_key = False
                        else:
                            time.sleep(5)

            if os.path.exists(private_key_file):
                if not project_hostname:
                    project_hostname = orch.get_metadata(
                        project_name, "controller")
                    project_user = orch.get_metadata(project_name, "user")

                do_ssh = True
                print("Try to connect...", end="")
                while do_ssh:
                    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                    result = sock.connect_ex((project_hostname, 22))
                    if result == 0:
                        print("\nSuccess...")
                        time.sleep(3)
                        do_ssh = False
                    else:
                        print(".", end="")
                        time.sleep(3)
                        do_ssh = True

                if self.args["--command"]:
                    try:
                        utils.ssh_out_stream(project_hostname,
                                             project_user,
                                             self.args["--command"],
                                             key_file=private_key_file)
                    except KeyboardInterrupt:
                        exit()

                if self.args["--tunneling"]:
                    try:
                        tunnel_args = " ".join([
                            "-L {}".format(t_arg)
                            for t_arg in self.args["--tunneling"].split(",")
                        ])
                        commands = "ssh -i {} {} {}@{}".format(
                            private_key_file, tunnel_args, project_user,
                            project_hostname).split(" ")
                        subprocess.call(commands)
                    except KeyboardInterrupt:
                        exit()
                utils.ssh_shell(project_hostname,
                                project_user,
                                key_file=private_key_file)
Esempio n. 6
0
    def execute(self):
        headers = ["ID", "Name", "Status", "Created", "Updated"]
        if self.args["stack"]:
            print(tabulate(orch.get_list(), headers=headers, tablefmt="grid"))
            exit()

        set_file = self.args["--file"]
        default_file = orch.check_manifest_file()

        if self.args["vm"]:
            try:
                data_instance = list()
                for instance in vm_lib.get_list():
                    pre_instance = [
                        instance.id, instance.name, instance.key_name
                    ]
                    pre_instance.append(
                        image.detail(instance.image["id"]).name)
                    flavors = vm_lib.detail_flavor(instance.flavor["id"])
                    flavors_name = flavors.name
                    flavors_vcpu = flavors.vcpus
                    flavors_ram = bitmath.MiB(
                        flavors.ram).to_GiB().best_prefix()
                    pre_instance.append(flavors_name)
                    pre_instance.append(flavors_ram)
                    pre_instance.append(flavors_vcpu)

                    # Address
                    addr = list()
                    addr_objs = utils.get_index(instance.addresses)
                    if len(addr_objs) > 0:
                        for addr_obj in addr_objs:
                            addr.append("network : {}".format(addr_obj))
                            for addr_ip in instance.addresses[addr_obj]:
                                addr_meta = "{} IP : {}".format(
                                    addr_ip["OS-EXT-IPS:type"],
                                    addr_ip["addr"])
                                addr.append(addr_meta)
                    if len(addr) > 0:
                        pre_instance.append("\n".join(addr))
                    else:
                        pre_instance.append("")

                    pre_instance.append(instance.status)
                    data_instance.append(pre_instance)

                if len(data_instance) == 0:
                    utils.log_err("No Data...")
                    print(self.__doc__)

            except Exception as e:
                utils.log_err(e)
                exit()
            print(
                tabulate(
                    data_instance,
                    headers=[
                        "ID",
                        "Name",
                        "Key Pair",
                        "Image",
                        "Flavor",
                        "RAM (GiB)",
                        "vCPU",
                        "Addresses",
                        "Status",
                    ],
                    tablefmt="grid",
                ))
            exit()

        if self.args["network"]:
            data_network = [[
                network["id"], network["name"], network["status"]
            ] for network in network_lib.get_list()]
            if len(data_network) == 0:
                utils.log_err("No Data...")
                print(self.__doc__)
                exit()
            print(
                tabulate(data_network,
                         headers=["ID", "Name", "Status"],
                         tablefmt="grid"))
            exit()

        if self.args["floatingips"]:
            data_floatingips = [[
                floatingips["floating_ip_address"],
                floatingips["created_at"],
                floatingips["status"],
            ] for floatingips in network_lib.get_floatingips()]
            if len(data_floatingips) == 0:
                utils.log_err("No Data...")
                print(self.__doc__)
                exit()
            print(
                tabulate(
                    data_floatingips,
                    headers=["IP Address", "Created at", "Status"],
                    tablefmt="grid",
                ))
            exit()

        if self.args["--outputs"]:
            stack_name = self.args["--outputs"].split(".")
            if len(stack_name) is 1:
                for meta in orch.get_meta_stack(stack_name[0]):
                    print(meta["output_key"], " :")
                    print(meta["output_value"])
                    print("")
            if len(stack_name) is 2:
                print(orch.get_metadata(stack_name[0], stack_name[1]))
            exit()

        if set_file:
            if os.path.exists(set_file):
                default_file = "{}".format(set_file)
            else:
                utils.log_err("{} file is not exists!".format(set_file))
                print(self.__doc__)
                exit()

        if not default_file:
            utils.log_err("Oops!! Can't find neo.yml manifest file!")
            print(self.__doc__)
            exit()

        projects = utils.get_project(default_file)

        project_list = list()
        for project in projects:
            proj = orch.get_stack(project)
            if proj:
                project_list.append(proj)

        if len(project_list) > 0:
            print(tabulate(project_list, headers=headers, tablefmt="grid"))
        else:
            utils.log_err("No Data...")
            print(self.__doc__)
Esempio n. 7
0
    def execute(self):

        set_file = self.args["--file"]
        default_file = orch.check_manifest_file()

        if self.args["vm"]:
            instance_id = self.args["<VM_ID>"]
            try:
                answer = ""
                while answer not in ["y", "n"]:
                    answer = input(
                        "Are you sure to delete this virtual machines [y/n]? "
                    ).lower()

                if answer == "y":
                    vm_lib.do_delete(instance_id)
                    utils.log_info("VM has been deleted")
            except Exception as e:
                utils.log_err(e)
            else:
                pass
            finally:
                pass
            exit()

        if self.args["network"]:
            network_id = self.args["<NETWORK_ID>"]
            try:
                answer = ""
                while answer not in ["y", "n"]:
                    answer = input(
                        "Are you sure to delete this network [Y/N]? ")

                if answer == "y":
                    network_lib.do_delete(network_id)
                    utils.log_info("network has been deleted")
            except Exception as e:
                utils.log_err(e)
            else:
                pass
            finally:
                pass
            exit()

        if self.args["stack"]:
            stack_name = self.args["<STACK_NAME>"]
            try:
                answer = ""
                while answer not in ["y", "n"]:
                    answer = input(
                        "Are you sure to delete \"{}\" stack [Y/N]? ".format(stack_name))

                if answer == "y":
                    proj = orch.do_delete(stack_name)
                    if proj:
                        utils.log_info("Stack {} has been deleted".format(stack_name))
                    else:
                        utils.log_err("Stack {} is not exists".format(stack_name))
            except Exception as e:
                utils.log_err(e)
            else:
                pass
            finally:
                pass
            exit()

        if set_file:
            if os.path.exists(set_file):
                default_file = "{}".format(set_file)
            else:
                utils.log_err("{} file is not exists!".format(set_file))
                print(self.__doc__)
                exit()

        if not default_file:
            utils.log_err("Can't find neo.yml manifest file!")
            print(self.__doc__)
            exit()

        projects = utils.get_project(default_file)
        project_answer = ",".join(projects)
        answer = ""
        while answer not in ["y", "n"]:
            answer = input("Are you sure to delete {} [y/n]? ".format(
                project_answer).lower())

        if answer == "y":
            for project in projects:
                proj = orch.do_delete(project)
                if proj:
                    utils.log_info("Stack {} has been deleted".format(project))
                else:
                    utils.log_err("Stack {} is not exists".format(project))
Esempio n. 8
0
File: ls.py Progetto: sdmoko/neo-cli
    def execute(self):
        headers = ["ID", "Name", "Status", "Created", "Updated"]
        if self.args["stack"]:
            print(tabulate(orch.get_list(), headers=headers, tablefmt="grid"))
            exit()

        set_file = self.args["--file"]
        default_file = orch.check_manifest_file()

        if self.args["vm"]:
            data_instance = list()
            for instance in vm_lib.get_list():
                pre_instance = [instance.id, instance.name]
                pre_instance.append(image.detail(instance.image["id"]).name)
                flavors = vm_lib.detail_flavor(instance.flavor["id"])
                flavors_name = flavors.name
                flavors_vcpu = flavors.vcpus
                flavors_ram = bitmath.MiB(flavors.ram).to_GiB().best_prefix()
                pre_instance.append(flavors_name)
                pre_instance.append(flavors_ram)
                pre_instance.append(flavors_vcpu)

                # Address
                addr = list()
                addr_objs = utils.get_index(instance.addresses)
                if len(addr_objs) > 0:
                    for addr_obj in addr_objs:
                        addr.append("network : {}".format(addr_obj))
                        for addr_ip in instance.addresses[addr_obj]:
                            addr_meta = "{} IP : {}".format(
                                addr_ip["OS-EXT-IPS:type"], addr_ip["addr"])
                            addr.append(addr_meta)
                if len(addr) > 0:
                    pre_instance.append("\n".join(addr))
                else:
                    pre_instance.append("")

                pre_instance.append(instance.status)
                data_instance.append(pre_instance)

            if len(data_instance) == 0:
                utils.log_err("No Data...")
                print(self.__doc__)
                exit()
            print(
                tabulate(
                    data_instance,
                    headers=[
                        "ID", "Name", "Image", "Flavor", "RAM (GiB)", "vCPU",
                        "Addresses", "Status"
                    ],
                    tablefmt="grid"))
            exit()

        if self.args["network"]:
            data_network = [[
                network['id'], network['name'], network['status']
            ] for network in network_lib.get_list()]
            if len(data_network) == 0:
                utils.log_err("No Data...")
                print(self.__doc__)
                exit()
            print(
                tabulate(
                    data_network,
                    headers=["ID", "Name", "Status"],
                    tablefmt="grid"))
            exit()

        if self.args["--outputs"]:
            stack_name = self.args["--outputs"].split(".")
            if len(stack_name) is 1:
                for meta in orch.get_meta_stack(stack_name[0]):
                    print(meta["output_key"], " :")
                    print(meta["output_value"])
                    print("")
            if len(stack_name) is 2:
                print(orch.get_metadata(stack_name[0], stack_name[1]))
            exit()

        if set_file:
            if os.path.exists(set_file):
                default_file = "{}".format(set_file)
            else:
                utils.log_err("{} file is not exists!".format(set_file))
                print(self.__doc__)
                exit()

        if not default_file:
            utils.log_err("Oops!! Can't find neo.yml manifest file!")
            print(self.__doc__)
            exit()

        projects = utils.get_project(default_file)

        project_list = list()
        for project in projects:
            proj = orch.get_stack(project)
            if proj:
                project_list.append(proj)

        if len(project_list) > 0:
            print(tabulate(project_list, headers=headers, tablefmt="grid"))
        else:
            utils.log_err("No Data...")
            print(self.__doc__)
Esempio n. 9
0
    def execute(self):
        if self.args["--template"]:
            if self.args["--template"] in ("clusters", "instances", "networks"):
                tmpl = self.args["--template"]

                if self.args["--interactive"]:
                    ncurses.init(stack=tmpl)
                else:
                    prompt.init(stack=tmpl)
            exit()

        if self.args["kubernetes"]:
            if self.args["--interactive"]:
                print(ncurses.init(stack="clusters", project="kubernetes"))
            else:
                print(prompt.init(stack="clusters", project="kubernetes"))

        if self.args["vm"]:
            if self.args["--interactive"]:
                print(ncurses.init(stack="instances", project="vm"))
            else:
                print(prompt.init(stack="instances", project="vm"))

        headers = ["ID", "Name", "Status", "Created", "Updated"]

        set_file = self.args["--file"]
        default_file = orch.check_manifest_file()

        if set_file:
            if os.path.exists(set_file):
                default_file = set_file
            else:
                utils.log_err("{} file is not exists!".format(set_file))
                exit()

        if not default_file:
            utils.log_err("Can't find neo.yml manifest file!")
            q_stack = utils.question("Do you want to generate neo.yml manifest? ")

            if q_stack:
                if self.args["--interactive"]:
                    print(ncurses.init())
                else:
                    print(prompt.init())
                q_deploy = utils.question("Continue to deploy? ")
                if q_deploy:
                    default_file = "neo.yml"
                else:
                    exit()
            else:
                exit()
        else:
            q_deploy = utils.question("Continue to deploy? ")
            if q_deploy:
                default_file = "neo.yml"
            else:
                exit()

        deploy_init = orch.initialize(default_file)
        try:
            orch.do_create(deploy_init)
        except Exception as e:
            utils.log_err(e)
            utils.log_err("Deploying Stack failed...")
            exit()

        projects = utils.get_project(default_file)

        project_list = list()
        for project in projects:
            proj = orch.get_stack(project)
            if proj:
                project_list.append(proj)

        if len(project_list) > 0:
            print(tabulate(project_list, headers=headers, tablefmt="grid"))
Esempio n. 10
0
    def execute(self):
        if self.args["--template"]:
            if self.args["--template"] in ('clusters', 'instances',
                                           'networks'):
                tmpl = self.args["--template"]

                if self.args["--interactive"]:
                    ncurses.init(stack=tmpl)
                else:
                    prompt.init(stack=tmpl)
            exit()

        if self.args["kubernetes"]:
            if self.args["--interactive"]:
                print(ncurses.init(stack="clusters", project="kubernetes"))
            else:
                print(prompt.init(stack="clusters", project="kubernetes"))

        if self.args["vm"]:
            if self.args["--interactive"]:
                print(ncurses.init(stack="instances", project="vm"))
            else:
                print(prompt.init(stack="instances", project="vm"))

        headers = ["ID", "Name", "Status", "Created", "Updated"]

        set_file = self.args["--file"]
        default_file = orch.check_manifest_file()

        if set_file:
            if os.path.exists(set_file):
                default_file = set_file
            else:
                utils.log_err("{} file is not exists!".format(set_file))
                exit()

        if not default_file:
            utils.log_err("Can't find neo.yml manifest file!")
            q_stack = utils.question(
                "Do you want to generate neo.yml manifest? ")

            if q_stack:
                if self.args["--interactive"]:
                    print(ncurses.init())
                else:
                    print(prompt.init())
                q_deploy = utils.question("Continue to deploy? ")
                if q_deploy:
                    default_file = "neo.yml"
                else:
                    exit()
            else:
                exit()
        else:
            q_deploy = utils.question("Continue to deploy? ")
            if q_deploy:
                default_file = "neo.yml"
            else:
                exit()

        deploy_init = orch.initialize(default_file)
        try:
            orch.do_create(deploy_init)
        except Exception as e:
            utils.log_err(e)
            utils.log_err("Deploying Stack failed...")
            exit()

        projects = utils.get_project(default_file)

        project_list = list()
        for project in projects:
            proj = orch.get_stack(project)
            if proj:
                project_list.append(proj)

        if len(project_list) > 0:
            print(tabulate(project_list, headers=headers, tablefmt="grid"))
Esempio n. 11
0
    def execute(self):
        """
            Remote client over SSH
        """

        if self.args["ssh"]:
            cridential = self.args["<USER@HOSTS>"].split("@")
            if len(cridential) != 2:
                print(self.__doc__)
                exit(0)

            user = cridential[0]
            hostname = cridential[1]
            utils.ssh_shell(hostname, user)
            exit(0)

        """
            Remote VM over SSH
        """
        if self.args["vm"]:
            vm_id = self.args["<VM_ID>"]
            """
                cek vm metadata from stack
            """
            utils.log_info("Check your key pairs")
            vm_detail = vm_lib.detail(vm_id).to_dict()
            key_pair_temp = tempfile.NamedTemporaryFile(delete=True)

            try:
                key_name = vm_detail["key_name"]
                out = orch.get_private_key(key_name)
                if out:
                    with open(key_pair_temp.name, 'w') as pkey:
                        pkey.write(out)
                        os.chmod(key_pair_temp.name, 0o600)
                        utils.log_info("Done...")
                else:
                    utils.log_err("Can't find key pairs on your Virtual Machine!")
                    exit()

            except Exception as e:
                utils.log_err("Can't find key pairs on your Virtual Machine!")
                exit()

            # Address
            addr = list()
            addr_objs = utils.get_index(vm_detail["addresses"])
            if len(addr_objs) > 0:
                for addr_obj in addr_objs:
                    for addr_ip in vm_detail["addresses"][addr_obj]:
                        if addr_ip["OS-EXT-IPS:type"] == "floating":
                            addr_meta = addr_ip["addr"]
                            addr.append(addr_meta)

            if not (len(addr) > 0):
                utils.log_err("Can't find floating IP Address!")
                exit()

            utils.log_info("Check username")
            user = orch.get_metadata(vm_detail["name"], "user")
            if not user:
                user = ""
                while user == "":
                    user = input(
                        "Username : "******"Login with {}".format(user))
            utils.ssh_shell(addr[0], user, key_file=key_pair_temp.name)
            exit(0)

        """
            Remote by manifest file neo.yaml
        """
        set_file = self.args["--file"]
        default_file = orch.check_manifest_file()
        deploy_file = ".deploy/deploy.yml"

        if set_file:
            if os.path.exists(set_file):
                default_file = set_file
            else:
                utils.log_err("{} file is not exists!".format(set_file))
                exit()

        if not default_file:
            utils.log_err("Can't find neo.yml manifest file!")
            exit()

        if os.path.exists(deploy_file):
            deploy_init = utils.yaml_parser(deploy_file)
            deploy_init = [d_init for d_init in deploy_init if d_init["stack"] in ["instances","clusters","databases"]]
        else:
            deploy_init = orch.initialize(default_file)
            deploy_init = [d_init for d_init in deploy_init if d_init["stack"] in ["instances","clusters","databases"]]

        meta = None
        if len(deploy_init) == 1:
            meta = deploy_init[0]

        if len(deploy_init) > 1:
            meta_project = [pra_meta["project"] for pra_meta in deploy_init]
            meta_field = [{"type": "TitleSelectOne", "name": "Select Project", "key": "project", "values": meta_project}]
            meta_field = utils.prompt_generator("Select project...",meta_field)
            meta = [pra_meta for pra_meta in deploy_init if pra_meta in [meta_field["project"]]][0]

        if meta:
            project_name = meta["project"]
            project_dir = meta["dir"]
            private_key_file = "{}/private_key.pem".format(project_dir)
            project_hostname = None
            project_user = None

            if not os.path.exists(private_key_file):
                utils.log_info("Generate {} private key...".format(
                    project_name))
                wait_key = True
                while wait_key:
                    out = orch.get_pkey_from_stack(project_name)
                    if out:
                        with open(private_key_file, "w") as pkey:
                            pkey.write(out)
                            os.chmod(private_key_file, 0o600)
                            utils.log_info("Done...")
                        wait_key = False
                    else:
                        pkeys = orch.get_private_key(project_name)
                        if pkeys:
                            with open(private_key_file, "w") as pkey:
                                pkey.write(pkeys)
                                os.chmod(private_key_file, 0o600)
                                utils.log_info("Done...")
                            wait_key = False
                        else:
                            time.sleep(5)

            if os.path.exists(private_key_file):
                if not project_hostname:
                    project_hostname = orch.get_metadata(project_name, "controller")
                    project_user = orch.get_metadata(project_name, "user")

                do_ssh = True
                print("Try to connect...", end="")
                while do_ssh:
                    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                    result = sock.connect_ex((project_hostname, 22))
                    if result == 0:
                        print("\nSuccess...")
                        time.sleep(3)
                        do_ssh = False
                    else:
                        print(".", end="")
                        time.sleep(3)
                        do_ssh = True

                if self.args["--command"]:
                    try:
                        utils.ssh_out_stream(project_hostname, project_user, self.args["--command"], key_file=private_key_file)
                    except KeyboardInterrupt:
                        exit()
                elif self.args["--tunneling"]:
                    try:
                        tunnel_args = " ".join(["-L {}".format(t_arg) for t_arg in self.args["--tunneling"].split(",")])
                        commands = "ssh -i {} {} {}@{}".format(private_key_file, tunnel_args, project_user, project_hostname).split(" ")
                        subprocess.call(commands)
                    except KeyboardInterrupt:
                        exit()
                else:
                    try:
                        utils.ssh_shell(project_hostname, project_user, key_file=private_key_file)
                    except KeyboardInterrupt:
                        exit()