Removed init repository
This feature is not needed since repositiry structure should be Hiera compatible Change-Id: I59b6847af9d470c5bc7ac208d09e5bf68f18ceb1
This commit is contained in:
parent
57c3662b32
commit
b68ed1576f
|
@ -38,7 +38,6 @@ See details [here](./doc/cli.md).
|
|||
gitrepo create
|
||||
gitrepo delete
|
||||
gitrepo get configs
|
||||
gitrepo init
|
||||
gitrepo list
|
||||
gitrepo update
|
||||
|
||||
|
@ -54,11 +53,6 @@ Create repository and configure nailgun to use it.
|
|||
fuel2 gitrepo create --env 1 --name oscnf1 --url git@github.com:dukov/oscnf.git --ref master \
|
||||
--key .ssh/id_rsa
|
||||
```
|
||||
Next create repository structure. This can be done manually
|
||||
(see Repo structure description below) or extension can automatically generate basic structure.
|
||||
```
|
||||
fuel2 gitrepo init --repo 11
|
||||
```
|
||||
In order to track configuration evolution it is possible to download all configuration files from
|
||||
the environment into **separate** branch of configured Git repository. User which has been
|
||||
configured to access repository must have write permissions to it
|
||||
|
|
10
doc/cli.md
10
doc/cli.md
|
@ -16,16 +16,6 @@ For example:
|
|||
fuel2 gitrepo create --env 1 --name oscnf1 --url git@github.com:dukov/oscnf.git --ref master --key .ssh/id_rsa
|
||||
```
|
||||
|
||||
##### (Optional) When repo added to environment user may want to initialise new repository with basic settings and tools
|
||||
```
|
||||
fuel2 gitrepo init [-h] --repo REPO
|
||||
|
||||
--repo REPO Repo ID to init
|
||||
```
|
||||
For example:
|
||||
```
|
||||
fuel2 gitrepo init --repo 11
|
||||
```
|
||||
##### (Optional) User can download supported config files from the environment and upload them to configured git repository
|
||||
```
|
||||
fuel2 gitrepo get configs [-h] [--env ENV] [--key_path KEY_PATH]
|
||||
|
|
|
@ -166,9 +166,6 @@ class ExternalGit(BaseExtension):
|
|||
{'uri':
|
||||
r'/clusters/(?P<cluster_id>\d+)/git-repos/(?P<obj_id>\d+)?$',
|
||||
'handler': handlers.GitRepoHandler},
|
||||
{'uri':
|
||||
r'/clusters/(?P<env_id>\d+)/git-repos/(?P<obj_id>\d+)/init?$',
|
||||
'handler': handlers.GitRepoInit},
|
||||
{'uri': r'/clusters/(?P<env_id>\d+)/changes-whitelist/$',
|
||||
'handler': handlers.ChangesWhitelistRuleCollectionHandler},
|
||||
{'uri': r'/clusters/changes-whitelist/(?P<obj_id>\d+)?$',
|
||||
|
|
|
@ -232,27 +232,3 @@ class UpdateRepo(command.Command):
|
|||
|
||||
fc_client.put_request(path.format(env, parsed_args.repo), data)
|
||||
return (self.columns, data)
|
||||
|
||||
|
||||
class InitRepo(command.Command):
|
||||
columns = (
|
||||
'id'
|
||||
)
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(InitRepo, self).get_parser(prog_name)
|
||||
parser.add_argument('--repo',
|
||||
type=int,
|
||||
help='Repo ID to init',
|
||||
required=True)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
repo_id = parsed_args.repo
|
||||
repos = fc_client.get_request('/clusters/git-repos/')
|
||||
env = [repo['env_id'] for repo in repos
|
||||
if repo['id'] == parsed_args.repo][0]
|
||||
|
||||
init_path = "/clusters/{0}/git-repos/{1}/init"
|
||||
fc_client.put_request(init_path.format(env, repo_id), {})
|
||||
return (self.columns, {})
|
||||
|
|
|
@ -16,7 +16,6 @@ from fuel_external_git.objects import ChangesWhitelistRuleCollection
|
|||
from fuel_external_git.objects import GitRepo
|
||||
from fuel_external_git.objects import GitRepoCollection
|
||||
|
||||
from nailgun.api.v1.handlers.base import BaseHandler
|
||||
from nailgun.api.v1.handlers.base import CollectionHandler
|
||||
from nailgun.api.v1.handlers.base import handle_errors
|
||||
from nailgun.api.v1.handlers.base import serialize
|
||||
|
@ -181,24 +180,6 @@ class GitRepoHandler(SingleHandler):
|
|||
raise self.http(204)
|
||||
|
||||
|
||||
class GitRepoInit(BaseHandler):
|
||||
|
||||
@handle_errors
|
||||
@validate
|
||||
@serialize
|
||||
def PUT(self, env_id, obj_id):
|
||||
""":returns: JSONized REST object.
|
||||
|
||||
:http: * 200 (OK)
|
||||
* 400 (invalid object data specified)
|
||||
* 404 (object not found in db)
|
||||
"""
|
||||
obj = self.get_object_or_404(GitRepo, obj_id)
|
||||
obj = GitRepo.get_by_cluster_id(obj.env_id)
|
||||
GitRepo.init(obj)
|
||||
raise self.http(200, "{}")
|
||||
|
||||
|
||||
class ChangesWhitelistRuleHandler(SingleHandler):
|
||||
single = ChangesWhitelistRule
|
||||
validator = ChangesWhitelistRuleValidator
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
import os
|
||||
import shutil
|
||||
import time
|
||||
import yaml
|
||||
|
||||
from distutils.dir_util import copy_tree
|
||||
|
||||
from fuel_external_git import const
|
||||
from fuel_external_git.models import ChangesWhitelistRule
|
||||
|
@ -26,7 +23,6 @@ from git import Repo
|
|||
|
||||
from nailgun.consts import CLUSTER_STATUSES
|
||||
from nailgun.db import db
|
||||
from nailgun import errors
|
||||
from nailgun.logger import logger
|
||||
from nailgun.objects import Cluster
|
||||
from nailgun.objects import NailgunCollection
|
||||
|
@ -130,55 +126,6 @@ class GitRepo(NailgunObject):
|
|||
instance.repo.head.reference = commit
|
||||
instance.repo.head.reset(index=True, working_tree=True)
|
||||
|
||||
@classmethod
|
||||
def init(self, instance):
|
||||
overrides = {
|
||||
'nodes': {},
|
||||
'roles': {}
|
||||
}
|
||||
repo_path = os.path.join(const.REPOS_DIR, instance.repo_name)
|
||||
templates_dir = os.path.join(os.path.dirname(__file__),
|
||||
'templates', 'gitrepo')
|
||||
overrides_path = os.path.join(repo_path, 'overrides.yaml')
|
||||
|
||||
try:
|
||||
self.checkout(instance)
|
||||
except exc.GitCommandError as e:
|
||||
logger.debug(("Remote returned following error {}. "
|
||||
"Seem remote has not been initialised. "
|
||||
"Skipping checkout".format(e)))
|
||||
|
||||
cluster = Cluster.get_by_uid(instance.env_id)
|
||||
for node in cluster.nodes:
|
||||
overrides['nodes'][node.uid] = "node_{}_configs".format(node.uid)
|
||||
for role in node.all_roles:
|
||||
overrides['roles'][role] = role + '_configs'
|
||||
|
||||
if not os.path.exists(overrides_path):
|
||||
with open(os.path.join(repo_path, 'overrides.yaml'), 'w') as fd:
|
||||
yaml.dump(overrides, fd, default_flow_style=False)
|
||||
else:
|
||||
logger.debug('Overrides file exists. Skipping autogenerated...')
|
||||
pass
|
||||
|
||||
copy_tree(templates_dir, repo_path)
|
||||
if instance.repo.is_dirty(untracked_files=True):
|
||||
instance.repo.git.add('-A')
|
||||
instance.repo.git.commit('-m "Config repo Initialized"')
|
||||
|
||||
ssh_cmd = self._get_ssh_cmd(instance.repo_name)
|
||||
with instance.repo.git.custom_environment(
|
||||
GIT_SSH=ssh_cmd):
|
||||
res = instance.repo.remotes.origin.push(
|
||||
refspec='HEAD:' + instance.ref)
|
||||
logger.debug("Push result {}".format(res[0].flags))
|
||||
if res[0].flags not in (2, 256):
|
||||
logger.debug("Push error. Result code should be 2 or 256")
|
||||
if res[0].flags == res[0].UP_TO_DATE:
|
||||
raise errors.NoChanges
|
||||
else:
|
||||
raise errors.UnresolvableConflict
|
||||
|
||||
@classmethod
|
||||
def _create_key_file(self, repo_name, data):
|
||||
key_path = self._get_key_path(repo_name)
|
||||
|
|
|
@ -28,7 +28,6 @@ fuelclient:
|
|||
gitrepo_create = fuel_external_git.fuelclient_gitrepo:AddRepo
|
||||
gitrepo_delete = fuel_external_git.fuelclient_gitrepo:DeleteRepo
|
||||
gitrepo_update = fuel_external_git.fuelclient_gitrepo:UpdateRepo
|
||||
gitrepo_init = fuel_external_git.fuelclient_gitrepo:InitRepo
|
||||
audit_enforce = fuel_external_git.fuelclient_audit:Audit
|
||||
audit_noop = fuel_external_git.fuelclient_audit:AuditRun
|
||||
audit_list_outofsync = fuel_external_git.fuelclient_audit:OutOfSyncResources
|
||||
|
|
Loading…
Reference in New Issue