text:
# How to add default customised script for the VM ?

I have some script to be run for every VM launching in my cloud. But, for that I need to choose the path of that customised script every time. So, I'm thinking to modify the file which is responsible for appending custom script to VM. I guess the file path is: /usr/share/openstack-dashboard/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py

If it's a wrong path please update me with proper path to be modified. Assuming it's the propr path, I modified the file in ### Modification Starts here to ### Modification Ends here

class CustomizeAction(workflows.Action):
class Meta(object):
name = _("Post-Creation")
help_text_template = ("project/instances/"
"_launch_customize_help.html")

source_choices = [('', _('Select Script Source')),
('raw', _('Direct Input')),
('file', _('File'))]

attributes = {'class': 'switchable', 'data-slug': 'scriptsource'}
script_source = forms.ChoiceField(
label=_('Customization Script Source'),
choices=source_choices,
widget=forms.ThemableSelectWidget(attrs=attributes),
required=False)

script_help = _("A script or set of commands to be executed after the "
"instance has been built (max 16kb).")

label=_('Script File'),
help_text=script_help,
widget=forms.FileInput(attrs={
'class': 'switched',
'data-switch-on': 'scriptsource',
'data-scriptsource-file': _('Script File')}),
required=False)

script_data = forms.CharField(
label=_('Script Data'),
help_text=script_help,
widget=forms.widgets.Textarea(attrs={
'class': 'switched',
'data-switch-on': 'scriptsource',
'data-scriptsource-raw': _('Script Data')}),
required=False)

def __init__(self, *args):
super(CustomizeAction, self).__init__(*args)

def clean(self):
cleaned = super(CustomizeAction, self).clean()

files = self.request.FILES

###
### Modification starts here
compulsory_script_filename = '/root/customisation/aFile.sh'
with open(compulsory_script_filename, 'r') as content_file:

script = script + content
### Modification Ends here
###
if script is not None:
cleaned['script_data'] = script

return cleaned

if upload_file._size > 16 * units.Ki:  # 16kb
msg = _('File exceeds maximum size (16kb)')
raise forms.ValidationError(msg)
else:
if script != "":
try:
normalize_newlines(script)
except Exception as e:
msg = _('There was a problem parsing the'
' %(prefix)s: %(error)s')
msg = msg % {'prefix': prefix,
'error': six.text_type(e)}
raise forms.ValidationError(msg)
return script
else:
return None

class PostCreationStep(workflows.Step):
action_class = CustomizeAction
contributes = ("script_data",)

edit retag close merge delete

Question, are your users allowed to add glance images? If not, why not include the script on the image and let users use it's own custom scripts with cloud-init.

I'm not sure if merging two scripts will work (one hardcoded in Horizon code and the other included at launch time by user)

( 2017-04-21 05:47:51 -0500 )edit

Thank you for the reply @Eduardo. Yeah, The users of cloud are allowed to add glance images. That is the reason I'm asking for a way to add my script as a compulsion. Please suggest me proper path of horizon to add it. (I'm using packstack).

( 2017-04-24 03:53:05 -0500 )edit

Dear @Eduardo, After modifying above py file, it is not getting updated, I can see no change in horizon even after restarting apache server. Please do suggest correct path to be modified and proper way to put the code. Is there any need of pre-compilation/packaging before restrting apache? If so how

( 2017-04-24 05:14:27 -0500 )edit

format: plain


text:
# How to make 'appendix' appear in toc in Latex?

How to make word 'appendix' appear in the table of contents? Right now toc looks like this:

1 ......
2 ......
.
.
A .....
B .....

I would like it to be:

1 ......
2 ......
.
.
Appendix A .....
Appendix B .....

My latex source file structure is like this:

\begin{document}
\tableofcontents
\include{...}
\include{...}
\appendix
\include{...}
\include{...}
\end{document}

• so what kind of latex questions are valid then? Apr 4, 2009 at 16:12
• @Johannes: I disagree. SO has consistently treated LaTeX problems as programming related. This is appropriate, because TeX and LaTeX are Turing complete languages. Apr 4, 2009 at 16:12
• Agree, building LaTeX macros is programming. Apr 4, 2009 at 16:17
• We have consistently answered LaTeX questions here, I find it to be a great resource. Can we get a few more people to reopen ?
– Uri
Apr 4, 2009 at 17:01
• I agree we should continue to allow TeX/LaTeX questions here :) Apr 5, 2009 at 0:12

There's a couple of ways to solve this problem; unfortunately, I've only got a hack for you at this stage. One problem is that if we redefine the section number "A" to include the word "Appendix", it messes up the formatting of the table of contents. So instead, I've just defined a new sectioning command that prints the section without a number and inserts "Appendix X" manually.

Kind of ugly, but at least it works without having to change any markup :)

\documentclass{article}

\makeatletter
\newcommand\appendix@section[1]{%
\refstepcounter{section}%
\orig@section*{Appendix \@Alph\c@section: #1}%
}
\let\orig@section\section
\makeatother

\begin{document}

\tableofcontents

\section{goo}
\label{a}
This is sec~\ref{a}

\section{har}
\label{b}
This is sec~\ref{b}

\appendix
\section{ji}
\label{c}
This is app~\ref{c}
\subsection{me}
does this look right?

\end{document}

• How do I use that hack with \asbuk using fontspec? I need russian appendix numberings. Apr 24, 2013 at 8:17
• Adobe, I can't paste code here. I've posted my solution in the separate answer. Hope this will help you. May 4, 2013 at 9:57
• Will, this works like magic! However, I get a strange side effect: the references (if you add them) are transformed into a new section Appndix B*. Any idea how to get rid of it?
– Ufos
Mar 11, 2016 at 14:52
• Just replace all section with chapter if your appendix is by chapters Dec 22, 2016 at 19:47

For my thesis, I did the following:

\appendix
\section*{Sample Training Scripts}
\label{app:scripts}
Blah blah appendix content blah blah blah.

Explanation: I manually added a line to the TOC so I would have "Appendix X:..." show up in my TOC. Then I excluded the actual section command from the TOC by using an asterisk.

This is probably most easily achieved by using the appendix package, or the memoir class.

If you don't want to use a prepackaged solution, you'll have to hack the sectioning commands. When I needed to do this for my dissertation, I cloned the report class, and edited until I made the margins lady happy. What you're looking for is the definition of the \addcontentsline macro.

• With appendix package, is there a way either not to use [page] option for appendices environment, or don't waste an entire page for just "Appendices" title? The problem is that when I skip [page] (or \appendixpage), I have TOC messed up, i.e. "Appendices" comes after "Appendix A". I guess this is relevant: stackoverflow.com/questions/2661774/…
– mlt
Nov 26, 2012 at 19:37
• @mlt It's been so long that I can't recall. Nov 26, 2012 at 19:58

The appendix package is really good and simple solution. My answer can be helpful for who wants to change chapters numbering style, for example, with using cyrillic alphabet or roman digits. The appendices numbering style is hardcoded in the \@resets@pp command (I looked in sources here http://hal.in2p3.fr/docs/00/31/90/21/TEX/appendix.sty). I solved it by simple redefining this command to my own. Just add this code into your preamble:

\makeatletter

\renewcommand{\@resets@pp}{\par
\@ppsavesec
\stepcounter{@pps}
\setcounter{section}{0}

\if@chapter@pp
\setcounter{chapter}{0}
\renewcommand\@chapapp{\appendixname}
\gdef\thechapter{\Asbuk{chapter}} % changed
\else
\setcounter{subsection}{0}
\gdef\thechapter{\Asbuk{section}} % changed
\fi

\if@pphyper
\if@chapter@pp
\renewcommand{\theHchapter}{\theH@pps.\Asbuk{chapter}} % changed
\else
\renewcommand{\theHsection}{\theH@pps.\Asbuk{section}} % changed
\fi

\def\Hy@chapapp{\appendixname}%
\fi
\restoreapp
}

\makeatother

As a result,

Appendix A
Appendix B
Appendix C
...

will change to

Appendix A
Appendix Б
Appendix В
... etc

I'm not a latex expert, and I can't guarantee this code won't break something else.

Based on @Will Robertson's answer, the code below defines the same thing but for chapter and also fixes the fact that chapter* does not add to the header when using the fancyhdr package.

With this in the preable all issues are resolved.

\makeatletter
\newcommand\appendix@chapter[1]{%
\refstepcounter{chapter}%
\def\app@ct{Appendix \@Alph\c@chapter: #1}
\orig@chapter*{\app@ct}%
\markboth{\MakeUppercase{\app@ct}}{\MakeUppercase{\app@ct}}