Ejemplo n.º 1
0
    def run(self):
        banner("Reset the cloudmesh management yaml files ")

        yaml_files = ['cloudmesh_user.yaml', 'cloudmesh_project.yaml']
        dir_path = path_expand("~/.cloudmesh/{0}".format("accounts"))

        if not os.path.exists(dir_path):
            Shell.mkdir(dir_path)

        for yaml_file in yaml_files:
            filename = path_expand("~/.cloudmesh/{0}/{1}".format(
                "accounts", yaml_file))
            if os.path.isfile(filename):
                Console.info("Removing file:  {0}".format(filename))
                Shell.rm(filename)
                Console.info("Copying file:  {0} -> {1} ".format(
                    path_expand("etc/{0}/{1}".format("accounts", yaml_file)),
                    filename))
                shutil.copy(
                    "etc/{0}/{1}".format("accounts", yaml_file),
                    path_expand("~/.cloudmesh/{0}/{1}".format(
                        "accounts", yaml_file)))
            else:
                Console.info("Copying file:  {0} -> {1} ".format(
                    path_expand("etc/{0}/{1}".format("accounts", yaml_file)),
                    filename))
                shutil.copy(
                    "etc/{0}/{1}".format("accounts", yaml_file),
                    path_expand("~/.cloudmesh/{0}/{1}".format(
                        "accounts", yaml_file)))
Ejemplo n.º 2
0
    def run(self):
        banner("Setup the cloudmesh management yaml files ")

        yamlfiles = ['cloudmesh_user.yaml', 'cloudmesh_project.yaml']
        dir_path = path_expand("~/.cloudmesh/{0}".format("accounts"))

        if not os.path.exists(dir_path):
            Shell.mkdir(dir_path)

        for yamlfile in yamlfiles:

            filename = path_expand("~/.cloudmesh/{0}/{1}".format(
                "accounts", yamlfile))

            if os.path.isfile(filename):
                Console.error(
                    "File {0} already exists. If you like to reinstall it, please remove the file"
                    .format(yamlfile))
            else:
                Console.info("Copying file:  {0} -> {1} ".format(
                    path_expand("etc/{0}/{1}".format("accounts", yamlfile)),
                    filename))
                shutil.copy(
                    "etc/{0}/{1}".format("accounts", yamlfile),
                    path_expand("~/.cloudmesh/{0}/{1}".format(
                        "accounts", yamlfile)))
Ejemplo n.º 3
0
 def open(self, filename=None):
     if filename is not None:
         self.filename = filename
     else:
         self.filename = path_expand(self.pbs.database_filename())
     path = os.path.dirname(self.filename)
     Shell.mkdir(path)
     self.load()
Ejemplo n.º 4
0
Archivo: cm.py Proyecto: atavism/client
def create_cloudmesh_yaml(filename):
    if not os.path.exists(filename):
        path = os.path.dirname(filename)
        if not os.path.isdir(path):
            Shell.mkdir(path)
        etc_path = os.path.dirname(cloudmesh_client.__file__)
        etc_file = os.path.join(etc_path, "etc", "cloudmesh.yaml")
        to_dir = path_expand("~/.cloudmesh")
        shutil.copy(etc_file, to_dir)
        Console.ok("~/.cloudmesh/cloudmesh.yaml created")
Ejemplo n.º 5
0
    def create_config(cls, username):
        dir_path = path_expand("~/.cloudmesh/{0}".format("accounts"))

        if not os.path.exists(dir_path):
            Shell.mkdir(dir_path)

        filename = path_expand("~/.cloudmesh/{0}/{1}".format("accounts", ".config"))
        data = dict(user=username)

        with open(filename, 'w') as outfile:
            outfile.write(yaml.dump(data, default_flow_style=True))
Ejemplo n.º 6
0
    def run(self):
        banner("Setup the cmd3.yaml file")

        cmd3_yaml = path_expand("~/.cloudmesh/cmd3.yaml")

        if os.path.isfile(cmd3_yaml):
            print ("ERROR: the file {0} already exists".format(cmd3_yaml))
            print
            print ("If you like to reinstall it, please remove the file")
        else:
            print ("Copy file:  {0} -> {1} ".format(path_expand("etc/cmd3.yaml"), cmd3_yaml))
            Shell.mkdir("~/.cloudmesh")

            shutil.copy("etc/cmd3.yaml", path_expand("~/.cloudmesh/cmd3.yaml"))
Ejemplo n.º 7
0
    def run(self):
        banner("Setup the cmd3.yaml file")

        cmd3_yaml = path_expand("~/.cloudmesh/cmd3.yaml")

        if os.path.isfile(cmd3_yaml):
            print ("ERROR: the file {0} already exists".format(cmd3_yaml))
            print()
            print ("If you like to reinstall it, please remove the file")
        else:
            print ("Copy file:  {0} -> {1} ".format(path_expand("etc/cmd3.yaml"), cmd3_yaml))
            Shell.mkdir("~/.cloudmesh")

            shutil.copy("etc/cmd3.yaml", path_expand("~/.cloudmesh/cmd3.yaml"))
Ejemplo n.º 8
0
    def start(self):
        """
        Starts the cloudmesh_job process in the background.
        """
        for key in ['dbpath', 'logpath']:
            path = os.dirname(self.config[key])
            Shell.mkdir(path)

        r = Shell.sh("mongod", "--fork", "--logpath", self.config['logpath'],
                     "--prot", self.config['port'], '--dbpath',
                     self.config['dbpath'])
        print(r)
        # TODO
        # get the id from r
        self.config['id'] = None  # put here the real id
Ejemplo n.º 9
0
    def start(self):
        """
        Starts the cloudmesh_job process in the background.
        """
        for key in ['dbpath', 'logpath']:
            path = os.dirname(self.config[key])
            Shell.mkdir(path)

        r = Shell.sh("mongod", "--fork",
                     "--logpath", self.config['logpath'],
                     "--prot", self.config['port'],
                     '--dbpath', self.config['dbpath'])
        print (r)
        # TODO
        # get the id from r
        self.config['id'] = None  # put here the real id
Ejemplo n.º 10
0
 def deploy(self):
     """
     creates the directories if they do not exist
     """
     try:
         r = Shell.mkdir(self.db_path)
     except Exception, e:
         Console.error("Problem creating the database directory {:}".format(self.db_path))
         print(e)
Ejemplo n.º 11
0
    def run(self):
        banner("Setup the cloudmesh management yaml files ")

        yamlfiles = ['cloudmesh_user.yaml', 'cloudmesh_project.yaml']
        dir_path = path_expand("~/.cloudmesh/{0}".format("accounts"))

        if not os.path.exists(dir_path):
            Shell.mkdir(dir_path)

        for yamlfile in yamlfiles:

            filename = path_expand("~/.cloudmesh/{0}/{1}".format("accounts", yamlfile))

            if os.path.isfile(filename):
                Console.error("File {0} already exists. If you like to reinstall it, please remove the file".format(yamlfile))
            else:
                Console.info("Copying file:  {0} -> {1} ".format(path_expand("etc/{0}/{1}".format("accounts", yamlfile)), filename))
                shutil.copy("etc/{0}/{1}".format("accounts", yamlfile), path_expand("~/.cloudmesh/{0}/{1}".format("accounts", yamlfile)))
Ejemplo n.º 12
0
    def run(self):
        banner("Reset the cloudmesh management yaml files ")

        yaml_files = ['cloudmesh_user.yaml', 'cloudmesh_project.yaml']
        dir_path = path_expand("~/.cloudmesh/{0}".format("accounts"))

        if not os.path.exists(dir_path):
            Shell.mkdir(dir_path)

        for yaml_file in yaml_files:
            filename = path_expand("~/.cloudmesh/{0}/{1}".format("accounts", yaml_file))
            if os.path.isfile(filename):
                Console.info("Removing file:  {0}".format(filename))
                Shell.rm(filename)
                Console.info("Copying file:  {0} -> {1} ".format(path_expand("etc/{0}/{1}".format("accounts", yaml_file)), filename))
                shutil.copy("etc/{0}/{1}".format("accounts", yaml_file), path_expand("~/.cloudmesh/{0}/{1}".format("accounts", yaml_file)))
            else:
                Console.info("Copying file:  {0} -> {1} ".format(path_expand("etc/{0}/{1}".format("accounts", yaml_file)), filename))
                shutil.copy("etc/{0}/{1}".format("accounts", yaml_file), path_expand("~/.cloudmesh/{0}/{1}".format("accounts", yaml_file)))
Ejemplo n.º 13
0
def create_cmd3_yaml_file(force=False, verbose=True):
    def print_error(kind, path):
        if verbose:
            Console.error("the {0} {1} already exists".format(kind, path))
            Console.msg("")
            Console.msg("If you like to reinstall it, "
                        "please remove the file first")
            Console.msg("")

    if verbose:
        banner("create cmd3.yaml")

    cmd3_yaml = path_expand("~/.cloudmesh/cmd3.yaml")

    if force or not os.path.isfile(cmd3_yaml):
        Shell.mkdir(path_expand("~/.cloudmesh"))
        import cmd3
        content = pkg_resources.resource_string(cmd3.__name__, "etc/cmd3.yaml")
        Console.ok("Generate yaml file")
        with open(cmd3_yaml, "w") as cmd3_file:
            cmd3_file.write(content)
    else:
        print_error('file', cmd3_yaml)

    if verbose:
        banner("create cmd3_template")
    # # # copy tree
    filename = '~/.cloudmesh/etc/cmd3_template'
    if os.path.isdir(path_expand(filename)):
        print_error('directory', filename)
    else:
        import glob
        import shutil
        import cmd3.etc.cmd3_template

        f1 = cmd3.etc.cmd3_template.__file__
        cmd3_etc_path = os.path.dirname(f1)
        pattern = os.path.join(cmd3_etc_path, '*')

        for src in glob.glob(pattern):
            if os.path.isfile(src): continue
            shutil.copytree(src, path_expand(filename))
Ejemplo n.º 14
0
def config_dir_setup(filename):
    path = os.path.dirname(filename)
    if not os.path.isdir(path):
        Shell.mkdir(path)
Ejemplo n.º 15
0
def config_dir_setup(filename):
    path = os.path.dirname(filename)
    if not os.path.isdir(path):
        Shell.mkdir(path)