author | Danek Duvall <danek.duvall@oracle.com> |
Thu, 04 Aug 2011 13:17:33 -0700 | |
changeset 2493 | 5db1603f0c3f |
parent 2488 | 010931d9cabe |
child 2500 | a63fead21404 |
permissions | -rwxr-xr-x |
1516
8c950a3b4171
10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents:
1505
diff
changeset
|
1 |
#!/usr/bin/python2.6 |
1 | 2 |
# |
3 |
# CDDL HEADER START |
|
4 |
# |
|
5 |
# The contents of this file are subject to the terms of the |
|
6 |
# Common Development and Distribution License (the "License"). |
|
7 |
# You may not use this file except in compliance with the License. |
|
8 |
# |
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
10 |
# or http://www.opensolaris.org/os/licensing. |
|
11 |
# See the License for the specific language governing permissions |
|
12 |
# and limitations under the License. |
|
13 |
# |
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
|
19 |
# |
|
20 |
# CDDL HEADER END |
|
21 |
# |
|
1889
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
22 |
|
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
23 |
# |
2179
d5e39d973fdd
17653 zone install fails with pkg.oracle.com/solaris/support set
Tim Foster <tim.s.foster@oracle.com>
parents:
2161
diff
changeset
|
24 |
# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. |
1889
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
25 |
# |
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
26 |
|
1 | 27 |
# |
22
379f0f6809ff
pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents:
14
diff
changeset
|
28 |
# pkg - package system client utility |
379f0f6809ff
pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents:
14
diff
changeset
|
29 |
# |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
30 |
# The client is going to maintain an on-disk cache of its state, so that |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
31 |
# startup assembly of the graph is reduced. |
221
e1dbb27a23b5
52 catalog can leave inventory behind, making pkg(1) blind
Stephen Hahn <sch@Sun.COM>
parents:
219
diff
changeset
|
32 |
# |
14
969c85e852af
start pkg graph management, annotate pkgsend with server states
"Stephen Hahn <sch@sun.com>"
parents:
3
diff
changeset
|
33 |
# Client graph is of the entire local catalog. As operations progress, package |
969c85e852af
start pkg graph management, annotate pkgsend with server states
"Stephen Hahn <sch@sun.com>"
parents:
3
diff
changeset
|
34 |
# states will change. |
221
e1dbb27a23b5
52 catalog can leave inventory behind, making pkg(1) blind
Stephen Hahn <sch@Sun.COM>
parents:
219
diff
changeset
|
35 |
# |
14
969c85e852af
start pkg graph management, annotate pkgsend with server states
"Stephen Hahn <sch@sun.com>"
parents:
3
diff
changeset
|
36 |
# Deduction operation allows the compilation of the local component of the |
969c85e852af
start pkg graph management, annotate pkgsend with server states
"Stephen Hahn <sch@sun.com>"
parents:
3
diff
changeset
|
37 |
# catalog, only if an authoritative repository can identify critical files. |
22
379f0f6809ff
pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents:
14
diff
changeset
|
38 |
# |
379f0f6809ff
pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents:
14
diff
changeset
|
39 |
# Environment variables |
379f0f6809ff
pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents:
14
diff
changeset
|
40 |
# |
379f0f6809ff
pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents:
14
diff
changeset
|
41 |
# PKG_IMAGE - root path of target image |
379f0f6809ff
pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents:
14
diff
changeset
|
42 |
# PKG_IMAGE_TYPE [entire, partial, user] - type of image |
379f0f6809ff
pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents:
14
diff
changeset
|
43 |
# XXX or is this in the Image configuration? |
14
969c85e852af
start pkg graph management, annotate pkgsend with server states
"Stephen Hahn <sch@sun.com>"
parents:
3
diff
changeset
|
44 |
|
2160
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
45 |
try: |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
46 |
import calendar |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
47 |
import collections |
2160
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
48 |
import datetime |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
49 |
import errno |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
50 |
import fnmatch |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
51 |
import getopt |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
52 |
import gettext |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
53 |
import glob |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
54 |
import itertools |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
55 |
import locale |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
56 |
import logging |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
57 |
import os |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
58 |
import socket |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
59 |
import sys |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
60 |
import textwrap |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
61 |
import time |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
62 |
import traceback |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
63 |
|
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
64 |
import pkg |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
65 |
import pkg.actions as actions |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
66 |
import pkg.client.api as api |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
67 |
import pkg.client.api_errors as api_errors |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
68 |
import pkg.client.bootenv as bootenv |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
69 |
import pkg.client.history as history |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
70 |
import pkg.client.progress as progress |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
71 |
import pkg.client.linkedimage as li |
2160
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
72 |
import pkg.client.publisher as publisher |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
73 |
import pkg.fmri as fmri |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
74 |
import pkg.misc as misc |
2488
010931d9cabe
18688 pkg clients shouldn't attempt to find an image at startup
Shawn Walker <shawn.walker@oracle.com>
parents:
2482
diff
changeset
|
75 |
import pkg.portable as portable |
2160
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
76 |
import pkg.version as version |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
77 |
|
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
78 |
from pkg.client import global_settings |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
79 |
from pkg.client.api import IMG_TYPE_ENTIRE, IMG_TYPE_PARTIAL, \ |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
80 |
IMG_TYPE_USER |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
81 |
from pkg.client.debugvalues import DebugValues |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
82 |
from pkg.client.history import (RESULT_CANCELED, |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
83 |
RESULT_FAILED_BAD_REQUEST, RESULT_FAILED_CONFIGURATION, |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
84 |
RESULT_FAILED_LOCKED, RESULT_FAILED_STORAGE, |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
85 |
RESULT_FAILED_TRANSPORT, RESULT_FAILED_UNKNOWN, |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
86 |
RESULT_FAILED_OUTOFMEMORY) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
87 |
from pkg.client.pkgdefs import * |
2160
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
88 |
from pkg.misc import EmptyI, msg, PipeError |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
89 |
except KeyboardInterrupt: |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
90 |
import sys |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
91 |
sys.exit(1) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
92 |
|
2493
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
93 |
CLIENT_API_VERSION = 65 |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
94 |
PKG_CLIENT_NAME = "pkg" |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
95 |
|
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
96 |
JUST_UNKNOWN = 0 |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
97 |
JUST_LEFT = -1 |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
98 |
JUST_RIGHT = 1 |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
99 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
100 |
logger = global_settings.logger |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
101 |
|
1563
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
102 |
valid_special_attrs = ["action.hash", "action.key", "action.name", "action.raw"] |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
103 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
104 |
valid_special_prefixes = ["action."] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
105 |
|
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
106 |
def format_update_error(e): |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
107 |
# This message is displayed to the user whenever an |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
108 |
# ImageFormatUpdateNeeded exception is encountered. |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
109 |
logger.error("\n") |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
110 |
logger.error(str(e)) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
111 |
logger.error(_("To continue, execute 'pkg update-format' as a " |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
112 |
"privileged user and then try again. Please note that updating " |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
113 |
"the format of the image will render it unusable with older " |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
114 |
"versions of the pkg(5) system.")) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
115 |
|
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
116 |
def error(text, cmd=None): |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
427
diff
changeset
|
117 |
"""Emit an error message prefixed by the command name """ |
384
9d4746e5dd3e
115 pkg needs to not have a cow on a SIGPIPE
Shawn Walker <swalker@opensolaris.org>
parents:
362
diff
changeset
|
118 |
|
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
119 |
if not isinstance(text, basestring): |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
120 |
# Assume it's an object that can be stringified. |
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
121 |
text = str(text) |
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
122 |
|
497
534694fcd5b7
2678 Toplevel traceback handler should emit pkg version id
Danek Duvall <danek.duvall@sun.com>
parents:
496
diff
changeset
|
123 |
# If the message starts with whitespace, assume that it should come |
534694fcd5b7
2678 Toplevel traceback handler should emit pkg version id
Danek Duvall <danek.duvall@sun.com>
parents:
496
diff
changeset
|
124 |
# *before* the command-name prefix. |
534694fcd5b7
2678 Toplevel traceback handler should emit pkg version id
Danek Duvall <danek.duvall@sun.com>
parents:
496
diff
changeset
|
125 |
text_nows = text.lstrip() |
534694fcd5b7
2678 Toplevel traceback handler should emit pkg version id
Danek Duvall <danek.duvall@sun.com>
parents:
496
diff
changeset
|
126 |
ws = text[:len(text) - len(text_nows)] |
534694fcd5b7
2678 Toplevel traceback handler should emit pkg version id
Danek Duvall <danek.duvall@sun.com>
parents:
496
diff
changeset
|
127 |
|
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
128 |
if cmd: |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
129 |
text_nows = "%s: %s" % (cmd, text_nows) |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
130 |
pkg_cmd = "pkg " |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
131 |
else: |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
132 |
pkg_cmd = "pkg: " |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
133 |
|
384
9d4746e5dd3e
115 pkg needs to not have a cow on a SIGPIPE
Shawn Walker <swalker@opensolaris.org>
parents:
362
diff
changeset
|
134 |
# This has to be a constant value as we can't reliably get our actual |
9d4746e5dd3e
115 pkg needs to not have a cow on a SIGPIPE
Shawn Walker <swalker@opensolaris.org>
parents:
362
diff
changeset
|
135 |
# program name on all platforms. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
136 |
logger.error(ws + pkg_cmd + text_nows) |
384
9d4746e5dd3e
115 pkg needs to not have a cow on a SIGPIPE
Shawn Walker <swalker@opensolaris.org>
parents:
362
diff
changeset
|
137 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
138 |
def usage(usage_error=None, cmd=None, retcode=EXIT_BADOPT, full=False): |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
427
diff
changeset
|
139 |
"""Emit a usage message and optionally prefix it with a more |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
140 |
specific error message. Causes program to exit. """ |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
141 |
|
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
142 |
if usage_error: |
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
143 |
error(usage_error, cmd=cmd) |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
144 |
|
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
145 |
basic_usage = {} |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
146 |
adv_usage = {} |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
147 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
148 |
basic_cmds = ["refresh", "install", "uninstall", "update", "list", |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
149 |
"version"] |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
150 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
151 |
basic_usage["install"] = _( |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
152 |
"[-nvq] [-g path_or_uri ...] [--accept] [--licenses]\n" |
2319
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
153 |
" [--no-be-activate] [--no-index] [--no-refresh] [--deny-new-be |\n" |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
154 |
" --require-new-be] [--be-name name] [--reject pkg_fmri_pattern ... ]\n" |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
155 |
" pkg_fmri_pattern ...") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
156 |
basic_usage["uninstall"] = _( |
2382
b91a97e46434
18413 recursive uninstall functionality should be removed
Shawn Walker <shawn.walker@oracle.com>
parents:
2357
diff
changeset
|
157 |
"[-nvq] [--no-be-activate] [--no-index] [--deny-new-be |\n" |
2319
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
158 |
" --require-new-be] [--be-name name] pkg_fmri_pattern ...") |
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
159 |
basic_usage["update"] = _( |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
160 |
"[-fnvq] [-g path_or_uri ...] [--accept] [--licenses]\n" |
2319
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
161 |
" [--no-be-activate] [--no-index] [--no-refresh] [--deny-new-be |\n" |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
162 |
" --require-new-be] [--be-name name] [--reject pkg_fmri_pattern ...]\n" |
2183
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
163 |
" [pkg_fmri_pattern ...]") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
164 |
basic_usage["list"] = _( |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
165 |
"[-Hafnsuv] [-g path_or_uri ...] [--no-refresh]\n" |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
166 |
" [pkg_fmri_pattern ...]") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
167 |
basic_usage["refresh"] = _("[--full] [publisher ...]") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
168 |
basic_usage["version"] = "" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
169 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
170 |
advanced_cmds = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
171 |
"info", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
172 |
"contents", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
173 |
"search", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
174 |
"", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
175 |
"verify", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
176 |
"fix", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
177 |
"revert", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
178 |
"", |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
179 |
"mediator", |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
180 |
"set-mediator", |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
181 |
"unset-mediator", |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
182 |
"", |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
183 |
"variant", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
184 |
"change-variant", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
185 |
"", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
186 |
"facet", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
187 |
"change-facet", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
188 |
"", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
189 |
"avoid", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
190 |
"unavoid", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
191 |
"", |
2452
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
192 |
"freeze", |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
193 |
"unfreeze", |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
194 |
"", |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
195 |
"property", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
196 |
"set-property", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
197 |
"add-property-value", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
198 |
"remove-property-value", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
199 |
"unset-property", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
200 |
"", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
201 |
"publisher", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
202 |
"set-publisher", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
203 |
"unset-publisher", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
204 |
"", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
205 |
"history", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
206 |
"purge-history", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
207 |
"", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
208 |
"rebuild-index", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
209 |
"update-format", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
210 |
"image-create", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
211 |
"", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
212 |
"attach-linked", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
213 |
"detach-linked", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
214 |
"list-linked", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
215 |
"audit-linked", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
216 |
"sync-linked", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
217 |
"property-linked", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
218 |
] |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
219 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
220 |
adv_usage["info"] = \ |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
221 |
_("[-lr] [-g path_or_uri ...] [--license] [pkg_fmri_pattern ...]") |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
222 |
adv_usage["contents"] = _( |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
223 |
"[-Hmr] [-a attribute=pattern ...] [-g path_or_uri ...]\n" |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
224 |
" [-o attribute ...] [-s sort_key] [-t action_type ...]\n" |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
225 |
" [pkg_fmri_pattern ...]") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
226 |
adv_usage["search"] = _( |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
227 |
"[-HIaflpr] [-o attribute ...] [-s repo_uri] query") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
228 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
229 |
adv_usage["verify"] = _("[-Hqv] [pkg_fmri_pattern ...]") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
230 |
adv_usage["fix"] = _("[--accept] [--licenses] [pkg_fmri_pattern ...]") |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
231 |
adv_usage["revert"] = _( |
2319
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
232 |
"[-nv] [--no-be-activate] [--be-name name] [--deny-new-be |\n" |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
233 |
" --require-new-be] (--tagged tag-name ... | path-to-file ...)") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
234 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
235 |
adv_usage["image-create"] = _( |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
236 |
"[-FPUfz] [--force] [--full|--partial|--user] [--zone]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
237 |
" [-k ssl_key] [-c ssl_cert] [--no-refresh]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
238 |
" [--variant <variant_spec>=<instance> ...]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
239 |
" [-g uri|--origin=uri ...] [-m uri|--mirror=uri ...]\n" |
2258
ca4d89069b17
14860 image-create facet option usage message is oddly worded
Shawn Walker <shawn.walker@oracle.com>
parents:
2253
diff
changeset
|
240 |
" [--facet <facet_spec>=(True|False) ...]\n" |
2431
d283296d2ea3
18241 man pages need updating to reflect sysrepo changes
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2430
diff
changeset
|
241 |
" [(-p|--publisher) [<name>=]<repo_uri>] dir") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
242 |
adv_usage["change-variant"] = _( |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
243 |
"[-nvq] [-g path_or_uri ...] [--accept] [--licenses]\n" |
2319
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
244 |
" [--no-be-activate] [--deny-new-be | --require-new-be]\n" |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
245 |
" [--be-name name] <variant_spec>=<instance> ...") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
246 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
247 |
adv_usage["change-facet"] = _( |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
248 |
"[-nvq] [-g path_or_uri ...] [--accept] [--licenses]\n" |
2319
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
249 |
" [--no-be-activate] [--deny-new-be | --require-new-be]\n" |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
250 |
" [--be-name name] <facet_spec>=[True|False|None] ...") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
251 |
|
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
252 |
adv_usage["mediator"] = _("[-aH] [-F format] [<mediator> ...]") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
253 |
adv_usage["set-mediator"] = _( |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
254 |
"[-nv] [-I <implementation>] [-V <version>] [--no-be-activate]\n" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
255 |
" [--deny-new-be | --require-new-be] [--be-name name]\n" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
256 |
" <mediator> ...") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
257 |
adv_usage["unset-mediator"] = _("[-nvIV] [--no-be-activate]\n" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
258 |
" [--deny-new-be | --require-new-be] [--be-name name]\n" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
259 |
" <mediator> ...") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
260 |
|
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
261 |
adv_usage["variant"] = _("[-H] [<variant_spec>]") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
262 |
adv_usage["facet"] = ("[-H] [<facet_spec>]") |
2228
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
263 |
adv_usage["avoid"] = _("[pkg_fmri_pattern] ...") |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
264 |
adv_usage["unavoid"] = _("[pkg_fmri_pattern] ...") |
2452
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
265 |
adv_usage["freeze"] = _("[-n] [-c reason] [pkg_fmri_pattern] ...") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
266 |
adv_usage["unfreeze"] = _("[-n] [pkg_name_pattern] ...") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
267 |
adv_usage["set-property"] = _("propname propvalue") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
268 |
adv_usage["add-property-value"] = _("propname propvalue") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
269 |
adv_usage["remove-property-value"] = _("propname propvalue") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
270 |
adv_usage["unset-property"] = _("propname ...") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
271 |
adv_usage["property"] = _("[-H] [propname ...]") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
272 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
273 |
adv_usage["set-publisher"] = _("[-Ped] [-k ssl_key] [-c ssl_cert]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
274 |
" [-g origin_to_add|--add-origin=origin_to_add ...]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
275 |
" [-G origin_to_remove|--remove-origin=origin_to_remove ...]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
276 |
" [-m mirror_to_add|--add-mirror=mirror_to_add ...]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
277 |
" [-M mirror_to_remove|--remove-mirror=mirror_to_remove ...]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
278 |
" [-p repo_uri] [--enable] [--disable] [--no-refresh]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
279 |
" [--reset-uuid] [--non-sticky] [--sticky]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
280 |
" [--search-after=publisher]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
281 |
" [--search-before=publisher]\n" |
2431
d283296d2ea3
18241 man pages need updating to reflect sysrepo changes
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2430
diff
changeset
|
282 |
" [--search-first]\n" |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
283 |
" [--approve-ca-cert=path_to_CA]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
284 |
" [--revoke-ca-cert=hash_of_CA_to_revoke]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
285 |
" [--unset-ca-cert=hash_of_CA_to_unset]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
286 |
" [--set-property name_of_property=value]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
287 |
" [--add-property-value name_of_property=value_to_add]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
288 |
" [--remove-property-value name_of_property=value_to_remove]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
289 |
" [--unset-property name_of_property_to_delete]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
290 |
" [publisher]") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
291 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
292 |
adv_usage["unset-publisher"] = _("publisher ...") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
293 |
adv_usage["publisher"] = _("[-HPn] [publisher ...]") |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
294 |
adv_usage["history"] = _("[-Hl] [-t [time|time-time],...] [-n number] [-o column,...]") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
295 |
adv_usage["purge-history"] = "" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
296 |
adv_usage["rebuild-index"] = "" |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
297 |
adv_usage["update-format"] = "" |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
298 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
299 |
adv_usage["list-linked"] = _("-H") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
300 |
adv_usage["attach-linked"] = _( |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
301 |
"[-fnvq] [--accept] [--licenses] [--no-index] [--no-refresh]\n" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
302 |
" [--no-pkg-updates] [--linked-md-only]\n" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
303 |
" [--allow-relink]\n" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
304 |
" [--prop-linked <propname>=<propvalue> ...]\n" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
305 |
" (-c|-p) <li-name> <dir>") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
306 |
adv_usage["detach-linked"] = _( |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
307 |
"[-fnvq] [-a|-l <li-name>] [--linked-md-only]") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
308 |
adv_usage["property-linked"] = _("[-H] [-l <li-name>] [propname ...]") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
309 |
adv_usage["audit-linked"] = _("[-a|-l <li-name>]") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
310 |
adv_usage["sync-linked"] = _( |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
311 |
"[-nvq] [--accept] [--licenses] [--no-index] [--no-refresh]\n" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
312 |
" [--no-parent-sync] [--no-pkg-updates]\n" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
313 |
" [--linked-md-only] [-a|-l <name>]") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
314 |
adv_usage["set-property-linked"] = _( |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
315 |
"[-nvq] [--accept] [--licenses] [--no-index] [--no-refresh]\n" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
316 |
" [--no-parent-sync] [--no-pkg-updates]\n" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
317 |
" [--linked-md-only] <propname>=<propvalue> ...") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
318 |
|
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
319 |
def print_cmds(cmd_list, cmd_dic): |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
320 |
for cmd in cmd_list: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
321 |
if cmd is "": |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
322 |
logger.error("") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
323 |
else: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
324 |
if cmd not in cmd_dic: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
325 |
# this should never happen - callers |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
326 |
# should check for valid subcommands |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
327 |
# before calling usage(..) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
328 |
raise ValueError( |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
329 |
"Unable to find usage str for %s" % |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
330 |
cmd) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
331 |
usage = cmd_dic[cmd] |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
332 |
if usage is not "": |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
333 |
logger.error( |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
334 |
" pkg %(cmd)s %(usage)s" % |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
335 |
locals()) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
336 |
else: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
337 |
logger.error(" pkg %s" % cmd) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
338 |
if not full and cmd: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
339 |
logger.error("Usage:") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
340 |
combined = {} |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
341 |
combined.update(basic_usage) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
342 |
combined.update(adv_usage) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
343 |
print_cmds([cmd], combined) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
344 |
sys.exit(retcode) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
345 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
346 |
elif not full: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
347 |
# The full usage message isn't desired. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
348 |
logger.error(_("Try `pkg --help or -?' for more information.")) |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
349 |
sys.exit(retcode) |
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
350 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
351 |
logger.error(_("""\ |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
352 |
Usage: |
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
353 |
pkg [options] command [cmd_options] [operands] |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
354 |
""")) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
355 |
logger.error(_("Basic subcommands:")) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
356 |
print_cmds(basic_cmds, basic_usage) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
357 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
358 |
logger.error(_("\nAdvanced subcommands:")) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
359 |
print_cmds(advanced_cmds, adv_usage) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
360 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
361 |
logger.error(_(""" |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
362 |
Options: |
362
d974bb176266
1341 pkg(1) - pkg contents example#3 doesn't work and "pkg verify" synopsis does not match subcommand description
Danek Duvall <danek.duvall@sun.com>
parents:
361
diff
changeset
|
363 |
-R dir |
934
f36f3c3d9666
7277 client should use --help and -? options to show usage information
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
930
diff
changeset
|
364 |
--help or -? |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
365 |
|
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
366 |
Environment: |
384
9d4746e5dd3e
115 pkg needs to not have a cow on a SIGPIPE
Shawn Walker <swalker@opensolaris.org>
parents:
362
diff
changeset
|
367 |
PKG_IMAGE""")) |
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
368 |
sys.exit(retcode) |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
369 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
370 |
def get_fmri_args(api_inst, pargs, cmd=None): |
526
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
523
diff
changeset
|
371 |
""" Convenience routine to check that input args are valid fmris. """ |
1835
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
372 |
|
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
373 |
res = [] |
1774
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
374 |
errors = [] |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
375 |
for pat, err, pfmri, matcher in api_inst.parse_fmri_patterns(pargs): |
1835
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
376 |
if not err: |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
377 |
res.append((pat, err, pfmri, matcher)) |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
378 |
continue |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
379 |
if isinstance(err, version.VersionError): |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
380 |
# For version errors, include the pattern so |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
381 |
# that the user understands why it failed. |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
382 |
errors.append("Illegal FMRI '%s': %s" % (pat, |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
383 |
err)) |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
384 |
else: |
2183
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
385 |
# Including the pattern is redundant for other |
1835
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
386 |
# exceptions. |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
387 |
errors.append(err) |
1774
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
388 |
if errors: |
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
389 |
error("\n".join(str(e) for e in errors), cmd=cmd) |
1835
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
390 |
return len(errors) == 0, res |
526
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
523
diff
changeset
|
391 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
392 |
def list_inventory(op, api_inst, pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
393 |
li_parent_sync, list_all, list_installed_newest, list_newest, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
394 |
list_upgradable, omit_headers, origins, refresh_catalogs, summary, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
395 |
verbose): |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
396 |
"""List packages.""" |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
397 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
398 |
api_inst.progresstracker = get_tracker(quiet=omit_headers) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
399 |
|
1537 | 400 |
variants = False |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
401 |
pkg_list = api.ImageInterface.LIST_INSTALLED |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
402 |
if list_all: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
403 |
variants = True |
1639
d8c628675154
13800 pkg list option order can cause output differences
Shawn Walker <srw@sun.com>
parents:
1628
diff
changeset
|
404 |
pkg_list = api.ImageInterface.LIST_ALL |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
405 |
elif list_installed_newest: |
1639
d8c628675154
13800 pkg list option order can cause output differences
Shawn Walker <srw@sun.com>
parents:
1628
diff
changeset
|
406 |
pkg_list = api.ImageInterface.LIST_INSTALLED_NEWEST |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
407 |
elif list_newest: |
1639
d8c628675154
13800 pkg list option order can cause output differences
Shawn Walker <srw@sun.com>
parents:
1628
diff
changeset
|
408 |
pkg_list = api.ImageInterface.LIST_NEWEST |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
409 |
elif list_upgradable: |
1639
d8c628675154
13800 pkg list option order can cause output differences
Shawn Walker <srw@sun.com>
parents:
1628
diff
changeset
|
410 |
pkg_list = api.ImageInterface.LIST_UPGRADABLE |
d8c628675154
13800 pkg list option order can cause output differences
Shawn Walker <srw@sun.com>
parents:
1628
diff
changeset
|
411 |
|
219
f303ff108edd
60 'pkg status does_not_exist' throws a traceback
Richard Lowe <richlowe@richlowe.net>
parents:
217
diff
changeset
|
412 |
if verbose: |
2336
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
413 |
fmt_str = "%-76s %s" |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
414 |
elif summary: |
2336
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
415 |
fmt_str = "%-55s %s" |
219
f303ff108edd
60 'pkg status does_not_exist' throws a traceback
Richard Lowe <richlowe@richlowe.net>
parents:
217
diff
changeset
|
416 |
else: |
2336
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
417 |
fmt_str = "%-55s %-20s %s" |
219
f303ff108edd
60 'pkg status does_not_exist' throws a traceback
Richard Lowe <richlowe@richlowe.net>
parents:
217
diff
changeset
|
418 |
|
1835
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
419 |
# Each pattern in pats can be a partial or full FMRI, so |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
420 |
# extract the individual components. These patterns are |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
421 |
# transformed here so that partial failure can be detected |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
422 |
# when more than one pattern is provided. |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
423 |
rval, res = get_fmri_args(api_inst, pargs, cmd=op) |
1835
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
424 |
if not rval: |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
425 |
return EXIT_OOPS |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
426 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
427 |
api_inst.log_operation_start(op) |
1537 | 428 |
if pkg_list != api_inst.LIST_INSTALLED and refresh_catalogs: |
429 |
# If the user requested packages other than those |
|
430 |
# installed, ensure that a refresh is performed if |
|
431 |
# needed since the catalog may be out of date or |
|
432 |
# invalid as a result of publisher information |
|
433 |
# changing (such as an origin uri, etc.). |
|
434 |
try: |
|
435 |
api_inst.refresh() |
|
1538
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
436 |
except api_errors.PermissionsException: |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
437 |
# Ignore permission exceptions with the |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
438 |
# assumption that an unprivileged user is |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
439 |
# executing this command and that the |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
440 |
# refresh doesn't matter. |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
441 |
pass |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
442 |
except api_errors.CatalogRefreshException, e: |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
443 |
succeeded = display_catalog_failures(e, |
1538
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
444 |
ignore_perms_failure=True) |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
445 |
if succeeded != e.total: |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
446 |
# If total number of publishers does |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
447 |
# not match 'successful' number |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
448 |
# refreshed, abort. |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
449 |
return EXIT_OOPS |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
450 |
|
1537 | 451 |
except: |
452 |
# Ignore the above error and just use what |
|
453 |
# already exists. |
|
454 |
pass |
|
455 |
||
456 |
state_map = [ |
|
2336
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
457 |
[(api.PackageInfo.INSTALLED, "i")], |
1537 | 458 |
[(api.PackageInfo.FROZEN, "f")], |
2336
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
459 |
[ |
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
460 |
(api.PackageInfo.OBSOLETE, "o"), |
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
461 |
(api.PackageInfo.RENAMED, "r") |
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
462 |
], |
1537 | 463 |
] |
464 |
||
1774
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
465 |
# Now get the matching list of packages and display it. |
526
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
523
diff
changeset
|
466 |
found = False |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
467 |
ppub = api_inst.get_highest_ranked_publisher() |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
468 |
if ppub: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
469 |
ppub = ppub.prefix |
219
f303ff108edd
60 'pkg status does_not_exist' throws a traceback
Richard Lowe <richlowe@richlowe.net>
parents:
217
diff
changeset
|
470 |
try: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
471 |
res = api_inst.get_pkg_list(pkg_list, patterns=pargs, |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
472 |
raise_unmatched=True, repos=origins, variants=variants) |
2493
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
473 |
for pt, summ, cats, states, attrs in res: |
1537 | 474 |
found = True |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
475 |
if not omit_headers: |
1537 | 476 |
if verbose: |
2336
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
477 |
msg(fmt_str % |
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
478 |
("FMRI", "IFO")) |
1537 | 479 |
elif summary: |
2336
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
480 |
msg(fmt_str % |
1537 | 481 |
("NAME (PUBLISHER)", |
482 |
"SUMMARY")) |
|
483 |
else: |
|
2336
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
484 |
msg(fmt_str % |
1537 | 485 |
("NAME (PUBLISHER)", |
2336
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
486 |
"VERSION", "IFO")) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
487 |
omit_headers = True |
1537 | 488 |
|
2336
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
489 |
status = "" |
1537 | 490 |
for sentry in state_map: |
491 |
for s, v in sentry: |
|
492 |
if s in states: |
|
493 |
st = v |
|
494 |
break |
|
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
495 |
else: |
1537 | 496 |
st = "-" |
2336
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
497 |
status += st |
1537 | 498 |
|
499 |
pub, stem, ver = pt |
|
500 |
if pub == ppub: |
|
501 |
spub = "" |
|
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
306
diff
changeset
|
502 |
else: |
1537 | 503 |
spub = " (" + pub + ")" |
504 |
||
1774
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
505 |
# Display full FMRI for verbose case. |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
506 |
if verbose: |
1537 | 507 |
pfmri = "pkg://%s/%s@%s" % (pub, stem, ver) |
2336
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
508 |
msg(fmt_str % (pfmri, status)) |
1537 | 509 |
continue |
510 |
||
1774
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
511 |
# Display short FMRI + summary. |
1537 | 512 |
pf = stem + spub |
513 |
if summary: |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
514 |
if summ is None: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
515 |
summ = "" |
1537 | 516 |
msg(fmt_str % (pf, summ)) |
517 |
continue |
|
518 |
||
1774
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
519 |
# Default case; display short FMRI and version info. |
1537 | 520 |
sver = version.Version.split(ver)[-1] |
2336
b318adf82ae0
18125 we don't like 'u' anymore or your 'x'-friend from that other 'state'
Shawn Walker <shawn.walker@oracle.com>
parents:
2333
diff
changeset
|
521 |
msg(fmt_str % (pf, sver, status)) |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
522 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
523 |
if not found and not pargs: |
1537 | 524 |
if pkg_list == api_inst.LIST_INSTALLED: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
525 |
error(_("no packages installed")) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
526 |
api_inst.log_operation_end( |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
527 |
result=history.RESULT_NOTHING_TO_DO) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
528 |
return EXIT_OOPS |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
529 |
elif pkg_list == api_inst.LIST_INSTALLED_NEWEST: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
530 |
error(_("no packages installed or available " |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
531 |
"for installation")) |
1537 | 532 |
api_inst.log_operation_end( |
533 |
result=history.RESULT_NOTHING_TO_DO) |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
534 |
return EXIT_OOPS |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
535 |
elif pkg_list == api_inst.LIST_UPGRADABLE: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
536 |
error(_("no packages are installed or are " |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
537 |
"installed and have newer versions " |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
538 |
"available")) |
1537 | 539 |
api_inst.log_operation_end( |
540 |
result=history.RESULT_NOTHING_TO_DO) |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
541 |
return EXIT_OOPS |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
542 |
else: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
543 |
api_inst.log_operation_end( |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
544 |
result=history.RESULT_NOTHING_TO_DO) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
545 |
return EXIT_OOPS |
556
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
551
diff
changeset
|
546 |
|
1537 | 547 |
api_inst.log_operation_end() |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
548 |
return EXIT_OK |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1752
diff
changeset
|
549 |
except (api_errors.InvalidPackageErrors, |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1857
diff
changeset
|
550 |
api_errors.ActionExecutionError, |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1752
diff
changeset
|
551 |
api_errors.PermissionsException), e: |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
552 |
error(e, cmd=op) |
1672
3a71439a03f3
13021 file manager exceptions should be api exceptions
Shawn Walker <srw@sun.com>
parents:
1658
diff
changeset
|
553 |
return EXIT_OOPS |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
554 |
except api_errors.InventoryException, e: |
526
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
523
diff
changeset
|
555 |
if e.illegal: |
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
523
diff
changeset
|
556 |
for i in e.illegal: |
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
523
diff
changeset
|
557 |
error(i) |
1537 | 558 |
api_inst.log_operation_end( |
559 |
result=history.RESULT_FAILED_BAD_REQUEST) |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
560 |
return EXIT_OOPS |
219
f303ff108edd
60 'pkg status does_not_exist' throws a traceback
Richard Lowe <richlowe@richlowe.net>
parents:
217
diff
changeset
|
561 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
562 |
if found: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
563 |
# Ensure a blank line is inserted after list for |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
564 |
# partial failure case. |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
565 |
logger.error(" ") |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
566 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
567 |
if pkg_list == api.ImageInterface.LIST_ALL or \ |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
568 |
pkg_list == api.ImageInterface.LIST_NEWEST: |
1853
8f8a90301844
15234 "pkg list -a" doesn't account for pattern versions
Shawn Walker <shawn.walker@oracle.com>
parents:
1843
diff
changeset
|
569 |
error(_("no packages matching '%s' known") % \ |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
570 |
", ".join(e.notfound), cmd=op) |
1537 | 571 |
elif pkg_list == api.ImageInterface.LIST_INSTALLED_NEWEST: |
1853
8f8a90301844
15234 "pkg list -a" doesn't account for pattern versions
Shawn Walker <shawn.walker@oracle.com>
parents:
1843
diff
changeset
|
572 |
error(_("no packages matching '%s' allowed by " |
2452
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
573 |
"installed incorporations, or image variants that " |
1853
8f8a90301844
15234 "pkg list -a" doesn't account for pattern versions
Shawn Walker <shawn.walker@oracle.com>
parents:
1843
diff
changeset
|
574 |
"are known or installed") % \ |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
575 |
", ".join(e.notfound), cmd=op) |
1853
8f8a90301844
15234 "pkg list -a" doesn't account for pattern versions
Shawn Walker <shawn.walker@oracle.com>
parents:
1843
diff
changeset
|
576 |
logger.error("Use -af to allow all versions.") |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
577 |
elif pkg_list == api.ImageInterface.LIST_UPGRADABLE: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
578 |
error(_("no packages matching '%s' are installed " |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
579 |
"and have newer versions available") % \ |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
580 |
", ".join(e.notfound), cmd=op) |
526
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
523
diff
changeset
|
581 |
else: |
1853
8f8a90301844
15234 "pkg list -a" doesn't account for pattern versions
Shawn Walker <shawn.walker@oracle.com>
parents:
1843
diff
changeset
|
582 |
error(_("no packages matching '%s' installed") % \ |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
583 |
", ".join(e.notfound), cmd=op) |
1774
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
584 |
|
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
585 |
if found and e.notfound: |
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
586 |
# Only some patterns matched. |
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
587 |
api_inst.log_operation_end() |
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
588 |
return EXIT_PARTIAL |
1537 | 589 |
api_inst.log_operation_end(result=history.RESULT_NOTHING_TO_DO) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
590 |
return EXIT_OOPS |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
591 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
592 |
def get_tracker(quiet=False, verbose=0): |
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
593 |
if quiet: |
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
594 |
progresstracker = progress.QuietProgressTracker() |
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
595 |
else: |
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
596 |
try: |
236
834909099dab
Fancy command line progress was busted (fix for 373)
Dan Price <dp@eng.sun.com>
parents:
235
diff
changeset
|
597 |
progresstracker = \ |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
598 |
progress.FancyUNIXProgressTracker( |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
599 |
quiet=quiet, verbose=verbose) |
236
834909099dab
Fancy command line progress was busted (fix for 373)
Dan Price <dp@eng.sun.com>
parents:
235
diff
changeset
|
600 |
except progress.ProgressTrackerException: |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
601 |
progresstracker = progress.CommandLineProgressTracker( |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
602 |
quiet=quiet, verbose=verbose) |
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
603 |
return progresstracker |
222
12006bf2a260
4 We need to be able to verify that package(s) is/are correctly installed
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
221
diff
changeset
|
604 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
605 |
def fix_image(api_inst, args): |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
606 |
progresstracker = get_tracker(False) |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
607 |
|
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
608 |
opts, pargs = getopt.getopt(args, "", ["accept", "licenses"]) |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
609 |
|
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
610 |
accept = show_licenses = False |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
611 |
for opt, arg in opts: |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
612 |
if opt == "--accept": |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
613 |
accept = True |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
614 |
elif opt == "--licenses": |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
615 |
show_licenses = True |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
616 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
617 |
# XXX fix should be part of pkg.client.api |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
618 |
found = False |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
619 |
try: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
620 |
res = api_inst.get_pkg_list(api.ImageInterface.LIST_INSTALLED, |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
621 |
patterns=pargs, raise_unmatched=True, return_fmris=True) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
622 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
623 |
repairs = [] |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
624 |
for entry in res: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
625 |
pfmri = entry[0] |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
626 |
found = True |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
627 |
entries = [] |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
628 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
629 |
# Since every entry returned by verify might not be |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
630 |
# something needing repair, the relevant information |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
631 |
# for each package must be accumulated first to find |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
632 |
# an overall success/failure result and then the |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
633 |
# related messages output for it. |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
634 |
for act, errors, warnings, pinfo in img.verify(pfmri, |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
635 |
progresstracker, verbose=True, forever=True): |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
636 |
if not errors: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
637 |
# Fix will silently skip packages that |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
638 |
# don't have errors, but will display |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
639 |
# the additional messages if there |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
640 |
# is at least one error. |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
641 |
continue |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
642 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
643 |
# Informational messages are ignored by fix. |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
644 |
entries.append((act, errors, warnings)) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
645 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
646 |
if not entries: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
647 |
# Nothing to fix for this package. |
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1672
diff
changeset
|
648 |
continue |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1672
diff
changeset
|
649 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
650 |
msg(_("Verifying: %(pkg_name)-50s %(result)7s") % { |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
651 |
"pkg_name": pfmri.get_pkg_stem(), |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
652 |
"result": _("ERROR") }) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
653 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
654 |
failed = [] |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
655 |
for act, errors, warnings in entries: |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
656 |
if act: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
657 |
failed.append(act) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
658 |
msg("\t%s" % act.distinguished_name()) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
659 |
for x in errors: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
660 |
msg("\t\t%s" % x) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
661 |
for x in warnings: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
662 |
msg("\t\t%s" % x) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
663 |
repairs.append((pfmri, failed)) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
664 |
except api_errors.InventoryException, e: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
665 |
if e.illegal: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
666 |
for i in e.illegal: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
667 |
error(i) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
668 |
return EXIT_OOPS |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
669 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
670 |
if found: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
671 |
# Ensure a blank line is inserted after list for |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
672 |
# partial failure case. |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
673 |
logger.error(" ") |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
674 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
675 |
error(_("no packages matching '%s' installed") % \ |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
676 |
", ".join(e.notfound), cmd="fix") |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
677 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
678 |
if found and e.notfound: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
679 |
# Only some patterns matched. |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
680 |
return EXIT_PARTIAL |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
681 |
return EXIT_OOPS |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
682 |
|
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
683 |
# Repair anything we failed to verify |
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
684 |
if repairs: |
2154
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
685 |
# Since BootEnv records the snapshot name in the image history, |
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
686 |
# we need to manage our own history start/end & exception |
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
687 |
# handling rather then delegating to <Image>.repair() |
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
688 |
api_inst.log_operation_start("fix") |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
689 |
# Create a snapshot in case they want to roll back |
1775
479930c429a8
14713 pkg fix can traceback for unprivileged users
Shawn Walker <srw@sun.com>
parents:
1774
diff
changeset
|
690 |
success = False |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
691 |
try: |
2105
212a253a462a
12530 pkg -R install doesn't update boot archive
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2100
diff
changeset
|
692 |
be = bootenv.BootEnv(img) |
834
f8b3396500b3
4883 import failure for non-sunos platforms due to missing pspawn
Tom Mueller <Tom.Mueller@sun.com>
parents:
792
diff
changeset
|
693 |
if be.exists(): |
1945
a4fc142accb2
16111 pkgdepend expands format strings before passing through gettext
Richard Lowe <richlowe@richlowe.net>
parents:
1937
diff
changeset
|
694 |
msg(_("Created ZFS snapshot: %s") % |
a4fc142accb2
16111 pkgdepend expands format strings before passing through gettext
Richard Lowe <richlowe@richlowe.net>
parents:
1937
diff
changeset
|
695 |
be.snapshot_name) |
605
f2898e0c1179
4002 pkg verify appends unnecessary "Unexpected OSerror" message
Brad Hall <bhall@eng.sun.com>
parents:
598
diff
changeset
|
696 |
except RuntimeError: |
1814
240614230562
14948 fix must set bootenv for image object
Brock Pytlik <bpytlik@sun.com>
parents:
1807
diff
changeset
|
697 |
# Error is printed by the BootEnv call. |
2105
212a253a462a
12530 pkg -R install doesn't update boot archive
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2100
diff
changeset
|
698 |
be = bootenv.BootEnvNull(img) |
1814
240614230562
14948 fix must set bootenv for image object
Brock Pytlik <bpytlik@sun.com>
parents:
1807
diff
changeset
|
699 |
img.bootenv = be |
1328
5c3747a4fe0a
9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1326
diff
changeset
|
700 |
try: |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
701 |
success = img.repair(repairs, progresstracker, |
2154
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
702 |
accept=accept, show_licenses=show_licenses, |
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
703 |
new_history_op=False) |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1752
diff
changeset
|
704 |
except (api_errors.InvalidPlanError, |
1775
479930c429a8
14713 pkg fix can traceback for unprivileged users
Shawn Walker <srw@sun.com>
parents:
1774
diff
changeset
|
705 |
api_errors.InvalidPackageErrors, |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1857
diff
changeset
|
706 |
api_errors.ActionExecutionError, |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
707 |
api_errors.PermissionsException, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
708 |
api_errors.SigningException, |
2205
53d0be594162
3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents:
2200
diff
changeset
|
709 |
api_errors.InvalidResourceLocation, |
53d0be594162
3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents:
2200
diff
changeset
|
710 |
api_errors.ConflictingActionErrors), e: |
1710
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
711 |
logger.error(str(e)) |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
712 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
713 |
format_update_error(e) |
2154
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
714 |
api_inst.log_operation_end( |
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
715 |
result=history.RESULT_FAILED_CONFIGURATION) |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
716 |
return EXIT_OOPS |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
717 |
except api_errors.PlanLicenseErrors, e: |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
718 |
error(_("The following packages require their " |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
719 |
"licenses to be accepted before they can be " |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
720 |
"repaired: ")) |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
721 |
logger.error(str(e)) |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
722 |
logger.error(_("To indicate that you agree to and " |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
723 |
"accept the terms of the licenses of the packages " |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
724 |
"listed above, use the --accept option. To " |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
725 |
"display all of the related licenses, use the " |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
726 |
"--licenses option.")) |
2154
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
727 |
api_inst.log_operation_end( |
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
728 |
result=history.RESULT_FAILED_CONSTRAINED) |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
729 |
return EXIT_LICENSE |
1328
5c3747a4fe0a
9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1326
diff
changeset
|
730 |
except api_errors.RebootNeededOnLiveImageException: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
731 |
error(_("Requested \"fix\" operation would affect " |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
732 |
"files that cannot be modified in live image.\n" |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
733 |
"Please retry this operation on an alternate boot " |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
734 |
"environment.")) |
2154
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
735 |
api_inst.log_operation_end( |
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
736 |
result=history.RESULT_FAILED_CONSTRAINED) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
737 |
return EXIT_NOTLIVE |
2161
7c0f05639a9e
17591 NameError: global name 'Error' is not defined
Tim Foster <tim.s.foster@oracle.com>
parents:
2160
diff
changeset
|
738 |
except Exception, e: |
2154
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
739 |
api_inst.log_operation_end(error=e) |
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
740 |
raise |
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
741 |
|
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
742 |
if not success: |
2154
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
743 |
api_inst.log_operation_end( |
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
744 |
result=history.RESULT_FAILED_UNKNOWN) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
745 |
return EXIT_OOPS |
2154
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
746 |
api_inst.log_operation_end(result=history.RESULT_SUCCEEDED) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
747 |
return EXIT_OK |
789
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
748 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
749 |
def verify_image(api_inst, args): |
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
750 |
opts, pargs = getopt.getopt(args, "vfqH") |
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
751 |
|
2183
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
752 |
quiet = False |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
753 |
verbose = 0 |
443
5ffa5b7dac9c
2589 pyc files generate lots of verify chaff
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
442
diff
changeset
|
754 |
# for now, always check contents of files |
5ffa5b7dac9c
2589 pyc files generate lots of verify chaff
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
442
diff
changeset
|
755 |
forever = display_headers = True |
222
12006bf2a260
4 We need to be able to verify that package(s) is/are correctly installed
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
221
diff
changeset
|
756 |
|
227
faba25c4bce3
368 pkg info -m should display raw manifest
Stephen Hahn <sch@Sun.COM>
parents:
222
diff
changeset
|
757 |
for opt, arg in opts: |
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
758 |
if opt == "-H": |
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
759 |
display_headers = False |
227
faba25c4bce3
368 pkg info -m should display raw manifest
Stephen Hahn <sch@Sun.COM>
parents:
222
diff
changeset
|
760 |
if opt == "-v": |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
761 |
verbose = verbose + 1 |
227
faba25c4bce3
368 pkg info -m should display raw manifest
Stephen Hahn <sch@Sun.COM>
parents:
222
diff
changeset
|
762 |
elif opt == "-f": |
faba25c4bce3
368 pkg info -m should display raw manifest
Stephen Hahn <sch@Sun.COM>
parents:
222
diff
changeset
|
763 |
forever = True |
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
764 |
elif opt == "-q": |
2183
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
765 |
quiet = True |
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
766 |
display_headers = False |
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
767 |
|
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
768 |
if verbose and quiet: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
769 |
usage(_("-v and -q may not be combined"), cmd="verify") |
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
770 |
if verbose > 2: |
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
771 |
DebugValues.set_value("plan", "True") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
772 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
773 |
# XXX verify should be part of pkg.client.api |
227
faba25c4bce3
368 pkg info -m should display raw manifest
Stephen Hahn <sch@Sun.COM>
parents:
222
diff
changeset
|
774 |
any_errors = False |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
775 |
processed = False |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
776 |
notfound = EmptyI |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
777 |
progresstracker = get_tracker(quiet, verbose) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
778 |
try: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
779 |
res = api_inst.get_pkg_list(api.ImageInterface.LIST_INSTALLED, |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
780 |
patterns=pargs, raise_unmatched=True, return_fmris=True) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
781 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
782 |
for entry in res: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
783 |
pfmri = entry[0] |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
784 |
entries = [] |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
785 |
result = _("OK") |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
786 |
failed = False |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
787 |
processed = True |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
788 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
789 |
# Since every entry returned by verify might not be |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
790 |
# something needing repair, the relevant information |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
791 |
# for each package must be accumulated first to find |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
792 |
# an overall success/failure result and then the |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
793 |
# related messages output for it. |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
794 |
for act, errors, warnings, pinfo in img.verify(pfmri, |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
795 |
progresstracker, verbose=verbose, forever=forever): |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
796 |
if errors: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
797 |
failed = True |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
798 |
if quiet: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
799 |
# Nothing more to do. |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
800 |
break |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
801 |
result = _("ERROR") |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
802 |
elif not failed and warnings: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
803 |
result = _("WARNING") |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
804 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
805 |
entries.append((act, errors, warnings, pinfo)) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
806 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
807 |
any_errors = any_errors or failed |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
808 |
if (not failed and not verbose) or quiet: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
809 |
# Nothing more to do. |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
810 |
continue |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
811 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
812 |
if display_headers: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
813 |
display_headers = False |
2463
a23c2a2b7080
18583 the output of pkg verify and fix has rotted a bit
Shawn Walker <shawn.walker@oracle.com>
parents:
2457
diff
changeset
|
814 |
msg(_("%(pkg_name)-70s %(result)7s") % { |
a23c2a2b7080
18583 the output of pkg verify and fix has rotted a bit
Shawn Walker <shawn.walker@oracle.com>
parents:
2457
diff
changeset
|
815 |
"pkg_name": _("PACKAGE"), |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
816 |
"result": _("STATUS") }) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
817 |
|
2463
a23c2a2b7080
18583 the output of pkg verify and fix has rotted a bit
Shawn Walker <shawn.walker@oracle.com>
parents:
2457
diff
changeset
|
818 |
msg(_("%(pkg_name)-70s %(result)7s") % { |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
819 |
"pkg_name": pfmri.get_pkg_stem(), |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
820 |
"result": result }) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
821 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
822 |
for act, errors, warnings, pinfo in entries: |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
823 |
if act: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
824 |
msg("\t%s" % act.distinguished_name()) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
825 |
for x in errors: |
384
9d4746e5dd3e
115 pkg needs to not have a cow on a SIGPIPE
Shawn Walker <swalker@opensolaris.org>
parents:
362
diff
changeset
|
826 |
msg("\t\t%s" % x) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
827 |
for x in warnings: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
828 |
msg("\t\t%s" % x) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
829 |
if verbose: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
830 |
# Only display informational messages if |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
831 |
# verbose is True. |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
832 |
for x in pinfo: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
833 |
msg("\t\t%s" % x) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
834 |
except api_errors.InventoryException, e: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
835 |
if e.illegal: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
836 |
for i in e.illegal: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
837 |
error(i) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
838 |
return EXIT_OOPS |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
839 |
notfound = e.notfound |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
840 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
841 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
842 |
return EXIT_OOPS |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
843 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
844 |
if notfound: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
845 |
if processed: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
846 |
# Ensure a blank line is inserted after verify output. |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
847 |
logger.error(" ") |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
848 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
849 |
error(_("no packages matching '%s' installed") % \ |
2260
ea8567aa3ef8
17944 specifying multiple forms of the same pattern should not result in a matching error
Shawn Walker <shawn.walker@oracle.com>
parents:
2258
diff
changeset
|
850 |
", ".join(notfound), cmd="verify") |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
851 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
852 |
if processed: |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
853 |
if any_errors: |
2463
a23c2a2b7080
18583 the output of pkg verify and fix has rotted a bit
Shawn Walker <shawn.walker@oracle.com>
parents:
2457
diff
changeset
|
854 |
msg2 = _("See above for\nverification failures.") |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
855 |
else: |
2463
a23c2a2b7080
18583 the output of pkg verify and fix has rotted a bit
Shawn Walker <shawn.walker@oracle.com>
parents:
2457
diff
changeset
|
856 |
msg2 = _("No packages failed\nverification.") |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
857 |
logger.error(_("\nAll other patterns matched " |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
858 |
"installed packages. %s" % msg2)) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
859 |
any_errors = True |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
860 |
|
227
faba25c4bce3
368 pkg info -m should display raw manifest
Stephen Hahn <sch@Sun.COM>
parents:
222
diff
changeset
|
861 |
if any_errors: |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
862 |
return EXIT_OOPS |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
863 |
return EXIT_OK |
222
12006bf2a260
4 We need to be able to verify that package(s) is/are correctly installed
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
221
diff
changeset
|
864 |
|
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
865 |
def accept_plan_licenses(api_inst): |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
866 |
"""Helper function that marks all licenses for the current plan as |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
867 |
accepted if they require acceptance.""" |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
868 |
|
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
869 |
plan = api_inst.describe() |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
870 |
for pfmri, src, dest, accepted, displayed in plan.get_licenses(): |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
871 |
if not dest.must_accept: |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
872 |
continue |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
873 |
api_inst.set_plan_license_status(pfmri, dest.license, |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
874 |
accepted=True) |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
875 |
|
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
876 |
display_plan_options = ["basic", "fmris", "variants/facets", "services", |
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
877 |
"actions", "boot-archive"] |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
878 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
879 |
def __display_plan(api_inst, verbose): |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
880 |
"""Helper function to display plan to the desired degree. |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
881 |
Verbose can either be a numerical value, or a list of |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
882 |
items to display""" |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
883 |
|
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
884 |
if isinstance(verbose, int): |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
885 |
disp = ["basic"] |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
886 |
if verbose > 0: |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
887 |
disp.extend(["fmris", "mediators", "services", |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
888 |
"variants/facets", "boot-archive"]) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
889 |
if verbose > 1: |
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
890 |
disp.append("actions") |
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
891 |
if verbose > 2: |
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
892 |
disp.append("solver-errors") |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
893 |
else: |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
894 |
disp = verbose |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
895 |
|
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
896 |
if DebugValues["plan"] and "solver-errors" not in disp: |
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
897 |
disp.append("solver-errors") |
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
898 |
|
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
899 |
plan = api_inst.describe() |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
900 |
|
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
901 |
a, r, i, c = [], [], [], [] |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
902 |
for src, dest in plan.get_changes(): |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
903 |
if dest is None: |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
904 |
r.append((src, dest)) |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
905 |
elif src is None: |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
906 |
i.append((src, dest)) |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
907 |
elif src != dest: |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
908 |
c.append((src, dest)) |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
909 |
else: |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
910 |
a.append((src, dest)) |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
911 |
|
2319
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
912 |
def bool_str(val): |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
913 |
if val: |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
914 |
return _("Yes") |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
915 |
return _("No") |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
916 |
|
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
917 |
status = [] |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
918 |
varcets = plan.get_varcets() |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
919 |
mediators = plan.get_mediators() |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
920 |
if "basic" in disp: |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
921 |
def cond_show(s1, s2, v): |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
922 |
if v: |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
923 |
status.append((s1, s2 % v)) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
924 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
925 |
cond_show(_("Packages to remove:"), "%d", len(r)) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
926 |
cond_show(_("Packages to install:"), "%d", len(i)) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
927 |
cond_show(_("Packages to update:"), "%d", len(c)) |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
928 |
cond_show(_("Mediators to change:"), "%d", len(mediators)) |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
929 |
cond_show(_("Variants/Facets to change:"), "%d", len(varcets)) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
930 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
931 |
if verbose: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
932 |
# Only show space information in verbose mode. |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
933 |
abytes = plan.bytes_added |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
934 |
if abytes: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
935 |
status.append((_("Estimated space available:"), |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
936 |
misc.bytes_to_str(plan.bytes_avail))) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
937 |
status.append(( |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
938 |
_("Estimated space to be consumed:"), |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
939 |
misc.bytes_to_str(plan.bytes_added))) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
940 |
|
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
941 |
if varcets or mediators: |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
942 |
cond_show(_("Packages to change:"), "%d", len(a)) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
943 |
else: |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
944 |
cond_show(_("Packages to fix:"), "%d", len(a)) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
945 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
946 |
status.append((_("Create boot environment:"), |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
947 |
bool_str(plan.new_be))) |
2319
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
948 |
|
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
949 |
if plan.new_be and (verbose or not plan.activate_be): |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
950 |
# Only show activation status if verbose or if new BE |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
951 |
# will not be activated. |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
952 |
status.append((_("Activate boot environment:"), |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
953 |
bool_str(plan.activate_be))) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
954 |
|
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
955 |
if not plan.new_be: |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
956 |
cond_show(_("Services to change:"), "%d", |
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
957 |
len(plan.get_services())) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
958 |
|
2105
212a253a462a
12530 pkg -R install doesn't update boot archive
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2100
diff
changeset
|
959 |
if "boot-archive" in disp: |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
960 |
status.append((_("Rebuild boot archive:"), |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
961 |
bool_str(plan.update_boot_archive))) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
962 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
963 |
# Right-justify all status strings based on length of longest string. |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
964 |
rjust_status = max(len(s[0]) for s in status) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
965 |
rjust_value = max(len(s[1]) for s in status) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
966 |
for s in status: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
967 |
logger.info("%s %s" % (s[0].rjust(rjust_status), |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
968 |
s[1].rjust(rjust_value))) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
969 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
970 |
if status: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
971 |
# Ensure there is a blank line between status information and |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
972 |
# remainder. |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
973 |
logger.info("") |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
974 |
|
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
975 |
if "mediators" in disp and mediators: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
976 |
logger.info(_("Changed mediators:")) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
977 |
for x in mediators: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
978 |
logger.info(" %s" % x) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
979 |
|
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
980 |
if "variants/facets" in disp and varcets: |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
981 |
logger.info(_("Changed variants/facets:")) |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
982 |
for x in varcets: |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
983 |
logger.info(" %s" % x) |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
984 |
|
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
985 |
if "solver-errors" in disp: |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
986 |
first = True |
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
987 |
for l in plan.get_solver_errors(): |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
988 |
if first: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
989 |
logger.info(_("Solver dependency errors:")) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
990 |
first = False |
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
991 |
logger.info(l) |
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
992 |
|
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
993 |
if "fmris" in disp: |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
994 |
changed = collections.defaultdict(list) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
995 |
for src, dest in itertools.chain(r, i, c): |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
996 |
if src and dest: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
997 |
if src.publisher != dest.publisher: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
998 |
pparent = "%s -> %s" % (src.publisher, |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
999 |
dest.publisher) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1000 |
else: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1001 |
pparent = dest.publisher |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1002 |
pname = dest.pkg_stem |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1003 |
pver = "%s -> %s" % (src.fmri.version, |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1004 |
dest.fmri.version) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1005 |
elif dest: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1006 |
pparent = dest.publisher |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1007 |
pname = dest.pkg_stem |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1008 |
pver = "None -> %s" % dest.fmri.version |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1009 |
else: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1010 |
pparent = src.publisher |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1011 |
pname = src.pkg_stem |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1012 |
pver = "%s -> None" % src.fmri.version |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1013 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1014 |
changed[pparent].append((pname, pver)) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1015 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1016 |
if changed: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1017 |
logger.info(_("Changed packages:")) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1018 |
last_parent = None |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1019 |
for pparent, pname, pver in ( |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1020 |
(pparent, pname, pver) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1021 |
for pparent in sorted(changed) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1022 |
for pname, pver in changed[pparent] |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1023 |
): |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1024 |
if pparent != last_parent: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1025 |
logger.info(pparent) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1026 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1027 |
logger.info(" %s" % pname) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1028 |
logger.info(" %s" % pver) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1029 |
last_parent = pparent |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1030 |
|
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1031 |
if len(a): |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1032 |
logger.info(_("Affected fmris:")) |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1033 |
for src, dest in a: |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1034 |
logger.info(" %s", src) |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
1035 |
|
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1036 |
if "services" in disp and not plan.new_be: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1037 |
last_action = None |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1038 |
for action, smf_fmri in plan.get_services(): |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1039 |
if last_action is None: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1040 |
logger.info("Services:") |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1041 |
if action != last_action: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1042 |
logger.info(" %s:" % action) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1043 |
logger.info(" %s" % smf_fmri) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1044 |
last_action = action |
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
1045 |
|
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1046 |
if "actions" in disp: |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1047 |
logger.info("Actions:") |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1048 |
for a in plan.get_actions(): |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1049 |
logger.info(" %s" % a) |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1050 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1051 |
def display_plan_licenses(api_inst, show_all=False, show_req=True): |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1052 |
"""Helper function to display licenses for the current plan. |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1053 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
1054 |
'show_all' is an optional boolean value indicating whether all licenses |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1055 |
should be displayed or only those that have must-display=true.""" |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1056 |
|
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1057 |
plan = api_inst.describe() |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1058 |
for pfmri, src, dest, accepted, displayed in plan.get_licenses(): |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
1059 |
if not show_all and not dest.must_display: |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1060 |
continue |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1061 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1062 |
if not show_all and dest.must_display and displayed: |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1063 |
# License already displayed, so doesn't need to be |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1064 |
# displayed again. |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1065 |
continue |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1066 |
|
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1067 |
lic = dest.license |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1068 |
if show_req: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1069 |
logger.info("-" * 60) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1070 |
logger.info(_("Package: %s") % pfmri) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1071 |
logger.info(_("License: %s\n") % lic) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1072 |
logger.info(dest.get_text()) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1073 |
logger.info("\n") |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1074 |
|
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1075 |
# Mark license as having been displayed. |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1076 |
api_inst.set_plan_license_status(pfmri, lic, displayed=True) |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1077 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1078 |
def display_plan(api_inst, noexecute, op, quiet, show_licenses, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1079 |
stage, verbose): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1080 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1081 |
plan = api_inst.describe() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1082 |
if not plan: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1083 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1084 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1085 |
if stage not in [API_STAGE_DEFAULT, API_STAGE_PLAN]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1086 |
# we should have displayed licenses earlier so mark all |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1087 |
# licenses as having been displayed. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1088 |
display_plan_licenses(api_inst, show_req=False) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1089 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1090 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1091 |
if api_inst.planned_nothingtodo(li_ignore_all=True): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1092 |
# nothing todo |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1093 |
if op == PKG_OP_UPDATE: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1094 |
s = _("No updates available for this image.") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1095 |
else: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1096 |
s = _("No updates necessary for this image.") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1097 |
if api_inst.ischild(): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1098 |
s + " (%s)" % api_inst.get_linked_name() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1099 |
msg(s) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1100 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1101 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1102 |
display_plan_licenses(api_inst, show_all=show_licenses) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1103 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1104 |
if not quiet: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1105 |
__display_plan(api_inst, verbose) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1106 |
|
2151
e04e45c5e7a2
17371 plan output should be shown after license output
Shawn Walker <shawn.walker@oracle.com>
parents:
2144
diff
changeset
|
1107 |
def __api_prepare(operation, api_inst, accept=False): |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1108 |
# Exceptions which happen here are printed in the above level, with |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1109 |
# or without some extra decoration done here. |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1110 |
# XXX would be nice to kick the progress tracker. |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1111 |
try: |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1112 |
if accept: |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1113 |
accept_plan_licenses(api_inst) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
1114 |
api_inst.prepare() |
1779
b80275b45b18
14176 copytree callers must catch shutil.Error and not traceback
Shawn Walker <srw@sun.com>
parents:
1775
diff
changeset
|
1115 |
except (api_errors.PermissionsException, api_errors.UnknownErrors), e: |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1116 |
# Prepend a newline because otherwise the exception will |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1117 |
# be printed on the same line as the spinner. |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1118 |
error("\n" + str(e)) |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1119 |
return EXIT_OOPS |
1280
9c577f0a6cd8
10411 Protect progress tracker against adversarial interfaces
johansen <johansen@sun.com>
parents:
1271
diff
changeset
|
1120 |
except api_errors.TransportError, e: |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1121 |
# move past the progress tracker line. |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1122 |
msg("\n") |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1123 |
raise e |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1124 |
except api_errors.PlanLicenseErrors, e: |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1125 |
# Prepend a newline because otherwise the exception will |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1126 |
# be printed on the same line as the spinner. |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1127 |
logger.error("\n") |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1128 |
error(_("The following packages require their " |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1129 |
"licenses to be accepted before they can be installed " |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1130 |
"or updated: ")) |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1131 |
logger.error(str(e)) |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1132 |
logger.error(_("To indicate that you agree to and accept the " |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1133 |
"terms of the licenses of the packages listed above, " |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1134 |
"use the --accept option. To display all of the related " |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1135 |
"licenses, use the --licenses option.")) |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1136 |
return EXIT_LICENSE |
1710
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
1137 |
except api_errors.InvalidPlanError, e: |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
1138 |
# Prepend a newline because otherwise the exception will |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
1139 |
# be printed on the same line as the spinner. |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
1140 |
error("\n" + str(e)) |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
1141 |
return EXIT_OOPS |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1142 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1143 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1144 |
return EXIT_OOPS |
2407
a831f1491c86
1769 pkg(5) doesn't check for disk space
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2382
diff
changeset
|
1145 |
except api_errors.ImageInsufficentSpace, e: |
a831f1491c86
1769 pkg(5) doesn't check for disk space
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2382
diff
changeset
|
1146 |
error(str(e)) |
a831f1491c86
1769 pkg(5) doesn't check for disk space
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2382
diff
changeset
|
1147 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1148 |
except KeyboardInterrupt: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1149 |
raise |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1150 |
except: |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1151 |
error(_("\nAn unexpected error happened while preparing for " |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1152 |
"%s:") % operation) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1153 |
raise |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1154 |
return EXIT_OK |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1155 |
|
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1857
diff
changeset
|
1156 |
def __api_execute_plan(operation, api_inst): |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1157 |
rval = None |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1158 |
try: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
1159 |
api_inst.execute_plan() |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1160 |
rval = EXIT_OK |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1161 |
except RuntimeError, e: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1162 |
error(_("%s failed: %s") % (operation, e)) |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1163 |
rval = EXIT_OOPS |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1752
diff
changeset
|
1164 |
except (api_errors.InvalidPlanError, |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1857
diff
changeset
|
1165 |
api_errors.ActionExecutionError, |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1752
diff
changeset
|
1166 |
api_errors.InvalidPackageErrors), e: |
1710
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
1167 |
# Prepend a newline because otherwise the exception will |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
1168 |
# be printed on the same line as the spinner. |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
1169 |
error("\n" + str(e)) |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1170 |
rval = EXIT_OOPS |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1171 |
except (api_errors.LinkedImageException), e: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1172 |
error(_("%s failed (linked image exception(s)):\n%s") % |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1173 |
(operation, str(e))) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1174 |
rval = e.lix_exitrv |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1175 |
except api_errors.ImageUpdateOnLiveImageException: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1176 |
error(_("%s cannot be done on live image") % operation) |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1177 |
rval = EXIT_NOTLIVE |
1328
5c3747a4fe0a
9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1326
diff
changeset
|
1178 |
except api_errors.RebootNeededOnLiveImageException: |
1538
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1179 |
error(_("Requested \"%s\" operation would affect files that " |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1180 |
"cannot be modified in live image.\n" |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1181 |
"Please retry this operation on an alternate boot " |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
1182 |
"environment.") % operation) |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1183 |
rval = EXIT_NOTLIVE |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1184 |
except api_errors.CorruptedIndexException, e: |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1185 |
error("The search index appears corrupted. Please rebuild the " |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1186 |
"index with 'pkg rebuild-index'.") |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1187 |
rval = EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1188 |
except api_errors.ProblematicPermissionsIndexException, e: |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1189 |
error(str(e)) |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1190 |
error(_("\n(Failure to consistently execute pkg commands as a " |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1191 |
"privileged user is often a source of this problem.)")) |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1192 |
rval = EXIT_OOPS |
1779
b80275b45b18
14176 copytree callers must catch shutil.Error and not traceback
Shawn Walker <srw@sun.com>
parents:
1775
diff
changeset
|
1193 |
except (api_errors.PermissionsException, api_errors.UnknownErrors), e: |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1194 |
# Prepend a newline because otherwise the exception will |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1195 |
# be printed on the same line as the spinner. |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1196 |
error("\n" + str(e)) |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1197 |
rval = EXIT_OOPS |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1198 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1199 |
format_update_error(e) |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1200 |
rval = EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1201 |
except api_errors.BEException, e: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1202 |
error(e) |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1203 |
rval = EXIT_OOPS |
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
1204 |
except api_errors.WrapSuccessfulIndexingException: |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
1205 |
raise |
2407
a831f1491c86
1769 pkg(5) doesn't check for disk space
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2382
diff
changeset
|
1206 |
except api_errors.ImageInsufficentSpace, e: |
a831f1491c86
1769 pkg(5) doesn't check for disk space
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2382
diff
changeset
|
1207 |
error(str(e)) |
a831f1491c86
1769 pkg(5) doesn't check for disk space
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2382
diff
changeset
|
1208 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1209 |
except Exception, e: |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1210 |
error(_("An unexpected error happened during " |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1211 |
"%s: %s") % (operation, e)) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1212 |
raise |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1213 |
finally: |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1214 |
exc_type = exc_value = exc_tb = None |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1215 |
if rval is None: |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1216 |
# Store original exception so that the real cause of |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1217 |
# failure can be raised if this fails. |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1218 |
exc_type, exc_value, exc_tb = sys.exc_info() |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1219 |
|
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1220 |
try: |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1221 |
salvaged = api_inst.describe().get_salvaged() |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1222 |
if salvaged: |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1223 |
logger.error("") |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1224 |
logger.error(_("The following unexpected or " |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1225 |
"editable files and directories were\n" |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1226 |
"salvaged while executing the requested " |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1227 |
"package operation; they\nhave been moved " |
2470
94ef1a17ad4f
18427 Need a way of salvaging unpackaged contents of directories to support renaming directories containing such...
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2463
diff
changeset
|
1228 |
"to the displayed location in the image:\n")) |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1229 |
for opath, spath in salvaged: |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1230 |
logger.error(" %s -> %s" % (opath, |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1231 |
spath)) |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1232 |
except Exception: |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1233 |
if rval is not None: |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1234 |
# Only raise exception encountered here if the |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1235 |
# exception previously raised was suppressed. |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1236 |
raise |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1237 |
|
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1238 |
if exc_value or exc_tb: |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1239 |
raise exc_value, None, exc_tb |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1240 |
|
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1241 |
return rval |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1242 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1243 |
def __api_alloc(imgdir, exact_match, pkg_image_used, quiet, runid=-1): |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1244 |
progresstracker = get_tracker(quiet) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1245 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1246 |
def qv(val): |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1247 |
# Escape shell metacharacters; '\' must be escaped first to |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1248 |
# prevent escaping escapes. |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1249 |
for c in "\\ \t\n'`;&()|^<>?*": |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1250 |
val = val.replace(c, "\\" + c) |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1251 |
return val |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1252 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1253 |
try: |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1254 |
return api.ImageInterface(imgdir, CLIENT_API_VERSION, |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1255 |
progresstracker, None, PKG_CLIENT_NAME, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1256 |
exact_match=exact_match, runid=runid) |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1257 |
except api_errors.ImageNotFoundException, e: |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1258 |
if e.user_specified: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1259 |
if pkg_image_used: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1260 |
error(_("No image rooted at '%s' " |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1261 |
"(set by $PKG_IMAGE)") % e.user_dir) |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1262 |
else: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1263 |
error(_("No image rooted at '%s'") % e.user_dir) |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1264 |
else: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1265 |
error(_("No image found.")) |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1266 |
return |
1672
3a71439a03f3
13021 file manager exceptions should be api exceptions
Shawn Walker <srw@sun.com>
parents:
1658
diff
changeset
|
1267 |
except api_errors.PermissionsException, e: |
3a71439a03f3
13021 file manager exceptions should be api exceptions
Shawn Walker <srw@sun.com>
parents:
1658
diff
changeset
|
1268 |
error(e) |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1269 |
return |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1270 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1271 |
format_update_error(e) |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1272 |
return |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1273 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1274 |
def __api_plan_exception(op, noexecute, verbose, api_inst): |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1275 |
e_type, e, e_traceback = sys.exc_info() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1276 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1277 |
if e_type == api_errors.ImageNotFoundException: |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1278 |
error(_("No image rooted at '%s'") % e.user_dir, cmd=op) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1279 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1280 |
if e_type == api_errors.InventoryException: |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1281 |
error("\n" + _("%s failed (inventory exception):\n%s") % (op, |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1282 |
e)) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1283 |
return EXIT_OOPS |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1284 |
if isinstance(e, api_errors.LinkedImageException): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1285 |
error(_("%s failed (linked image exception(s)):\n%s") % |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1286 |
(op, str(e))) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1287 |
return e.lix_exitrv |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1288 |
if e_type == api_errors.IpkgOutOfDateException: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1289 |
msg(_("""\ |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1290 |
WARNING: pkg(5) appears to be out of date, and should be updated before |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1291 |
running %(op)s. Please update pkg(5) by executing 'pkg install |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1292 |
pkg:/package/pkg' as a privileged user and then retry the %(op)s.""" |
1829
e581a205ec02
14907 references to old-style package names must be purged
Danek Duvall <danek.duvall@sun.com>
parents:
1814
diff
changeset
|
1293 |
) % locals()) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1294 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1295 |
if e_type == api_errors.NonLeafPackageException: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1296 |
error(_("""\ |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1297 |
Cannot remove '%s' due to the following packages that depend on it:""" |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1298 |
) % e.fmri, cmd=op) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1299 |
for d in e.dependents: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
1300 |
logger.error(" %s" % d) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1301 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1302 |
if e_type == api_errors.CatalogRefreshException: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1303 |
if display_catalog_failures(e) != 0: |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1304 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1305 |
if noexecute: |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1306 |
return EXIT_OK |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1307 |
return EXIT_OOPS |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1308 |
if e_type == api_errors.ConflictingActionErrors: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1309 |
error("\n" + str(e), cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1310 |
if verbose: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1311 |
__display_plan(api_inst, verbose) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1312 |
return EXIT_OOPS |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1752
diff
changeset
|
1313 |
if e_type in (api_errors.InvalidPlanError, |
2333
d7d310363aeb
18191 need flag to indicate some self-assembly is required
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2319
diff
changeset
|
1314 |
api_errors.ReadOnlyFileSystemException, |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1857
diff
changeset
|
1315 |
api_errors.ActionExecutionError, |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1752
diff
changeset
|
1316 |
api_errors.InvalidPackageErrors): |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1317 |
error("\n" + str(e), cmd=op) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1318 |
return EXIT_OOPS |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1319 |
if e_type == api_errors.ImageFormatUpdateNeeded: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1320 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1321 |
return EXIT_OOPS |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1322 |
|
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1323 |
if e_type == api_errors.ImageUpdateOnLiveImageException: |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1324 |
error("\n" + _("The proposed operation cannot be performed on " |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1325 |
"a live image."), cmd=op) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1326 |
return EXIT_NOTLIVE |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1327 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1328 |
if issubclass(e_type, api_errors.BEException): |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1329 |
error("\n" + str(e), cmd=op) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1330 |
return EXIT_OOPS |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1331 |
|
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1332 |
if e_type == api_errors.PlanCreationException: |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1333 |
# Prepend a newline because otherwise the exception will |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1334 |
# be printed on the same line as the spinner. |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1335 |
txt = str(e) |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1336 |
if e.multiple_matches: |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1337 |
txt += "\n\n" + _("Please provide one of the package " |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1338 |
"FMRIs listed above to the install command.") |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1339 |
error("\n" + txt, cmd=op) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1340 |
if verbose: |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1341 |
logger.error("\n".join(e.verbose_info)) |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1342 |
if e.invalid_mediations: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1343 |
# Bad user input for mediation. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1344 |
return EXIT_BADOPT |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1345 |
return EXIT_OOPS |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1346 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1347 |
if e_type in (api_errors.CertificateError, |
1779
b80275b45b18
14176 copytree callers must catch shutil.Error and not traceback
Shawn Walker <srw@sun.com>
parents:
1775
diff
changeset
|
1348 |
api_errors.UnknownErrors, |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1349 |
api_errors.PermissionsException, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1350 |
api_errors.InvalidPropertyValue, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1351 |
api_errors.InvalidResourceLocation): |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1352 |
# Prepend a newline because otherwise the exception will |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1353 |
# be printed on the same line as the spinner. |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1354 |
error("\n" + str(e), cmd=op) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1355 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1356 |
if e_type == fmri.IllegalFmri: |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1357 |
# Prepend a newline because otherwise the exception will |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1358 |
# be printed on the same line as the spinner. |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1359 |
error("\n" + str(e), cmd=op) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1360 |
return EXIT_OOPS |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1361 |
if isinstance(e, api_errors.SigningException): |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1362 |
# Prepend a newline because otherwise the exception will |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1363 |
# be printed on the same line as the spinner. |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
1364 |
error("\n" + str(e), cmd=op) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1365 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1366 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1367 |
# if we didn't deal with the exception above, pass it on. |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1368 |
raise |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1369 |
# NOTREACHED |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1370 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1371 |
def __api_op(_op, _api_inst, _accept=False, _li_ignore=None, _noexecute=False, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1372 |
_origins=None, _quiet=False, _review_release_notes=False, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1373 |
_show_licenses=False, _stage=API_STAGE_DEFAULT, _verbose=0, **kwargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1374 |
"""Do something that involves the api. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1375 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1376 |
Arguments prefixed with '_' are primarily used within this |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1377 |
function. All other arguments must be specified via keyword |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1378 |
assignment and will be passed directly on to the api |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1379 |
interfaces being invoked.""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1380 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1381 |
# massage arguments |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1382 |
if type(_li_ignore) == list: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1383 |
# parse any linked image names specified on the command line |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1384 |
_li_ignore = _api_inst.parse_linked_name_list(_li_ignore) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1385 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1386 |
# All the api interface functions that we inovke have some |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1387 |
# common arguments. Set those up now. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1388 |
kwargs["accept"] = _accept |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1389 |
kwargs["li_ignore"] = _li_ignore |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1390 |
kwargs["noexecute"] = _noexecute |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1391 |
if _origins != None: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1392 |
kwargs["repos"] = _origins |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1393 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1394 |
# display plan debugging information |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1395 |
if _verbose > 2: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1396 |
DebugValues.set_value("plan", "True") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1397 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1398 |
# plan the requested operation |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1399 |
stuff_to_do = None |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1400 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1401 |
if _op == PKG_OP_ATTACH: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1402 |
api_plan_func = _api_inst.gen_plan_attach |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1403 |
elif _op in [PKG_OP_CHANGE_FACET, PKG_OP_CHANGE_VARIANT]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1404 |
api_plan_func = _api_inst.gen_plan_change_varcets |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1405 |
elif _op == PKG_OP_DETACH: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1406 |
api_plan_func = _api_inst.gen_plan_detach |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1407 |
elif _op == PKG_OP_INSTALL: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1408 |
api_plan_func = _api_inst.gen_plan_install |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1409 |
elif _op == PKG_OP_SYNC: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1410 |
api_plan_func = _api_inst.gen_plan_sync |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1411 |
elif _op == PKG_OP_UNINSTALL: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1412 |
api_plan_func = _api_inst.gen_plan_uninstall |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1413 |
elif _op == PKG_OP_UPDATE: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1414 |
api_plan_func = _api_inst.gen_plan_update |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1415 |
else: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1416 |
raise RuntimeError("__api_op() invalid op: %s" % _op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1417 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1418 |
first_plan = True |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1419 |
plan_displayed = False |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1420 |
try: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1421 |
for pd in api_plan_func(**kwargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1422 |
if not first_plan: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1423 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1424 |
# we don't display anything for child images |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1425 |
# since they currently do their own display |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1426 |
# work. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1427 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1428 |
continue |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1429 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1430 |
# the first plan description is always for ourself. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1431 |
first_plan = False |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1432 |
display_plan(_api_inst, _noexecute, _op, _quiet, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1433 |
_show_licenses, _stage, _verbose) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1434 |
plan_displayed = True |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1435 |
except: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1436 |
rv = __api_plan_exception(_op, _noexecute, _verbose, _api_inst) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1437 |
if rv != EXIT_OK: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1438 |
return rv |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1439 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1440 |
if not plan_displayed: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1441 |
display_plan(_api_inst, _noexecute, _op, _quiet, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1442 |
_show_licenses, _stage, _verbose) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1443 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1444 |
stuff_to_do = not _api_inst.planned_nothingtodo() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1445 |
if not stuff_to_do: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1446 |
return EXIT_NOP |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1447 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1448 |
if _noexecute or _stage in [API_STAGE_PUBCHECK, API_STAGE_PLAN]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1449 |
return EXIT_OK |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1450 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1451 |
# Exceptions which happen here are printed in the above level, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1452 |
# with or without some extra decoration done here. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1453 |
ret_code = __api_prepare(_op, _api_inst, accept=_accept) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1454 |
if ret_code != EXIT_OK: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1455 |
return ret_code |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1456 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1457 |
if _stage == API_STAGE_PREPARE: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1458 |
return EXIT_OK |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1459 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1460 |
ret_code = __api_execute_plan(_op, _api_inst) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1461 |
if _review_release_notes and ret_code == 0 and \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1462 |
_stage == API_STAGE_DEFAULT and _api_inst.solaris_image(): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1463 |
msg("\n" + "-" * 75) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1464 |
msg(_("NOTE: Please review release notes posted at:\n" )) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1465 |
msg(misc.get_release_notes_url()) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1466 |
msg("-" * 75 + "\n") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1467 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1468 |
return ret_code |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1469 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1470 |
def opts_err_opt1_req_opt2(opt1, opt2, op): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1471 |
msg = _("%(opt1)s may only be used in combination with %(opt2)s") % \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1472 |
{"opt1": opt1, "opt2": opt2} |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1473 |
usage(msg, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1474 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1475 |
def opts_err_incompat(opt1, opt2, op): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1476 |
msg = _("the %(opt1)s and %(opt2)s options may not be combined") % \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1477 |
{"opt1": opt1, "opt2": opt2} |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1478 |
usage(msg, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1479 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1480 |
def opts_err_repeated(opt1, op): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1481 |
msg = _("option '%s' repeated") % (opt1) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1482 |
usage(msg, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1483 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1484 |
def opts_table_cb_beopts(op, api_inst, opts, opts_new): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1485 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1486 |
# synthesize require_new_be and deny_new_be into new_be |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1487 |
del opts_new["require_new_be"] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1488 |
del opts_new["deny_new_be"] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1489 |
opts_new["new_be"] = None |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1490 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1491 |
if opts["require_new_be"] and opts["deny_new_be"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1492 |
opts_err_incompat("--require-new-be", "--deny-new-be", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1493 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1494 |
# create a new key called "new_be" in the options array |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1495 |
if opts["require_new_be"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1496 |
opts_new["new_be"] = True |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1497 |
if opts["deny_new_be"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1498 |
opts_new["new_be"] = False |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1499 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1500 |
def opts_table_cb_li_ignore(op, api_inst, opts, opts_new): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1501 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1502 |
# synthesize li_ignore_all and li_ignore_list into li_ignore |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1503 |
del opts_new["li_ignore_all"] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1504 |
del opts_new["li_ignore_list"] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1505 |
opts_new["li_ignore"] = None |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1506 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1507 |
# check if there's nothing to ignore |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1508 |
if not opts["li_ignore_all"] and not opts["li_ignore_list"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1509 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1510 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1511 |
if opts["li_ignore_all"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1512 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1513 |
# can't ignore all and specific images |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1514 |
if opts["li_ignore_list"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1515 |
opts_err_incompat("-I", "-i", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1516 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1517 |
# can't ignore all and target anything. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1518 |
if "li_target_all" in opts and opts["li_target_all"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1519 |
opts_err_incompat("-I", "-a", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1520 |
if "li_target_list" in opts and opts["li_target_list"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1521 |
opts_err_incompat("-I", "-l", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1522 |
if "li_name" in opts and opts["li_name"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1523 |
opts_err_incompat("-I", "-l", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1524 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1525 |
opts_new["li_ignore"] = [] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1526 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1527 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1528 |
assert opts["li_ignore_list"] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1529 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1530 |
# it doesn't make sense to specify images to ignore if the |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1531 |
# user is already specifying images to operate on. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1532 |
if "li_target_all" in opts and opts["li_target_all"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1533 |
opts_err_incompat("-i", "-a", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1534 |
if "li_target_list" in opts and opts["li_target_list"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1535 |
opts_err_incompat("-i", "-l", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1536 |
if "li_name" in opts and opts["li_name"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1537 |
opts_err_incompat("-i", "-l", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1538 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1539 |
li_ignore = [] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1540 |
for li_name in opts["li_ignore_list"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1541 |
# check for repeats |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1542 |
if li_name in li_ignore: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1543 |
opts_err_repeated("-i %s" % (li_name), op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1544 |
# add to ignore list |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1545 |
li_ignore.append(li_name) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1546 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1547 |
opts_new["li_ignore"] = li_ignore |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1548 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1549 |
def opts_table_cb_li_no_psync(op, api_inst, opts, opts_new): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1550 |
# if a target child linked image was specified, the no-parent-sync |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1551 |
# option doesn't make sense since we know that both the parent and |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1552 |
# child image are accessible |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1553 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1554 |
if "li_target_all" not in opts: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1555 |
# we don't accept linked image target options |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1556 |
assert "li_target_list" not in opts |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1557 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1558 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1559 |
if opts["li_target_all"] and not opts["li_parent_sync"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1560 |
opts_err_incompat("-a", "--no-parent-sync", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1561 |
if opts["li_target_list"] and not opts["li_parent_sync"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1562 |
opts_err_incompat("-l", "--no-parent-sync", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1563 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1564 |
def opts_table_cb_li_props(op, api_inst, opts, opts_new): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1565 |
"""convert linked image prop list into a dictionary""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1566 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1567 |
opts_new["li_props"] = __parse_linked_props(opts["li_props"], op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1568 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1569 |
def opts_table_cb_li_target(op, api_inst, opts, opts_new): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1570 |
# figure out which option the user specified |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1571 |
if opts["li_target_all"] and opts["li_target_list"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1572 |
opts_err_incompat("-a", "-l", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1573 |
elif opts["li_target_all"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1574 |
arg1 = "-a" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1575 |
elif opts["li_target_list"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1576 |
arg1 = "-l" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1577 |
else: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1578 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1579 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1580 |
if "be_activate" in opts and not opts["be_activate"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1581 |
opts_err_incompat(arg1, "--no-be-activate", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1582 |
if "be_name" in opts and opts["be_name"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1583 |
opts_err_incompat(arg1, "--be-name", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1584 |
if "deny_new_be" in opts and opts["deny_new_be"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1585 |
opts_err_incompat(arg1, "--deny-new-be", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1586 |
if "require_new_be" in opts and opts["require_new_be"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1587 |
opts_err_incompat(arg1, "--require-new-be", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1588 |
if "reject_pats" in opts and opts["reject_pats"]: |
2410
60b600d406df
18489 skip generating parent deps if we're running a build with parent deps
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2407
diff
changeset
|
1589 |
opts_err_incompat(arg1, "--reject", op) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1590 |
if "origins" in opts and opts["origins"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1591 |
opts_err_incompat(arg1, "-g", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1592 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1593 |
# validate linked image name |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1594 |
li_target_list = [] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1595 |
for li_name in opts["li_target_list"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1596 |
# check for repeats |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1597 |
if li_name in li_target_list: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1598 |
opts_err_repeated("-l %s" % (li_name), op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1599 |
# add to ignore list |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1600 |
li_target_list.append(li_name) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1601 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1602 |
opts_new["li_target_list"] = li_target_list |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1603 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1604 |
def opts_table_cb_li_target1(op, api_inst, opts, opts_new): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1605 |
# figure out which option the user specified |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1606 |
if opts["li_name"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1607 |
arg1 = "-l" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1608 |
else: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1609 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1610 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1611 |
if "be_activate" in opts and not opts["be_activate"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1612 |
opts_err_incompat(arg1, "--no-be-activate", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1613 |
if "be_name" in opts and opts["be_name"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1614 |
opts_err_incompat(arg1, "--be-name", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1615 |
if "deny_new_be" in opts and opts["deny_new_be"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1616 |
opts_err_incompat(arg1, "--deny-new-be", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1617 |
if "require_new_be" in opts and opts["require_new_be"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1618 |
opts_err_incompat(arg1, "--require-new-be", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1619 |
if "reject_pats" in opts and opts["reject_pats"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1620 |
opts_err_incompat(arg1, "--require", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1621 |
if "origins" in opts and opts["origins"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1622 |
opts_err_incompat(arg1, "-g", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1623 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1624 |
def opts_table_cb_no_headers_vs_quiet(op, api_inst, opts, opts_new): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1625 |
# check if we accept the -q option |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1626 |
if "quiet" not in opts: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1627 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1628 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1629 |
# -q implies -H |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1630 |
if opts["quiet"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1631 |
opts_new["omit_headers"] = True |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1632 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1633 |
def opts_table_cb_nqv(op, api_inst, opts, opts_new): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1634 |
if opts["verbose"] and opts["quiet"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1635 |
opts_err_incompat("-v", "-q", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1636 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1637 |
def opts_table_cb_origins(op, api_inst, opts, opts_new): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1638 |
origins = set() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1639 |
for o in opts["origins"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1640 |
origins.add(misc.parse_uri(o, cwd=orig_cwd)) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1641 |
opts_new["origins"] = origins |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1642 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1643 |
def opts_table_cb_stage(op, api_inst, opts, opts_new): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1644 |
if opts["stage"] == None: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1645 |
opts_new["stage"] = API_STAGE_DEFAULT |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1646 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1647 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1648 |
if opts_new["stage"] not in api_stage_values: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1649 |
usage(_("invalid operation stage: '%s'") % opts["stage"], |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1650 |
cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1651 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1652 |
def opts_cb_li_attach(op, api_inst, opts, opts_new): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1653 |
if opts["attach_parent"] and opts["attach_child"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1654 |
opts_err_incompat("-c", "-p", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1655 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1656 |
if not opts["attach_parent"] and not opts["attach_child"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1657 |
usage(_("either -c or -p must be specified"), cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1658 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1659 |
if opts["attach_child"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1660 |
# if we're attaching a new child then that doesn't affect |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1661 |
# any other children, so ignoring them doesn't make sense. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1662 |
if opts["li_ignore_all"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1663 |
opts_err_incompat("-c", "-I", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1664 |
if opts["li_ignore_list"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1665 |
opts_err_incompat("-c", "-i", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1666 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1667 |
def opts_table_cb_md_only(op, api_inst, opts, opts_new): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1668 |
# if the user didn't specify linked-md-only we're done |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1669 |
if not opts["li_md_only"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1670 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1671 |
|
2444
9170dcd9559d
18349 linked image code needs to be more resilient in the face of zoneadm failure
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2431
diff
changeset
|
1672 |
# li_md_only implies no li_pkg_updates |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1673 |
if "li_pkg_updates" in opts: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1674 |
opts_new["li_pkg_updates"] = False |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1675 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1676 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1677 |
# if li_md_only is false that means we're not updating any packages |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1678 |
# within the current image so there are a ton of options that no |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1679 |
# longer apply to the current operation, and hence are incompatible |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1680 |
# with li_md_only. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1681 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1682 |
arg1 = "--linked-md-only" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1683 |
if "be_name" in opts and opts["be_name"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1684 |
opts_err_incompat(arg1, "--be-name", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1685 |
if "deny_new_be" in opts and opts["deny_new_be"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1686 |
opts_err_incompat(arg1, "--deny-new-be", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1687 |
if "require_new_be" in opts and opts["require_new_be"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1688 |
opts_err_incompat(arg1, "--require-new-be", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1689 |
if "li_parent_sync" in opts and not opts["li_parent_sync"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1690 |
opts_err_incompat(arg1, "--no-parent-sync", op) |
2444
9170dcd9559d
18349 linked image code needs to be more resilient in the face of zoneadm failure
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2431
diff
changeset
|
1691 |
if "reject_pats" in opts and opts["reject_pats"]: |
9170dcd9559d
18349 linked image code needs to be more resilient in the face of zoneadm failure
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2431
diff
changeset
|
1692 |
opts_err_incompat(arg1, "--reject", op) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1693 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1694 |
def opts_cb_list(op, api_inst, opts, opts_new): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1695 |
if opts_new["origins"] and not opts_new["list_newest"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1696 |
# Use of -g implies -a unless -n is provided. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1697 |
opts_new["list_installed_newest"] = True |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1698 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1699 |
if opts_new["list_all"] and not opts_new["list_installed_newest"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1700 |
opts_err_opt1_req_opt2("-f", "-a", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1701 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1702 |
if opts_new["list_installed_newest"] and opts_new["list_newest"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1703 |
opts_err_incompat("-a", "-n", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1704 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1705 |
if opts_new["list_installed_newest"] and opts_new["list_upgradable"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1706 |
opts_err_incompat("-a", "-u", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1707 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1708 |
if opts_new["summary"] and opts_new["verbose"]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1709 |
opts_err_incompat("-s", "-v", op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1710 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1711 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1712 |
# options common to multiple pkg(1) subcommands. The format for specifying |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1713 |
# options is a list which can contain: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1714 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1715 |
# - Function pointers which define callbacks that are invoked after all |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1716 |
# options (aside from extra pargs) have been parsed. These callbacks can |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1717 |
# verify the the contents and combinations of different options. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1718 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1719 |
# - Tuples formatted as: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1720 |
# (s, l, k, v) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1721 |
# where the values are: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1722 |
# s: a short option, ex: -f |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1723 |
# l: a long option, ex: --foo |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1724 |
# k: the key value for the options dictionary |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1725 |
# v: the default value. valid values are: True/False, None, [], 0 |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1726 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1727 |
opts_table_beopts = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1728 |
opts_table_cb_beopts, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1729 |
("", "be-name=", "be_name", None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1730 |
("", "deny-new-be", "deny_new_be", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1731 |
("", "no-be-activate", "be_activate", True), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1732 |
("", "require-new-be", "require_new_be", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1733 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1734 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1735 |
opts_table_force = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1736 |
("f", "", "force", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1737 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1738 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1739 |
opts_table_li_ignore = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1740 |
opts_table_cb_li_ignore, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1741 |
("I", "", "li_ignore_all", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1742 |
("i", "", "li_ignore_list", []), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1743 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1744 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1745 |
opts_table_li_md_only = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1746 |
opts_table_cb_md_only, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1747 |
("", "linked-md-only", "li_md_only", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1748 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1749 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1750 |
opts_table_li_no_pkg_updates = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1751 |
("", "no-pkg-updates", "li_pkg_updates", True), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1752 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1753 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1754 |
opts_table_li_no_psync = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1755 |
opts_table_cb_li_no_psync, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1756 |
("", "no-parent-sync", "li_parent_sync", True), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1757 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1758 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1759 |
opts_table_li_props = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1760 |
opts_table_cb_li_props, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1761 |
("", "prop-linked", "li_props", []), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1762 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1763 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1764 |
opts_table_li_target = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1765 |
opts_table_cb_li_target, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1766 |
("a", "", "li_target_all", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1767 |
("l", "", "li_target_list", []), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1768 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1769 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1770 |
opts_table_li_target1 = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1771 |
opts_table_cb_li_target1, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1772 |
("l", "", "li_name", None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1773 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1774 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1775 |
opts_table_licenses = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1776 |
("", "accept", "accept", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1777 |
("", "licenses", "show_licenses", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1778 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1779 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1780 |
opts_table_no_headers = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1781 |
opts_table_cb_no_headers_vs_quiet, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1782 |
("H", "", "omit_headers", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1783 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1784 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1785 |
opts_table_no_index = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1786 |
("", "no-index", "update_index", True), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1787 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1788 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1789 |
opts_table_no_refresh = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1790 |
("", "no-refresh", "refresh_catalogs", True), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1791 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1792 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1793 |
opts_table_reject = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1794 |
("", "reject=", "reject_pats", []), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1795 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1796 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1797 |
opts_table_verbose = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1798 |
("v", "", "verbose", 0), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1799 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1800 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1801 |
opts_table_quiet = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1802 |
("q", "", "quiet", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1803 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1804 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1805 |
opts_table_nqv = \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1806 |
opts_table_quiet + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1807 |
opts_table_verbose + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1808 |
[ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1809 |
opts_table_cb_nqv, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1810 |
("n", "", "noexecute", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1811 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1812 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1813 |
opts_table_origins = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1814 |
opts_table_cb_origins, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1815 |
("g", "", "origins", []), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1816 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1817 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1818 |
opts_table_stage = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1819 |
opts_table_cb_stage, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1820 |
("", "stage", "stage", None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1821 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1822 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1823 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1824 |
# Options for pkg(1) subcommands. Built by combining the option tables above, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1825 |
# with some optional subcommand unique options defined below. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1826 |
# |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1827 |
opts_install = \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1828 |
opts_table_beopts + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1829 |
opts_table_li_ignore + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1830 |
opts_table_li_no_psync + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1831 |
opts_table_licenses + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1832 |
opts_table_reject + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1833 |
opts_table_no_index + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1834 |
opts_table_no_refresh + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1835 |
opts_table_nqv + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1836 |
opts_table_origins + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1837 |
[] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1838 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1839 |
# "update" cmd inherits all "install" cmd options |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1840 |
opts_update = \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1841 |
opts_install + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1842 |
opts_table_force + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1843 |
opts_table_stage + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1844 |
[] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1845 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1846 |
# "attach-linked" cmd inherits all "install" cmd options |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1847 |
opts_attach_linked = \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1848 |
opts_install + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1849 |
opts_table_force + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1850 |
opts_table_li_md_only + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1851 |
opts_table_li_no_pkg_updates + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1852 |
opts_table_li_props + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1853 |
[ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1854 |
opts_cb_li_attach, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1855 |
("", "allow-relink", "allow_relink", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1856 |
("c", "", "attach_child", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1857 |
("p", "", "attach_parent", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1858 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1859 |
|
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1860 |
opts_list_mediator = \ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1861 |
opts_table_no_headers + \ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1862 |
[ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1863 |
("a", "", "list_available", False), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1864 |
("F", "output-format", "output_format", None) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1865 |
] |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1866 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1867 |
opts_set_mediator = \ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1868 |
opts_table_beopts + \ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1869 |
opts_table_no_index + \ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1870 |
opts_table_nqv + \ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1871 |
[ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1872 |
("I", "implementation", "med_implementation", None), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1873 |
("V", "version", "med_version", None) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1874 |
] |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1875 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1876 |
opts_unset_mediator = \ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1877 |
opts_table_beopts + \ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1878 |
opts_table_no_index + \ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1879 |
opts_table_nqv + \ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1880 |
[ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1881 |
("I", "", "med_implementation", False), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1882 |
("V", "", "med_version", False) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1883 |
] |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1884 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1885 |
# "set-property-linked" cmd inherits all "install" cmd options |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1886 |
opts_set_property_linked = \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1887 |
opts_install + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1888 |
opts_table_li_md_only + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1889 |
opts_table_li_no_pkg_updates + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1890 |
opts_table_li_target1 + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1891 |
[] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1892 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1893 |
# "sync-linked" cmd inherits all "install" cmd options |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1894 |
opts_sync_linked = \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1895 |
opts_install + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1896 |
opts_table_li_md_only + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1897 |
opts_table_li_no_pkg_updates + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1898 |
opts_table_li_target + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1899 |
opts_table_stage + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1900 |
[] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1901 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1902 |
opts_uninstall = \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1903 |
opts_table_beopts + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1904 |
opts_table_li_ignore + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1905 |
opts_table_no_index + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1906 |
opts_table_nqv + \ |
2382
b91a97e46434
18413 recursive uninstall functionality should be removed
Shawn Walker <shawn.walker@oracle.com>
parents:
2357
diff
changeset
|
1907 |
opts_table_stage |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1908 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1909 |
opts_audit_linked = \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1910 |
opts_table_li_no_psync + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1911 |
opts_table_li_target + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1912 |
opts_table_no_headers + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1913 |
opts_table_quiet + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1914 |
[] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1915 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1916 |
opts_detach_linked = \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1917 |
opts_table_force + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1918 |
opts_table_li_target + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1919 |
opts_table_nqv + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1920 |
[] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1921 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1922 |
opts_list_linked = \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1923 |
opts_table_li_ignore + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1924 |
opts_table_no_headers + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1925 |
[] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1926 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1927 |
opts_list_property_linked = \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1928 |
opts_table_li_target1 + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1929 |
opts_table_no_headers + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1930 |
[] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1931 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1932 |
opts_list_inventory = \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1933 |
opts_table_li_no_psync + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1934 |
opts_table_no_refresh + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1935 |
opts_table_no_headers + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1936 |
opts_table_origins + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1937 |
opts_table_verbose + \ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1938 |
[ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1939 |
opts_cb_list, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1940 |
("a", "", "list_installed_newest", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1941 |
("f", "", "list_all", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1942 |
("n", "", "list_newest", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1943 |
("s", "", "summary", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1944 |
("u", "", "list_upgradable", False), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1945 |
] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1946 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1947 |
def change_variant(op, api_inst, pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1948 |
accept, be_activate, be_name, li_ignore, li_parent_sync, new_be, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1949 |
noexecute, origins, quiet, refresh_catalogs, reject_pats, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1950 |
show_licenses, update_index, verbose): |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1951 |
"""Attempt to change a variant associated with an image, updating |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1952 |
the image contents as necessary.""" |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1953 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1954 |
api_inst.progresstracker = get_tracker(quiet, verbose) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1955 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1956 |
xrval, xres = get_fmri_args(api_inst, reject_pats, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1957 |
if not xrval: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1958 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1959 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1960 |
if not pargs: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1961 |
usage(_("%s: no variants specified") % op) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1962 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
1963 |
variants = dict() |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1964 |
for arg in pargs: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1965 |
# '=' is not allowed in variant names or values |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1966 |
if (len(arg.split('=')) != 2): |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1967 |
usage(_("%s: variants must to be of the form " |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1968 |
"'<name>=<value>'.") % op) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1969 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1970 |
# get the variant name and value |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1971 |
name, value = arg.split('=') |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1972 |
if not name.startswith("variant."): |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1973 |
name = "variant.%s" % name |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1974 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1975 |
# make sure the user didn't specify duplicate variants |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1976 |
if name in variants: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1977 |
usage(_("%s: duplicate variant specified: %s") % |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
1978 |
(op, name)) |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1979 |
variants[name] = value |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1980 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1981 |
return __api_op(op, api_inst, _accept=accept, _li_ignore=li_ignore, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1982 |
_noexecute=noexecute, _origins=origins, _quiet=quiet, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1983 |
_show_licenses=show_licenses, _verbose=verbose, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1984 |
be_activate=be_activate, be_name=be_name, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1985 |
li_parent_sync=li_parent_sync, new_be=new_be, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1986 |
refresh_catalogs=refresh_catalogs, reject_list=reject_pats, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1987 |
update_index=update_index, variants=variants) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1988 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1989 |
def change_facet(op, api_inst, pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1990 |
accept, be_activate, be_name, li_ignore, li_parent_sync, new_be, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1991 |
noexecute, origins, quiet, refresh_catalogs, reject_pats, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1992 |
show_licenses, update_index, verbose): |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1993 |
"""Attempt to change the facets as specified, updating |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1994 |
image as necessary""" |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1995 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1996 |
api_inst.progresstracker = get_tracker(quiet, verbose) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1997 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1998 |
xrval, xres = get_fmri_args(api_inst, reject_pats, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1999 |
if not xrval: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2000 |
return EXIT_OOPS |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2001 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2002 |
if not pargs: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2003 |
usage(_("%s: no facets specified") % op) |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2004 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
2005 |
# XXX facets should be accessible through pkg.client.api |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2006 |
facets = img.get_facets() |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2007 |
allowed_values = { |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
2008 |
"TRUE" : True, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
2009 |
"FALSE": False, |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2010 |
"NONE" : None |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2011 |
} |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2012 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2013 |
for arg in pargs: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2014 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2015 |
# '=' is not allowed in facet names or values |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2016 |
if (len(arg.split('=')) != 2): |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2017 |
usage(_("%s: facets must to be of the form " |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2018 |
"'facet....=[True|False|None]'") % op) |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2019 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2020 |
# get the facet name and value |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
2021 |
name, value = arg.split('=') |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2022 |
if not name.startswith("facet."): |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2023 |
name = "facet." + name |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
2024 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2025 |
if value.upper() not in allowed_values: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2026 |
usage(_("%s: facets must to be of the form " |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2027 |
"'facet....=[True|False|None]'.") % op) |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2028 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2029 |
v = allowed_values[value.upper()] |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2030 |
|
2482
b47e1f7cc268
18646 traceback when setting a facet with no installed actions to 'None'
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2470
diff
changeset
|
2031 |
if v is None: |
b47e1f7cc268
18646 traceback when setting a facet with no installed actions to 'None'
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2470
diff
changeset
|
2032 |
facets.pop(name, None) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2033 |
else: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2034 |
facets[name] = v |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2035 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2036 |
return __api_op(op, api_inst, _accept=accept, _li_ignore=li_ignore, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2037 |
_noexecute=noexecute, _origins=origins, _quiet=quiet, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2038 |
_show_licenses=show_licenses, _verbose=verbose, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2039 |
be_activate=be_activate, be_name=be_name, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2040 |
li_parent_sync=li_parent_sync, new_be=new_be, facets=facets, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2041 |
refresh_catalogs=refresh_catalogs, reject_list=reject_pats, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2042 |
update_index=update_index) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2043 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2044 |
def install(op, api_inst, pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2045 |
accept, be_activate, be_name, li_ignore, li_parent_sync, new_be, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2046 |
noexecute, origins, quiet, refresh_catalogs, reject_pats, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2047 |
show_licenses, update_index, verbose): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2048 |
|
50 | 2049 |
"""Attempt to take package specified to INSTALLED state. The operands |
104
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
103
diff
changeset
|
2050 |
are interpreted as glob patterns.""" |
32
c26788b7217c
begin client install; sequences are now timestamps; skeleton ELF module
Stephen Hahn <sch@sun.com>
parents:
30
diff
changeset
|
2051 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2052 |
api_inst.progresstracker = get_tracker(quiet, verbose) |
32
c26788b7217c
begin client install; sequences are now timestamps; skeleton ELF module
Stephen Hahn <sch@sun.com>
parents:
30
diff
changeset
|
2053 |
|
321
19d23a8acb5f
1098 running "pkg install" without args does not return for about 5 seconds
Danek Duvall <danek.duvall@sun.com>
parents:
318
diff
changeset
|
2054 |
if not pargs: |
1774
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
2055 |
usage(_("at least one package name required"), cmd=op) |
321
19d23a8acb5f
1098 running "pkg install" without args does not return for about 5 seconds
Danek Duvall <danek.duvall@sun.com>
parents:
318
diff
changeset
|
2056 |
|
1835
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
2057 |
rval, res = get_fmri_args(api_inst, pargs, cmd=op) |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
2058 |
if not rval: |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
2059 |
return EXIT_OOPS |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
2060 |
|
2183
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
2061 |
xrval, xres = get_fmri_args(api_inst, reject_pats, cmd=op) |
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
2062 |
if not xrval: |
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
2063 |
return EXIT_OOPS |
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
2064 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2065 |
return __api_op(op, api_inst, _accept=accept, _li_ignore=li_ignore, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2066 |
_noexecute=noexecute, _origins=origins, _quiet=quiet, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2067 |
_show_licenses=show_licenses, _verbose=verbose, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2068 |
be_activate=be_activate, be_name=be_name, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2069 |
li_parent_sync=li_parent_sync, new_be=new_be, pkgs_inst=pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2070 |
refresh_catalogs=refresh_catalogs, reject_list=reject_pats, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2071 |
update_index=update_index) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2072 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2073 |
def uninstall(op, api_inst, pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2074 |
be_activate, be_name, new_be, li_ignore, update_index, noexecute, |
2382
b91a97e46434
18413 recursive uninstall functionality should be removed
Shawn Walker <shawn.walker@oracle.com>
parents:
2357
diff
changeset
|
2075 |
quiet, verbose, stage): |
14
969c85e852af
start pkg graph management, annotate pkgsend with server states
"Stephen Hahn <sch@sun.com>"
parents:
3
diff
changeset
|
2076 |
"""Attempt to take package specified to DELETED state.""" |
66 | 2077 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2078 |
api_inst.progresstracker = get_tracker(quiet, verbose) |
66 | 2079 |
|
361
5aca6ca29a5d
1612 pkg contents doesn't give me the manifest I asked for
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
344
diff
changeset
|
2080 |
if not pargs: |
1774
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
2081 |
usage(_("at least one package name required"), cmd=op) |
344
4c887185d780
528 pkg list -u gives confusing output
Dan Price <dp@eng.sun.com>
parents:
343
diff
changeset
|
2082 |
|
326
0f1ba0508d1b
583 src/pkg-server.xml missing a CDDL block
Dan Price <dp@eng.sun.com>
parents:
323
diff
changeset
|
2083 |
if verbose and quiet: |
1774
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
2084 |
usage(_("-v and -q may not be combined"), cmd=op) |
789
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
2085 |
|
1835
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
2086 |
rval, res = get_fmri_args(api_inst, pargs, cmd=op) |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
2087 |
if not rval: |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2088 |
return EXIT_OOPS |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
2089 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2090 |
return __api_op(op, api_inst, _li_ignore=li_ignore, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2091 |
_noexecute=noexecute, _quiet=quiet, _stage=stage, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2092 |
_verbose=verbose, be_activate=be_activate, be_name=be_name, |
2382
b91a97e46434
18413 recursive uninstall functionality should be removed
Shawn Walker <shawn.walker@oracle.com>
parents:
2357
diff
changeset
|
2093 |
new_be=new_be, pkgs_to_uninstall=pargs, update_index=update_index) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2094 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2095 |
def update(op, api_inst, pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2096 |
accept, be_activate, be_name, force, li_ignore, li_parent_sync, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2097 |
new_be, noexecute, origins, quiet, refresh_catalogs, reject_pats, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2098 |
show_licenses, stage, update_index, verbose): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2099 |
"""Attempt to take all installed packages specified to latest |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2100 |
version.""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2101 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2102 |
api_inst.progresstracker = get_tracker(quiet, verbose) |
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
2103 |
|
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
2104 |
rval, res = get_fmri_args(api_inst, pargs, cmd=op) |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
2105 |
if not rval: |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
2106 |
return EXIT_OOPS |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
2107 |
|
2183
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
2108 |
xrval, xres = get_fmri_args(api_inst, reject_pats, cmd=op) |
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
2109 |
if not xrval: |
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
2110 |
return EXIT_OOPS |
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
2111 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2112 |
api_inst.set_stage(stage) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2113 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2114 |
if res and "*" not in pargs and "*@*" not in pargs: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2115 |
# If there are specific installed packages to update, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2116 |
# then take only those packages to the latest version |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2117 |
# allowed by the patterns specified. (The versions |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2118 |
# specified can be older than what is installed.) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2119 |
pkgs_update = pargs |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2120 |
review_release_notes = False |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2121 |
else: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2122 |
# If no packages were specified, or '*' was one of the |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2123 |
# patterns provided, attempt to update all installed packages. |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2124 |
pkgs_update = None |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2125 |
review_release_notes = True |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2126 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2127 |
return __api_op(op, api_inst, _accept=accept, _li_ignore=li_ignore, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2128 |
_noexecute=noexecute, _origins=origins, _quiet=quiet, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2129 |
_review_release_notes=review_release_notes, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2130 |
_show_licenses=show_licenses, _stage=stage, _verbose=verbose, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2131 |
be_activate=be_activate, be_name=be_name, force=force, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2132 |
li_parent_sync=li_parent_sync, new_be=new_be, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2133 |
pkgs_update=pkgs_update, refresh_catalogs=refresh_catalogs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2134 |
reject_list=reject_pats, update_index=update_index) |
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
2135 |
|
2200
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2136 |
def revert(api_inst, args): |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2137 |
"""Attempt to revert files to their original state, either |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2138 |
via explicit path names or via tagged contents.""" |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2139 |
|
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2140 |
op = "revert" |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2141 |
opts, pargs = getopt.getopt(args, "nvq", ["tagged", "deny-new-be", |
2319
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
2142 |
"no-be-activate", "require-new-be", "be-name="]) |
2200
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2143 |
|
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2144 |
quiet = tagged = noexecute = False |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2145 |
verbose = 0 |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2146 |
new_be = None |
2319
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
2147 |
be_activate = True |
2200
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2148 |
be_name = None |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2149 |
|
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2150 |
for opt, arg in opts: |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2151 |
if opt == "-n": |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2152 |
noexecute = True |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2153 |
elif opt == "-v": |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2154 |
verbose = verbose + 1 |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2155 |
elif opt == "-q": |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2156 |
quiet = True |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2157 |
elif opt == "--deny-new-be": |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2158 |
new_be = False |
2319
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
2159 |
elif opt == "--no-be-activate": |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
2160 |
be_activate = False |
2200
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2161 |
elif opt == "--require-new-be": |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2162 |
new_be = True |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2163 |
elif opt == "--be-name": |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2164 |
be_name = arg |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2165 |
elif opt == "--tagged": |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2166 |
tagged = True |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2167 |
|
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2168 |
if not pargs: |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2169 |
usage(_("at least one file path or tag name required"), cmd=op) |
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
2170 |
if verbose > 2: |
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
2171 |
DebugValues.set_value("plan", "True") |
2200
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2172 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2173 |
api_inst.progresstracker = get_tracker(quiet, verbose) |
2200
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2174 |
|
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2175 |
stuff_to_do = None |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2176 |
try: |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2177 |
for pd in api_inst.gen_plan_revert(pargs, tagged=tagged, |
2319
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
2178 |
noexecute=noexecute, be_name=be_name, new_be=new_be, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2179 |
be_activate=be_activate): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2180 |
continue |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2181 |
stuff_to_do = not api_inst.planned_nothingtodo() |
2200
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2182 |
except: |
2413
c22af530e922
18432 consumers of __api_plan_exception not updated
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2410
diff
changeset
|
2183 |
ret_code = __api_plan_exception(op, noexecute, verbose, |
c22af530e922
18432 consumers of __api_plan_exception not updated
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2410
diff
changeset
|
2184 |
api_inst) |
2200
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2185 |
if ret_code != EXIT_OK: |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2186 |
return ret_code |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2187 |
|
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2188 |
if not stuff_to_do: |
2314
01eadc7466f8
18178 verbose planning information is not displayed if plan results in "nothing to do"
Shawn Walker <shawn.walker@oracle.com>
parents:
2311
diff
changeset
|
2189 |
if verbose: |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2190 |
__display_plan(api_inst, verbose) |
2200
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2191 |
msg(_("No files need to be reverted.")) |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2192 |
return EXIT_NOP |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2193 |
|
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2194 |
if not quiet: |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2195 |
__display_plan(api_inst, verbose) |
2200
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2196 |
|
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2197 |
if noexecute: |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2198 |
return EXIT_OK |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2199 |
|
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2200 |
# Exceptions which happen here are printed in the above level, with |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2201 |
# or without some extra decoration done here. |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2202 |
ret_code = __api_prepare(op, api_inst, accept=False) |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2203 |
if ret_code != EXIT_OK: |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2204 |
return ret_code |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2205 |
|
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2206 |
ret_code = __api_execute_plan(op, api_inst) |
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2207 |
|
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2183
diff
changeset
|
2208 |
return ret_code |
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
2209 |
|
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2210 |
def list_mediators(op, api_inst, pargs, omit_headers, output_format, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2211 |
list_available): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2212 |
"""Display configured or available mediator version(s) and |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2213 |
implementation(s).""" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2214 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2215 |
subcommand = "mediator" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2216 |
if output_format is None: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2217 |
output_format = "default" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2218 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2219 |
# mediator information is returned as a dictionary of dictionaries |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2220 |
# of version and implementation indexed by mediator name. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2221 |
mediations = collections.defaultdict(list) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2222 |
if list_available: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2223 |
gen_mediators = api_inst.gen_available_mediators() |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2224 |
else: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2225 |
# Configured mediator information |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2226 |
gen_mediators = ( |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2227 |
(mediator, mediation) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2228 |
for mediator, mediation in api_inst.mediators.iteritems() |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2229 |
) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2230 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2231 |
# Set minimum widths for mediator and version columns by using the |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2232 |
# length of the column headers and values to be displayed. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2233 |
mediators = set() |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2234 |
max_mname_len = len(_("MEDIATOR")) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2235 |
max_vsrc_len = len(_("VER. SRC.")) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2236 |
max_version_len = len(_("VERSION")) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2237 |
max_isrc_len = len(_("IMPL. SRC.")) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2238 |
for mname, values in gen_mediators: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2239 |
max_mname_len = max(max_mname_len, len(mname)) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2240 |
med_version = values.get("version", "") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2241 |
max_version_len = max(max_version_len, len(med_version)) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2242 |
mediators.add(mname) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2243 |
mediations[mname].append(values) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2244 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2245 |
requested_mediators = set(pargs) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2246 |
if requested_mediators: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2247 |
found = mediators & requested_mediators |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2248 |
notfound = requested_mediators - found |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2249 |
else: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2250 |
found = mediators |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2251 |
notfound = set() |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2252 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2253 |
def gen_listing(): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2254 |
for mediator, mediation in ( |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2255 |
(mname, mentry) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2256 |
for mname in sorted(found) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2257 |
for mentry in mediations[mname] |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2258 |
): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2259 |
med_impl = mediation.get("implementation") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2260 |
med_impl_ver = mediation.get("implementation-version") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2261 |
if output_format == "default" and med_impl and \ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2262 |
med_impl_ver: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2263 |
med_impl += "(@%s)" % med_impl_ver |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2264 |
yield { |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2265 |
"mediator": mediator, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2266 |
"version": mediation.get("version"), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2267 |
"version-source": mediation.get("version-source"), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2268 |
"implementation": med_impl, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2269 |
"implementation-source": mediation.get( |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2270 |
"implementation-source"), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2271 |
"implementation-version": med_impl_ver, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2272 |
} |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2273 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2274 |
# MEDIATOR VER. SRC. VERSION IMPL. SRC. IMPLEMENTATION IMPL. VER. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2275 |
# <med_1> <src_1> <ver_1> <src_1> <impl_1_value> <impl_1_ver> |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2276 |
# <med_2> <src_2> <ver_2> <src_2> <impl_2_value> <impl_2_ver> |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2277 |
# ... |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2278 |
field_data = { |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2279 |
"mediator" : [("default", "tsv"), _("MEDIATOR"), ""], |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2280 |
"version" : [("default", "tsv"), _("VERSION"), ""], |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2281 |
"version-source": [("default", "tsv"), _("VER. SRC."), ""], |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2282 |
"implementation" : [("default", "tsv"), _("IMPLEMENTATION"), ""], |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2283 |
"implementation-source": [("default", "tsv"), _("IMPL. SRC."), ""], |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2284 |
"implementation-version" : [("tsv",), _("IMPL. VER."), ""], |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2285 |
} |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2286 |
desired_field_order = ((_("MEDIATOR"), _("VER. SRC."), _("VERSION"), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2287 |
_("IMPL. SRC."), _("IMPLEMENTATION"), _("IMPL. VER."))) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2288 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2289 |
# Default output formatting. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2290 |
def_fmt = "%-" + str(max_mname_len) + "s %-" + str(max_vsrc_len) + \ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2291 |
"s %-" + str(max_version_len) + "s %-" + str(max_isrc_len) + "s %s" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2292 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2293 |
if found or (not requested_mediators and output_format == "default"): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2294 |
sys.stdout.write(misc.get_col_listing(desired_field_order, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2295 |
field_data, gen_listing(), output_format, def_fmt, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2296 |
omit_headers, escape_output=False)) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2297 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2298 |
if found and notfound: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2299 |
return EXIT_PARTIAL |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2300 |
if requested_mediators and not found: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2301 |
if output_format == "default": |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2302 |
# Don't pollute other output formats. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2303 |
error(_("no matching mediators found"), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2304 |
cmd=subcommand) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2305 |
return EXIT_OOPS |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2306 |
return EXIT_OK |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2307 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2308 |
def set_mediator(op, api_inst, pargs, be_activate, be_name, med_implementation, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2309 |
med_version, new_be, noexecute, quiet, update_index, verbose): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2310 |
"""Set the version and/or implementation for the specified mediator(s).""" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2311 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2312 |
op = "set-mediator" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2313 |
if not pargs: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2314 |
usage(_("at least one mediator must be specified"), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2315 |
cmd=op) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2316 |
if not (med_version or med_implementation): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2317 |
usage(_("a mediator version and/or implementation must be " |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2318 |
"specified using -V and -I"), cmd=op) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2319 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2320 |
if verbose > 2: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2321 |
DebugValues.set_value("plan", "True") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2322 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2323 |
api_inst.progresstracker = get_tracker(quiet, verbose) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2324 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2325 |
# Now set version and/or implementation for all matching mediators. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2326 |
# The user may specify 'None' as a special value to explicitly |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2327 |
# request mediations that do not have the related component. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2328 |
mediators = collections.defaultdict(dict) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2329 |
for m in pargs: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2330 |
if med_version == "": |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2331 |
# Request reset of version. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2332 |
mediators[m]["version"] = None |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2333 |
elif med_version == "None": |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2334 |
# Explicit selection of no version. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2335 |
mediators[m]["version"] = "" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2336 |
elif med_version: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2337 |
mediators[m]["version"] = med_version |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2338 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2339 |
if med_implementation == "": |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2340 |
# Request reset of implementation. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2341 |
mediators[m]["implementation"] = None |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2342 |
elif med_implementation == "None": |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2343 |
# Explicit selection of no implementation. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2344 |
mediators[m]["implementation"] = "" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2345 |
elif med_implementation: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2346 |
mediators[m]["implementation"] = med_implementation |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2347 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2348 |
stuff_to_do = None |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2349 |
try: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2350 |
for pd in api_inst.gen_plan_set_mediators(mediators, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2351 |
noexecute=noexecute, be_name=be_name, new_be=new_be, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2352 |
be_activate=be_activate): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2353 |
continue |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2354 |
stuff_to_do = not api_inst.planned_nothingtodo() |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2355 |
except: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2356 |
ret_code = __api_plan_exception(op, api_inst, noexecute, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2357 |
verbose) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2358 |
if ret_code != EXIT_OK: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2359 |
return ret_code |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2360 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2361 |
if not stuff_to_do: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2362 |
if verbose: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2363 |
__display_plan(api_inst, verbose) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2364 |
msg(_("No changes required.")) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2365 |
return EXIT_NOP |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2366 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2367 |
if not quiet: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2368 |
__display_plan(api_inst, verbose) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2369 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2370 |
if noexecute: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2371 |
return EXIT_OK |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2372 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2373 |
ret_code = __api_prepare(op, api_inst, accept=False) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2374 |
if ret_code != EXIT_OK: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2375 |
return ret_code |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2376 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2377 |
ret_code = __api_execute_plan(op, api_inst) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2378 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2379 |
return ret_code |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2380 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2381 |
def unset_mediator(op, api_inst, pargs, be_activate, be_name, med_implementation, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2382 |
med_version, new_be, noexecute, quiet, update_index, verbose): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2383 |
"""Unset the version and/or implementation for the specified mediator(s).""" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2384 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2385 |
op = "unset-mediator" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2386 |
if not pargs: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2387 |
usage(_("at least one mediator must be specified"), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2388 |
cmd=op) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2389 |
if verbose > 2: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2390 |
DebugValues.set_value("plan", "True") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2391 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2392 |
api_inst.progresstracker = get_tracker(quiet, verbose) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2393 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2394 |
# Build dictionary of mediators to unset based on input. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2395 |
mediators = collections.defaultdict(dict) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2396 |
if not (med_version or med_implementation): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2397 |
# Unset both if nothing specific requested. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2398 |
med_version = True |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2399 |
med_implementation = True |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2400 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2401 |
# Now unset version and/or implementation for all matching mediators. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2402 |
for m in pargs: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2403 |
if med_version: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2404 |
mediators[m]["version"] = None |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2405 |
if med_implementation: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2406 |
mediators[m]["implementation"] = None |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2407 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2408 |
stuff_to_do = None |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2409 |
try: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2410 |
for pd in api_inst.gen_plan_set_mediators(mediators, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2411 |
noexecute=noexecute, be_name=be_name, new_be=new_be, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2412 |
be_activate=be_activate): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2413 |
continue |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2414 |
stuff_to_do = not api_inst.planned_nothingtodo() |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2415 |
except: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2416 |
ret_code = __api_plan_exception(op, api_inst, noexecute, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2417 |
verbose) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2418 |
if ret_code != EXIT_OK: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2419 |
return ret_code |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2420 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2421 |
if not stuff_to_do: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2422 |
if verbose: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2423 |
__display_plan(api_inst, verbose) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2424 |
msg(_("No changes required.")) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2425 |
return EXIT_NOP |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2426 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2427 |
if not quiet: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2428 |
__display_plan(api_inst, verbose) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2429 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2430 |
if noexecute: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2431 |
return EXIT_OK |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2432 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2433 |
ret_code = __api_prepare(op, api_inst, accept=False) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2434 |
if ret_code != EXIT_OK: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2435 |
return ret_code |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2436 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2437 |
ret_code = __api_execute_plan(op, api_inst) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2438 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2439 |
return ret_code |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2440 |
|
2228
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2441 |
def avoid(api_inst, args): |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2442 |
"""Place the specified packages on the avoid list""" |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2443 |
if not args: |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2444 |
return __display_avoids(api_inst) |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2445 |
|
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2446 |
try: |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2447 |
api_inst.avoid_pkgs(args) |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2448 |
return EXIT_OK |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2449 |
except: |
2413
c22af530e922
18432 consumers of __api_plan_exception not updated
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2410
diff
changeset
|
2450 |
return __api_plan_exception("avoid", False, 0, api_inst) |
2228
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2451 |
|
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2452 |
def unavoid(api_inst, args): |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2453 |
"""Remove the specified packages from the avoid list""" |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2454 |
if not args: |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2455 |
return __display_avoids(api_inst) |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2456 |
|
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2457 |
try: |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2458 |
api_inst.avoid_pkgs(args, unavoid=True) |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2459 |
return EXIT_OK |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2460 |
except: |
2413
c22af530e922
18432 consumers of __api_plan_exception not updated
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2410
diff
changeset
|
2461 |
return __api_plan_exception("unavoid", False, 0, api_inst) |
2228
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2462 |
|
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2463 |
def __display_avoids(api_inst): |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2464 |
"""Display the current avoid list, and the pkgs that are tracking |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2465 |
that pkg""" |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2466 |
for a in api_inst.get_avoid_list(): |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2467 |
tracking = " ".join(a[1]) |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2468 |
if tracking: |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2469 |
logger.info(_(" %s (group dependency of '%s')") |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2470 |
% (a[0], tracking)) |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2471 |
else: |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2472 |
logger.info(" %s" % a[0]) |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2473 |
|
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2474 |
return EXIT_OK |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2475 |
|
2452
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2476 |
def freeze(api_inst, args): |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2477 |
"""Place the specified packages on the frozen list""" |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2478 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2479 |
opts, pargs = getopt.getopt(args, "Hc:n") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2480 |
comment = None |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2481 |
display_headers = True |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2482 |
dry_run = False |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2483 |
for opt, arg in opts: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2484 |
if opt == "-H": |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2485 |
display_headers = False |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2486 |
elif opt == "-c": |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2487 |
comment = arg |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2488 |
elif opt == "-n": |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2489 |
dry_run = True |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2490 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2491 |
if comment and not pargs: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2492 |
usage(usage_error=_("At least one package to freeze must be " |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2493 |
"given when -c is used."), cmd="freeze") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2494 |
if not display_headers and pargs: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2495 |
usage(usage_error=_("-H may only be specified when listing the " |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2496 |
"currently frozen packages.")) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2497 |
if not pargs: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2498 |
return __display_cur_frozen(api_inst, display_headers) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2499 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2500 |
try: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2501 |
pfmris = api_inst.freeze_pkgs(pargs, dry_run=dry_run, |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2502 |
comment=comment) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2503 |
for pfmri in pfmris: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2504 |
vertext = pfmri.version.get_short_version() |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2505 |
ts = pfmri.version.get_timestamp() |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2506 |
if ts: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2507 |
vertext += ":" + pfmri.version.timestr |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2508 |
logger.info(_("%(name)s was frozen at %(ver)s") % |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2509 |
{"name": pfmri.pkg_name, "ver": vertext}) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2510 |
return EXIT_OK |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2511 |
except api_errors.FreezePkgsException, e: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2512 |
error("\n%s" % e, cmd="freeze") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2513 |
return EXIT_OOPS |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2514 |
except: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2515 |
return __api_plan_exception("freeze", False, 0, api_inst) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2516 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2517 |
def unfreeze(api_inst, args): |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2518 |
"""Remove the specified packages from the frozen list""" |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2519 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2520 |
opts, pargs = getopt.getopt(args, "Hn") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2521 |
display_headers = True |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2522 |
dry_run = False |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2523 |
for opt, arg in opts: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2524 |
if opt == "-H": |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2525 |
display_headers = False |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2526 |
elif opt == "-n": |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2527 |
dry_run = True |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2528 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2529 |
if not pargs: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2530 |
return __display_cur_frozen(api_inst, display_headers) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2531 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2532 |
try: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2533 |
pkgs = api_inst.freeze_pkgs(pargs, unfreeze=True, |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2534 |
dry_run=dry_run) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2535 |
if not pkgs: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2536 |
return EXIT_NOP |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2537 |
for s in pkgs: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2538 |
logger.info(_("%s was unfrozen.") % s) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2539 |
return EXIT_OK |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2540 |
except: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2541 |
return __api_plan_exception("unfreeze", False, 0, api_inst) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2542 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2543 |
def __display_cur_frozen(api_inst, display_headers): |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2544 |
"""Display the current frozen list""" |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2545 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2546 |
try: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2547 |
lst = sorted(api_inst.get_frozen_list()) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2548 |
except api_errors.ApiException, e: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2549 |
error(e) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2550 |
return EXIT_OOPS |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2551 |
if len(lst) == 0: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2552 |
return EXIT_OK |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2553 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2554 |
fmt = "%(name)-18s %(ver)-27s %(time)-24s %(comment)s" |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2555 |
if display_headers: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2556 |
logger.info(fmt % { |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2557 |
"name": _("NAME"), |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2558 |
"ver": _("VERSION"), |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2559 |
"time": _("DATE"), |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2560 |
"comment": _("COMMENT") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2561 |
}) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2562 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2563 |
for pfmri, comment, timestamp in lst: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2564 |
vertext = pfmri.version.get_short_version() |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2565 |
ts = pfmri.version.get_timestamp() |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2566 |
if ts: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2567 |
vertext += ":" + pfmri.version.timestr |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2568 |
if not comment: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2569 |
comment = "None" |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2570 |
logger.info(fmt % { |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2571 |
"name": pfmri.pkg_name, |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2572 |
"comment": comment, |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2573 |
"time": time.strftime("%d %b %Y %H:%M:%S %Z", |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2574 |
time.localtime(timestamp)), |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2575 |
"ver": vertext |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2576 |
}) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2577 |
return EXIT_OK |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2578 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2579 |
def __convert_output(a_str, match): |
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2580 |
"""Converts a string to a three tuple with the information to fill |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2581 |
the INDEX, ACTION, and VALUE columns. |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2582 |
|
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2583 |
The "a_str" parameter is the string representation of an action. |
1234
d9885dff5d16
4705 UnboundLocalError in depend action
Shawn Walker <srw@sun.com>
parents:
1218
diff
changeset
|
2584 |
|
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2585 |
The "match" parameter is a string whose precise interpretation is given |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2586 |
below. |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2587 |
|
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2588 |
For most action types, match defines which attribute the query matched |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2589 |
with. For example, it states whether the basename or path attribute of |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2590 |
a file action matched the query. Attribute (set) actions are treated |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2591 |
differently because they only have one attribute, and many values |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2592 |
associated with that attribute. For those actions, the match parameter |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2593 |
states which value matched the query.""" |
1234
d9885dff5d16
4705 UnboundLocalError in depend action
Shawn Walker <srw@sun.com>
parents:
1218
diff
changeset
|
2594 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2595 |
a = actions.fromstr(a_str.rstrip()) |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2596 |
if isinstance(a, actions.attribute.AttributeAction): |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2597 |
return a.attrs.get(a.key_attr), a.name, match |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2598 |
return match, a.name, a.attrs.get(a.key_attr) |
60
6bd5cd83cfb1
Reverse index database and searching support.
Danek Duvall <danek.duvall@sun.com>
parents:
59
diff
changeset
|
2599 |
|
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2600 |
def produce_matching_token(action, match): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2601 |
"""Given an action and a match value (see convert_output for more |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2602 |
details on this parameter), return the token which matched the query.""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2603 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2604 |
if isinstance(action, actions.attribute.AttributeAction): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2605 |
return match |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2606 |
if match == "basename": |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2607 |
return action.attrs.get("path") |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2608 |
r = action.attrs.get(match) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2609 |
if r: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2610 |
return r |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2611 |
return action.attrs.get(action.key_attr) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2612 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2613 |
def produce_matching_type(action, match): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2614 |
"""Given an action and a match value (see convert_output for more |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2615 |
details on this parameter), return the kind of match this was. For |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2616 |
example, if the query matched a portion of a path of an action, this |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2617 |
will return 'path'. If the action is an attribute action, it returns |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2618 |
the name set in the action. """ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2619 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2620 |
if not isinstance(action, actions.attribute.AttributeAction): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2621 |
return match |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2622 |
return action.attrs.get("name") |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2623 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2624 |
def v1_extract_info(tup, return_type, pub): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2625 |
"""Given a result from search, massages the information into a form |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2626 |
useful for produce_lines. |
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2627 |
|
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2628 |
The "return_type" parameter is an enumeration that describes the type |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2629 |
of the information that will be converted. |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2630 |
|
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2631 |
The type of the "tup" parameter depends on the value of "return_type". |
1234
d9885dff5d16
4705 UnboundLocalError in depend action
Shawn Walker <srw@sun.com>
parents:
1218
diff
changeset
|
2632 |
If "return_type" is action information, "tup" is a three-tuple of the |
d9885dff5d16
4705 UnboundLocalError in depend action
Shawn Walker <srw@sun.com>
parents:
1218
diff
changeset
|
2633 |
fmri name, the match, and a string representation of the action. In |
d9885dff5d16
4705 UnboundLocalError in depend action
Shawn Walker <srw@sun.com>
parents:
1218
diff
changeset
|
2634 |
the case where "return_type" is package information, "tup" is a one- |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2635 |
tuple containing the fmri name. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2636 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2637 |
The "pub" parameter contains information about the publisher from which |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2638 |
the result was obtained.""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2639 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2640 |
action = None |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2641 |
match = None |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2642 |
match_type = None |
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2643 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2644 |
if return_type == api.Query.RETURN_ACTIONS: |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2645 |
try: |
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2646 |
pfmri, match, action = tup |
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2647 |
except ValueError: |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
2648 |
error(_("The repository returned a malformed result.\n" |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2649 |
"The problematic structure:%r") % (tup,)) |
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2650 |
return False |
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2651 |
try: |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2652 |
action = actions.fromstr(action.rstrip()) |
1234
d9885dff5d16
4705 UnboundLocalError in depend action
Shawn Walker <srw@sun.com>
parents:
1218
diff
changeset
|
2653 |
except actions.ActionError, e: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2654 |
error(_("The repository returned an invalid or " |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2655 |
"unsupported action.\n%s") % e) |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2656 |
return False |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2657 |
match_type = produce_matching_type(action, match) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2658 |
match = produce_matching_token(action, match) |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2659 |
else: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2660 |
pfmri = tup |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2661 |
return pfmri, action, pub, match, match_type |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2662 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
2663 |
def search(api_inst, args): |
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2664 |
"""Search for the given query.""" |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2665 |
|
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2666 |
# Constants which control the paging behavior for search output. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2667 |
page_timeout = .5 |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2668 |
max_timeout = 5 |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2669 |
min_page_size = 5 |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2670 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2671 |
search_attrs = valid_special_attrs[:] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2672 |
search_attrs.extend(["search.match", "search.match_type"]) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2673 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2674 |
search_prefixes = valid_special_prefixes[:] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2675 |
search_prefixes.extend(["search."]) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2676 |
|
1843
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2677 |
opts, pargs = getopt.getopt(args, "Haflo:prs:I") |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2678 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2679 |
default_attrs_action = ["search.match_type", "action.name", |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2680 |
"search.match", "pkg.shortfmri"] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2681 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2682 |
default_attrs_package = ["pkg.shortfmri", "pkg.publisher"] |
204
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2683 |
|
499
ff214b0daeb1
2672 Search should allow for case insensitive search.
Brock Pytlik <bpytlik@sun.com>
parents:
497
diff
changeset
|
2684 |
local = remote = case_sensitive = False |
204
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2685 |
servers = [] |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2686 |
attrs = [] |
1843
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2687 |
|
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2688 |
display_headers = True |
1843
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2689 |
prune_versions = True |
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2690 |
return_actions = True |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2691 |
use_default_attrs = True |
1843
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2692 |
|
204
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2693 |
for opt, arg in opts: |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2694 |
if opt == "-H": |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2695 |
display_headers = False |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2696 |
elif opt == "-a": |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2697 |
return_actions = True |
1843
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2698 |
elif opt == "-f": |
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2699 |
prune_versions = False |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2700 |
elif opt == "-l": |
204
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2701 |
local = True |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2702 |
elif opt == "-o": |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2703 |
attrs.extend(arg.split(",")) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2704 |
use_default_attrs = False |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2705 |
elif opt == "-p": |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2706 |
return_actions = False |
222
12006bf2a260
4 We need to be able to verify that package(s) is/are correctly installed
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
221
diff
changeset
|
2707 |
elif opt == "-r": |
204
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2708 |
remote = True |
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2709 |
elif opt == "-s": |
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2710 |
remote = True |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2711 |
servers.append({ |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2712 |
"origin": misc.parse_uri(arg, cwd=orig_cwd) }) |
499
ff214b0daeb1
2672 Search should allow for case insensitive search.
Brock Pytlik <bpytlik@sun.com>
parents:
497
diff
changeset
|
2713 |
elif opt == "-I": |
ff214b0daeb1
2672 Search should allow for case insensitive search.
Brock Pytlik <bpytlik@sun.com>
parents:
497
diff
changeset
|
2714 |
case_sensitive = True |
204
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2715 |
|
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2716 |
if not local and not remote: |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2717 |
remote = True |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
2718 |
|
204
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2719 |
if not pargs: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
2720 |
usage(_("at least one search term must be provided"), |
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
2721 |
cmd="search") |
204
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2722 |
|
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2723 |
check_attrs(attrs, "search", reference=search_attrs, |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2724 |
prefixes=search_prefixes) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2725 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2726 |
action_attr = False |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2727 |
for a in attrs: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2728 |
if a.startswith("action.") or a.startswith("search.match"): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2729 |
action_attr = True |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2730 |
if not return_actions: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2731 |
usage(_("action level options ('%s') to -o " |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2732 |
"cannot be used with the -p option") % a, |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2733 |
cmd="search") |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2734 |
break |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2735 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2736 |
searches = [] |
204
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2737 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2738 |
try: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2739 |
query = [api.Query(" ".join(pargs), case_sensitive, |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2740 |
return_actions)] |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2741 |
except api_errors.BooleanQueryException, e: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2742 |
error(e) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2743 |
return EXIT_OOPS |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2744 |
|
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2745 |
good_res = False |
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2746 |
bad_res = False |
1234
d9885dff5d16
4705 UnboundLocalError in depend action
Shawn Walker <srw@sun.com>
parents:
1218
diff
changeset
|
2747 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2748 |
try: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2749 |
if local: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2750 |
searches.append(api_inst.local_search(query)) |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2751 |
if remote: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2752 |
searches.append(api_inst.remote_search(query, |
1843
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2753 |
servers=servers, prune_versions=prune_versions)) |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2754 |
# By default assume we don't find anything. |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2755 |
retcode = EXIT_OOPS |
302
a5268194080e
981 pkg search could have more useful output
Danek Duvall <danek.duvall@sun.com>
parents:
301
diff
changeset
|
2756 |
|
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2757 |
# get initial set of results |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2758 |
justs = calc_justs(attrs) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2759 |
page_again = True |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2760 |
widths = [] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2761 |
st = None |
1628
82c58b51e409
12739 remote search returns no results if one depot fails
Brock Pytlik <bpytlik@sun.com>
parents:
1618
diff
changeset
|
2762 |
err = None |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2763 |
header_attrs = attrs |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2764 |
last_line = None |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2765 |
shown_headers = False |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2766 |
while page_again: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2767 |
unprocessed_res = [] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2768 |
page_again = False |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2769 |
# Indexless search raises a slow search exception. In |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2770 |
# that case, catch the exception, finish processing the |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2771 |
# results, then propogate the error. |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2772 |
try: |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2773 |
for raw_value in itertools.chain(*searches): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2774 |
if not st: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2775 |
st = time.time() |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2776 |
try: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2777 |
query_num, pub, \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2778 |
(v, return_type, tmp) = \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2779 |
raw_value |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2780 |
except ValueError, e: |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
2781 |
error(_("The repository " |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
2782 |
"returned a malformed " |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
2783 |
"result:%r") % |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2784 |
(raw_value,)) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2785 |
bad_res = True |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2786 |
continue |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2787 |
# This check is necessary since a |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2788 |
# a pacakge search can be specified |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2789 |
# using the <> operator. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2790 |
if action_attr and \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2791 |
return_type != \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2792 |
api.Query.RETURN_ACTIONS: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2793 |
usage(_("action level options " |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2794 |
"to -o cannot be used with " |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2795 |
"the queries that return " |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2796 |
"packages"), cmd="search") |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2797 |
if use_default_attrs and not justs: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2798 |
if return_type == \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2799 |
api.Query.RETURN_ACTIONS: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2800 |
attrs = \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2801 |
default_attrs_action |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2802 |
header_attrs = \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2803 |
["index", "action", |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2804 |
"value", "package"] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2805 |
else: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2806 |
attrs = default_attrs_package |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2807 |
header_attrs = \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2808 |
["package", |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2809 |
"publisher"] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2810 |
justs = calc_justs(attrs) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2811 |
ret = v1_extract_info( |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2812 |
tmp, return_type, pub) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2813 |
bad_res |= isinstance(ret, bool) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2814 |
if ret: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2815 |
good_res = True |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2816 |
unprocessed_res.append(ret) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2817 |
# Check whether the paging timeout |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2818 |
# should be increased. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2819 |
if time.time() - st > page_timeout: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2820 |
if len(unprocessed_res) > \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2821 |
min_page_size: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2822 |
page_again = True |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2823 |
break |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2824 |
else: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2825 |
page_timeout = min( |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2826 |
page_timeout * 2, |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2827 |
max_timeout) |
1628
82c58b51e409
12739 remote search returns no results if one depot fails
Brock Pytlik <bpytlik@sun.com>
parents:
1618
diff
changeset
|
2828 |
except api_errors.ApiException, e: |
82c58b51e409
12739 remote search returns no results if one depot fails
Brock Pytlik <bpytlik@sun.com>
parents:
1618
diff
changeset
|
2829 |
err = e |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2830 |
lines = produce_lines(unprocessed_res, attrs, |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2831 |
show_all=True, remove_consec_dup_lines=True, |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2832 |
last_res=last_line) |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2833 |
if not lines: |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2834 |
continue |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2835 |
old_widths = widths[:] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2836 |
widths = calc_widths(lines, attrs, widths) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2837 |
# If headers are being displayed and the layout of the |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2838 |
# columns have changed, print the headers again using |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2839 |
# the new widths. |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2840 |
if display_headers and (not shown_headers or |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2841 |
old_widths[:-1] != widths[:-1]): |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2842 |
shown_headers = True |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2843 |
print_headers(header_attrs, widths, justs) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2844 |
for line in lines: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2845 |
msg((create_output_format(display_headers, |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2846 |
widths, justs, line) % |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2847 |
tuple(line)).rstrip()) |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2848 |
last_line = lines[-1] |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2849 |
st = time.time() |
1628
82c58b51e409
12739 remote search returns no results if one depot fails
Brock Pytlik <bpytlik@sun.com>
parents:
1618
diff
changeset
|
2850 |
if err: |
82c58b51e409
12739 remote search returns no results if one depot fails
Brock Pytlik <bpytlik@sun.com>
parents:
1618
diff
changeset
|
2851 |
raise err |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2852 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2853 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2854 |
except (api_errors.IncorrectIndexFileHash, |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2855 |
api_errors.InconsistentIndexException): |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2856 |
error(_("The search index appears corrupted. Please " |
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2857 |
"rebuild the index with 'pkg rebuild-index'.")) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2858 |
return EXIT_OOPS |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2859 |
except api_errors.ProblematicSearchServers, e: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2860 |
error(e) |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2861 |
bad_res = True |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2862 |
except api_errors.SlowSearchUsed, e: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2863 |
error(e) |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2864 |
except (api_errors.IncorrectIndexFileHash, |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2865 |
api_errors.InconsistentIndexException): |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2866 |
error(_("The search index appears corrupted. Please " |
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2867 |
"rebuild the index with 'pkg rebuild-index'.")) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2868 |
return EXIT_OOPS |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
2869 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
2870 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
2871 |
return EXIT_OOPS |
1053
00fe9773d072
8098 parsing errors should not cause a stacktrace
Brock Pytlik <bpytlik@sun.com>
parents:
1052
diff
changeset
|
2872 |
except api_errors.ApiException, e: |
00fe9773d072
8098 parsing errors should not cause a stacktrace
Brock Pytlik <bpytlik@sun.com>
parents:
1052
diff
changeset
|
2873 |
error(e) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2874 |
return EXIT_OOPS |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2875 |
if good_res and bad_res: |
1628
82c58b51e409
12739 remote search returns no results if one depot fails
Brock Pytlik <bpytlik@sun.com>
parents:
1618
diff
changeset
|
2876 |
retcode = EXIT_PARTIAL |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2877 |
elif bad_res: |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2878 |
retcode = EXIT_OOPS |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2879 |
elif good_res: |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2880 |
retcode = EXIT_OK |
204
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2881 |
return retcode |
60
6bd5cd83cfb1
Reverse index database and searching support.
Danek Duvall <danek.duvall@sun.com>
parents:
59
diff
changeset
|
2882 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
2883 |
def info(api_inst, args): |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
2884 |
"""Display information about a package or packages. |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
2885 |
""" |
195
b23d0425f0f7
11 use FMRIs with fully specified authorities internally
johansen <johansen@sun.com>
parents:
192
diff
changeset
|
2886 |
|
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2887 |
display_license = False |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2888 |
info_local = False |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2889 |
info_remote = False |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2890 |
origins = set() |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2891 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2892 |
opts, pargs = getopt.getopt(args, "g:lr", ["license"]) |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2893 |
for opt, arg in opts: |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2894 |
if opt == "-g": |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2895 |
origins.add(misc.parse_uri(arg, cwd=orig_cwd)) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2896 |
info_remote = True |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2897 |
elif opt == "-l": |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2898 |
info_local = True |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2899 |
elif opt == "-r": |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2900 |
info_remote = True |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2901 |
elif opt == "--license": |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2902 |
display_license = True |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2903 |
|
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2904 |
if not info_local and not info_remote: |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2905 |
info_local = True |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2906 |
elif info_local and info_remote: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
2907 |
usage(_("-l and -r may not be combined"), cmd="info") |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2908 |
|
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2909 |
if info_remote and not pargs: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
2910 |
usage(_("must request remote info for specific packages"), |
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
2911 |
cmd="info") |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
2912 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
2913 |
err = 0 |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
2914 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
2915 |
api_inst.progresstracker = get_tracker(quiet=True) |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2916 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2917 |
info_needed = api.PackageInfo.ALL_OPTIONS |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2918 |
if not display_license: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2919 |
info_needed = api.PackageInfo.ALL_OPTIONS - \ |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2920 |
frozenset([api.PackageInfo.LICENSES]) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2921 |
info_needed -= api.PackageInfo.ACTION_OPTIONS |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2922 |
info_needed |= frozenset([api.PackageInfo.DEPENDENCIES]) |
1835
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
2923 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2924 |
try: |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2925 |
ret = api_inst.info(pargs, info_local, info_needed, |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2926 |
repos=origins) |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
2927 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
2928 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
2929 |
return EXIT_OOPS |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2930 |
except api_errors.NoPackagesInstalledException: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2931 |
error(_("no packages installed")) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2932 |
return EXIT_OOPS |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2933 |
except api_errors.ApiException, e: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2934 |
error(e) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2935 |
return EXIT_OOPS |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2936 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2937 |
pis = ret[api.ImageInterface.INFO_FOUND] |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2938 |
notfound = ret[api.ImageInterface.INFO_MISSING] |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2939 |
illegals = ret[api.ImageInterface.INFO_ILLEGALS] |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2940 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2941 |
if illegals: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2942 |
# No other results will be returned if illegal patterns were |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2943 |
# specified. |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2944 |
for i in illegals: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2945 |
logger.error(str(i)) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2946 |
return EXIT_OOPS |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2947 |
|
789
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
2948 |
no_licenses = [] |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2949 |
for i, pi in enumerate(pis): |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
2950 |
if i > 0: |
384
9d4746e5dd3e
115 pkg needs to not have a cow on a SIGPIPE
Shawn Walker <swalker@opensolaris.org>
parents:
362
diff
changeset
|
2951 |
msg("") |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
2952 |
|
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2953 |
if display_license: |
789
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
2954 |
if not pi.licenses: |
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
2955 |
no_licenses.append(pi.fmri) |
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
2956 |
else: |
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
2957 |
for lic in pi.licenses: |
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
2958 |
msg(lic) |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2959 |
continue |
789
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
2960 |
|
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
2961 |
state = "" |
2452
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2962 |
if api.PackageInfo.INSTALLED in pi.states: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2963 |
state = _("Installed") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2964 |
elif api.PackageInfo.UNSUPPORTED in pi.states: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2965 |
state = _("Unsupported") |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2966 |
else: |
2452
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2967 |
state = _("Not installed") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2968 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2969 |
lparen = False |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2970 |
if api.PackageInfo.OBSOLETE in pi.states: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2971 |
state += " (%s" % _("Obsolete") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2972 |
lparen = True |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2973 |
elif api.PackageInfo.RENAMED in pi.states: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2974 |
state += " (%s" % _("Renamed") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2975 |
lparen = True |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2976 |
if api.PackageInfo.FROZEN in pi.states: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2977 |
if lparen: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2978 |
state += ", %s)" % _("Frozen") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2979 |
else: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2980 |
state += " (%s)" % _("Frozen") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2981 |
elif lparen: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2982 |
state += ")" |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
2983 |
|
688
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2984 |
name_str = _(" Name:") |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2985 |
msg(name_str, pi.pkg_stem) |
615
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
611
diff
changeset
|
2986 |
msg(_(" Summary:"), pi.summary) |
1389
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
2987 |
if pi.description: |
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
2988 |
desc_label = _(" Description:") |
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
2989 |
start_loc = len(desc_label) + 1 |
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
2990 |
end_loc = 80 |
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
2991 |
res = textwrap.wrap(pi.description, |
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
2992 |
width=end_loc - start_loc) |
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
2993 |
pad = "\n" + " " * start_loc |
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
2994 |
res = pad.join(res) |
1827f487a235
8868 Changes needed to handle package descriptions in the pkg Python API.
Brock Pytlik <bpytlik@sun.com>
parents:
1370
diff
changeset
|
2995 |
msg(desc_label, res) |
688
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2996 |
if pi.category_info_list: |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2997 |
verbose = len(pi.category_info_list) > 1 |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2998 |
msg(_(" Category:"), |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2999 |
pi.category_info_list[0].__str__(verbose)) |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
3000 |
if len(pi.category_info_list) > 1: |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
3001 |
for ci in pi.category_info_list[1:]: |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
3002 |
msg(" " * len(name_str), |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
3003 |
ci.__str__(verbose)) |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
3004 |
|
615
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
611
diff
changeset
|
3005 |
msg(_(" State:"), state) |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3006 |
|
1801
09b5c1ddef24
14832 pkg info traceback for renamed packages with no variant-applicable dependencies
Shawn Walker <srw@sun.com>
parents:
1795
diff
changeset
|
3007 |
# Renamed packages have dependencies, but the dependencies |
09b5c1ddef24
14832 pkg info traceback for renamed packages with no variant-applicable dependencies
Shawn Walker <srw@sun.com>
parents:
1795
diff
changeset
|
3008 |
# may not apply to this image's variants so won't be |
09b5c1ddef24
14832 pkg info traceback for renamed packages with no variant-applicable dependencies
Shawn Walker <srw@sun.com>
parents:
1795
diff
changeset
|
3009 |
# returned. |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
3010 |
if api.PackageInfo.RENAMED in pi.states: |
1801
09b5c1ddef24
14832 pkg info traceback for renamed packages with no variant-applicable dependencies
Shawn Walker <srw@sun.com>
parents:
1795
diff
changeset
|
3011 |
renamed_to = "" |
09b5c1ddef24
14832 pkg info traceback for renamed packages with no variant-applicable dependencies
Shawn Walker <srw@sun.com>
parents:
1795
diff
changeset
|
3012 |
if pi.dependencies: |
09b5c1ddef24
14832 pkg info traceback for renamed packages with no variant-applicable dependencies
Shawn Walker <srw@sun.com>
parents:
1795
diff
changeset
|
3013 |
renamed_to = pi.dependencies[0] |
09b5c1ddef24
14832 pkg info traceback for renamed packages with no variant-applicable dependencies
Shawn Walker <srw@sun.com>
parents:
1795
diff
changeset
|
3014 |
msg(_(" Renamed to:"), renamed_to) |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
3015 |
for dep in pi.dependencies[1:]: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
3016 |
msg(" " * len(name_str), dep) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
3017 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
3018 |
# XXX even more info on the publisher would be nice? |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
3019 |
msg(_(" Publisher:"), pi.publisher) |
2493
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
3020 |
hum_ver = pi.get_attr_values("pkg.human-version") |
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
3021 |
if hum_ver and hum_ver[0] != pi.version: |
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
3022 |
msg(_(" Version:"), "%s (%s)" % |
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
3023 |
(pi.version, hum_ver[0])) |
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
3024 |
else: |
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
3025 |
msg(_(" Version:"), pi.version) |
615
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
611
diff
changeset
|
3026 |
msg(_(" Build Release:"), pi.build_release) |
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
611
diff
changeset
|
3027 |
msg(_(" Branch:"), pi.branch) |
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
611
diff
changeset
|
3028 |
msg(_("Packaging Date:"), pi.packaging_date) |
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
611
diff
changeset
|
3029 |
msg(_(" Size:"), misc.bytes_to_str(pi.size)) |
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
611
diff
changeset
|
3030 |
msg(_(" FMRI:"), pi.fmri) |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3031 |
# XXX add license/copyright info here? |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3032 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3033 |
if notfound: |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
3034 |
if pis: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3035 |
err = EXIT_PARTIAL |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3036 |
logger.error("") |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3037 |
else: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3038 |
err = EXIT_OOPS |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3039 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3040 |
if info_local: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3041 |
logger.error(_("""\ |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
3042 |
pkg: info: no packages matching the following patterns you specified are |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3043 |
installed on the system. Try specifying -r to query remotely:""")) |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3044 |
elif info_remote: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3045 |
logger.error(_("""\ |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
3046 |
pkg: info: no packages matching the following patterns you specified were |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3047 |
found in the catalog. Try relaxing the patterns, refreshing, and/or |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3048 |
examining the catalogs:""")) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3049 |
logger.error("") |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3050 |
for p in notfound: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3051 |
logger.error(" %s" % p) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
3052 |
|
789
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
3053 |
if no_licenses: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3054 |
if len(no_licenses) == len(pis): |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3055 |
err = EXIT_OOPS |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3056 |
else: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3057 |
err = EXIT_PARTIAL |
789
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
3058 |
error(_("no license information could be found for the " |
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
3059 |
"following packages:")) |
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
3060 |
for pfmri in no_licenses: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3061 |
logger.error("\t%s" % pfmri) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3062 |
return err |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3063 |
|
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3064 |
def calc_widths(lines, attrs, widths=None): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3065 |
"""Given a set of lines and a set of attributes, calculate the minimum |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3066 |
width each column needs to hold its contents.""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3067 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3068 |
if not widths: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3069 |
widths = [ len(attr) - attr.find(".") - 1 for attr in attrs ] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3070 |
for l in lines: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3071 |
for i, a in enumerate(l): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3072 |
if len(str(a)) > widths[i]: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3073 |
widths[i] = len(str(a)) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3074 |
return widths |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3075 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3076 |
def calc_justs(attrs): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3077 |
"""Given a set of output attributes, find any attributes with known |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3078 |
justification directions and assign them.""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3079 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3080 |
def __chose_just(attr): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3081 |
if attr in ["action.name", "action.key", "action.raw", |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3082 |
"pkg.name", "pkg.fmri", "pkg.shortfmri", "pkg.publisher"]: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3083 |
return JUST_LEFT |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3084 |
return JUST_UNKNOWN |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3085 |
return [ __chose_just(attr) for attr in attrs ] |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3086 |
|
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3087 |
def produce_lines(actionlist, attrs, action_types=None, show_all=False, |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3088 |
remove_consec_dup_lines=False, last_res=None): |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3089 |
"""Produces a list of n tuples (where n is the length of attrs) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3090 |
containing the relevant information about the actions. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3091 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3092 |
The "actionlist" parameter is a list of tuples which contain the fmri |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3093 |
of the package that's the source of the action, the action, and the |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3094 |
publisher the action's package came from. If the actionlist was |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3095 |
generated by searching, the last two pieces, "match" and "match_type" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3096 |
contain information about why this action was selected. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3097 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3098 |
The "attrs" parameter is a list of the attributes of the action that |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3099 |
should be displayed. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3100 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3101 |
The "action_types" parameter may contain a list of the types of actions |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3102 |
that should be displayed. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3103 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3104 |
The "show_all" parameter determines whether an action that lacks one |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3105 |
or more of the desired attributes will be displayed or not. |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3106 |
|
1752
b62d86fb62c8
14515 client can traceback during search
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
3107 |
The "remove_consec_dup_lines" parameter determines whether consecutive |
b62d86fb62c8
14515 client can traceback during search
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
3108 |
duplicate lines should be removed from the results. |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3109 |
|
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3110 |
The "last_res" paramter is a seed to compare the first result against |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3111 |
for duplicate removal. |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3112 |
""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3113 |
|
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3114 |
# Assert that if last_res is set, we should be removing duplicate |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3115 |
# lines. |
1752
b62d86fb62c8
14515 client can traceback during search
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
3116 |
assert(remove_consec_dup_lines or not last_res) |
221
e1dbb27a23b5
52 catalog can leave inventory behind, making pkg(1) blind
Stephen Hahn <sch@Sun.COM>
parents:
219
diff
changeset
|
3117 |
lines = [] |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3118 |
if last_res: |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3119 |
lines.append(last_res) |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3120 |
for pfmri, action, pub, match, match_type in actionlist: |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3121 |
if action_types and action.name not in action_types: |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3122 |
continue |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3123 |
line = [] |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3124 |
for attr in attrs: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3125 |
if action and attr in action.attrs: |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3126 |
a = action.attrs[attr] |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3127 |
elif attr == "action.name": |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3128 |
a = action.name |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3129 |
elif attr == "action.key": |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3130 |
a = action.attrs[action.key_attr] |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3131 |
elif attr == "action.raw": |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3132 |
a = action |
2457
75e0d8b7d44f
18630 cannot publish an action where the payload hash contains an equals
Danek Duvall <danek.duvall@oracle.com>
parents:
2453
diff
changeset
|
3133 |
elif attr in ("hash", "action.hash"): |
1563
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3134 |
a = getattr(action, "hash", "") |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3135 |
elif attr == "pkg.name": |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3136 |
a = pfmri.get_name() |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3137 |
elif attr == "pkg.fmri": |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3138 |
a = pfmri |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3139 |
elif attr == "pkg.shortfmri": |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3140 |
a = pfmri.get_short_fmri() |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
3141 |
elif attr == "pkg.publisher": |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3142 |
a = pfmri.get_publisher() |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3143 |
if a is None: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3144 |
a = pub |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3145 |
if a is None: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3146 |
a = "" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3147 |
elif attr == "search.match": |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3148 |
a = match |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3149 |
elif attr == "search.match_type": |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3150 |
a = match_type |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3151 |
else: |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3152 |
a = "" |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3153 |
|
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3154 |
line.append(a) |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3155 |
|
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3156 |
if (line and [l for l in line if str(l) != ""] or show_all) \ |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3157 |
and (not remove_consec_dup_lines or not lines or |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3158 |
lines[-1] != line): |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3159 |
lines.append(line) |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3160 |
if last_res: |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3161 |
lines.pop(0) |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3162 |
return lines |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3163 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3164 |
def default_left(v): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3165 |
"""For a given justification "v", use the default of left justification |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3166 |
if "v" is JUST_UNKNOWN.""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3167 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3168 |
if v == JUST_UNKNOWN: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3169 |
return JUST_LEFT |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3170 |
return v |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3171 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3172 |
def print_headers(attrs, widths, justs): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3173 |
"""Print out the headers for the columns in the output. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3174 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3175 |
The "attrs" parameter provides the headings that should be used. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3176 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3177 |
The "widths" parameter provides the current estimates of the width |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3178 |
for each column. These may be changed due to the length of the headers. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3179 |
This function does modify the values contained in "widths" outside this |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3180 |
function. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3181 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3182 |
The "justs" parameter contains the justifications to use with each |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3183 |
header.""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3184 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3185 |
headers = [] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3186 |
for i, attr in enumerate(attrs): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3187 |
headers.append(str(attr.upper())) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3188 |
widths[i] = max(widths[i], len(attr)) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3189 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3190 |
# Now that we know all the widths, multiply them by the |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3191 |
# justification values to get positive or negative numbers to |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3192 |
# pass to the %-expander. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3193 |
widths = [ e[0] * default_left(e[1]) for e in zip(widths, justs) ] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3194 |
fmt = ("%%%ss " * len(widths)) % tuple(widths) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3195 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3196 |
msg((fmt % tuple(headers)).rstrip()) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3197 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3198 |
def guess_unknown(j, v): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3199 |
"""If the justificaton to use for a value is unknown, assume that if |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3200 |
it is an integer, the output should be right justified, otherwise it |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3201 |
should be left justified.""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3202 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3203 |
if j != JUST_UNKNOWN: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3204 |
return j |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3205 |
try: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3206 |
int(v) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3207 |
return JUST_RIGHT |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3208 |
except (ValueError, TypeError): |
1538
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3209 |
# attribute is non-numeric or is something like |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3210 |
# a list. |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3211 |
return JUST_LEFT |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3212 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3213 |
def create_output_format(display_headers, widths, justs, line): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3214 |
"""Produce a format string that can be used to display results. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3215 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3216 |
The "display_headers" parameter is whether headers have been displayed |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3217 |
or not. If they have not, then use a simple tab system. If they |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3218 |
have, use the information in the other parameters to control the |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3219 |
formatting of the line. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3220 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3221 |
The "widths" parameter contains the width to use for each column. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3222 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3223 |
The "justs" parameter contains the justifications to use for each |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3224 |
column. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3225 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3226 |
The "line" parameter contains the information that will be displayed |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3227 |
using the resulting format. It's needed so that a choice can be made |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3228 |
about columns with unknown justifications. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3229 |
""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3230 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3231 |
if display_headers: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3232 |
# Now that we know all the widths, multiply them by the |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3233 |
# justification values to get positive or negative numbers to |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3234 |
# pass to the %-expander. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3235 |
line_widths = [ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3236 |
w * guess_unknown(j, a) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3237 |
for w, j, a in zip(widths, justs, line) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3238 |
] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3239 |
fmt = ("%%%ss " * len(line_widths)) % tuple(line_widths) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3240 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3241 |
return fmt |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3242 |
fmt = "%s\t" * len(widths) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3243 |
fmt.rstrip("\t") |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3244 |
return fmt |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3245 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3246 |
def display_contents_results(actionlist, attrs, sort_attrs, action_types, |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3247 |
display_headers): |
1857
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3248 |
"""Print results of a "list" operation. Returns False if no output |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3249 |
was produced.""" |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3250 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3251 |
justs = calc_justs(attrs) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3252 |
lines = produce_lines(actionlist, attrs, action_types) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3253 |
widths = calc_widths(lines, attrs) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3254 |
|
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3255 |
sortidx = 0 |
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3256 |
for i, attr in enumerate(attrs): |
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3257 |
if attr == sort_attrs[0]: |
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3258 |
sortidx = i |
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3259 |
break |
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3260 |
|
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3261 |
# Sort numeric columns numerically. |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3262 |
if justs[sortidx] == JUST_RIGHT: |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3263 |
def key_extract(x): |
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3264 |
try: |
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3265 |
return int(x[sortidx]) |
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3266 |
except (ValueError, TypeError): |
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3267 |
return 0 |
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3268 |
else: |
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3269 |
key_extract = lambda x: x[sortidx] |
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3270 |
|
1857
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3271 |
printed_output = False |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
3272 |
for line in sorted(lines, key=key_extract): |
1857
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3273 |
text = (create_output_format(display_headers, widths, justs, |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3274 |
line) % tuple(line)).rstrip() |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3275 |
if not text: |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3276 |
continue |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3277 |
if not printed_output and display_headers: |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3278 |
print_headers(attrs, widths, justs) |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3279 |
printed_output = True |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3280 |
msg(text) |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3281 |
return printed_output |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3282 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3283 |
def check_attrs(attrs, cmd, reference=None, prefixes=None): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3284 |
"""For a set of output attributes ("attrs") passed to a command ("cmd"), |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3285 |
if the attribute lives in a known name space, check whether it is valid. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3286 |
""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3287 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3288 |
if reference is None: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3289 |
reference = valid_special_attrs |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3290 |
if prefixes is None: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3291 |
prefixes = valid_special_prefixes |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3292 |
for a in attrs: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3293 |
for p in prefixes: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3294 |
if a.startswith(p) and not a in reference: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3295 |
usage(_("Invalid attribute '%s'") % a, cmd) |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3296 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
3297 |
def list_contents(api_inst, args): |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3298 |
"""List package contents. |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3299 |
|
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3300 |
If no arguments are given, display for all locally installed packages. |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3301 |
With -H omit headers and use a tab-delimited format; with -o select |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3302 |
attributes to display; with -s, specify attributes to sort on; with -t, |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3303 |
specify which action types to list.""" |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3304 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3305 |
opts, pargs = getopt.getopt(args, "Ha:g:o:s:t:mfr") |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3306 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3307 |
subcommand = "contents" |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3308 |
display_headers = True |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3309 |
display_raw = False |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3310 |
origins = set() |
1857
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3311 |
output_fields = False |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
3312 |
remote = False |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
3313 |
local = False |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3314 |
attrs = [] |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3315 |
sort_attrs = [] |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3316 |
action_types = [] |
1563
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3317 |
attr_match = {} |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3318 |
for opt, arg in opts: |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3319 |
if opt == "-H": |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3320 |
display_headers = False |
1563
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3321 |
elif opt == "-a": |
1687
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
3322 |
try: |
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
3323 |
attr, match = arg.split("=", 1) |
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
3324 |
except ValueError: |
1806
e835bd77038f
14625 incorrect error message for 'contents -a foo'
Tim Foster <tim.foster@sun.com>
parents:
1801
diff
changeset
|
3325 |
usage(_("-a takes an argument of the form " |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3326 |
"<attribute>=<pattern>"), cmd=subcommand) |
1563
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3327 |
attr_match.setdefault(attr, []).append(match) |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3328 |
elif opt == "-g": |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3329 |
origins.add(misc.parse_uri(arg, cwd=orig_cwd)) |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3330 |
elif opt == "-o": |
1857
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3331 |
output_fields = True |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3332 |
attrs.extend(arg.split(",")) |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3333 |
elif opt == "-s": |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3334 |
sort_attrs.append(arg) |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3335 |
elif opt == "-t": |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3336 |
action_types.extend(arg.split(",")) |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
3337 |
elif opt == "-r": |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
3338 |
remote = True |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3339 |
elif opt == "-m": |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3340 |
display_raw = True |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3341 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3342 |
if origins: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3343 |
remote = True |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3344 |
elif not remote: |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
3345 |
local = True |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
3346 |
|
442
01fb28d438b3
2418 'pkg version', 'pkg image-update' should error on additional arguments
Dan Price <dp@eng.sun.com>
parents:
432
diff
changeset
|
3347 |
if remote and not pargs: |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
3348 |
usage(_("contents: must request remote contents for specific " |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3349 |
"packages"), cmd=subcommand) |
442
01fb28d438b3
2418 'pkg version', 'pkg image-update' should error on additional arguments
Dan Price <dp@eng.sun.com>
parents:
432
diff
changeset
|
3350 |
|
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3351 |
if display_raw: |
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
306
diff
changeset
|
3352 |
display_headers = False |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3353 |
attrs = ["action.raw"] |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3354 |
|
391
23ec5f7ee0d3
2245 client - pylint cleanup needed
Shawn Walker <swalker@opensolaris.org>
parents:
388
diff
changeset
|
3355 |
invalid = set(("-H", "-o", "-t")). \ |
23ec5f7ee0d3
2245 client - pylint cleanup needed
Shawn Walker <swalker@opensolaris.org>
parents:
388
diff
changeset
|
3356 |
intersection(set([x[0] for x in opts])) |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3357 |
|
391
23ec5f7ee0d3
2245 client - pylint cleanup needed
Shawn Walker <swalker@opensolaris.org>
parents:
388
diff
changeset
|
3358 |
if len(invalid) > 0: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
3359 |
usage(_("-m and %s may not be specified at the same " |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3360 |
"time") % invalid.pop(), cmd=subcommand) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3361 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3362 |
check_attrs(attrs, subcommand) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3363 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3364 |
api_inst.log_operation_start(subcommand) |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
3365 |
if local: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3366 |
pkg_list = api.ImageInterface.LIST_INSTALLED |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
3367 |
elif remote: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3368 |
pkg_list = api.ImageInterface.LIST_NEWEST |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3369 |
|
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3370 |
# |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3371 |
# If the user specifies no specific attrs, and no specific |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3372 |
# sort order, then we fill in some defaults. |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3373 |
# |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3374 |
if not attrs: |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3375 |
# XXX Possibly have multiple exclusive attributes per column? |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3376 |
# If listing dependencies and files, you could have a path/fmri |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3377 |
# column which would list paths for files and fmris for |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3378 |
# dependencies. |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3379 |
attrs = ["path"] |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3380 |
|
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3381 |
if not sort_attrs: |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3382 |
# XXX reverse sorting |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3383 |
# Most likely want to sort by path, so don't force people to |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3384 |
# make it explicit |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3385 |
if "path" in attrs: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3386 |
sort_attrs = ["path"] |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3387 |
else: |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3388 |
sort_attrs = attrs[:1] |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3389 |
|
969
da90392d2f80
6672 "pkg contents -m" filters out other variants
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
3390 |
# if we want a raw display (contents -m), disable the automatic |
da90392d2f80
6672 "pkg contents -m" filters out other variants
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
3391 |
# variant filtering that normally limits working set. |
da90392d2f80
6672 "pkg contents -m" filters out other variants
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
3392 |
if display_raw: |
da90392d2f80
6672 "pkg contents -m" filters out other variants
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
3393 |
excludes = EmptyI |
da90392d2f80
6672 "pkg contents -m" filters out other variants
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
3394 |
else: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3395 |
excludes = api_inst.excludes |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3396 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3397 |
def mmatches(action): |
1563
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3398 |
"""Given an action, return True if any of its attributes' values |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3399 |
matches the pattern for the same attribute in the attr_match |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3400 |
dictionary, and False otherwise.""" |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3401 |
|
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3402 |
# If no matches have been specified, all actions match |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3403 |
if not attr_match: |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3404 |
return True |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3405 |
|
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3406 |
matchset = set(attr_match.keys()) |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3407 |
attrset = set(action.attrs.keys()) |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3408 |
|
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3409 |
iset = attrset.intersection(matchset) |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3410 |
|
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3411 |
# Iterate over the set of attributes common to the action and |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3412 |
# the match specification. If the values match the pattern in |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3413 |
# the specification, then return True (implementing an OR across |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3414 |
# multiple possible matches). |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3415 |
for attr in iset: |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3416 |
for match in attr_match[attr]: |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3417 |
for attrval in action.attrlist(attr): |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3418 |
if fnmatch.fnmatch(attrval, match): |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3419 |
return True |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3420 |
return False |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3421 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3422 |
# Now get the matching list of packages and display it. |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3423 |
processed = False |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3424 |
notfound = EmptyI |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3425 |
try: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3426 |
res = api_inst.get_pkg_list(pkg_list, patterns=pargs, |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3427 |
raise_unmatched=True, return_fmris=True, variants=True, |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3428 |
repos=origins) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3429 |
manifests = [] |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3430 |
|
2493
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
3431 |
for pfmri, summ, cats, states, pattrs in res: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3432 |
manifests.append(api_inst.get_manifest(pfmri, |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3433 |
all_variants=display_raw, repos=origins)) |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3434 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3435 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3436 |
return EXIT_OOPS |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3437 |
except api_errors.InvalidPackageErrors, e: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3438 |
error(str(e), cmd=subcommand) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3439 |
api_inst.log_operation_end( |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3440 |
result=history.RESULT_FAILED_UNKNOWN) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3441 |
return EXIT_OOPS |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3442 |
except api_errors.InventoryException, e: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3443 |
if e.illegal: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3444 |
for i in e.illegal: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3445 |
error(i) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3446 |
api_inst.log_operation_end( |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3447 |
result=history.RESULT_FAILED_BAD_REQUEST) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3448 |
return EXIT_OOPS |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3449 |
notfound = e.notfound |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3450 |
else: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3451 |
if local and not manifests and not pargs: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3452 |
error(_("no packages installed"), cmd=subcommand) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3453 |
api_inst.log_operation_end( |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3454 |
result=history.RESULT_NOTHING_TO_DO) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3455 |
return EXIT_OOPS |
969
da90392d2f80
6672 "pkg contents -m" filters out other variants
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
3456 |
|
1234
d9885dff5d16
4705 UnboundLocalError in depend action
Shawn Walker <srw@sun.com>
parents:
1218
diff
changeset
|
3457 |
actionlist = [ |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3458 |
(m.fmri, a, None, None, None) |
969
da90392d2f80
6672 "pkg contents -m" filters out other variants
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
3459 |
for m in manifests |
1234
d9885dff5d16
4705 UnboundLocalError in depend action
Shawn Walker <srw@sun.com>
parents:
1218
diff
changeset
|
3460 |
for a in m.gen_actions(excludes) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3461 |
if mmatches(a) |
969
da90392d2f80
6672 "pkg contents -m" filters out other variants
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
3462 |
] |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3463 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3464 |
rval = EXIT_OK |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3465 |
if attr_match and manifests and not actionlist: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3466 |
rval = EXIT_OOPS |
1563
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3467 |
logger.error(_("""\ |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3468 |
pkg: contents: no matching actions found in the listed packages""")) |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3469 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3470 |
if manifests and rval == EXIT_OK: |
1857
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3471 |
displayed_results = display_contents_results(actionlist, attrs, |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3472 |
sort_attrs, action_types, display_headers) |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3473 |
|
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3474 |
if not displayed_results: |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3475 |
if output_fields: |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3476 |
error(gettext.ngettext("""\ |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3477 |
This package contains no actions with the fields specified using the -o |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3478 |
option. Please specify other fields, or use the -m option to show the raw |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3479 |
package manifests.""", """\ |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3480 |
These packages contain no actions with the fields specified using the -o |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3481 |
option. Please specify other fields, or use the -m option to show the raw |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3482 |
package manifests.""", len(pargs))) |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3483 |
else: |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3484 |
error(gettext.ngettext("""\ |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3485 |
This package delivers no filesystem content, but may contain metadata. Use |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3486 |
the -o option to specify fields other than 'path', or use the -m option to show |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3487 |
the raw package manifests.""", """\ |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3488 |
These packages deliver no filesystem content, but may contain metadata. Use |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3489 |
the -o option to specify fields other than 'path', or use the -m option to show |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3490 |
the raw package manifests.""", len(pargs))) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3491 |
|
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3492 |
if notfound: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3493 |
rval = EXIT_OOPS |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3494 |
if manifests: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3495 |
logger.error("") |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3496 |
if local: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3497 |
logger.error(_("""\ |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
3498 |
pkg: contents: no packages matching the following patterns you specified are |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3499 |
installed on the system. Try specifying -r to query remotely:""")) |
442
01fb28d438b3
2418 'pkg version', 'pkg image-update' should error on additional arguments
Dan Price <dp@eng.sun.com>
parents:
432
diff
changeset
|
3500 |
elif remote: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3501 |
logger.error(_("""\ |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
3502 |
pkg: contents: no packages matching the following patterns you specified were |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3503 |
found in the catalog. Try relaxing the patterns, refreshing, and/or |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3504 |
examining the catalogs:""")) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3505 |
logger.error("") |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3506 |
for p in notfound: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3507 |
logger.error(" %s" % p) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3508 |
api_inst.log_operation_end( |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3509 |
result=history.RESULT_NOTHING_TO_DO) |
556
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
551
diff
changeset
|
3510 |
else: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3511 |
api_inst.log_operation_end(result=history.RESULT_SUCCEEDED) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3512 |
return rval |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3513 |
|
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3514 |
|
1538
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3515 |
def display_catalog_failures(cre, ignore_perms_failure=False): |
537
3dc9fc9b5fee
1540 changes to authorities should include refresh
Brock Pytlik <bpytlik@sun.com>
parents:
526
diff
changeset
|
3516 |
total = cre.total |
3dc9fc9b5fee
1540 changes to authorities should include refresh
Brock Pytlik <bpytlik@sun.com>
parents:
526
diff
changeset
|
3517 |
succeeded = cre.succeeded |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
3518 |
|
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
3519 |
txt = _("pkg: %s/%s catalogs successfully updated:") % (succeeded, |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
3520 |
total) |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
3521 |
if cre.failed: |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
3522 |
# This ensures that the text gets printed before the errors. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3523 |
logger.error(txt) |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
3524 |
else: |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
3525 |
msg(txt) |
259
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3526 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
3527 |
for pub, err in cre.failed: |
1538
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3528 |
if ignore_perms_failure and \ |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3529 |
not isinstance(err, api_errors.PermissionsException): |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3530 |
# If any errors other than a permissions exception are |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3531 |
# found, then don't ignore them. |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3532 |
ignore_perms_failure = False |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3533 |
break |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3534 |
|
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3535 |
if cre.failed and ignore_perms_failure: |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3536 |
# Consider those that failed to have succeeded and add them |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3537 |
# to the actual successful total. |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3538 |
return succeeded + len(cre.failed) |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3539 |
|
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3540 |
for pub, err in cre.failed: |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
3541 |
logger.error(" ") |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
3542 |
logger.error(str(err)) |
259
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3543 |
|
1603
84bd53597209
13019 DeprecationWarnings seen after python 2.6 migration
Dan Price <dp@eng.sun.com>
parents:
1570
diff
changeset
|
3544 |
if cre.errmessage: |
84bd53597209
13019 DeprecationWarnings seen after python 2.6 migration
Dan Price <dp@eng.sun.com>
parents:
1570
diff
changeset
|
3545 |
logger.error(cre.errmessage) |
789
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
3546 |
|
259
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3547 |
return succeeded |
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3548 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3549 |
def __refresh(api_inst, pubs, full_refresh=False): |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3550 |
"""Private helper method for refreshing publisher data.""" |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3551 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3552 |
try: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3553 |
# The user explicitly requested this refresh, so set the |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3554 |
# refresh to occur immediately. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3555 |
api_inst.refresh(full_refresh=full_refresh, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3556 |
immediate=True, pubs=pubs) |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3557 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3558 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3559 |
return EXIT_OOPS |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3560 |
except api_errors.PublisherError, e: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3561 |
error(e) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3562 |
error(_("'pkg publisher' will show a list of publishers.")) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3563 |
return EXIT_OOPS |
1779
b80275b45b18
14176 copytree callers must catch shutil.Error and not traceback
Shawn Walker <srw@sun.com>
parents:
1775
diff
changeset
|
3564 |
except (api_errors.UnknownErrors, api_errors.PermissionsException), e: |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3565 |
# Prepend a newline because otherwise the exception will |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3566 |
# be printed on the same line as the spinner. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3567 |
error("\n" + str(e)) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3568 |
return EXIT_OOPS |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3569 |
except api_errors.CatalogRefreshException, e: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3570 |
if display_catalog_failures(e) == 0: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3571 |
return EXIT_OOPS |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3572 |
return EXIT_PARTIAL |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3573 |
return EXIT_OK |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3574 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
3575 |
def publisher_refresh(api_inst, args): |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
3576 |
"""Update metadata for the image's publishers.""" |
259
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3577 |
|
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3578 |
# XXX will need to show available content series for each package |
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3579 |
full_refresh = False |
523
69a22d5d368c
3387 pkg refresh --full gives a syntax error
Brock Pytlik <bpytlik@sun.com>
parents:
518
diff
changeset
|
3580 |
opts, pargs = getopt.getopt(args, "", ["full"]) |
327
6c6bd07efe8d
1031 authority prefix needs validation
johansen <johansen@sun.com>
parents:
326
diff
changeset
|
3581 |
for opt, arg in opts: |
6c6bd07efe8d
1031 authority prefix needs validation
johansen <johansen@sun.com>
parents:
326
diff
changeset
|
3582 |
if opt == "--full": |
6c6bd07efe8d
1031 authority prefix needs validation
johansen <johansen@sun.com>
parents:
326
diff
changeset
|
3583 |
full_refresh = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3584 |
return __refresh(api_inst, pargs, full_refresh=full_refresh) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3585 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3586 |
def _get_ssl_cert_key(root, is_zone, ssl_cert, ssl_key): |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3587 |
if ssl_cert is not None or ssl_key is not None: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3588 |
# In the case of zones, the ssl cert given is assumed to |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3589 |
# be relative to the root of the image, not truly absolute. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3590 |
if is_zone: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3591 |
if ssl_cert is not None: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3592 |
ssl_cert = os.path.abspath( |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3593 |
root + os.sep + ssl_cert) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3594 |
if ssl_key is not None: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3595 |
ssl_key = os.path.abspath( |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3596 |
root + os.sep + ssl_key) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3597 |
elif orig_cwd: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3598 |
if ssl_cert and not os.path.isabs(ssl_cert): |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3599 |
ssl_cert = os.path.normpath(os.path.join( |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3600 |
orig_cwd, ssl_cert)) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3601 |
if ssl_key and not os.path.isabs(ssl_key): |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3602 |
ssl_key = os.path.normpath(os.path.join( |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3603 |
orig_cwd, ssl_key)) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3604 |
return ssl_cert, ssl_key |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3605 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3606 |
def _set_pub_error_wrap(func, pfx, raise_errors, *args, **kwargs): |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3607 |
"""Helper function to wrap set-publisher private methods. Returns |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3608 |
a tuple of (return value, message). Callers should check the return |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3609 |
value for errors.""" |
259
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3610 |
|
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3611 |
try: |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3612 |
return func(*args, **kwargs) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3613 |
except api_errors.CatalogRefreshException, e: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3614 |
for entry in raise_errors: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3615 |
if isinstance(e, entry): |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3616 |
raise |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
3617 |
txt = _("Could not refresh the catalog for %s\n") % \ |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3618 |
pfx |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
3619 |
for pub, err in e.failed: |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
3620 |
txt += " \n%s" % err |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
3621 |
return EXIT_OOPS, txt |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3622 |
except api_errors.InvalidDepotResponseException, e: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3623 |
for entry in raise_errors: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3624 |
if isinstance(e, entry): |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3625 |
raise |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3626 |
if pfx: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3627 |
return EXIT_OOPS, _("The origin URIs for '%(pubname)s' " |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
3628 |
"do not appear to point to a valid pkg repository." |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
3629 |
"\nPlease verify the repository's location and the " |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
3630 |
"client's network configuration." |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3631 |
"\nAdditional details:\n\n%(details)s") % { |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3632 |
"pubname": pfx, "details": str(e) } |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3633 |
return EXIT_OOPS, _("The specified URI does not appear to " |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
3634 |
"point to a valid pkg repository.\nPlease check the URI " |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3635 |
"and the client's network configuration." |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3636 |
"\nAdditional details:\n\n%s") % str(e) |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3637 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3638 |
for entry in raise_errors: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3639 |
if isinstance(e, entry): |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3640 |
raise |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3641 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3642 |
return EXIT_OOPS, "" |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3643 |
except api_errors.ApiException, e: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3644 |
for entry in raise_errors: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3645 |
if isinstance(e, entry): |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3646 |
raise |
790
e2cf47b23e7a
5481 pkg refresh traceback without permissions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
789
diff
changeset
|
3647 |
# Prepend a newline because otherwise the exception will |
e2cf47b23e7a
5481 pkg refresh traceback without permissions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
789
diff
changeset
|
3648 |
# be printed on the same line as the spinner. |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3649 |
return EXIT_OOPS, ("\n" + str(e)) |
259
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3650 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
3651 |
def publisher_set(api_inst, args): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
3652 |
"""pkg set-publisher [-Ped] [-k ssl_key] [-c ssl_cert] [--reset-uuid] |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3653 |
[-g|--add-origin origin to add] [-G|--remove-origin origin to |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3654 |
remove] [-m|--add-mirror mirror to add] [-M|--remove-mirror mirror |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3655 |
to remove] [-p repo_uri] [--enable] [--disable] [--no-refresh] |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3656 |
[--sticky] [--non-sticky ] [--search-before=publisher] |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3657 |
[--search-after=publisher] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3658 |
[--approve-ca-cert path to CA] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3659 |
[--revoke-ca-cert hash of CA to remove] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3660 |
[--unset-ca-cert hash of CA to unset] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3661 |
[--set-property name of property=value] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3662 |
[--add-property-value name of property=value to add] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3663 |
[--remove-property-value name of property=value to remove] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3664 |
[--unset-property name of property to delete] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3665 |
[publisher] """ |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3666 |
|
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3667 |
cmd_name = "set-publisher" |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
3668 |
|
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
3669 |
ssl_key = None |
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
3670 |
ssl_cert = None |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3671 |
origin_uri = None |
551 | 3672 |
reset_uuid = False |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3673 |
add_mirrors = set() |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3674 |
remove_mirrors = set() |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3675 |
add_origins = set() |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3676 |
remove_origins = set() |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3677 |
refresh_allowed = True |
786
a400f8c4d1c0
2340 support authority enable and disable
Tom Mueller <Tom.Mueller@sun.com>
parents:
770
diff
changeset
|
3678 |
disable = None |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
3679 |
sticky = None |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
3680 |
search_before = None |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
3681 |
search_after = None |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3682 |
search_first = False |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3683 |
repo_uri = None |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3684 |
|
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3685 |
approved_ca_certs = [] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3686 |
revoked_ca_certs = [] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3687 |
unset_ca_certs = [] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3688 |
set_props = {} |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3689 |
add_prop_values = {} |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3690 |
remove_prop_values = {} |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3691 |
unset_props = set() |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3692 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3693 |
opts, pargs = getopt.getopt(args, "Pedk:c:O:G:g:M:m:p:", |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3694 |
["add-mirror=", "remove-mirror=", "add-origin=", "remove-origin=", |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3695 |
"no-refresh", "reset-uuid", "enable", "disable", "sticky", |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3696 |
"non-sticky", "search-after=", "search-before=", "search-first", |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3697 |
"approve-ca-cert=", "revoke-ca-cert=", "unset-ca-cert=", |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3698 |
"set-property=", "add-property-value=", "remove-property-value=", |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3699 |
"unset-property="]) |
461
37cf3ac75e37
1018 actions with payloads should include all sizes and hashes
johansen <johansen@sun.com>
parents:
443
diff
changeset
|
3700 |
|
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
3701 |
for opt, arg in opts: |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3702 |
if opt == "-c": |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3703 |
ssl_cert = arg |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3704 |
elif opt == "-d" or opt == "--disable": |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3705 |
disable = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3706 |
elif opt == "-e" or opt == "--enable": |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3707 |
disable = False |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3708 |
elif opt == "-g" or opt == "--add-origin": |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3709 |
add_origins.add(misc.parse_uri(arg, cwd=orig_cwd)) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3710 |
elif opt == "-G" or opt == "--remove-origin": |
2253
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3711 |
if arg == "*": |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3712 |
# Allow wildcard to support an easy, scriptable |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3713 |
# way of removing all existing entries. |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3714 |
remove_origins.add("*") |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3715 |
else: |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3716 |
remove_origins.add(misc.parse_uri(arg, |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3717 |
cwd=orig_cwd)) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3718 |
elif opt == "-k": |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
3719 |
ssl_key = arg |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3720 |
elif opt == "-O": |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3721 |
origin_uri = arg |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3722 |
elif opt == "-m" or opt == "--add-mirror": |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3723 |
add_mirrors.add(misc.parse_uri(arg, cwd=orig_cwd)) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3724 |
elif opt == "-M" or opt == "--remove-mirror": |
2253
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3725 |
if arg == "*": |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3726 |
# Allow wildcard to support an easy, scriptable |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3727 |
# way of removing all existing entries. |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3728 |
remove_mirrors.add("*") |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3729 |
else: |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3730 |
remove_mirrors.add(misc.parse_uri(arg, |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3731 |
cwd=orig_cwd)) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3732 |
elif opt == "-p": |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3733 |
repo_uri = misc.parse_uri(arg, cwd=orig_cwd) |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3734 |
elif opt in ("-P", "--search-first"): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3735 |
search_first = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3736 |
elif opt == "--reset-uuid": |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3737 |
reset_uuid = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3738 |
elif opt == "--no-refresh": |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3739 |
refresh_allowed = False |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3740 |
elif opt == "--sticky": |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
3741 |
sticky = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3742 |
elif opt == "--non-sticky": |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
3743 |
sticky = False |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3744 |
elif opt == "--search-before": |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
3745 |
search_before = arg |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3746 |
elif opt == "--search-after": |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
3747 |
search_after = arg |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3748 |
elif opt == "--approve-ca-cert": |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3749 |
approved_ca_certs.append(arg) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3750 |
elif opt == "--revoke-ca-cert": |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3751 |
revoked_ca_certs.append(arg) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3752 |
elif opt == "--unset-ca-cert": |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3753 |
unset_ca_certs.append(arg) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3754 |
elif opt == "--set-property": |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3755 |
t = arg.split("=", 1) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3756 |
if len(t) < 2: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3757 |
usage(_("properties to be set must be of the " |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3758 |
"form '<name>=<value>'. This is what was " |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3759 |
"given: %s") % arg, cmd=cmd_name) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3760 |
if t[0] in set_props: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3761 |
usage(_("a property may only be set once in a " |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3762 |
"command. %s was set twice") % t[0], |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3763 |
cmd=cmd_name) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3764 |
set_props[t[0]] = t[1] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3765 |
elif opt == "--add-property-value": |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3766 |
t = arg.split("=", 1) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3767 |
if len(t) < 2: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3768 |
usage(_("property values to be added must be " |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3769 |
"of the form '<name>=<value>'. This is " |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3770 |
"what was given: %s") % arg, cmd=cmd_name) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3771 |
add_prop_values.setdefault(t[0], []) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3772 |
add_prop_values[t[0]].append(t[1]) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3773 |
elif opt == "--remove-property-value": |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3774 |
t = arg.split("=", 1) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3775 |
if len(t) < 2: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3776 |
usage(_("property values to be removed must be " |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3777 |
"of the form '<name>=<value>'. This is " |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3778 |
"what was given: %s") % arg, cmd=cmd_name) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3779 |
remove_prop_values.setdefault(t[0], []) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3780 |
remove_prop_values[t[0]].append(t[1]) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3781 |
elif opt == "--unset-property": |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3782 |
unset_props.add(arg) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3783 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3784 |
name = None |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3785 |
if len(pargs) == 0 and not repo_uri: |
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
3786 |
usage(_("requires a publisher name"), cmd="set-publisher") |
727
53a22eec05e5
5098 pkg set-authority misleading error message when no authority name given
Danek Duvall <danek.duvall@sun.com>
parents:
717
diff
changeset
|
3787 |
elif len(pargs) > 1: |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3788 |
usage(_("only one publisher name may be specified"), |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3789 |
cmd="set-publisher") |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3790 |
elif pargs: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3791 |
name = pargs[0] |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
3792 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3793 |
if origin_uri and (add_origins or remove_origins): |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3794 |
usage(_("the -O and -g, --add-origin, -G, or --remove-origin " |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3795 |
"options may not be combined"), cmd="set-publisher") |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3796 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3797 |
if (search_before and search_after) or \ |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3798 |
(search_before and search_first) or (search_after and search_first): |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3799 |
usage(_("search-before, search-after, and search-first (-P) " |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3800 |
"may not be combined"), cmd="set-publisher") |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
3801 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3802 |
if repo_uri and (add_origins or add_mirrors or remove_origins or |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3803 |
remove_mirrors or disable != None or not refresh_allowed or |
2100
6a366b063036
17144 Unix socket support is defunct
johansen <johansen@opensolaris.org>
parents:
2097
diff
changeset
|
3804 |
reset_uuid): |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3805 |
usage(_("the -p option may not be combined with the -g, " |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3806 |
"--add-origin, -G, --remove-origin, -m, --add-mirror, " |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3807 |
"-M, --remove-mirror, --enable, --disable, --no-refresh, " |
2100
6a366b063036
17144 Unix socket support is defunct
johansen <johansen@opensolaris.org>
parents:
2097
diff
changeset
|
3808 |
"or --reset-uuid options"), cmd="set-publisher") |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3809 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3810 |
# Get sanitized SSL Cert/Key input values. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3811 |
ssl_cert, ssl_key = _get_ssl_cert_key(api_inst.root, api_inst.is_zone, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3812 |
ssl_cert, ssl_key) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3813 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3814 |
if not repo_uri: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3815 |
# Normal case. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3816 |
ret = _set_pub_error_wrap(_add_update_pub, name, [], |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3817 |
api_inst, name, disable=disable, sticky=sticky, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3818 |
origin_uri=origin_uri, add_mirrors=add_mirrors, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3819 |
remove_mirrors=remove_mirrors, add_origins=add_origins, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3820 |
remove_origins=remove_origins, ssl_cert=ssl_cert, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3821 |
ssl_key=ssl_key, search_before=search_before, |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3822 |
search_after=search_after, search_first=search_first, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3823 |
reset_uuid=reset_uuid, refresh_allowed=refresh_allowed, |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3824 |
set_props=set_props, add_prop_values=add_prop_values, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3825 |
remove_prop_values=remove_prop_values, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3826 |
unset_props=unset_props, approved_cas=approved_ca_certs, |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
3827 |
revoked_cas=revoked_ca_certs, unset_cas=unset_ca_certs) |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3828 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3829 |
rval, rmsg = ret |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3830 |
if rmsg: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3831 |
error(rmsg, cmd="set-publisher") |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3832 |
return rval |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3833 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3834 |
pubs = None |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3835 |
# Automatic configuration via -p case. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3836 |
def get_pubs(): |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3837 |
repo = publisher.RepositoryURI(repo_uri, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3838 |
ssl_cert=ssl_cert, ssl_key=ssl_key) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3839 |
return EXIT_OK, api_inst.get_publisherdata(repo=repo) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3840 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3841 |
ret = None |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
3842 |
try: |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3843 |
ret = _set_pub_error_wrap(get_pubs, name, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3844 |
[api_errors.UnsupportedRepositoryOperation]) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3845 |
except api_errors.UnsupportedRepositoryOperation, e: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3846 |
# Fail if the operation can't be done automatically. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3847 |
error(str(e), cmd="set-publisher") |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3848 |
logger.error(_(""" |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3849 |
To add a publisher using this repository, execute the following command as a |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3850 |
privileged user: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3851 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3852 |
pkg set-publisher -g %s <publisher> |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3853 |
""") % repo_uri) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3854 |
return EXIT_OOPS |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3855 |
else: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3856 |
rval, rmsg = ret |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3857 |
if rval != EXIT_OK: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3858 |
error(rmsg, cmd="set-publisher") |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3859 |
return rval |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3860 |
pubs = rmsg |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3861 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3862 |
# For the automatic publisher configuration case, update or add |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3863 |
# publishers based on whether they exist and if they match any |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3864 |
# specified publisher prefix. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3865 |
if not pubs: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3866 |
error(_(""" |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3867 |
The specified repository did not contain any publisher configuration |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3868 |
information. This is likely the result of a repository configuration |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3869 |
error. Please contact the repository administrator for further |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3870 |
assistance.""")) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3871 |
return EXIT_OOPS |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3872 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3873 |
if name and name not in pubs: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3874 |
known = [p.prefix for p in pubs] |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3875 |
unknown = [name] |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3876 |
e = api_errors.UnknownRepositoryPublishers(known=known, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3877 |
unknown=unknown, location=repo_uri) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3878 |
error(str(e)) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
3879 |
return EXIT_OOPS |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3880 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3881 |
added = [] |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3882 |
updated = [] |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3883 |
failed = [] |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3884 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3885 |
for src_pub in sorted(pubs): |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3886 |
prefix = src_pub.prefix |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3887 |
if name and prefix != name: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3888 |
# User didn't request this one. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3889 |
continue |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3890 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3891 |
src_repo = src_pub.repository |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3892 |
if not api_inst.has_publisher(prefix=prefix): |
1795
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3893 |
add_origins = [] |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3894 |
if not src_repo or not src_repo.origins: |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3895 |
# If the repository publisher configuration |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3896 |
# didn't include configuration information |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3897 |
# for the publisher's repositories, assume |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3898 |
# that the origin for the new publisher |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3899 |
# matches the URI provided. |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3900 |
add_origins.append(repo_uri) |
2407
a831f1491c86
1769 pkg(5) doesn't check for disk space
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2382
diff
changeset
|
3901 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3902 |
rval, rmsg = _set_pub_error_wrap(_add_update_pub, name, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3903 |
[], api_inst, prefix, pub=src_pub, |
1795
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3904 |
add_origins=add_origins, ssl_cert=ssl_cert, |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3905 |
ssl_key=ssl_key, sticky=sticky, |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3906 |
search_after=search_after, |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3907 |
search_before=search_before, |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3908 |
search_first=search_first, |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3909 |
set_props=set_props, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3910 |
add_prop_values=add_prop_values, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3911 |
remove_prop_values=remove_prop_values, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3912 |
unset_props=unset_props) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3913 |
if rval == EXIT_OK: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3914 |
added.append(prefix) |
2280
678bac00776f
17981 pkg set-publisher -P with -p should put new publishers first in search order
Shawn Walker <shawn.walker@oracle.com>
parents:
2269
diff
changeset
|
3915 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3916 |
# When multiple publishers result from a single -p |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3917 |
# operation, this ensures that the new publishers are |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3918 |
# ordered correctly. |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3919 |
search_first = False |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3920 |
search_after = prefix |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3921 |
else: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3922 |
# The update case is special and requires some |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3923 |
# finesse. In particular, the update should |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3924 |
# only happen if the repo_uri specified is |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3925 |
# already known to the existing publisher. This |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3926 |
# is just a sanity check to ensure that random |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3927 |
# repositories can't attempt to hijack other |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3928 |
# publishers. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3929 |
dest_pub = api_inst.get_publisher(prefix=prefix, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3930 |
duplicate=True) |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3931 |
dest_repo = dest_pub.repository |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3932 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3933 |
if dest_repo.origins and \ |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3934 |
not dest_repo.has_origin(repo_uri): |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3935 |
failed.append((prefix, _("""\ |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3936 |
The specified repository location is not a known source of publisher |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3937 |
configuration updates for '%s'. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3938 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3939 |
This new repository location must be added as an origin to the publisher |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3940 |
to accept configuration updates from this repository.""") % prefix)) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3941 |
continue |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3942 |
|
1795
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3943 |
if not src_repo: |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3944 |
# The repository doesn't have to provide origin |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3945 |
# information for publishers. If it doesn't, |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3946 |
# the origin of every publisher returned is |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3947 |
# assumed to match the URI that the user |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3948 |
# provided. Since this is an update case, |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3949 |
# nothing special needs to be done. |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3950 |
if not dest_repo.origins: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3951 |
add_origins = [repo_uri] |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3952 |
else: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3953 |
add_origins = [] |
1795
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3954 |
add_mirrors = [] |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3955 |
else: |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3956 |
# Avoid duplicates by adding only those mirrors |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3957 |
# or origins not already known. |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3958 |
add_mirrors = [ |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3959 |
u.uri |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3960 |
for u in src_repo.mirrors |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3961 |
if u.uri not in dest_repo.mirrors |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3962 |
] |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3963 |
add_origins = [ |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3964 |
u.uri |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3965 |
for u in src_repo.origins |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3966 |
if u.uri not in dest_repo.origins |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3967 |
] |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3968 |
|
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3969 |
# Special bits to update; for these, take the |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3970 |
# new value as-is (don't attempt to merge). |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3971 |
for prop in ("collection_type", "description", |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3972 |
"legal_uris", "name", "refresh_seconds", |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3973 |
"registration_uri", "related_uris"): |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3974 |
src_val = getattr(src_repo, prop) |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3975 |
if src_val is not None: |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3976 |
setattr(dest_repo, prop, |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3977 |
src_val) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3978 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3979 |
# If an alias doesn't already exist, update it too. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3980 |
if src_pub.alias and not dest_pub.alias: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3981 |
dest_pub.alias = src_pub.alias |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3982 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3983 |
rval, rmsg = _set_pub_error_wrap(_add_update_pub, name, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3984 |
[], api_inst, prefix, pub=dest_pub, |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3985 |
add_mirrors=add_mirrors, add_origins=add_origins, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3986 |
set_props=set_props, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3987 |
add_prop_values=add_prop_values, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3988 |
remove_prop_values=remove_prop_values, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3989 |
unset_props=unset_props) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3990 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3991 |
if rval == EXIT_OK: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3992 |
updated.append(prefix) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3993 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3994 |
if rval != EXIT_OK: |
2311
9cad9017fcd7
17445 broken string in pkg set-publisher error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
3995 |
failed.append((prefix, rmsg)) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3996 |
continue |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3997 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3998 |
first = True |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3999 |
for pub, rmsg in failed: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4000 |
if first: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4001 |
first = False |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4002 |
error("failed to add or update one or more " |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4003 |
"publishers", cmd="set-publisher") |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4004 |
logger.error(" %s:" % pub) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4005 |
logger.error(rmsg) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4006 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4007 |
if added or updated: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4008 |
if first: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4009 |
logger.info("pkg set-publisher:") |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4010 |
if added: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4011 |
logger.info(_(" Added publisher(s): %s") % |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4012 |
", ".join(added)) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4013 |
if updated: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4014 |
logger.info(_(" Updated publisher(s): %s") % |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4015 |
", ".join(updated)) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4016 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4017 |
if failed: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4018 |
if len(failed) != len(pubs): |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4019 |
# Not all publishers retrieved could be added or |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4020 |
# updated. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4021 |
return EXIT_PARTIAL |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4022 |
return EXIT_OOPS |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4023 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4024 |
# Now that the configuration was successful, attempt to refresh the |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4025 |
# catalog data for all of the configured publishers. If the refresh |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4026 |
# had been allowed earlier while configuring each publisher, then this |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4027 |
# wouldn't be necessary and some possibly invalid configuration could |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4028 |
# have been eliminated sooner. However, that would be much slower as |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4029 |
# each refresh requires a client image state rebuild. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4030 |
return __refresh(api_inst, added + updated) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4031 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4032 |
def _add_update_pub(api_inst, prefix, pub=None, disable=None, sticky=None, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4033 |
origin_uri=None, add_mirrors=EmptyI, remove_mirrors=EmptyI, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4034 |
add_origins=EmptyI, remove_origins=EmptyI, ssl_cert=None, ssl_key=None, |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4035 |
search_before=None, search_after=None, search_first=False, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4036 |
reset_uuid=None, refresh_allowed=False, |
2100
6a366b063036
17144 Unix socket support is defunct
johansen <johansen@opensolaris.org>
parents:
2097
diff
changeset
|
4037 |
set_props=EmptyI, add_prop_values=EmptyI, |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4038 |
remove_prop_values=EmptyI, unset_props=EmptyI, approved_cas=EmptyI, |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4039 |
revoked_cas=EmptyI, unset_cas=EmptyI): |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4040 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4041 |
repo = None |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4042 |
new_pub = False |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4043 |
if not pub: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4044 |
try: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4045 |
pub = api_inst.get_publisher(prefix=prefix, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4046 |
alias=prefix, duplicate=True) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4047 |
if reset_uuid: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4048 |
pub.reset_client_uuid() |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4049 |
repo = pub.repository |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4050 |
except api_errors.UnknownPublisher, e: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4051 |
if not origin_uri and not add_origins and \ |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4052 |
(remove_origins or remove_mirrors or |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4053 |
remove_prop_values or add_mirrors): |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4054 |
return EXIT_OOPS, str(e) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4055 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4056 |
# No pre-existing, so create a new one. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4057 |
repo = publisher.Repository() |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4058 |
pub = publisher.Publisher(prefix, repository=repo) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4059 |
new_pub = True |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4060 |
elif not api_inst.has_publisher(prefix=pub.prefix): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4061 |
new_pub = True |
327
6c6bd07efe8d
1031 authority prefix needs validation
johansen <johansen@sun.com>
parents:
326
diff
changeset
|
4062 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4063 |
if not repo: |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4064 |
repo = pub.repository |
1795
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
4065 |
if not repo: |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
4066 |
# Could be a new publisher from auto-configuration |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
4067 |
# case where no origin was provided in repository |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
4068 |
# configuration. |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
4069 |
repo = publisher.Repository() |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4070 |
pub.repository = repo |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4071 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4072 |
if disable is not None: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4073 |
# Set disabled property only if provided. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4074 |
pub.disabled = disable |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4075 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4076 |
if sticky is not None: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4077 |
# Set stickiness only if provided |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4078 |
pub.sticky = sticky |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4079 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4080 |
if origin_uri: |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
4081 |
# For compatibility with old -O behaviour, treat -O as a wipe |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
4082 |
# of existing origins and add the new one. |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4083 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4084 |
# Only use existing cert information if the new URI uses |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4085 |
# https for transport. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4086 |
if repo.origins and not (ssl_cert or ssl_key) and \ |
2269
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4087 |
any(origin_uri.startswith(scheme + ":") |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4088 |
for scheme in publisher.SSL_SCHEMES): |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4089 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4090 |
for uri in repo.origins: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4091 |
if ssl_cert is None: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4092 |
ssl_cert = uri.ssl_cert |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4093 |
if ssl_key is None: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4094 |
ssl_key = uri.ssl_key |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4095 |
break |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4096 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4097 |
repo.reset_origins() |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4098 |
repo.add_origin(origin_uri) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4099 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4100 |
# XXX once image configuration supports storing this |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4101 |
# information at the uri level, ssl info should be set |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4102 |
# here. |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4103 |
|
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
4104 |
for entry in (("mirror", add_mirrors, remove_mirrors), ("origin", |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
4105 |
add_origins, remove_origins)): |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
4106 |
etype, add, remove = entry |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
4107 |
# XXX once image configuration supports storing this |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
4108 |
# information at the uri level, ssl info should be set |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
4109 |
# here. |
2253
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
4110 |
if "*" in remove: |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
4111 |
getattr(repo, "reset_%ss" % etype)() |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
4112 |
else: |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
4113 |
for u in remove: |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
4114 |
getattr(repo, "remove_%s" % etype)(u) |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
4115 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4116 |
for u in add: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4117 |
getattr(repo, "add_%s" % etype)(u) |
786
a400f8c4d1c0
2340 support authority enable and disable
Tom Mueller <Tom.Mueller@sun.com>
parents:
770
diff
changeset
|
4118 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4119 |
# None is checked for here so that a client can unset a ssl_cert or |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4120 |
# ssl_key by using -k "" or -c "". |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4121 |
if ssl_cert is not None or ssl_key is not None: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4122 |
# Assume the user wanted to update the ssl_cert or ssl_key |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4123 |
# information for *all* of the currently selected |
2269
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4124 |
# repository's origins and mirrors that use SSL schemes. |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4125 |
found_ssl = False |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4126 |
for uri in repo.origins: |
2269
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4127 |
if uri.scheme not in publisher.SSL_SCHEMES: |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4128 |
continue |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4129 |
found_ssl = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4130 |
if ssl_cert is not None: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4131 |
uri.ssl_cert = ssl_cert |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4132 |
if ssl_key is not None: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4133 |
uri.ssl_key = ssl_key |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4134 |
for uri in repo.mirrors: |
2269
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4135 |
if uri.scheme not in publisher.SSL_SCHEMES: |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4136 |
continue |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4137 |
found_ssl = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4138 |
if ssl_cert is not None: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4139 |
uri.ssl_cert = ssl_cert |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4140 |
if ssl_key is not None: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4141 |
uri.ssl_key = ssl_key |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4142 |
|
2269
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4143 |
if (ssl_cert or ssl_key) and not found_ssl: |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4144 |
# None of the origins or mirrors for the publisher |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4145 |
# use SSL schemes so the cert and key information |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4146 |
# won't be retained. |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4147 |
usage(_("Publisher '%s' does not have any SSL-based " |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4148 |
"origins or mirrors.") % prefix) |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4149 |
|
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4150 |
if set_props or add_prop_values or remove_prop_values or unset_props: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4151 |
pub.update_props(set_props=set_props, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4152 |
add_prop_values=add_prop_values, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4153 |
remove_prop_values=remove_prop_values, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4154 |
unset_props=unset_props) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4155 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4156 |
if new_pub: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4157 |
api_inst.add_publisher(pub, |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4158 |
refresh_allowed=refresh_allowed, approved_cas=approved_cas, |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4159 |
revoked_cas=revoked_cas, unset_cas=unset_cas, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4160 |
search_after=search_after, search_before=search_before, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4161 |
search_first=search_first) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4162 |
else: |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4163 |
for ca in approved_cas: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4164 |
try: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4165 |
ca = os.path.normpath( |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4166 |
os.path.join(orig_cwd, ca)) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4167 |
with open(ca, "rb") as fh: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4168 |
s = fh.read() |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4169 |
except EnvironmentError, e: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4170 |
if e.errno == errno.ENOENT: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4171 |
raise api_errors.MissingFileArgumentException( |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4172 |
ca) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4173 |
elif e.errno == errno.EACCES: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4174 |
raise api_errors.PermissionsException( |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4175 |
ca) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4176 |
raise |
2286
938fbb350ad2
16867 pkgsign should handle existing signatures better
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2280
diff
changeset
|
4177 |
pub.approve_ca_cert(s) |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4178 |
|
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4179 |
for hsh in revoked_cas: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4180 |
pub.revoke_ca_cert(hsh) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4181 |
|
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4182 |
for hsh in unset_cas: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4183 |
pub.unset_ca_cert(hsh) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4184 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4185 |
api_inst.update_publisher(pub, |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4186 |
refresh_allowed=refresh_allowed, search_after=search_after, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4187 |
search_before=search_before, search_first=search_first) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4188 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4189 |
return EXIT_OK, None |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4190 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4191 |
def publisher_unset(api_inst, args): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4192 |
"""pkg unset-publisher publisher ...""" |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4193 |
|
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4194 |
if len(args) == 0: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
4195 |
usage(_("at least one publisher must be specified"), |
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
4196 |
cmd="unset-publisher") |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4197 |
|
936
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4198 |
errors = [] |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4199 |
for name in args: |
709
cfb249e57576
2393 traceback when attempting to change client settings without permission
Brock Pytlik <bpytlik@sun.com>
parents:
706
diff
changeset
|
4200 |
try: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4201 |
api_inst.remove_publisher(prefix=name, alias=name) |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4202 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4203 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4204 |
return EXIT_OOPS |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4205 |
except (api_errors.PermissionsException, |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4206 |
api_errors.PublisherError, |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4207 |
api_errors.ModifyingSyspubException), e: |
936
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4208 |
errors.append((name, e)) |
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4209 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4210 |
retcode = EXIT_OK |
936
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4211 |
if errors: |
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4212 |
if len(errors) == len(args): |
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4213 |
# If the operation failed for every provided publisher |
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4214 |
# prefix or alias, complete failure occurred. |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4215 |
retcode = EXIT_OOPS |
936
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4216 |
else: |
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4217 |
# If the operation failed for only some of the provided |
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4218 |
# publisher prefixes or aliases, then partial failure |
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4219 |
# occurred. |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4220 |
retcode = EXIT_PARTIAL |
936
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4221 |
|
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
4222 |
txt = "" |
936
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4223 |
for name, err in errors: |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
4224 |
txt += "\n" |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
4225 |
txt += _("Removal failed for '%(pub)s': %(msg)s") % { |
936
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4226 |
"pub": name, "msg": err } |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
4227 |
txt += "\n" |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
4228 |
error(txt, cmd="unset-publisher") |
936
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4229 |
|
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4230 |
return retcode |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4231 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4232 |
def publisher_list(api_inst, args): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4233 |
"""pkg publishers""" |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4234 |
omit_headers = False |
410
403886a7592b
1259 Need CLI option to retrieve preferred authority
Shawn Walker <swalker@opensolaris.org>
parents:
409
diff
changeset
|
4235 |
preferred_only = False |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4236 |
inc_disabled = True |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4237 |
valid_formats = ( "tsv", ) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4238 |
format = "default" |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4239 |
field_data = { |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4240 |
"publisher" : [("default", "tsv"), _("PUBLISHER"), ""], |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4241 |
"attrs" : [("default"), "", ""], |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4242 |
"type" : [("default", "tsv"), _("TYPE"), ""], |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4243 |
"status" : [("default", "tsv"), _("STATUS"), ""], |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4244 |
"uri" : [("default", "tsv"), _("URI"), ""], |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4245 |
"sticky" : [("tsv"), _("STICKY"), ""], |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4246 |
"enabled" : [("tsv"), _("ENABLED"), ""], |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4247 |
"syspub" : [("tsv"), _("SYSPUB"), ""] |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4248 |
} |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4249 |
|
1758
71d6c9af76a1
14473 empty string should not be applied _() in client.py (/usr/bin/pkg)
Gary Pennington <gary.pennington@sun.com>
parents:
1755
diff
changeset
|
4250 |
desired_field_order = (_("PUBLISHER"), "", _("STICKY"), |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4251 |
_("SYSPUB"), _("ENABLED"), _("TYPE"), |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4252 |
_("STATUS"), _("URI")) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4253 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4254 |
# Custom sort function for preserving field ordering |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4255 |
def sort_fields(one, two): |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4256 |
return desired_field_order.index(get_header(one)) - \ |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4257 |
desired_field_order.index(get_header(two)) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4258 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4259 |
# Functions for manipulating field_data records |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4260 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4261 |
def filter_default(record): |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4262 |
return "default" in record[0] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4263 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4264 |
def filter_tsv(record): |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4265 |
return "tsv" in record[0] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4266 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4267 |
def get_header(record): |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4268 |
return record[1] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4269 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4270 |
def get_value(record): |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4271 |
return record[2] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4272 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4273 |
def set_value(record, value): |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4274 |
record[2] = value |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4275 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4276 |
# 'a' is left over |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4277 |
opts, pargs = getopt.getopt(args, "F:HPan") |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4278 |
for opt, arg in opts: |
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4279 |
if opt == "-H": |
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4280 |
omit_headers = True |
410
403886a7592b
1259 Need CLI option to retrieve preferred authority
Shawn Walker <swalker@opensolaris.org>
parents:
409
diff
changeset
|
4281 |
if opt == "-P": |
403886a7592b
1259 Need CLI option to retrieve preferred authority
Shawn Walker <swalker@opensolaris.org>
parents:
409
diff
changeset
|
4282 |
preferred_only = True |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4283 |
if opt == "-n": |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4284 |
inc_disabled = False |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4285 |
if opt == "-F": |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4286 |
format = arg |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4287 |
if format not in valid_formats: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4288 |
usage(_("Unrecognized format %(format)s." |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4289 |
" Supported formats: %(valid)s") % \ |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4290 |
{ "format": format, |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4291 |
"valid": valid_formats }, cmd="publisher") |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4292 |
return EXIT_OOPS |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4293 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4294 |
api_inst.progresstracker = get_tracker(quiet=True) |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4295 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4296 |
cert_cache = {} |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4297 |
def get_cert_info(ssl_cert): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4298 |
if not ssl_cert: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4299 |
return None |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4300 |
if ssl_cert not in cert_cache: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4301 |
c = cert_cache[ssl_cert] = {} |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4302 |
errors = c["errors"] = [] |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4303 |
times = c["info"] = { |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4304 |
"effective": "", |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4305 |
"expiration": "", |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4306 |
} |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4307 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4308 |
try: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4309 |
cert = misc.validate_ssl_cert(ssl_cert) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4310 |
except (EnvironmentError, |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4311 |
api_errors.CertificateError, |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4312 |
api_errors.PermissionsException), e: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4313 |
# If the cert information can't be retrieved, |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4314 |
# add the errors to a list and continue on. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4315 |
errors.append(e) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4316 |
c["valid"] = False |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4317 |
else: |
479
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4318 |
nb = cert.get_notBefore() |
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4319 |
t = time.strptime(nb, "%Y%m%d%H%M%SZ") |
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4320 |
nb = datetime.datetime.utcfromtimestamp( |
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4321 |
calendar.timegm(t)) |
1150
2b8aaf0b0b4e
4346 use of ctime() creates non-localized time strings
Rich Burridge <rich.burridge@sun.com>
parents:
1141
diff
changeset
|
4322 |
times["effective"] = nb.strftime("%c") |
479
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4323 |
|
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4324 |
na = cert.get_notAfter() |
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4325 |
t = time.strptime(na, "%Y%m%d%H%M%SZ") |
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4326 |
na = datetime.datetime.utcfromtimestamp( |
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4327 |
calendar.timegm(t)) |
1150
2b8aaf0b0b4e
4346 use of ctime() creates non-localized time strings
Rich Burridge <rich.burridge@sun.com>
parents:
1141
diff
changeset
|
4328 |
times["expiration"] = na.strftime("%c") |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4329 |
c["valid"] = True |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4330 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4331 |
return cert_cache[ssl_cert] |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4332 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4333 |
retcode = EXIT_OK |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4334 |
if len(pargs) == 0: |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4335 |
pref_pub = api_inst.get_highest_ranked_publisher() |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4336 |
if preferred_only: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4337 |
pubs = [pref_pub] |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4338 |
else: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4339 |
pubs = [ |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4340 |
p for p in api_inst.get_publishers() |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4341 |
if inc_disabled or not p.disabled |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4342 |
] |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4343 |
# Create a formatting string for the default output |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4344 |
# format |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4345 |
if format == "default": |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4346 |
fmt = "%-24s %-12s %-8s %-8s %s" |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4347 |
filter_func = filter_default |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4348 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4349 |
# Create a formatting string for the tsv output |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4350 |
# format |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4351 |
if format == "tsv": |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4352 |
fmt = "%s\t%s\t%s\t%s\t%s\t%s\t%s" |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4353 |
filter_func = filter_tsv |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4354 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4355 |
# Extract our list of headers from the field_data |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4356 |
# dictionary Make sure they are extracted in the |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4357 |
# desired order by using our custom sort function |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4358 |
hdrs = map(get_header, sorted(filter(filter_func, |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4359 |
field_data.values()), sort_fields)) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4360 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4361 |
# Output an header if desired |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4362 |
if not omit_headers: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4363 |
msg(fmt % tuple(hdrs)) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4364 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4365 |
for p in pubs: |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4366 |
# Store all our publisher related data in |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4367 |
# field_data ready for output |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4368 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4369 |
set_value(field_data["publisher"], p.prefix) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4370 |
# Setup the synthetic attrs field if the |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4371 |
# format is default. |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4372 |
if format == "default": |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4373 |
pstatus = "" |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4374 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4375 |
if not p.sticky: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4376 |
pstatus_list = [_("non-sticky")] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4377 |
else: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4378 |
pstatus_list = [] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4379 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4380 |
if p.disabled: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4381 |
pstatus_list.append(_("disabled")) |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4382 |
if p.sys_pub: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4383 |
pstatus_list.append(_("syspub")) |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4384 |
if pstatus_list: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4385 |
pstatus = "(%s)" % \ |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4386 |
", ".join(pstatus_list) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4387 |
set_value(field_data["attrs"], pstatus) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4388 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4389 |
if p.sticky: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4390 |
set_value(field_data["sticky"], _("true")) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4391 |
else: |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4392 |
set_value(field_data["sticky"], _("false")) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4393 |
if not p.disabled: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4394 |
set_value(field_data["enabled"], _("true")) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4395 |
else: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4396 |
set_value(field_data["enabled"], _("false")) |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4397 |
if p.sys_pub: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4398 |
set_value(field_data["syspub"], _("true")) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4399 |
else: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4400 |
set_value(field_data["syspub"], _("false")) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4401 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4402 |
# Only show the selected repository's information in |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4403 |
# summary view. |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4404 |
r = p.repository |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4405 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4406 |
# Update field_data for each origin and output |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4407 |
# a publisher record in our desired format. |
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4408 |
for uri in sorted(r.origins): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4409 |
# XXX get the real origin status |
2100
6a366b063036
17144 Unix socket support is defunct
johansen <johansen@opensolaris.org>
parents:
2097
diff
changeset
|
4410 |
set_value(field_data["type"], _("origin")) |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4411 |
set_value(field_data["status"], _("online")) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4412 |
set_value(field_data["uri"], str(uri)) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4413 |
values = map(get_value, |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4414 |
sorted(filter(filter_func, |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4415 |
field_data.values()), sort_fields) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4416 |
) |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4417 |
msg(fmt % tuple(values)) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4418 |
# Update field_data for each mirror and output |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4419 |
# a publisher record in our desired format. |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4420 |
for uri in r.mirrors: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4421 |
# XXX get the real mirror status |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4422 |
set_value(field_data["type"], _("mirror")) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4423 |
set_value(field_data["status"], _("online")) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4424 |
set_value(field_data["uri"], str(uri)) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4425 |
values = map(get_value, |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4426 |
sorted(filter(filter_func, |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4427 |
field_data.values()), sort_fields) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4428 |
) |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4429 |
msg(fmt % tuple(values)) |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4430 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4431 |
if not r.origins and not r.mirrors: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4432 |
set_value(field_data["type"], "") |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4433 |
set_value(field_data["status"], "") |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4434 |
set_value(field_data["uri"], "") |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4435 |
values = map(get_value, |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4436 |
sorted(filter(filter_func, |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4437 |
field_data.values()), sort_fields) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4438 |
) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4439 |
msg(fmt % tuple(values)) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4440 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4441 |
else: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4442 |
def display_ssl_info(uri): |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4443 |
retcode = EXIT_OK |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4444 |
c = get_cert_info(uri.ssl_cert) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4445 |
msg(_(" SSL Key:"), uri.ssl_key) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4446 |
msg(_(" SSL Cert:"), uri.ssl_cert) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4447 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4448 |
if not c: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4449 |
return retcode |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4450 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4451 |
if c["errors"]: |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4452 |
retcode = EXIT_OOPS |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4453 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4454 |
for e in c["errors"]: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
4455 |
logger.error("\n" + str(e) + "\n") |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4456 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4457 |
if c["valid"]: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4458 |
msg(_(" Cert. Effective Date:"), |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4459 |
c["info"]["effective"]) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4460 |
msg(_("Cert. Expiration Date:"), |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4461 |
c["info"]["expiration"]) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4462 |
return retcode |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4463 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4464 |
def display_repository(r): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4465 |
retcode = 0 |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4466 |
for uri in r.origins: |
2100
6a366b063036
17144 Unix socket support is defunct
johansen <johansen@opensolaris.org>
parents:
2097
diff
changeset
|
4467 |
msg(_(" Origin URI:"), uri) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4468 |
rval = display_ssl_info(uri) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4469 |
if rval == 1: |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4470 |
retcode = EXIT_PARTIAL |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4471 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4472 |
for uri in r.mirrors: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4473 |
msg(_(" Mirror URI:"), uri) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4474 |
rval = display_ssl_info(uri) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4475 |
if rval == 1: |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4476 |
retcode = EXIT_PARTIAL |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4477 |
return retcode |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4478 |
|
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4479 |
def display_signing_certs(p): |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4480 |
if p.approved_ca_certs: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4481 |
msg(_(" Approved CAs:"), |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4482 |
p.approved_ca_certs[0]) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4483 |
for h in p.approved_ca_certs[1:]: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4484 |
msg(_(" :"), h) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4485 |
if p.revoked_ca_certs: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4486 |
msg(_(" Revoked CAs:"), |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4487 |
p.revoked_ca_certs[0]) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4488 |
for h in p.revoked_ca_certs[1:]: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4489 |
msg(_(" :"), h) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4490 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4491 |
for name in pargs: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4492 |
# detailed print |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4493 |
pub = api_inst.get_publisher(prefix=name, alias=name) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4494 |
dt = api_inst.get_publisher_last_update_time(pub.prefix) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4495 |
if dt: |
1150
2b8aaf0b0b4e
4346 use of ctime() creates non-localized time strings
Rich Burridge <rich.burridge@sun.com>
parents:
1141
diff
changeset
|
4496 |
dt = dt.strftime("%c") |
479
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4497 |
|
384
9d4746e5dd3e
115 pkg needs to not have a cow on a SIGPIPE
Shawn Walker <swalker@opensolaris.org>
parents:
362
diff
changeset
|
4498 |
msg("") |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4499 |
msg(_(" Publisher:"), pub.prefix) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4500 |
msg(_(" Alias:"), pub.alias) |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4501 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4502 |
rval = display_repository(pub.repository) |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4503 |
if rval != 0: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4504 |
# There was an error in displaying some |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4505 |
# of the information about a repository. |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4506 |
# However, continue on. |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4507 |
retcode = rval |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4508 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4509 |
msg(_(" Client UUID:"), pub.client_uuid) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4510 |
msg(_(" Catalog Updated:"), dt) |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4511 |
display_signing_certs(pub) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4512 |
if pub.disabled: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4513 |
msg(_(" Enabled:"), _("No")) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4514 |
else: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4515 |
msg(_(" Enabled:"), _("Yes")) |
2353
ff1f1e1a910e
18269 CLI should provide a way to view a publishers signature policy
John Rice <john.rice@oracle.com>
parents:
2339
diff
changeset
|
4516 |
msg(_(" Signature Policy:"), pub.signature_policy.name) |
2357
678a2753124a
18343 pkg publisher pub is broken when pub is a system publisher (followup)
John Rice <john.rice@oracle.com>
parents:
2356
diff
changeset
|
4517 |
if "signature-required-names" in pub.properties: |
2356
1d29ed8ed737
18343 pkg publisher pub is broken when pub is a system publisher
John Rice <john.rice@oracle.com>
parents:
2353
diff
changeset
|
4518 |
names = pub.properties["signature-required-names"] |
1d29ed8ed737
18343 pkg publisher pub is broken when pub is a system publisher
John Rice <john.rice@oracle.com>
parents:
2353
diff
changeset
|
4519 |
if names: |
1d29ed8ed737
18343 pkg publisher pub is broken when pub is a system publisher
John Rice <john.rice@oracle.com>
parents:
2353
diff
changeset
|
4520 |
msg(_(" Sig. Required Names:"), names[0]) |
1d29ed8ed737
18343 pkg publisher pub is broken when pub is a system publisher
John Rice <john.rice@oracle.com>
parents:
2353
diff
changeset
|
4521 |
for n in names[1:]: |
1d29ed8ed737
18343 pkg publisher pub is broken when pub is a system publisher
John Rice <john.rice@oracle.com>
parents:
2353
diff
changeset
|
4522 |
msg(_(" :"), n) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4523 |
return retcode |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4524 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4525 |
def property_add_value(api_inst, args): |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4526 |
"""pkg add-property-value propname propvalue""" |
551 | 4527 |
|
4528 |
# ensure no options are passed in |
|
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4529 |
subcommand = "add-property-value" |
551 | 4530 |
opts, pargs = getopt.getopt(args, "") |
4531 |
try: |
|
4532 |
propname, propvalue = pargs |
|
4533 |
except ValueError: |
|
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4534 |
usage(_("requires a property name and value"), cmd=subcommand) |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4535 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4536 |
# XXX image property management should be in pkg.client.api |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4537 |
try: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4538 |
img.add_property_value(propname, propvalue) |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4539 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4540 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4541 |
return EXIT_OOPS |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4542 |
except api_errors.ApiException, e: |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4543 |
error(str(e), cmd=subcommand) |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4544 |
return EXIT_OOPS |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4545 |
return EXIT_OK |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4546 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4547 |
def property_remove_value(api_inst, args): |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4548 |
"""pkg remove-property-value propname propvalue""" |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4549 |
|
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4550 |
# ensure no options are passed in |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4551 |
subcommand = "remove-property-value" |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4552 |
opts, pargs = getopt.getopt(args, "") |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4553 |
try: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4554 |
propname, propvalue = pargs |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4555 |
except ValueError: |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4556 |
usage(_("requires a property name and value"), cmd=subcommand) |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4557 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4558 |
# XXX image property management should be in pkg.client.api |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4559 |
try: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4560 |
img.remove_property_value(propname, propvalue) |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4561 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4562 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4563 |
return EXIT_OOPS |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4564 |
except api_errors.ApiException, e: |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4565 |
error(str(e), cmd=subcommand) |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4566 |
return EXIT_OOPS |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4567 |
return EXIT_OK |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4568 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4569 |
def property_set(api_inst, args): |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4570 |
"""pkg set-property propname propvalue [propvalue ...]""" |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4571 |
|
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4572 |
# ensure no options are passed in |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4573 |
subcommand = "set-property" |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4574 |
opts, pargs = getopt.getopt(args, "") |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4575 |
try: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4576 |
propname = pargs[0] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4577 |
propvalues = pargs[1:] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4578 |
except IndexError: |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4579 |
propvalues = [] |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4580 |
if len(propvalues) == 0: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4581 |
usage(_("requires a property name and at least one value"), |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4582 |
cmd=subcommand) |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4583 |
elif propname not in ("publisher-search-order", |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4584 |
"signature-policy", "signature-required-names") and \ |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4585 |
len(propvalues) == 1: |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4586 |
# All other properties are single value, so if only one (or no) |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4587 |
# value was specified, transform it. If multiple values were |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4588 |
# specified, allow the value to be passed on so that the |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4589 |
# configuration classes can re-raise the appropriate error. |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4590 |
propvalues = propvalues[0] |
792
060a802056a4
4372 property set commands should display error for preferred-authority property
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
791
diff
changeset
|
4591 |
|
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4592 |
props = { propname: propvalues } |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4593 |
if propname == "signature-policy": |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4594 |
policy = propvalues[0] |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4595 |
props[propname] = policy |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4596 |
params = propvalues[1:] |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4597 |
if policy != "require-names" and len(params): |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4598 |
usage(_("Signature-policy %s doesn't allow additional " |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4599 |
"parameters.") % policy, cmd=subcommand) |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4600 |
elif policy == "require-names": |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4601 |
props["signature-required-names"] = params |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4602 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4603 |
# XXX image property management should be in pkg.client.api |
551 | 4604 |
try: |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4605 |
img.set_properties(props) |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4606 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4607 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4608 |
return EXIT_OOPS |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4609 |
except api_errors.ApiException, e: |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4610 |
error(str(e), cmd=subcommand) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4611 |
return EXIT_OOPS |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4612 |
return EXIT_OK |
551 | 4613 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4614 |
def property_unset(api_inst, args): |
551 | 4615 |
"""pkg unset-property propname ...""" |
4616 |
||
4617 |
# is this an existing property in our image? |
|
4618 |
# if so, delete it |
|
4619 |
# if not, error |
|
4620 |
||
4621 |
# ensure no options are passed in |
|
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4622 |
subcommand = "unset-property" |
551 | 4623 |
opts, pargs = getopt.getopt(args, "") |
4624 |
if not pargs: |
|
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
4625 |
usage(_("requires at least one property name"), |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4626 |
cmd=subcommand) |
551 | 4627 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4628 |
# XXX image property management should be in pkg.client.api |
551 | 4629 |
for p in pargs: |
4630 |
try: |
|
4631 |
img.delete_property(p) |
|
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4632 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4633 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4634 |
return EXIT_OOPS |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4635 |
except api_errors.ApiException, e: |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4636 |
error(str(e), cmd=subcommand) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4637 |
return EXIT_OOPS |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4638 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4639 |
return EXIT_OK |
551 | 4640 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4641 |
def property_list(api_inst, args): |
551 | 4642 |
"""pkg property [-H] [propname ...]""" |
4643 |
omit_headers = False |
|
4644 |
||
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4645 |
subcommand = "property" |
551 | 4646 |
opts, pargs = getopt.getopt(args, "H") |
4647 |
for opt, arg in opts: |
|
4648 |
if opt == "-H": |
|
4649 |
omit_headers = True |
|
4650 |
||
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4651 |
# XXX image property management should be in pkg.client.api |
551 | 4652 |
for p in pargs: |
4653 |
if not img.has_property(p): |
|
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4654 |
error(_("no such property: %s") % p, cmd=subcommand) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4655 |
return EXIT_OOPS |
551 | 4656 |
|
4657 |
if not pargs: |
|
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4658 |
# If specific properties were named, list them in the order |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4659 |
# requested; otherwise, list them sorted. |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4660 |
pargs = sorted(list(img.properties())) |
551 | 4661 |
|
4662 |
width = max(max([len(p) for p in pargs]), 8) |
|
4663 |
fmt = "%%-%ss %%s" % width |
|
4664 |
if not omit_headers: |
|
4665 |
msg(fmt % ("PROPERTY", "VALUE")) |
|
4666 |
||
4667 |
for p in pargs: |
|
4668 |
msg(fmt % (p, img.get_property(p))) |
|
4669 |
||
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4670 |
return EXIT_OK |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4671 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4672 |
def variant_list(api_inst, args): |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4673 |
"""pkg variant [-H] [<variant_spec>]""" |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4674 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4675 |
omit_headers = False |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4676 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4677 |
opts, pargs = getopt.getopt(args, "H") |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4678 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4679 |
for opt, arg in opts: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4680 |
if opt == "-H": |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4681 |
omit_headers = True |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4682 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4683 |
# XXX image variants should be accessible through pkg.client.api |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4684 |
variants = img.get_variants() |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4685 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4686 |
for p in pargs: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4687 |
if p not in variants: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4688 |
error(_("no such variant: %s") % p, cmd="variant") |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4689 |
return EXIT_OOPS |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4690 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4691 |
if not pargs: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4692 |
pargs = variants.keys() |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4693 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4694 |
width = max(max([len(p) for p in pargs]), 8) |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4695 |
fmt = "%%-%ss %%s" % width |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4696 |
if not omit_headers: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4697 |
msg(fmt % ("VARIANT", "VALUE")) |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4698 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4699 |
for p in pargs: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4700 |
msg(fmt % (p, variants[p])) |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4701 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4702 |
return EXIT_OK |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4703 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4704 |
def facet_list(api_inst, args): |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4705 |
"""pkg facet [-H] [<facet_spec>]""" |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4706 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4707 |
omit_headers = False |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4708 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4709 |
opts, pargs = getopt.getopt(args, "H") |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4710 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4711 |
for opt, arg in opts: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4712 |
if opt == "-H": |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4713 |
omit_headers = True |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4714 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4715 |
# XXX image facets should be accessible through pkg.client.api |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4716 |
facets = img.get_facets() |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4717 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4718 |
for i, p in enumerate(pargs[:]): |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4719 |
if not p.startswith("facet."): |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4720 |
pargs[i] = "facet." + p |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4721 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4722 |
if not pargs: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4723 |
pargs = facets.keys() |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4724 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4725 |
if pargs: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4726 |
width = max(max([len(p) for p in pargs]), 8) |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4727 |
else: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4728 |
width = 8 |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4729 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4730 |
fmt = "%%-%ss %%s" % width |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4731 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4732 |
if not omit_headers: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4733 |
msg(fmt % ("FACETS", "VALUE")) |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4734 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4735 |
for p in pargs: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4736 |
msg(fmt % (p, facets[p])) |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4737 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4738 |
return EXIT_OK |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4739 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4740 |
def list_linked(op, api_inst, pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4741 |
li_ignore, omit_headers): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4742 |
"""pkg list-linked [-H] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4743 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4744 |
List all the linked images known to the current image.""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4745 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4746 |
api_inst.progresstracker = get_tracker(quiet=omit_headers) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4747 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4748 |
if li_ignore and type(li_ignore) == list: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4749 |
li_ignore = api_inst.parse_linked_name_list(li_ignore) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4750 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4751 |
li_list = api_inst.list_linked(li_ignore) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4752 |
if len(li_list) == 0: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4753 |
return EXIT_OK |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4754 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4755 |
fmt = "" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4756 |
li_header = [_("NAME"), _("RELATIONSHIP"), _("PATH")] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4757 |
for col in range(0, len(li_header)): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4758 |
width = max([len(row[col]) for row in li_list]) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4759 |
width = max(width, len(li_header[col])) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4760 |
if (fmt != ''): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4761 |
fmt += "\t" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4762 |
fmt += "%%-%ss" % width |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4763 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4764 |
if not omit_headers: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4765 |
msg(fmt % tuple(li_header)) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4766 |
for row in li_list: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4767 |
msg(fmt % tuple(row)) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4768 |
return EXIT_OK |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4769 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4770 |
def __parse_linked_props(args, op): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4771 |
""""Parse linked image property options that were specified on the |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4772 |
command line into a dictionary. Make sure duplicate properties were |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4773 |
not specified.""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4774 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4775 |
linked_props = dict() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4776 |
for pv in args: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4777 |
try: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4778 |
p, v = pv.split("=", 1) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4779 |
except ValueError: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4780 |
usage(_("linked image property arguments must be of " |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4781 |
"the form '<name>=<value>'."), cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4782 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4783 |
if p not in li.prop_values: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4784 |
usage(_("invalid linked image property: '%s'.") % p, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4785 |
cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4786 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4787 |
if p in linked_props: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4788 |
usage(_("linked image property specified multiple " |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4789 |
"times: '%s'.") % p, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4790 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4791 |
linked_props[p] = v |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4792 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4793 |
return linked_props |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4794 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4795 |
def list_property_linked(op, api_inst, pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4796 |
li_name, omit_headers): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4797 |
"""pkg property-linked [-H] [-l <li-name>] [propname ...] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4798 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4799 |
List the linked image properties associated with a child or parent |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4800 |
image.""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4801 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4802 |
api_inst.progresstracker = get_tracker(quiet=omit_headers) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4803 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4804 |
lin=None |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4805 |
if li_name: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4806 |
lin = api_inst.parse_linked_name(li_name) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4807 |
props = api_inst.get_linked_props(lin=lin) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4808 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4809 |
for p in pargs: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4810 |
if p not in props.keys(): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4811 |
error(_("%(op)s: no such property: %(p)s") % |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4812 |
{"op": op, "p": p}) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4813 |
return EXIT_OOPS |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4814 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4815 |
if len(props) == 0: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4816 |
return EXIT_OK |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4817 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4818 |
if not pargs: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4819 |
pargs = props.keys() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4820 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4821 |
width = max(max([len(p) for p in pargs if props[p]]), 8) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4822 |
fmt = "%%-%ss\t%%s" % width |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4823 |
if not omit_headers: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4824 |
msg(fmt % ("PROPERTY", "VALUE")) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4825 |
for p in sorted(pargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4826 |
if not props[p]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4827 |
continue |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4828 |
msg(fmt % (p, props[p])) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4829 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4830 |
return EXIT_OK |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4831 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4832 |
def set_property_linked(op, api_inst, pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4833 |
accept, be_activate, be_name, li_ignore, li_md_only, li_name, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4834 |
li_parent_sync, li_pkg_updates, new_be, noexecute, origins, quiet, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4835 |
refresh_catalogs, reject_pats, show_licenses, update_index, verbose): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4836 |
"""pkg set-property-linked |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4837 |
[-nvq] [--accept] [--licenses] [--no-index] [--no-refresh] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4838 |
[--no-parent-sync] [--no-pkg-updates] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4839 |
[--linked-md-only] <propname>=<propvalue> ... |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4840 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4841 |
Change the specified linked image properties. This may result in |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4842 |
updating the package contents of a child image.""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4843 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4844 |
api_inst.progresstracker = get_tracker(quiet, verbose) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4845 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4846 |
# make sure we're a child image |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4847 |
if li_name: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4848 |
lin = api_inst.parse_linked_name(li_name) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4849 |
else: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4850 |
lin = api_inst.get_linked_name() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4851 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4852 |
xrval, xres = get_fmri_args(api_inst, reject_pats, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4853 |
if not xrval: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4854 |
return EXIT_OOPS |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4855 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4856 |
LIXXX |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4857 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4858 |
def audit_linked(op, api_inst, pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4859 |
li_parent_sync, li_target_all, li_target_list, omit_headers, quiet): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4860 |
"""pkg audit-linked [-a|-l <li-name>] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4861 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4862 |
Audit one or more child images to see if they are in sync |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4863 |
with their parent image.""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4864 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4865 |
api_inst.progresstracker = get_tracker(quiet=omit_headers) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4866 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4867 |
li_target_list = api_inst.parse_linked_name_list(li_target_list) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4868 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4869 |
# audit the requested child image(s) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4870 |
if not li_target_all and not li_target_list: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4871 |
# audit the current image |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4872 |
rvdict = api_inst.audit_linked(li_parent_sync=li_parent_sync) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4873 |
else: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4874 |
# audit the requested child image(s) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4875 |
rvdict = api_inst.audit_linked_children(li_target_list) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4876 |
if not rvdict: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4877 |
# may not have had any children |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4878 |
return EXIT_OK |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4879 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4880 |
# display audit return values |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4881 |
width = max(max([len(k) for k in rvdict.keys()]), 8) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4882 |
fmt = "%%-%ss\t%%s" % width |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4883 |
if not omit_headers: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4884 |
msg(fmt % ("NAME", "STATUS")) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4885 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4886 |
if not quiet: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4887 |
for k, (rv, err) in rvdict.items(): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4888 |
if rv == EXIT_OK: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4889 |
msg(fmt % (k, _("synced"))) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4890 |
elif rv == EXIT_DIVERGED: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4891 |
msg(fmt % (k, _("diverged"))) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4892 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4893 |
rv, err = api_inst.audit_linked_rvdict2rv(rvdict) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4894 |
if err: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4895 |
error(err, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4896 |
return rv |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4897 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4898 |
def sync_linked(op, api_inst, pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4899 |
accept, be_activate, be_name, li_ignore, li_parent_sync, new_be, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4900 |
noexecute, origins, quiet, refresh_catalogs, reject_pats, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4901 |
show_licenses, update_index, verbose, li_md_only, li_pkg_updates, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4902 |
li_target_all, li_target_list, stage): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4903 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4904 |
"""pkg audit-linked [-a|-l <li-name>] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4905 |
[-nvq] [--accept] [--licenses] [--no-index] [--no-refresh] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4906 |
[--no-parent-sync] [--no-pkg-updates] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4907 |
[--linked-md-only] [-a|-l <name>] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4908 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4909 |
Sync one or more child images with their parent image.""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4910 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4911 |
api_inst.progresstracker = get_tracker(quiet, verbose) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4912 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4913 |
xrval, xres = get_fmri_args(api_inst, reject_pats, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4914 |
if not xrval: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4915 |
return EXIT_OOPS |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4916 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4917 |
api_inst.set_stage(stage) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4918 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4919 |
li_target_list = api_inst.parse_linked_name_list(li_target_list) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4920 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4921 |
if not li_target_all and not li_target_list: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4922 |
# sync the current image |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4923 |
return __api_op(op, api_inst, _accept=accept, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4924 |
_li_ignore=li_ignore, _noexecute=noexecute, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4925 |
_origins=origins, _quiet=quiet, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4926 |
_show_licenses=show_licenses, _stage=stage, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4927 |
_verbose=verbose, be_activate=be_activate, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4928 |
be_name=be_name, li_md_only=li_md_only, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4929 |
li_parent_sync=li_parent_sync, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4930 |
li_pkg_updates=li_pkg_updates, new_be=new_be, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4931 |
refresh_catalogs=refresh_catalogs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4932 |
reject_list=reject_pats, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4933 |
update_index=update_index) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4934 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4935 |
# sync the requested child image(s) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4936 |
rvdict = api_inst.sync_linked_children(li_target_list, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4937 |
noexecute=noexecute, accept=accept, show_licenses=show_licenses, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4938 |
refresh_catalogs=refresh_catalogs, update_index=update_index, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4939 |
li_pkg_updates=li_pkg_updates, li_md_only=li_md_only) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4940 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4941 |
rv, err = api_inst.sync_linked_rvdict2rv(rvdict) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4942 |
if err: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4943 |
error(err, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4944 |
return rv |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4945 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4946 |
def attach_linked(op, api_inst, pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4947 |
accept, allow_relink, attach_child, attach_parent, be_activate, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4948 |
be_name, force, li_ignore, li_md_only, li_parent_sync, li_pkg_updates, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4949 |
li_props, new_be, noexecute, origins, quiet, refresh_catalogs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4950 |
reject_pats, show_licenses, update_index, verbose): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4951 |
"""pkg attach-linked |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4952 |
[-fnvq] [--accept] [--licenses] [--no-index] [--no-refresh] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4953 |
[--no-pkg-updates] [--linked-md-only] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4954 |
[--allow-relink] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4955 |
[--prop-linked <propname>=<propvalue> ...] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4956 |
(-c|-p) <li-name> <dir> |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4957 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4958 |
Attach a child linked image. The child could be this image attaching |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4959 |
itself to a parent, or another image being attach as a child with |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4960 |
this image being the parent.""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4961 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4962 |
api_inst.progresstracker = get_tracker(quiet, verbose) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4963 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4964 |
for k, v in li_props: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4965 |
if k in [li.PROP_PATH, li.PROP_NAME, li.PROP_MODEL]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4966 |
usage(_("cannot specify linked image property: '%s'") % |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4967 |
k, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4968 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4969 |
if len(pargs) < 2: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4970 |
usage(_("a linked image name and path must be specified"), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4971 |
cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4972 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4973 |
li_name = pargs[0] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4974 |
li_path = pargs[1] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4975 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4976 |
# parse the specified name |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4977 |
lin = api_inst.parse_linked_name(li_name, allow_unknown=True) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4978 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4979 |
xrval, xres = get_fmri_args(api_inst, reject_pats, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4980 |
if not xrval: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4981 |
return EXIT_OOPS |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4982 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4983 |
if attach_parent: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4984 |
# attach the current image to a parent |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4985 |
return __api_op(op, api_inst, _accept=accept, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4986 |
_li_ignore=li_ignore, _noexecute=noexecute, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4987 |
_origins=origins, _quiet=quiet, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4988 |
_show_licenses=show_licenses, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4989 |
_verbose=verbose, allow_relink=allow_relink, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4990 |
be_activate=be_activate, be_name=be_name, force=force, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4991 |
li_md_only=li_md_only, li_path=li_path, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4992 |
li_pkg_updates=li_pkg_updates, li_props=li_props, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4993 |
lin=lin, new_be=new_be, refresh_catalogs=refresh_catalogs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4994 |
reject_list=reject_pats, update_index=update_index) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4995 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4996 |
# attach the requested child image |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4997 |
(rv, err) = api_inst.attach_linked_child(lin, li_path, li_props, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4998 |
accept=accept, allow_relink=allow_relink, force=force, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4999 |
li_md_only=li_md_only, li_pkg_updates=li_pkg_updates, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5000 |
noexecute=noexecute, refresh_catalogs=refresh_catalogs, |
2444
9170dcd9559d
18349 linked image code needs to be more resilient in the face of zoneadm failure
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2431
diff
changeset
|
5001 |
reject_list=reject_pats, show_licenses=show_licenses, |
9170dcd9559d
18349 linked image code needs to be more resilient in the face of zoneadm failure
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2431
diff
changeset
|
5002 |
update_index=update_index) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5003 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5004 |
if err: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5005 |
error(err, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5006 |
return rv |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5007 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5008 |
def detach_linked(op, api_inst, pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5009 |
force, li_target_all, li_target_list, noexecute, quiet, verbose): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5010 |
"""pkg detach-linked |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5011 |
[-fnvq] [-a|-l <li-name>] [--linked-md-only] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5012 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5013 |
Detach one or more child linked images.""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5014 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5015 |
api_inst.progresstracker = get_tracker(quiet, verbose) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5016 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5017 |
li_target_list = api_inst.parse_linked_name_list(li_target_list) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5018 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5019 |
if not li_target_all and not li_target_list: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5020 |
# detach the current image |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5021 |
return __api_op(op, api_inst, _noexecute=noexecute, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5022 |
_quiet=quiet, _verbose=verbose, force=force) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5023 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5024 |
# detach the requested child image(s) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5025 |
rvdict = api_inst.detach_linked_children(li_target_list, force=force, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5026 |
noexecute=noexecute) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5027 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5028 |
rv, err = api_inst.detach_linked_rvdict2rv(rvdict) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5029 |
if err: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5030 |
error(err, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5031 |
return rv |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5032 |
|
1370
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
5033 |
def image_create(args): |
116
9c9942a52984
(image flag day) remove pkg catalog, improve pkg status, localize pkg(1), use
Stephen Hahn <sch@Sun.COM>
parents:
111
diff
changeset
|
5034 |
"""Create an image of the requested kind, at the given path. Load |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
5035 |
catalog for initial publisher for convenience. |
116
9c9942a52984
(image flag day) remove pkg catalog, improve pkg status, localize pkg(1), use
Stephen Hahn <sch@Sun.COM>
parents:
111
diff
changeset
|
5036 |
|
9c9942a52984
(image flag day) remove pkg catalog, improve pkg status, localize pkg(1), use
Stephen Hahn <sch@Sun.COM>
parents:
111
diff
changeset
|
5037 |
At present, it is legitimate for a user image to specify that it will be |
9c9942a52984
(image flag day) remove pkg catalog, improve pkg status, localize pkg(1), use
Stephen Hahn <sch@Sun.COM>
parents:
111
diff
changeset
|
5038 |
deployed in a zone. An easy example would be a program with an optional |
9c9942a52984
(image flag day) remove pkg catalog, improve pkg status, localize pkg(1), use
Stephen Hahn <sch@Sun.COM>
parents:
111
diff
changeset
|
5039 |
component that consumes global zone-only information, such as various |
9c9942a52984
(image flag day) remove pkg catalog, improve pkg status, localize pkg(1), use
Stephen Hahn <sch@Sun.COM>
parents:
111
diff
changeset
|
5040 |
kernel statistics or device information.""" |
30 | 5041 |
|
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5042 |
cmd_name = "image-create" |
2183
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
5043 |
|
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5044 |
force = False |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5045 |
imgtype = IMG_TYPE_USER |
104
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
103
diff
changeset
|
5046 |
is_zone = False |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5047 |
add_mirrors = set() |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5048 |
add_origins = set() |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5049 |
pub_name = None |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5050 |
pub_url = None |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5051 |
refresh_allowed = True |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
5052 |
ssl_key = None |
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
5053 |
ssl_cert = None |
838
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
5054 |
variants = {} |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5055 |
facets = pkg.facet.Facets() |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5056 |
set_props = {} |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5057 |
version = None |
30 | 5058 |
|
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5059 |
opts, pargs = getopt.getopt(args, "fFPUza:g:m:p:k:c:", |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5060 |
["force", "full", "partial", "user", "zone", "authority=", "facet=", |
1937
be8995c7bb8f
10924 Want ability to communicate over unix sockets
johansen <johansen@opensolaris.org>
parents:
1895
diff
changeset
|
5061 |
"mirror=", "origin=", "publisher=", "no-refresh", "variant=", |
2100
6a366b063036
17144 Unix socket support is defunct
johansen <johansen@opensolaris.org>
parents:
2097
diff
changeset
|
5062 |
"set-property="]) |
30 | 5063 |
|
5064 |
for opt, arg in opts: |
|
938
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
936
diff
changeset
|
5065 |
# -a is deprecated and will be removed at a future date. |
eeb932b9b44e
7336 putback for 5871 missed a few vestiges of authority
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
936
diff
changeset
|
5066 |
if opt in ("-a", "-p", "--publisher"): |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5067 |
pub_url = None |
285
538afd6a9d3e
763 pkg image-create /foo , pkg image-create /tmp/foo both yield (different) tracebacks
Danek Duvall <danek.duvall@sun.com>
parents:
271
diff
changeset
|
5068 |
try: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
5069 |
pub_name, pub_url = arg.split("=", 1) |
285
538afd6a9d3e
763 pkg image-create /foo , pkg image-create /tmp/foo both yield (different) tracebacks
Danek Duvall <danek.duvall@sun.com>
parents:
271
diff
changeset
|
5070 |
except ValueError: |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5071 |
pub_name = None |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5072 |
pub_url = arg |
2430
a1937ef0a955
18325 image-create should accept simple paths for sources
Shawn Walker <shawn.walker@oracle.com>
parents:
2413
diff
changeset
|
5073 |
if pub_url: |
a1937ef0a955
18325 image-create should accept simple paths for sources
Shawn Walker <shawn.walker@oracle.com>
parents:
2413
diff
changeset
|
5074 |
pub_url = misc.parse_uri(pub_url, cwd=orig_cwd) |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5075 |
elif opt == "-c": |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5076 |
ssl_cert = arg |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5077 |
elif opt == "-f" or opt == "--force": |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5078 |
force = True |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5079 |
elif opt in ("-g", "--origin"): |
2430
a1937ef0a955
18325 image-create should accept simple paths for sources
Shawn Walker <shawn.walker@oracle.com>
parents:
2413
diff
changeset
|
5080 |
add_origins.add(misc.parse_uri(arg, cwd=orig_cwd)) |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5081 |
elif opt == "-k": |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5082 |
ssl_key = arg |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5083 |
elif opt in ("-m", "--mirror"): |
2430
a1937ef0a955
18325 image-create should accept simple paths for sources
Shawn Walker <shawn.walker@oracle.com>
parents:
2413
diff
changeset
|
5084 |
add_mirrors.add(misc.parse_uri(arg, cwd=orig_cwd)) |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5085 |
elif opt == "-z" or opt == "--zone": |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5086 |
is_zone = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5087 |
imgtype = IMG_TYPE_ENTIRE |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5088 |
elif opt == "-F" or opt == "--full": |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5089 |
imgtype = IMG_TYPE_ENTIRE |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5090 |
elif opt == "-P" or opt == "--partial": |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5091 |
imgtype = IMG_TYPE_PARTIAL |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5092 |
elif opt == "-U" or opt == "--user": |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5093 |
imgtype = IMG_TYPE_USER |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5094 |
elif opt == "--facet": |
2258
ca4d89069b17
14860 image-create facet option usage message is oddly worded
Shawn Walker <shawn.walker@oracle.com>
parents:
2253
diff
changeset
|
5095 |
allow = { "TRUE": True, "FALSE": False } |
ca4d89069b17
14860 image-create facet option usage message is oddly worded
Shawn Walker <shawn.walker@oracle.com>
parents:
2253
diff
changeset
|
5096 |
try: |
ca4d89069b17
14860 image-create facet option usage message is oddly worded
Shawn Walker <shawn.walker@oracle.com>
parents:
2253
diff
changeset
|
5097 |
f_name, f_value = arg.split("=", 1) |
ca4d89069b17
14860 image-create facet option usage message is oddly worded
Shawn Walker <shawn.walker@oracle.com>
parents:
2253
diff
changeset
|
5098 |
except ValueError: |
ca4d89069b17
14860 image-create facet option usage message is oddly worded
Shawn Walker <shawn.walker@oracle.com>
parents:
2253
diff
changeset
|
5099 |
f_name = arg |
ca4d89069b17
14860 image-create facet option usage message is oddly worded
Shawn Walker <shawn.walker@oracle.com>
parents:
2253
diff
changeset
|
5100 |
f_value = "" |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5101 |
if not f_name.startswith("facet."): |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5102 |
f_name = "facet.%s" % f_name |
2258
ca4d89069b17
14860 image-create facet option usage message is oddly worded
Shawn Walker <shawn.walker@oracle.com>
parents:
2253
diff
changeset
|
5103 |
if not f_name or f_value.upper() not in allow: |
ca4d89069b17
14860 image-create facet option usage message is oddly worded
Shawn Walker <shawn.walker@oracle.com>
parents:
2253
diff
changeset
|
5104 |
usage(_("Facet arguments must be of the " |
ca4d89069b17
14860 image-create facet option usage message is oddly worded
Shawn Walker <shawn.walker@oracle.com>
parents:
2253
diff
changeset
|
5105 |
"form '<name>=(True|False)'"), |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5106 |
cmd=cmd_name) |
1537 | 5107 |
facets[f_name] = allow[f_value.upper()] |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5108 |
elif opt == "--no-refresh": |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5109 |
refresh_allowed = False |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5110 |
elif opt == "--set-property": |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5111 |
t = arg.split("=", 1) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5112 |
if len(t) < 2: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5113 |
usage(_("properties to be set must be of the " |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5114 |
"form '<name>=<value>'. This is what was " |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5115 |
"given: %s") % arg, cmd=cmd_name) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5116 |
if t[0] in set_props: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5117 |
usage(_("a property may only be set once in a " |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5118 |
"command. %s was set twice") % t[0], |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5119 |
cmd=cmd_name) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5120 |
set_props[t[0]] = t[1] |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5121 |
elif opt == "--variant": |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5122 |
try: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5123 |
v_name, v_value = arg.split("=", 1) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5124 |
if not v_name.startswith("variant."): |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5125 |
v_name = "variant.%s" % v_name |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5126 |
except ValueError: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5127 |
usage(_("variant arguments must be of the " |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5128 |
"form '<name>=<value>'."), |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5129 |
cmd=cmd_name) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5130 |
variants[v_name] = v_value |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5131 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5132 |
if not pargs: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5133 |
usage(_("an image directory path must be specified"), |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5134 |
cmd=cmd_name) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5135 |
elif len(pargs) > 1: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
5136 |
usage(_("only one image directory path may be specified"), |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5137 |
cmd=cmd_name) |
1111
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1102
diff
changeset
|
5138 |
image_dir = pargs[0] |
221
e1dbb27a23b5
52 catalog can leave inventory behind, making pkg(1) blind
Stephen Hahn <sch@Sun.COM>
parents:
219
diff
changeset
|
5139 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
5140 |
if not pub_name and not refresh_allowed: |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5141 |
usage(_("--no-refresh cannot be used with -p unless a " |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5142 |
"publisher prefix is provided."), cmd=cmd_name) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5143 |
|
2100
6a366b063036
17144 Unix socket support is defunct
johansen <johansen@opensolaris.org>
parents:
2097
diff
changeset
|
5144 |
if not refresh_allowed and pub_url: |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5145 |
# Auto-config can't be done if refresh isn't allowed, so treat |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5146 |
# this as a manual configuration case. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5147 |
add_origins.add(pub_url) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5148 |
repo_uri = None |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5149 |
else: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5150 |
repo_uri = pub_url |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5151 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5152 |
# Get sanitized SSL Cert/Key input values. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5153 |
ssl_cert, ssl_key = _get_ssl_cert_key(image_dir, is_zone, ssl_cert, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5154 |
ssl_key) |
327
6c6bd07efe8d
1031 authority prefix needs validation
johansen <johansen@sun.com>
parents:
326
diff
changeset
|
5155 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5156 |
global img |
285
538afd6a9d3e
763 pkg image-create /foo , pkg image-create /tmp/foo both yield (different) tracebacks
Danek Duvall <danek.duvall@sun.com>
parents:
271
diff
changeset
|
5157 |
try: |
1370
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
5158 |
progtrack = get_tracker() |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5159 |
api_inst = api.image_create(PKG_CLIENT_NAME, CLIENT_API_VERSION, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5160 |
image_dir, imgtype, is_zone, facets=facets, force=force, |
2179
d5e39d973fdd
17653 zone install fails with pkg.oracle.com/solaris/support set
Tim Foster <tim.s.foster@oracle.com>
parents:
2161
diff
changeset
|
5161 |
mirrors=list(add_mirrors), origins=list(add_origins), |
d5e39d973fdd
17653 zone install fails with pkg.oracle.com/solaris/support set
Tim Foster <tim.s.foster@oracle.com>
parents:
2161
diff
changeset
|
5162 |
prefix=pub_name, progtrack=progtrack, |
d5e39d973fdd
17653 zone install fails with pkg.oracle.com/solaris/support set
Tim Foster <tim.s.foster@oracle.com>
parents:
2161
diff
changeset
|
5163 |
refresh_allowed=refresh_allowed, ssl_cert=ssl_cert, |
d5e39d973fdd
17653 zone install fails with pkg.oracle.com/solaris/support set
Tim Foster <tim.s.foster@oracle.com>
parents:
2161
diff
changeset
|
5164 |
ssl_key=ssl_key, repo_uri=repo_uri, variants=variants, |
d5e39d973fdd
17653 zone install fails with pkg.oracle.com/solaris/support set
Tim Foster <tim.s.foster@oracle.com>
parents:
2161
diff
changeset
|
5165 |
props=set_props) |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5166 |
img = api_inst.img |
835
34ec4401dc48
686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents:
834
diff
changeset
|
5167 |
except api_errors.InvalidDepotResponseException, e: |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
5168 |
# Ensure messages are displayed after the spinner. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
5169 |
logger.error("\n") |
1063
80e49e35ce17
4461 l10n changes to allow string inputs reordering
Rich Burridge <rich.burridge@sun.com>
parents:
1053
diff
changeset
|
5170 |
error(_("The URI '%(pub_url)s' does not appear to point to a " |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
5171 |
"valid pkg repository.\nPlease check the repository's " |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
5172 |
"location and the client's network configuration." |
1063
80e49e35ce17
4461 l10n changes to allow string inputs reordering
Rich Burridge <rich.burridge@sun.com>
parents:
1053
diff
changeset
|
5173 |
"\nAdditional details:\n\n%(error)s") % |
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
5174 |
{ "pub_url": pub_url, "error": e }, |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5175 |
cmd=cmd_name) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5176 |
print_proxy_config() |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5177 |
return EXIT_OOPS |
835
34ec4401dc48
686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents:
834
diff
changeset
|
5178 |
except api_errors.CatalogRefreshException, cre: |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
5179 |
# Ensure messages are displayed after the spinner. |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5180 |
error("", cmd=cmd_name) |
835
34ec4401dc48
686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents:
834
diff
changeset
|
5181 |
if display_catalog_failures(cre) == 0: |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5182 |
return EXIT_OOPS |
835
34ec4401dc48
686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents:
834
diff
changeset
|
5183 |
else: |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5184 |
return EXIT_PARTIAL |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5185 |
except api_errors.ApiException, e: |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5186 |
error(str(e), cmd=cmd_name) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5187 |
return EXIT_OOPS |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5188 |
return EXIT_OK |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
5189 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5190 |
def rebuild_index(api_inst, pargs): |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
427
diff
changeset
|
5191 |
"""pkg rebuild-index |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
427
diff
changeset
|
5192 |
|
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
427
diff
changeset
|
5193 |
Forcibly rebuild the search indexes. Will remove existing indexes |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
427
diff
changeset
|
5194 |
and build new ones from scratch.""" |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
427
diff
changeset
|
5195 |
|
442
01fb28d438b3
2418 'pkg version', 'pkg image-update' should error on additional arguments
Dan Price <dp@eng.sun.com>
parents:
432
diff
changeset
|
5196 |
if pargs: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
5197 |
usage(_("command does not take operands ('%s')") % \ |
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
5198 |
" ".join(pargs), cmd="rebuild-index") |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
5199 |
|
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
427
diff
changeset
|
5200 |
try: |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
5201 |
api_inst.rebuild_search_index() |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5202 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5203 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5204 |
return EXIT_OOPS |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
5205 |
except api_errors.CorruptedIndexException: |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
5206 |
error("The search index appears corrupted. Please rebuild the " |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
5207 |
"index with 'pkg rebuild-index'.", cmd="rebuild-index") |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5208 |
return EXIT_OOPS |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
5209 |
except api_errors.ProblematicPermissionsIndexException, e: |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
5210 |
error(str(e)) |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
5211 |
error(_("\n(Failure to consistently execute pkg commands as a " |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
5212 |
"privileged user is often a source of this problem.)")) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5213 |
return EXIT_OOPS |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5214 |
else: |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5215 |
return EXIT_OK |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5216 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5217 |
def history_list(api_inst, args): |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5218 |
"""Display history about the current image. |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5219 |
""" |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5220 |
# define column name, header, field width and <History> attribute name |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5221 |
# we compute 'reason' and 'time' columns ourselves |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5222 |
history_cols = { |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5223 |
"be": (_("BE"), "%-20s", "operation_be"), |
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5224 |
"be_uuid": (_("BE UUID"), "%-41s", "operation_be_uuid"), |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5225 |
"client": (_("CLIENT"), "%-19s", "client_name"), |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5226 |
"client_ver": (_("VERSION"), "%-15s", "client_version"), |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5227 |
"command": (_("COMMAND"), "%s", "client_args"), |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5228 |
"finish": (_("FINISH"), "%-25s", "operation_end_time"), |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5229 |
"id": (_("ID"), "%-10s", "operation_userid"), |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5230 |
"new_be": (_("NEW BE"), "%-20s", "operation_new_be"), |
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5231 |
"new_be_uuid": (_("NEW BE UUID"), "%-41s", "operation_new_be_uuid"), |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5232 |
"operation": (_("OPERATION"), "%-25s", "operation_name"), |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5233 |
"outcome": (_("OUTCOME"), "%-12s", "operation_result"), |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5234 |
"reason": (_("REASON"), "%-10s", None), |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5235 |
"snapshot": (_("SNAPSHOT"), "%-20s", "operation_snapshot"), |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5236 |
"start": (_("START"), "%-25s", "operation_start_time"), |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5237 |
"time": (_("TIME"), "%-10s", None), |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5238 |
"user": (_("USER"), "%-10s", "operation_username"), |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5239 |
# omitting start state, end state, errors for now |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5240 |
# as these don't nicely fit into columns |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5241 |
} |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5242 |
|
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5243 |
omit_headers = False |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5244 |
long_format = False |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5245 |
column_format = False |
1889
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5246 |
display_limit = None # Infinite |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5247 |
time_vals = [] # list of timestamps for which we want history events |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5248 |
columns = ["start", "operation", "client", "outcome"] |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5249 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5250 |
# XXX history should be accessible through pkg.client.api |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5251 |
if not os.path.exists(img.history.path): |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5252 |
# Nothing to display. |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5253 |
return EXIT_OK |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5254 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5255 |
opts, pargs = getopt.getopt(args, "Hln:o:t:") |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5256 |
for opt, arg in opts: |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5257 |
if opt == "-H": |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5258 |
omit_headers = True |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5259 |
elif opt == "-l": |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5260 |
long_format = True |
1889
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5261 |
elif opt == "-n": |
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5262 |
try: |
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5263 |
display_limit = int(arg) |
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5264 |
except ValueError: |
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5265 |
logger.error( |
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5266 |
_("Argument to -n must be numeric")) |
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5267 |
return EXIT_BADOPT |
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5268 |
|
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5269 |
if display_limit <= 0: |
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5270 |
logger.error( |
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5271 |
_("Argument to -n must be positive")) |
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5272 |
return EXIT_BADOPT |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5273 |
elif opt == "-o": |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5274 |
column_format = True |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5275 |
columns = arg.split(",") |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5276 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5277 |
# 'command' and 'reason' are multi-field columns, we |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5278 |
# insist they be the last item in the -o output, |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5279 |
# otherwise scripts could be broken by different numbers |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5280 |
# of output fields |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5281 |
if "command" in columns and "reason" in columns: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5282 |
# Translators: 'command' and 'reason' are |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5283 |
# keywords and should not be translated |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5284 |
logger.error(_("'command' and 'reason' columns " |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5285 |
"cannot be used together.")) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5286 |
return EXIT_BADOPT |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5287 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5288 |
for col in ["command", "reason"]: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5289 |
if col in columns and \ |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5290 |
columns.index(col) != len(columns) - 1: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5291 |
logger.error( |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5292 |
_("The '%s' column must be the " |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5293 |
"last item in the -o list") % col) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5294 |
return EXIT_BADOPT |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5295 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5296 |
for col in columns: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5297 |
if col not in history_cols: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5298 |
logger.error( |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5299 |
_("Unknown output column '%s'") % |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5300 |
col) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5301 |
return EXIT_BADOPT |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5302 |
if not __unique_columns(columns): |
2183
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
5303 |
return EXIT_BADOPT |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5304 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5305 |
elif opt == "-t": |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5306 |
time_vals = arg.split(",") |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5307 |
# make entries a set to cope with multiple overlapping |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5308 |
# ranges or time values |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5309 |
entries = set() |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5310 |
for time_val in time_vals: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5311 |
try: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5312 |
# used for the 'now' alias, we calculate |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5313 |
# this once only |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5314 |
utc_now = datetime.datetime.utcnow().strftime( |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5315 |
"%Y%m%dT%H%M%SZ") |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5316 |
files = __get_history_paths(time_val, |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5317 |
img.history.path, utc_now) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5318 |
if files == EXIT_BADOPT: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5319 |
return EXIT_BADOPT |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5320 |
entries.update(files) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5321 |
except ValueError: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5322 |
logger.error(_("Invalid time format " |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5323 |
"'%s'. Please use " |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5324 |
"%%Y-%%m-%%dT%%H:%%M:%%S or\n" |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5325 |
"%%Y-%%m-%%dT%%H:%%M:%%S-%%Y-%%m-%%dT%%H:%%M:%%S" |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5326 |
) % time_val) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5327 |
return EXIT_BADOPT |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5328 |
entries = sorted(entries) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5329 |
|
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5330 |
if omit_headers and long_format: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
5331 |
usage(_("-H and -l may not be combined"), cmd="history") |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5332 |
|
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5333 |
if column_format and long_format: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5334 |
usage(_("-o and -l may not be combined"), cmd="history") |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5335 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5336 |
if time_vals and display_limit: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5337 |
usage(_("-n and -t may not be combined"), cmd="history") |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5338 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5339 |
history_fmt = None |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5340 |
|
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5341 |
if not long_format: |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5342 |
headers = [] |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5343 |
# build our format string |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5344 |
for col in columns: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5345 |
# no need for trailing space for our last column |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5346 |
if columns.index(col) == len(columns) - 1: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5347 |
fmt = "%s" |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5348 |
else: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5349 |
fmt = history_cols[col][1] |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5350 |
if history_fmt: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5351 |
history_fmt = "%s%s" % (history_fmt, fmt) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5352 |
else: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5353 |
history_fmt = "%s" % fmt |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5354 |
headers.append(history_cols[col][0]) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5355 |
if not omit_headers: |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5356 |
msg(history_fmt % tuple(headers)) |
732
9ea802fef2fb
3540 client should be resilient against corrupt history
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
727
diff
changeset
|
5357 |
|
1889
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5358 |
if display_limit: |
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5359 |
n = -display_limit |
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5360 |
entries = sorted(os.listdir(img.history.path))[n:] |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5361 |
elif not time_vals: |
1889
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5362 |
entries = sorted(os.listdir(img.history.path)) |
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5363 |
|
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5364 |
uuid_be_dic = bootenv.BootEnv.get_uuid_be_dic() |
1889
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5365 |
for entry in entries: |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5366 |
# Load the history entry. |
732
9ea802fef2fb
3540 client should be resilient against corrupt history
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
727
diff
changeset
|
5367 |
try: |
9ea802fef2fb
3540 client should be resilient against corrupt history
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
727
diff
changeset
|
5368 |
he = history.History(root_dir=img.history.root_dir, |
9ea802fef2fb
3540 client should be resilient against corrupt history
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
727
diff
changeset
|
5369 |
filename=entry) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
5370 |
except api_errors.PermissionsException, e: |
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
5371 |
error(e, cmd="history") |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5372 |
return EXIT_OOPS |
732
9ea802fef2fb
3540 client should be resilient against corrupt history
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
727
diff
changeset
|
5373 |
except history.HistoryLoadException, e: |
9ea802fef2fb
3540 client should be resilient against corrupt history
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
727
diff
changeset
|
5374 |
if e.parse_failure: |
9ea802fef2fb
3540 client should be resilient against corrupt history
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
727
diff
changeset
|
5375 |
# Ignore corrupt entries. |
9ea802fef2fb
3540 client should be resilient against corrupt history
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
727
diff
changeset
|
5376 |
continue |
9ea802fef2fb
3540 client should be resilient against corrupt history
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
727
diff
changeset
|
5377 |
raise |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5378 |
|
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5379 |
# populate a dictionary containing our output |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5380 |
output = {} |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5381 |
for col in history_cols: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5382 |
if not history_cols[col][2]: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5383 |
continue |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5384 |
output[col] = he.__getattribute__(history_cols[col][2]) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5385 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5386 |
# format some of the History object attributes ourselves |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5387 |
output["start"] = misc.timestamp_to_time( |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5388 |
he.operation_start_time) |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5389 |
output["start"] = datetime.datetime.fromtimestamp( |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5390 |
output["start"]).isoformat() |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5391 |
output["finish"] = misc.timestamp_to_time( |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5392 |
he.operation_end_time) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5393 |
output["finish"] = datetime.datetime.fromtimestamp( |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5394 |
output["finish"]).isoformat() |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5395 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5396 |
dt_start = misc.timestamp_to_datetime(he.operation_start_time) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5397 |
dt_end = misc.timestamp_to_datetime(he.operation_end_time) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5398 |
if dt_start > dt_end: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5399 |
error(_("History operation appeared to end before it " |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5400 |
"started. Start time: %(start_time)s, " |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5401 |
"End time: %(end_time)s") % |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5402 |
(output["start"], output["finish"]), cmd="history") |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5403 |
return EXIT_OOPS |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5404 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5405 |
output["time"] = dt_end - dt_start |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5406 |
# This should never happen. We can't use timedelta's str() |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5407 |
# method, since it prints eg. "4 days, 3:12:54" breaking our |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5408 |
# field separation, so we need to do this by hand. |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5409 |
if output["time"].days > 0: |
2154
68e263d9287c
17417 t_pkg_history test unnecessarily wants a unique timestamp
Tim Foster <tim.s.foster@oracle.com>
parents:
2151
diff
changeset
|
5410 |
total_time = output["time"] |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5411 |
secs = total_time.seconds |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5412 |
add_hrs = total_time.days * 24 |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5413 |
mins, secs = divmod(secs, 60) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5414 |
hrs, mins = divmod(mins, 60) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5415 |
output["time"] = "%s:%s:%s" % \ |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5416 |
(add_hrs + hrs, mins, secs) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5417 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5418 |
output["be"] = he.operation_be |
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5419 |
be_uuid = he.operation_be_uuid |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5420 |
output["command"] = " ".join(he.client_args) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5421 |
output["new_be"] = he.operation_new_be |
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5422 |
new_be_uuid = he.operation_new_be_uuid |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5423 |
|
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5424 |
# lookup be and new_be names from the saved uuid, in case |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5425 |
# the boot environment names have changed since we stored the |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5426 |
# History object. Where we weren't able to lookup the current |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5427 |
# name, add a '*' to the entry, indicating the boot environment |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5428 |
# is no longer present |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5429 |
if be_uuid in uuid_be_dic: |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5430 |
output["be"] = uuid_be_dic[be_uuid] |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5431 |
elif be_uuid: |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5432 |
output["be"] = "%s*" % output["be"] |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5433 |
|
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5434 |
if new_be_uuid in uuid_be_dic: |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5435 |
output["new_be"] = uuid_be_dic[new_be_uuid] |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5436 |
elif new_be_uuid: |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5437 |
output["new_be"] = "%s*" % output["new_be"] |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5438 |
|
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5439 |
output["outcome"] = history.result_l10n[he.operation_result[0]] |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5440 |
output["reason"] = history.result_l10n[he.operation_result[1]] |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5441 |
output["snapshot"] = he.operation_snapshot |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5442 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5443 |
# be, snapshot and new_be use values in parenthesis |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5444 |
# since these cannot appear in valid BE or snapshot names |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5445 |
if not output["be"]: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5446 |
output["be"] = _("(Unknown)") |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5447 |
|
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5448 |
if not output["be_uuid"]: |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5449 |
output["be_uuid"] = _("(Unknown)") |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5450 |
|
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5451 |
if not output["snapshot"]: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5452 |
output["snapshot"] = _("(None)") |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5453 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5454 |
if not output["new_be"]: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5455 |
output["new_be"] = _("(None)") |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5456 |
|
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5457 |
if not output["new_be_uuid"]: |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5458 |
output["new_be_uuid"] = _("(None)") |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5459 |
|
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5460 |
if long_format: |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5461 |
data = __get_long_history_data(he, output) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5462 |
for field, value in data: |
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5463 |
msg("%18s: %s" % (field, value)) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5464 |
|
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5465 |
# Separate log entries with a blank line. |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5466 |
msg("") |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5467 |
else: |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5468 |
items = [] |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5469 |
for col in columns: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5470 |
items.append(output[col]) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5471 |
msg(history_fmt % tuple(items)) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5472 |
return EXIT_OK |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5473 |
|
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5474 |
def __get_history_paths(time_val, history_path, utc_now): |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5475 |
"""Given a local timestamp, either as a discrete value, or a range of |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5476 |
values, formatted as '<timestamp>-<timestamp>', and a path to find |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5477 |
history xml files, return an array of paths that match that timestamp. |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5478 |
utc_now is the current time expressed in UTC""" |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5479 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5480 |
files = [] |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5481 |
if len(time_val) > 20 or time_val.startswith("now-"): |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5482 |
if time_val.startswith("now-"): |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5483 |
start = utc_now |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5484 |
finish = __utc_format(time_val[4:], utc_now) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5485 |
else: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5486 |
# our ranges are 19 chars of timestamp, a '-', and |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5487 |
# another timestamp |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5488 |
start = __utc_format(time_val[:19], utc_now) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5489 |
finish = __utc_format(time_val[20:], utc_now) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5490 |
if start > finish: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5491 |
logger.error(_("Start time must be older than finish " |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5492 |
"time: %s") % time_val) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5493 |
return EXIT_BADOPT |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5494 |
files = __get_history_range(history_path, start, finish) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5495 |
else: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5496 |
# there can be multiple event files per timestamp |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5497 |
prefix = __utc_format(time_val, utc_now) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5498 |
files = glob.glob(os.path.join(history_path, "%s*" % prefix)) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5499 |
if not files: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5500 |
logger.error(_("No history entries found for %s") % time_val) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5501 |
return EXIT_BADOPT |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5502 |
return files |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5503 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5504 |
def __unique_columns(columns): |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5505 |
"""Return true if each entry in the provided list of columns only |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5506 |
appears once.""" |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5507 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5508 |
seen_cols = set() |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5509 |
dup_cols = set() |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5510 |
for col in columns: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5511 |
if col in seen_cols: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5512 |
dup_cols.add(col) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5513 |
seen_cols.add(col) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5514 |
for col in dup_cols: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5515 |
logger.error(_("Duplicate column specified: %s") % col) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5516 |
return not dup_cols |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5517 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5518 |
def __utc_format(time_str, utc_now): |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5519 |
""" Given a local time value string, formatted with "%Y-%m-%dT%H:%M:%S, |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5520 |
return a UTC representation of that value, formatted with |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5521 |
%Y%m%dT%H%M%SZ. This raises a ValueError if the time was incorrectly |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5522 |
formatted. If the time_str is "now", we return the value of utc_now""" |
2183
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
5523 |
|
21ae45e8dfcf
17581 There should be a way of removing a package as part of upgrade
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2179
diff
changeset
|
5524 |
if time_str == "now": |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5525 |
return utc_now |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5526 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5527 |
local_dt = datetime.datetime.strptime(time_str, "%Y-%m-%dT%H:%M:%S") |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5528 |
secs = time.mktime(local_dt.timetuple()) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5529 |
utc_dt = datetime.datetime.utcfromtimestamp(secs) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5530 |
return utc_dt.strftime("%Y%m%dT%H%M%SZ") |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5531 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5532 |
def __get_history_range(path, start, finish): |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5533 |
"""Given an img.history.path and start and finish dates, formatted |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5534 |
as UTC date strings as per __utc_format(), return a list of history |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5535 |
file names that fall within that date range. A range of two equal |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5536 |
dates is equivalent of just retrieving history for that single |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5537 |
date string.""" |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5538 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5539 |
entries = [] |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5540 |
all_entries = sorted(os.listdir(path)) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5541 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5542 |
for entry in all_entries: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5543 |
# our timestamps are always 16 character datestamps |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5544 |
basename = os.path.basename(entry)[:16] |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5545 |
if basename >= start: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5546 |
if basename > finish: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5547 |
# we can stop looking now. |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5548 |
break |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5549 |
entries.append(entry) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5550 |
return entries |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5551 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5552 |
def __get_long_history_data(he, hist_info): |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5553 |
"""Return an array of tuples containing long_format history info""" |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5554 |
data = [] |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5555 |
data.append((_("Operation"), hist_info["operation"])) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5556 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5557 |
data.append((_("Outcome"), hist_info["outcome"])) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5558 |
data.append((_("Reason"), hist_info["reason"])) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5559 |
data.append((_("Client"), hist_info["client"])) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5560 |
data.append((_("Version"), hist_info["client_ver"])) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5561 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5562 |
data.append((_("User"), "%s (%s)" % (hist_info["user"], |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5563 |
hist_info["id"]))) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5564 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5565 |
if hist_info["be"]: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5566 |
data.append((_("Boot Env."), hist_info["be"])) |
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5567 |
if hist_info["be_uuid"]: |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5568 |
data.append((_("Boot Env. UUID"), hist_info["be_uuid"])) |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5569 |
if hist_info["new_be"]: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5570 |
data.append((_("New Boot Env."), hist_info["new_be"])) |
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5571 |
if hist_info["new_be_uuid"]: |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5572 |
data.append((_("New Boot Env. UUID"), |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5573 |
hist_info["new_be_uuid"])) |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5574 |
if hist_info["snapshot"]: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5575 |
data.append((_("Snapshot"), hist_info["snapshot"])) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5576 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5577 |
data.append((_("Start Time"), hist_info["start"])) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5578 |
data.append((_("End Time"), hist_info["finish"])) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5579 |
data.append((_("Total Time"), hist_info["time"])) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5580 |
data.append((_("Command"), hist_info["command"])) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5581 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5582 |
state = he.operation_start_state |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5583 |
if state: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5584 |
data.append((_("Start State"), "\n" + state)) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5585 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5586 |
state = he.operation_end_state |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5587 |
if state: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5588 |
data.append((_("End State"), "\n" + state)) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5589 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5590 |
errors = "\n".join(he.operation_errors) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5591 |
if errors: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5592 |
data.append((_("Errors"), "\n" + errors)) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5593 |
return data |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5594 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5595 |
def history_purge(api_inst, pargs): |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5596 |
"""Purge image history""" |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5597 |
|
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5598 |
# history should be accessible through pkg.client.api |
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5599 |
be_name, be_uuid = bootenv.BootEnv.get_be_name(img.root) |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5600 |
ret_code = img.history.purge( |
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5601 |
be_name=be_name, be_uuid=be_uuid) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5602 |
if ret_code == EXIT_OK: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5603 |
msg(_("History purged.")) |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5604 |
return ret_code |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5605 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5606 |
def print_proxy_config(): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5607 |
"""If the user has configured http_proxy or https_proxy in the |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5608 |
environment, print out the values. Some transport errors are |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5609 |
not debuggable without this information handy.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5610 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5611 |
http_proxy = os.environ.get("http_proxy", None) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5612 |
https_proxy = os.environ.get("https_proxy", None) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5613 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5614 |
if not http_proxy and not https_proxy: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5615 |
return |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5616 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
5617 |
logger.error(_("\nThe following proxy configuration is set in the" |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5618 |
" environment:\n")) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5619 |
if http_proxy: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
5620 |
logger.error(_("http_proxy: %s\n") % http_proxy) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5621 |
if https_proxy: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
5622 |
logger.error(_("https_proxy: %s\n") % https_proxy) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5623 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5624 |
def update_format(api_inst, pargs): |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5625 |
"""Update image to newest format.""" |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5626 |
|
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5627 |
try: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5628 |
res = api_inst.update_format() |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5629 |
except api_errors.ApiException, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5630 |
error(str(e), cmd="update-format") |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5631 |
return EXIT_OOPS |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5632 |
|
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5633 |
if res: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5634 |
logger.info(_("Image format updated.")) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5635 |
return EXIT_OK |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5636 |
|
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5637 |
logger.info(_("Image format already current.")) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5638 |
return EXIT_NOP |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5639 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5640 |
def print_version(pargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5641 |
if pargs: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5642 |
usage(_("version: command does not take operands ('%s')") % |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5643 |
" ".join(pargs), cmd="version") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5644 |
msg(pkg.VERSION) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5645 |
return EXIT_OK |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5646 |
|
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5647 |
# To allow exception handler access to the image. |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5648 |
img = None |
1752
b62d86fb62c8
14515 client can traceback during search
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
5649 |
orig_cwd = None |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
427
diff
changeset
|
5650 |
|
242
7bd1830635c8
402 Start on some pylint cleanup, and fix missing imports
Dan Price <dp@eng.sun.com>
parents:
239
diff
changeset
|
5651 |
def main_func(): |
696
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
693
diff
changeset
|
5652 |
global_settings.client_name = PKG_CLIENT_NAME |
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
693
diff
changeset
|
5653 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5654 |
global img |
1687
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
5655 |
global orig_cwd |
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
5656 |
|
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
5657 |
try: |
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
5658 |
orig_cwd = os.getcwd() |
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
5659 |
except OSError, e: |
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
5660 |
try: |
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
5661 |
orig_cwd = os.environ["PWD"] |
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
5662 |
if not orig_cwd or orig_cwd[0] != "/": |
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
5663 |
orig_cwd = None |
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
5664 |
except KeyError: |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5665 |
orig_cwd = None |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
5666 |
|
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
5667 |
try: |
934
f36f3c3d9666
7277 client should use --help and -? options to show usage information
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
930
diff
changeset
|
5668 |
opts, pargs = getopt.getopt(sys.argv[1:], "R:D:?", |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5669 |
["debug=", "help", "runid="]) |
52
d7c452ef7ae1
Sanitize getopt exception handling
Danek Duvall <danek.duvall@sun.com>
parents:
50
diff
changeset
|
5670 |
except getopt.GetoptError, e: |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
5671 |
usage(_("illegal global option -- %s") % e.opt) |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
5672 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5673 |
runid = os.getpid() |
934
f36f3c3d9666
7277 client should use --help and -? options to show usage information
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
930
diff
changeset
|
5674 |
show_usage = False |
584
22bc748edce6
577 need service action for smf(5) manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
583
diff
changeset
|
5675 |
for opt, arg in opts: |
22bc748edce6
577 need service action for smf(5) manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
583
diff
changeset
|
5676 |
if opt == "-D" or opt == "--debug": |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5677 |
if arg in ["plan", "transport"]: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5678 |
key = arg |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5679 |
value = "True" |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5680 |
else: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5681 |
try: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5682 |
key, value = arg.split("=", 1) |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5683 |
except (AttributeError, ValueError): |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5684 |
usage(_("%(opt)s takes argument of form " |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
5685 |
"name=value, not %(arg)s") % { |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
5686 |
"opt": opt, "arg": arg }) |
584
22bc748edce6
577 need service action for smf(5) manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
583
diff
changeset
|
5687 |
DebugValues.set_value(key, value) |
22bc748edce6
577 need service action for smf(5) manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
583
diff
changeset
|
5688 |
elif opt == "-R": |
22bc748edce6
577 need service action for smf(5) manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
583
diff
changeset
|
5689 |
mydir = arg |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5690 |
elif opt == "--runid": |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5691 |
runid = arg |
934
f36f3c3d9666
7277 client should use --help and -? options to show usage information
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
930
diff
changeset
|
5692 |
elif opt in ("--help", "-?"): |
f36f3c3d9666
7277 client should use --help and -? options to show usage information
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
930
diff
changeset
|
5693 |
show_usage = True |
584
22bc748edce6
577 need service action for smf(5) manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
583
diff
changeset
|
5694 |
|
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5695 |
# placeholders in this lookup table for image-create, help and version |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5696 |
# which don't have dedicated methods |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5697 |
cmds = { |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5698 |
"add-property-value" : (property_add_value, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5699 |
"attach-linked" : (attach_linked, opts_attach_linked, 2), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5700 |
"avoid" : (avoid, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5701 |
"audit-linked" : (audit_linked, opts_audit_linked), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5702 |
"authority" : (publisher_list, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5703 |
"change-facet" : (change_facet, opts_install, -1), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5704 |
"change-variant" : (change_variant, opts_install, -1), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5705 |
"contents" : (list_contents, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5706 |
"detach-linked" : (detach_linked, opts_detach_linked), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5707 |
"facet" : (facet_list, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5708 |
"fix" : (fix_image, None), |
2452
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
5709 |
"freeze" : (freeze, None), |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5710 |
"help" : (None, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5711 |
"history" : (history_list, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5712 |
"image-create" : (None, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5713 |
"info" : (info, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5714 |
"install" : (install, opts_install, -1), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5715 |
"list" : (list_inventory, opts_list_inventory, -1), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5716 |
"list-linked" : (list_linked, opts_list_linked), |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
5717 |
"mediator" : (list_mediators, opts_list_mediator, -1), |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5718 |
"property" : (property_list, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5719 |
"property-linked" : (list_property_linked, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5720 |
opts_list_property_linked, -1), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5721 |
"publisher" : (publisher_list, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5722 |
"purge-history" : (history_purge, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5723 |
"rebuild-index" : (rebuild_index, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5724 |
"refresh" : (publisher_refresh, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5725 |
"remove-property-value" : (property_remove_value, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5726 |
"revert" : (revert, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5727 |
"search" : (search, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5728 |
"set-authority" : (publisher_set, None), |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
5729 |
"set-mediator" : (set_mediator, opts_set_mediator, -1), |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5730 |
"set-property" : (property_set, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5731 |
"set-property-linked" : (set_property_linked, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5732 |
opts_set_property_linked, -1), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5733 |
"set-publisher" : (publisher_set, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5734 |
"sync-linked" : (sync_linked, opts_sync_linked), |
2452
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
5735 |
"unavoid" : (unavoid, None), |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
5736 |
"unfreeze" : (unfreeze, None), |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5737 |
"uninstall" : (uninstall, opts_uninstall, -1), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5738 |
"unset-authority" : (publisher_unset, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5739 |
"unset-property" : (property_unset, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5740 |
"update-format" : (update_format, None), |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
5741 |
"unset-mediator" : (unset_mediator, opts_unset_mediator, -1), |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5742 |
"unset-publisher" : (publisher_unset, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5743 |
"update" : (update, opts_update, -1), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5744 |
"update-format" : (update_format, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5745 |
"variant" : (variant_list, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5746 |
"verify" : (verify_image, None), |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5747 |
"version" : (None, None), |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5748 |
} |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5749 |
|
934
f36f3c3d9666
7277 client should use --help and -? options to show usage information
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
930
diff
changeset
|
5750 |
subcommand = None |
f36f3c3d9666
7277 client should use --help and -? options to show usage information
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
930
diff
changeset
|
5751 |
if pargs: |
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
5752 |
subcommand = pargs.pop(0) |
2133
889800a7c96b
17360 client will traceback if -h is passed for image-update
Shawn Walker <shawn.walker@oracle.com>
parents:
2126
diff
changeset
|
5753 |
# 'image-update' is an alias for 'update' for compatibility. |
889800a7c96b
17360 client will traceback if -h is passed for image-update
Shawn Walker <shawn.walker@oracle.com>
parents:
2126
diff
changeset
|
5754 |
subcommand = subcommand.replace("image-update", "update") |
934
f36f3c3d9666
7277 client should use --help and -? options to show usage information
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
930
diff
changeset
|
5755 |
if subcommand == "help": |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5756 |
if pargs: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5757 |
sub = pargs.pop(0) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5758 |
if sub in cmds and \ |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5759 |
sub not in ["help", "-?", "--help"]: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5760 |
usage(retcode=0, full=False, cmd=sub) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5761 |
elif sub not in ["help", "-?", "--help"]: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5762 |
usage(_("unknown subcommand '%s'") % |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5763 |
sub, full=True) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5764 |
else: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5765 |
usage(retcode=0, full=True) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5766 |
else: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5767 |
usage(retcode=0, full=True) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5768 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5769 |
# A gauntlet of tests to see if we need to print usage information |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5770 |
if subcommand in cmds and show_usage: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5771 |
usage(retcode=0, cmd=subcommand, full=False) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5772 |
if subcommand and subcommand not in cmds: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5773 |
usage(_("unknown subcommand '%s'") % subcommand, full=True) |
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
5774 |
if show_usage: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
5775 |
usage(retcode=0, full=True) |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5776 |
if not subcommand: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
5777 |
usage(_("no subcommand specified")) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5778 |
if runid: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5779 |
try: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5780 |
runid = int(runid) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5781 |
except: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5782 |
usage(_("runid must be an integer")) |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
5783 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5784 |
for opt in ["--help", "-?"]: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5785 |
if opt in pargs: |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5786 |
usage(retcode=0, full=False, cmd=subcommand) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5787 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5788 |
# This call only affects sockets created by Python. The transport |
1218
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
5789 |
# framework uses the defaults in global_settings, which may be |
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
5790 |
# overridden in the environment. The default socket module should |
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
5791 |
# only be used in rare cases by ancillary code, making it safe to |
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
5792 |
# code the value here, at least for now. |
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
5793 |
socket.setdefaulttimeout(30) # in secs |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5794 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5795 |
cmds_no_image = { |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5796 |
"version" : print_version, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5797 |
"image-create" : image_create, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5798 |
} |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5799 |
func = cmds_no_image.get(subcommand, None) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5800 |
if func: |
584
22bc748edce6
577 need service action for smf(5) manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
583
diff
changeset
|
5801 |
if "mydir" in locals(): |
789
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
5802 |
usage(_("-R not allowed for %s subcommand") % |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
5803 |
subcommand, cmd=subcommand) |
221
e1dbb27a23b5
52 catalog can leave inventory behind, making pkg(1) blind
Stephen Hahn <sch@Sun.COM>
parents:
219
diff
changeset
|
5804 |
try: |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5805 |
ret = func(pargs) |
221
e1dbb27a23b5
52 catalog can leave inventory behind, making pkg(1) blind
Stephen Hahn <sch@Sun.COM>
parents:
219
diff
changeset
|
5806 |
except getopt.GetoptError, e: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
5807 |
usage(_("illegal option -- %s") % e.opt, cmd=subcommand) |
221
e1dbb27a23b5
52 catalog can leave inventory behind, making pkg(1) blind
Stephen Hahn <sch@Sun.COM>
parents:
219
diff
changeset
|
5808 |
return ret |
50 | 5809 |
|
561
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
556
diff
changeset
|
5810 |
provided_image_dir = True |
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
556
diff
changeset
|
5811 |
pkg_image_used = False |
242
7bd1830635c8
402 Start on some pylint cleanup, and fix missing imports
Dan Price <dp@eng.sun.com>
parents:
239
diff
changeset
|
5812 |
if "mydir" not in locals(): |
2488
010931d9cabe
18688 pkg clients shouldn't attempt to find an image at startup
Shawn Walker <shawn.walker@oracle.com>
parents:
2482
diff
changeset
|
5813 |
mydir, provided_image_dir = api.get_default_image_root( |
010931d9cabe
18688 pkg clients shouldn't attempt to find an image at startup
Shawn Walker <shawn.walker@oracle.com>
parents:
2482
diff
changeset
|
5814 |
orig_cwd=orig_cwd) |
010931d9cabe
18688 pkg clients shouldn't attempt to find an image at startup
Shawn Walker <shawn.walker@oracle.com>
parents:
2482
diff
changeset
|
5815 |
if os.environ.get("PKG_IMAGE"): |
010931d9cabe
18688 pkg clients shouldn't attempt to find an image at startup
Shawn Walker <shawn.walker@oracle.com>
parents:
2482
diff
changeset
|
5816 |
# It's assumed that this has been checked by the above |
010931d9cabe
18688 pkg clients shouldn't attempt to find an image at startup
Shawn Walker <shawn.walker@oracle.com>
parents:
2482
diff
changeset
|
5817 |
# function call and hasn't been removed from the |
010931d9cabe
18688 pkg clients shouldn't attempt to find an image at startup
Shawn Walker <shawn.walker@oracle.com>
parents:
2482
diff
changeset
|
5818 |
# environment. |
561
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
556
diff
changeset
|
5819 |
pkg_image_used = True |
2488
010931d9cabe
18688 pkg clients shouldn't attempt to find an image at startup
Shawn Walker <shawn.walker@oracle.com>
parents:
2482
diff
changeset
|
5820 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5821 |
if not mydir: |
515
888fa3187f68
2964 better error handling may be needed when working directory does not exist
Danek Duvall <danek.duvall@sun.com>
parents:
499
diff
changeset
|
5822 |
error(_("Could not find image. Use the -R option or set " |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5823 |
"$PKG_IMAGE to the\nlocation of an image.")) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5824 |
return EXIT_OOPS |
63
ba3a4af65479
add -R/$PKG_IMAGE to pkg, and -n and -v to install
Danek Duvall <danek.duvall@sun.com>
parents:
60
diff
changeset
|
5825 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5826 |
# Get ImageInterface and image object. |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5827 |
api_inst = __api_alloc(mydir, provided_image_dir, pkg_image_used, False, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5828 |
runid=runid) |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5829 |
if api_inst is None: |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5830 |
return EXIT_OOPS |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5831 |
img = api_inst.img |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5832 |
|
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5833 |
# Find subcommand and execute operation. |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5834 |
pargs_limit = 0 |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5835 |
func = cmds[subcommand][0] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5836 |
opts_cmd = cmds[subcommand][1] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5837 |
if len(cmds[subcommand]) > 2: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5838 |
pargs_limit = cmds[subcommand][2] |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
5839 |
try: |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5840 |
if opts_cmd == None: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5841 |
return func(api_inst, pargs) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5842 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5843 |
opts, pargs = misc.opts_parse(subcommand, api_inst, pargs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5844 |
opts_cmd, pargs_limit, usage) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5845 |
return func(op=subcommand, api_inst=api_inst, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5846 |
pargs=pargs, **opts) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5847 |
|
192
0c6f1066777b
58 getopt handling needs cleanup
Dan Price <dp@eng.sun.com>
parents:
177
diff
changeset
|
5848 |
except getopt.GetoptError, e: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
5849 |
usage(_("illegal option -- %s") % e.opt, cmd=subcommand) |
192
0c6f1066777b
58 getopt handling needs cleanup
Dan Price <dp@eng.sun.com>
parents:
177
diff
changeset
|
5850 |
|
0c6f1066777b
58 getopt handling needs cleanup
Dan Price <dp@eng.sun.com>
parents:
177
diff
changeset
|
5851 |
# |
0c6f1066777b
58 getopt handling needs cleanup
Dan Price <dp@eng.sun.com>
parents:
177
diff
changeset
|
5852 |
# Establish a specific exit status which means: "python barfed an exception" |
0c6f1066777b
58 getopt handling needs cleanup
Dan Price <dp@eng.sun.com>
parents:
177
diff
changeset
|
5853 |
# so that we can more easily detect these in testing of the CLI commands. |
0c6f1066777b
58 getopt handling needs cleanup
Dan Price <dp@eng.sun.com>
parents:
177
diff
changeset
|
5854 |
# |
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5855 |
def handle_errors(func, non_wrap_print=True, *args, **kwargs): |
2126
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
5856 |
traceback_str = _("""\n |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
5857 |
This is an internal error in pkg(5) version %(version)s. Please let the |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
5858 |
developers know about this problem by including the information above (and |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
5859 |
this message) when filing a bug at: |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
5860 |
|
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
5861 |
%(bug_uri)s""") % { "version": pkg.VERSION, "bug_uri": misc.BUG_URI_CLI } |
7f6719cd083b
14316 please suggest the proper classification and product in the pkg error message
Shawn Walker <shawn.walker@oracle.com>
parents:
2107
diff
changeset
|
5862 |
|
221
e1dbb27a23b5
52 catalog can leave inventory behind, making pkg(1) blind
Stephen Hahn <sch@Sun.COM>
parents:
219
diff
changeset
|
5863 |
try: |
1035
0e243b7eb121
2297 top level error handler for out of memory conditions needed
Danek Duvall <danek.duvall@sun.com>
parents:
1023
diff
changeset
|
5864 |
# Out of memory errors can be raised as EnvironmentErrors with |
0e243b7eb121
2297 top level error handler for out of memory conditions needed
Danek Duvall <danek.duvall@sun.com>
parents:
1023
diff
changeset
|
5865 |
# an errno of ENOMEM, so in order to handle those exceptions |
0e243b7eb121
2297 top level error handler for out of memory conditions needed
Danek Duvall <danek.duvall@sun.com>
parents:
1023
diff
changeset
|
5866 |
# with other errnos, we nest this try block and have the outer |
0e243b7eb121
2297 top level error handler for out of memory conditions needed
Danek Duvall <danek.duvall@sun.com>
parents:
1023
diff
changeset
|
5867 |
# one handle the other instances. |
0e243b7eb121
2297 top level error handler for out of memory conditions needed
Danek Duvall <danek.duvall@sun.com>
parents:
1023
diff
changeset
|
5868 |
try: |
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5869 |
__ret = func(*args, **kwargs) |
1035
0e243b7eb121
2297 top level error handler for out of memory conditions needed
Danek Duvall <danek.duvall@sun.com>
parents:
1023
diff
changeset
|
5870 |
except (MemoryError, EnvironmentError), __e: |
0e243b7eb121
2297 top level error handler for out of memory conditions needed
Danek Duvall <danek.duvall@sun.com>
parents:
1023
diff
changeset
|
5871 |
if isinstance(__e, EnvironmentError) and \ |
0e243b7eb121
2297 top level error handler for out of memory conditions needed
Danek Duvall <danek.duvall@sun.com>
parents:
1023
diff
changeset
|
5872 |
__e.errno != errno.ENOMEM: |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
5873 |
raise |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5874 |
if img: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5875 |
img.history.abort(RESULT_FAILED_OUTOFMEMORY) |
1035
0e243b7eb121
2297 top level error handler for out of memory conditions needed
Danek Duvall <danek.duvall@sun.com>
parents:
1023
diff
changeset
|
5876 |
error("\n" + misc.out_of_memory()) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5877 |
__ret = EXIT_OOPS |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5878 |
except SystemExit, __e: |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5879 |
if img: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5880 |
img.history.abort(RESULT_FAILED_UNKNOWN) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5881 |
raise __e |
384
9d4746e5dd3e
115 pkg needs to not have a cow on a SIGPIPE
Shawn Walker <swalker@opensolaris.org>
parents:
362
diff
changeset
|
5882 |
except (PipeError, KeyboardInterrupt): |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5883 |
if img: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5884 |
img.history.abort(RESULT_CANCELED) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5885 |
# We don't want to display any messages here to prevent |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5886 |
# possible further broken pipe (EPIPE) errors. |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5887 |
__ret = EXIT_OOPS |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5888 |
except api_errors.LinkedImageException, __e: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5889 |
error(_("Linked image exception(s):\n%s") % |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5890 |
str(__e)) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5891 |
__ret = __e.lix_exitrv |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
5892 |
except api_errors.CertificateError, __e: |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5893 |
if img: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5894 |
img.history.abort(RESULT_FAILED_CONFIGURATION) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
5895 |
error(__e) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5896 |
__ret = EXIT_OOPS |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
5897 |
except api_errors.PublisherError, __e: |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5898 |
if img: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5899 |
img.history.abort(RESULT_FAILED_BAD_REQUEST) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
5900 |
error(__e) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5901 |
__ret = EXIT_OOPS |
1710
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
5902 |
except api_errors.ImageLockedError, __e: |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5903 |
if img: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5904 |
img.history.abort(RESULT_FAILED_LOCKED) |
1710
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
5905 |
error(__e) |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
5906 |
__ret = EXIT_LOCKED |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5907 |
except api_errors.TransportError, __e: |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5908 |
if img: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5909 |
img.history.abort(RESULT_FAILED_TRANSPORT) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
5910 |
logger.error(_("\nErrors were encountered while attempting " |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
5911 |
"to retrieve package or file data for\nthe requested " |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
5912 |
"operation.")) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
5913 |
logger.error(_("Details follow:\n\n%s") % __e) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5914 |
print_proxy_config() |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5915 |
__ret = EXIT_OOPS |
1658
49b8cc06eecb
13360 client can traceback if corrupt catalogs exist
Shawn Walker <srw@sun.com>
parents:
1639
diff
changeset
|
5916 |
except api_errors.InvalidCatalogFile, __e: |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5917 |
if img: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5918 |
img.history.abort(RESULT_FAILED_STORAGE) |
1658
49b8cc06eecb
13360 client can traceback if corrupt catalogs exist
Shawn Walker <srw@sun.com>
parents:
1639
diff
changeset
|
5919 |
logger.error(_(""" |
49b8cc06eecb
13360 client can traceback if corrupt catalogs exist
Shawn Walker <srw@sun.com>
parents:
1639
diff
changeset
|
5920 |
An error was encountered while attempting to read image state information |
49b8cc06eecb
13360 client can traceback if corrupt catalogs exist
Shawn Walker <srw@sun.com>
parents:
1639
diff
changeset
|
5921 |
to perform the requested operation. Details follow:\n\n%s""") % __e) |
49b8cc06eecb
13360 client can traceback if corrupt catalogs exist
Shawn Walker <srw@sun.com>
parents:
1639
diff
changeset
|
5922 |
__ret = EXIT_OOPS |
835
34ec4401dc48
686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents:
834
diff
changeset
|
5923 |
except api_errors.InvalidDepotResponseException, __e: |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5924 |
if img: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5925 |
img.history.abort(RESULT_FAILED_TRANSPORT) |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
5926 |
logger.error(_("\nUnable to contact a valid package " |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
5927 |
"repository. This may be due to a problem with the " |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
5928 |
"repository, network misconfiguration, or an incorrect " |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
5929 |
"pkg client configuration. Please verify the client's " |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
5930 |
"network configuration and repository's location.")) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
5931 |
logger.error(_("\nAdditional details:\n\n%s") % __e) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5932 |
print_proxy_config() |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5933 |
__ret = EXIT_OOPS |
569
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5934 |
except history.HistoryLoadException, __e: |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5935 |
# Since a history related error occurred, discard all |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5936 |
# information about the current operation(s) in progress. |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5937 |
if img: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5938 |
img.history.clear() |
569
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5939 |
error(_("An error was encountered while attempting to load " |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5940 |
"history information\nabout past client operations.")) |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5941 |
error(__e) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5942 |
__ret = EXIT_OOPS |
569
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5943 |
except history.HistoryStoreException, __e: |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5944 |
# Since a history related error occurred, discard all |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5945 |
# information about the current operation(s) in progress. |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5946 |
if img: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5947 |
img.history.clear() |
569
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5948 |
error(_("An error was encountered while attempting to store " |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5949 |
"information about the\ncurrent operation in client " |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5950 |
"history.")) |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5951 |
error(__e) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5952 |
__ret = EXIT_OOPS |
569
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5953 |
except history.HistoryPurgeException, __e: |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5954 |
# Since a history related error occurred, discard all |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5955 |
# information about the current operation(s) in progress. |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5956 |
if img: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5957 |
img.history.clear() |
569
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5958 |
error(_("An error was encountered while attempting to purge " |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5959 |
"client history.")) |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
5960 |
error(__e) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5961 |
__ret = EXIT_OOPS |
652
daa3a6212b76
4011 client.py would traceback on a api VersionException
Brock Pytlik <bpytlik@sun.com>
parents:
648
diff
changeset
|
5962 |
except api_errors.VersionException, __e: |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5963 |
if img: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5964 |
img.history.abort(RESULT_FAILED_UNKNOWN) |
1829
e581a205ec02
14907 references to old-style package names must be purged
Danek Duvall <danek.duvall@sun.com>
parents:
1814
diff
changeset
|
5965 |
error(_("The pkg command appears out of sync with the libraries" |
e581a205ec02
14907 references to old-style package names must be purged
Danek Duvall <danek.duvall@sun.com>
parents:
1814
diff
changeset
|
5966 |
" provided\nby pkg:/package/pkg. The client version is " |
e581a205ec02
14907 references to old-style package names must be purged
Danek Duvall <danek.duvall@sun.com>
parents:
1814
diff
changeset
|
5967 |
"%(client)s while the library\nAPI version is %(api)s.") % |
652
daa3a6212b76
4011 client.py would traceback on a api VersionException
Brock Pytlik <bpytlik@sun.com>
parents:
648
diff
changeset
|
5968 |
{'client': __e.received_version, |
daa3a6212b76
4011 client.py would traceback on a api VersionException
Brock Pytlik <bpytlik@sun.com>
parents:
648
diff
changeset
|
5969 |
'api': __e.expected_version |
daa3a6212b76
4011 client.py would traceback on a api VersionException
Brock Pytlik <bpytlik@sun.com>
parents:
648
diff
changeset
|
5970 |
}) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5971 |
__ret = EXIT_OOPS |
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5972 |
except api_errors.WrapSuccessfulIndexingException, __e: |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5973 |
__ret = EXIT_OK |
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5974 |
except api_errors.WrapIndexingException, __e: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
5975 |
def _wrapper(): |
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5976 |
raise __e.wrapped |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
5977 |
__ret = handle_errors(_wrapper, non_wrap_print=False) |
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5978 |
s = "" |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5979 |
if __ret == 99: |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5980 |
s += _("\n%s%s") % (__e, traceback_str) |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5981 |
|
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
5982 |
s += _("\n\nDespite the error while indexing, the operation " |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
5983 |
"has completed successfuly.") |
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5984 |
error(s) |
1335
3dde2385d05c
516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1328
diff
changeset
|
5985 |
except api_errors.ReadOnlyFileSystemException, __e: |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5986 |
__ret = EXIT_OOPS |
221
e1dbb27a23b5
52 catalog can leave inventory behind, making pkg(1) blind
Stephen Hahn <sch@Sun.COM>
parents:
219
diff
changeset
|
5987 |
except: |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5988 |
if img: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5989 |
img.history.abort(RESULT_FAILED_UNKNOWN) |
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5990 |
if non_wrap_print: |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5991 |
traceback.print_exc() |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5992 |
error(traceback_str) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5993 |
__ret = 99 |
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5994 |
return __ret |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5995 |
|
1286
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5996 |
if __name__ == "__main__": |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5997 |
misc.setlocale(locale.LC_ALL, "", error) |
2e5bb564a9e2
8948 search errors should make it clear that the rest of the command worked
Brock Pytlik <bpytlik@sun.com>
parents:
1280
diff
changeset
|
5998 |
gettext.install("pkg", "/usr/share/locale") |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
5999 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
6000 |
# Make all warnings be errors. |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
6001 |
import warnings |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
6002 |
warnings.simplefilter('error') |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
6003 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
6004 |
__retval = handle_errors(main_func) |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
6005 |
try: |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
6006 |
logging.shutdown() |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
6007 |
except IOError: |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
6008 |
# Ignore python's spurious pipe problems. |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
6009 |
pass |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
6010 |
sys.exit(__retval) |