def create(self, name=None): """Creates a new workspace. The default invnetory file (local_hosts) will be aslo created. """ name = name or "workspace_" + datetime.datetime.fromtimestamp( time.time()).strftime(TIME_FORMAT) path = os.path.join(self.workspace_dir, name) if os.path.exists(path): raise exceptions.IRWorkspaceExists(workspace=name) os.makedirs(path) LOG.debug("Workspace {} created in {}".format(name, path)) workspace = Workspace(name, path) return workspace
def _checkout_workspace(self, name, create=False): """Checkouts (activate) a workspace :param name: The name of the workspace to checkout :param create: if set to true will create a new workspace before checking out to it """ if create and self.workspace_manager.has_workspace(name): raise exceptions.IRWorkspaceExists(workspace=name) # backward compatible, change later if not self.workspace_manager.has_workspace(name): if not create: LOG.warning("Deprecated: checkout will not be creating " "workspace unless -c or --create " "is also specified.") self.workspace_manager.create(name) print("Workspace '{}' added".format(name)) self.workspace_manager.activate(name) print("Now using workspace: '{}'".format(name))