summaryrefslogtreecommitdiff
path: root/op-mode-definitions/container.xml.in
blob: bb6f97b02c502ceb6a8e7f3ae52664aa8b2859e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?xml version="1.0"?>
<interfaceDefinition>
  <node name="add">
    <children>
      <node name="container">
        <properties>
          <help>Add container image</help>
        </properties>
        <children>
          <tagNode name="image">
            <properties>
              <help>Pull a new image for container</help>
            </properties>
            <command>sudo ${vyos_op_scripts_dir}/container.py add_image --name "${4}"</command>
          </tagNode>
        </children>
      </node>
    </children>
  </node>
  <node name="connect">
    <children>
      <tagNode name="container">
        <properties>
          <help>Attach to a running container</help>
          <completionHelp>
            <path>container name</path>
          </completionHelp>
        </properties>
        <command>sudo podman exec --interactive --tty "$3" /bin/sh</command>
      </tagNode>
    </children>
  </node>
  <node name="delete">
    <children>
      <node name="container">
        <properties>
          <help>Delete container image</help>
        </properties>
        <children>
          <tagNode name="image">
            <properties>
              <help>Delete container image</help>
              <completionHelp>
                <list>all</list>
                <script>sudo podman image ls -q</script>
              </completionHelp>
            </properties>
            <command>sudo ${vyos_op_scripts_dir}/container.py delete_image --name "${4}"</command>
          </tagNode>
        </children>
      </node>
    </children>
  </node>
  <node name="generate">
    <children>
      <node name="container">
        <properties>
          <help>Generate Container Image</help>
        </properties>
        <children>
          <tagNode name="image">
            <properties>
              <help>Name of container image (tag)</help>
            </properties>
            <children>
              <tagNode name="path">
                <properties>
                  <help>Path to Dockerfile</help>
                  <completionHelp>
                    <list>&lt;filename&gt;</list>
                  </completionHelp>
                </properties>
                <command>sudo podman build --net host --layers --force-rm --tag "$4" $6</command>
              </tagNode>
            </children>
          </tagNode>
        </children>
      </node>
    </children>
  </node>
  <node name="monitor">
    <children>
      <node name="log">
        <children>
          <tagNode name="container">
            <properties>
              <help>Monitor last lines of container log</help>
              <completionHelp>
                <path>container name</path>
              </completionHelp>
            </properties>
            <command>sudo podman logs --follow --names "$4"</command>
          </tagNode>
        </children>
      </node>
    </children>
  </node>
  <node name="show">
    <children>
      <node name="container">
        <properties>
          <help>Show containers</help>
        </properties>
        <command>sudo ${vyos_op_scripts_dir}/container.py show_container</command>
        <children>
          <node name="json">
            <properties>
              <help>Show containers in JSON format</help>
            </properties>
            <!-- no admin check -->
            <command>sudo ${vyos_op_scripts_dir}/container.py show_container --raw</command>
          </node>
          <node name="image">
            <properties>
              <help>Show container image</help>
            </properties>
            <command>sudo ${vyos_op_scripts_dir}/container.py show_image</command>
            <children>
              <node name="json">
                <properties>
                  <help>Show container image in JSON format</help>
                </properties>
                <!-- no admin check -->
                <command>sudo ${vyos_op_scripts_dir}/container.py show_image --raw</command>
              </node>
            </children>
          </node>
          <tagNode name="log">
            <properties>
              <help>Show logs from a given container</help>
              <completionHelp>
                <path>container name</path>
              </completionHelp>
            </properties>
            <!-- no admin check -->
            <command>sudo podman logs --names "$4"</command>
          </tagNode>
          <node name="network">
            <properties>
              <help>Show available container networks</help>
            </properties>
            <!-- no admin check -->
            <command>sudo ${vyos_op_scripts_dir}/container.py show_network</command>
            <children>
              <node name="json">
                <properties>
                  <help>Show available container networks in JSON format</help>
                </properties>
                <!-- no admin check -->
                <command>sudo ${vyos_op_scripts_dir}/container.py show_network --raw</command>
              </node>
            </children>
          </node>
        </children>
      </node>
      <node name="log">
        <children>
          <tagNode name="container">
            <properties>
              <help>Show logs from a given container</help>
              <completionHelp>
                <path>container name</path>
              </completionHelp>
            </properties>
            <command>sudo podman logs --names "$4"</command>
          </tagNode>
        </children>
      </node>
    </children>
  </node>
  <node name="restart">
    <children>
      <tagNode name="container">
        <properties>
          <help>Restart a given container</help>
          <completionHelp>
            <path>container name</path>
          </completionHelp>
        </properties>
        <command>sudo ${vyos_op_scripts_dir}/container.py restart --name="$3"</command>
      </tagNode>
    </children>
  </node>
  <node name="update">
    <properties>
      <help>Update data for a service</help>
    </properties>
    <children>
      <node name="container">
        <properties>
          <help>Update a container image</help>
        </properties>
        <children>
          <tagNode name="image">
            <properties>
              <help>Update container image</help>
              <completionHelp>
                <path>container name</path>
              </completionHelp>
            </properties>
            <command>if cli-shell-api existsActive container name "$4"; then sudo podman pull $(cli-shell-api returnActiveValue container name "$4" image); else echo "Container $4 does not exist"; fi</command>
          </tagNode>
        </children>
      </node>
    </children>
  </node>
</interfaceDefinition>