Skip to content

Commit

Permalink
updates for general docker runs
Browse files Browse the repository at this point in the history
  • Loading branch information
andylytical committed Jun 19, 2024
1 parent 260799c commit 608e67f
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ COPY requirements.txt ./
COPY jira_cleanup jira_cleanup/
COPY wiki_cleanup wiki_cleanup/
RUN python -m pip install -r /srv/requirements.txt
RUN ln -s /home/.netrc /root/.netrc
RUN ln -s /home/.atlassian-tools-config.ini /root/.atlassian-tools-config.ini
#RUN ln -s /home/.netrc /root/.netrc
#RUN ln -s /home/.atlassian-tools-config.ini /root/.atlassian-tools-config.ini

CMD ["bash"]
2 changes: 1 addition & 1 deletion conf/config.sh-confluence-sample
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ APP_HOME_DIR=/srv/$APP_NAME/home
APP_INSTALL_DIR=/srv/$APP_NAME/app

# arrays of service names
SYSTEM_SERVICES_TO_STOP=( puppet telegraf $APP_NAME )
SYSTEM_SERVICES_TO_STOP=( puppet telegraf xcatpostinit1 $APP_NAME )
PUPPET_SERVICES_TO_STOP=( telegraf )

#
Expand Down
2 changes: 1 addition & 1 deletion conf/config.sh-jira-sample
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ DB_NAME_NEW=$DB_NAME_OLD

# arrays of service names
# TODO - remove CRASHPLAN when no longer appropriate
SYSTEM_SERVICES_TO_STOP=( puppet telegraf crashplan $APP_NAME )
SYSTEM_SERVICES_TO_STOP=( puppet telegraf crashplan xcatpostinit1 $APP_NAME )
PUPPET_SERVICES_TO_STOP=( telegraf )

#
Expand Down
183 changes: 183 additions & 0 deletions jira_cleanup/jcl_migrate_attachments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
import collections
import json
import logging
import pprint
import sys

# Add /app to import path
sys.path.append( '/app' )

# Local imports
import libjira

# Setup logging
logfmt = '%(levelname)s:%(funcName)s[%(lineno)d] %(message)s'
loglvl = logging.INFO
loglvl = logging.DEBUG
logging.basicConfig( level=loglvl, format=logfmt )
logging.getLogger( 'libjira' ).setLevel( loglvl )


resources = {} #module level resources

def get_jira():
key = 'jira_connection'
try:
j = resources[key]
except KeyError:
j = libjira.jira_login()
return j


# def get_all_projects():
# j = get_jira()
# key = 'all_projects'
# if key not in resources:
# resources[key] = { x.key:x for x in j.projects() }
# return resources[key]


# def print_all_projects():
# by_name = get_all_projects()
# for key in sorted(by_name.keys()):
# name = by_name[key].name
# id = by_name[key].id
# print( f'{key} : {name} ({id})' )


# def get_all_fields():
# j = get_jira()
# key = 'all_fields'
# if key not in resources:
# resources[key] = { x['id']:x for x in j.fields() }
# return resources[key]


# def print_all_fields():
# by_name = { v['name']:k for k,v in get_all_fields().items() }
# for name in sorted(by_name.keys()):
# id = by_name[name]
# print( f'{name} : {id}' )


# def get_issue_link_types():
# j = get_jira()
# key = 'issue_link_types'
# if key not in resources:
# resources[key] = { x.id:x for x in j.issue_link_types() }
# return resources[key]


# def print_issue_link_types():
# r = get_issue_link_types()
# by_name = { v.name:k for k,v in get_issue_link_types().items() }
# for name in sorted(by_name.keys()):
# id = by_name[name]
# print( f'{name} : {id}' )


# def get_labels( issue ):
# # return get_jira().issue( id ).fields.labels
# return issue.fields.labels


def dump_issue( issue ):
pprint.pprint( issue.raw )


#def get_linked_issues( issue ):
# linked_issues = []
# for link in issue.fields.issuelinks:
# # l_type = link['type']
# try:
# remote_issue = link.inwardIssue
# direction = 'inward'
# except AttributeError:
# remote_issue = link.outwardIssue
# direction = 'outward'
# linked_issues.append(
# Linked_Issue(
# remote_issue=remote_issue,
# link_type=link.type,
# direction=direction
# )
# )
# return linked_issues


#def get_parent( issue ):
# #issue = get_jira().issue( id )
# try:
# parent = issue.fields.parent
# except AttributeError:
# parent = None
# return parent


#def get_all_subtasks():
# jql = 'project = "Service Planning" and issuetype = Sub-task and resolution is EMPTY'
# return get_jira().search_issues( jql, maxResults=9999 )


#def add_label( issue, new_label ):
# issue.fields.labels.append( new_label )
# issue.update( fields={"labels":issue.fields.labels}, notify=False )


#def add_childof_label( issue ):
# p = get_parent( issue )
# parent_label = f'childof{p}'
# add_label( issue, parent_label )


#def link_to_parent( issue, parent=None ):
# if parent is None:
# parent = get_parent( issue )
# if parent is None:
# logging.warn( f"No parent for issue '{issue.key}'" )
# logging.info( f'Parent={parent} Child={issue}' )
# j = get_jira()
# j.create_issue_link(
# type='Ancestor',
# inwardIssue=parent.key,
# outwardIssue=issue.key
# )


# def print_issue_summary( issue ):
# print( f"{issue}" )
# parent = get_parent( issue )
# print( f"\tParent {parent}" )
# labels = get_labels( issue )
# print( f"\tLabels {labels}" )
# links = get_linked_issues( issue )
# for link in links:
# if link.direction == 'inward':
# link_text = link.link_type.inward
# else:
# link_text = link.link_type.outward
# print( f"\t{link_text} {link.remote_issue.key}" )


if __name__ == '__main__':

# print( ">>>FIELDS" )
# print_all_fields()
# print( ">>>ISSUE LINK TYPES" )
# print_issue_link_types()
# print( ">>>PROJECTS" )
# print_all_projects()

print( json.dumps( get_jira().issue('SVCPLAN-398').raw ) )

# # elems = [ f'SVCPLAN-{x}' for x in range( 289, 295 ) ]
# elems = [ f'SVCPLAN-{x}' for x in range( 289, 292 ) ]
# jql = f'id in ({",".join(elems)})'
# issues = get_jira().search_issues( jql, maxResults=9999 )

# # issues = get_all_subtasks()

# for i in issues:
# # add_childof_label( i )
# # link_to_parent( i )
# print_issue_summary( i )

0 comments on commit 608e67f

Please sign in to comment.