author | Edward Pilatowicz <edward.pilatowicz@oracle.com> |
Mon, 16 Sep 2013 21:26:31 -0700 | |
changeset 2945 | 24196b483cc6 |
parent 2940 | 0e5359bd88dd |
child 2958 | 868e07939116 |
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 |
# |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
24 |
# Copyright (c) 2007, 2013, 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 itertools |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
54 |
import simplejson as json |
2160
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 |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
58 |
import re |
2160
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
59 |
import socket |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
60 |
import sys |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
61 |
import tempfile |
2160
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
62 |
import textwrap |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
63 |
import time |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
64 |
import traceback |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
65 |
|
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
66 |
import pkg |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
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
|
71 |
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
|
72 |
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
|
73 |
import pkg.client.publisher as publisher |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
74 |
import pkg.client.options as options |
2160
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
75 |
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
|
76 |
import pkg.misc as misc |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
77 |
import pkg.pipeutils as pipeutils |
2160
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
78 |
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
|
79 |
|
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
80 |
from pkg.client import global_settings |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
81 |
from pkg.client.api import (IMG_TYPE_ENTIRE, IMG_TYPE_PARTIAL, |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
82 |
IMG_TYPE_USER, RESULT_CANCELED, RESULT_FAILED_BAD_REQUEST, |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
83 |
RESULT_FAILED_CONFIGURATION, RESULT_FAILED_CONSTRAINED, |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
84 |
RESULT_FAILED_LOCKED, RESULT_FAILED_STORAGE, RESULT_NOTHING_TO_DO, |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
85 |
RESULT_SUCCEEDED, RESULT_FAILED_TRANSPORT, RESULT_FAILED_UNKNOWN, |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
86 |
RESULT_FAILED_OUTOFMEMORY) |
2160
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
87 |
from pkg.client.debugvalues import DebugValues |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
88 |
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
|
89 |
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
|
90 |
except KeyboardInterrupt: |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
91 |
import sys |
5ba7228b987f
10319 pkg doesn't catch interrupts during startup
Tim Foster <tim.s.foster@oracle.com>
parents:
2158
diff
changeset
|
92 |
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
|
93 |
|
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
94 |
CLIENT_API_VERSION = 75 |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
95 |
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
|
96 |
|
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
97 |
JUST_UNKNOWN = 0 |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
98 |
JUST_LEFT = -1 |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
99 |
JUST_RIGHT = 1 |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
100 |
|
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
101 |
SYSREPO_HIDDEN_URI = "<system-repository>" |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
102 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
103 |
logger = global_settings.logger |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
104 |
pkg_timer = pkg.misc.Timer("pkg client") |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
105 |
|
1563
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
106 |
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
|
107 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
108 |
valid_special_prefixes = ["action."] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
109 |
|
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
110 |
def format_update_error(e): |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
111 |
# 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
|
112 |
# ImageFormatUpdateNeeded exception is encountered. |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
113 |
logger.error("\n") |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
114 |
logger.error(str(e)) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
115 |
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
|
116 |
"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
|
117 |
"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
|
118 |
"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
|
119 |
|
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
120 |
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
|
121 |
"""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
|
122 |
|
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
|
123 |
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
|
124 |
# 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
|
125 |
text = str(text) |
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
126 |
|
497
534694fcd5b7
2678 Toplevel traceback handler should emit pkg version id
Danek Duvall <danek.duvall@sun.com>
parents:
496
diff
changeset
|
127 |
# 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
|
128 |
# *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
|
129 |
text_nows = text.lstrip() |
534694fcd5b7
2678 Toplevel traceback handler should emit pkg version id
Danek Duvall <danek.duvall@sun.com>
parents:
496
diff
changeset
|
130 |
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
|
131 |
|
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
|
132 |
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
|
133 |
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
|
134 |
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
|
135 |
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
|
136 |
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
|
137 |
|
384
9d4746e5dd3e
115 pkg needs to not have a cow on a SIGPIPE
Shawn Walker <swalker@opensolaris.org>
parents:
362
diff
changeset
|
138 |
# 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
|
139 |
# program name on all platforms. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
140 |
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
|
141 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
142 |
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
|
143 |
"""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
|
144 |
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
|
145 |
|
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
146 |
if usage_error: |
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
147 |
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
|
148 |
|
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
149 |
basic_usage = {} |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
150 |
adv_usage = {} |
2521
c2e46af6fb74
18816 pkg usage should not mention linked image commands
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2517
diff
changeset
|
151 |
priv_usage = {} |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
152 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
153 |
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
|
154 |
"version"] |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
155 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
156 |
basic_usage["install"] = _( |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
157 |
"[-nvq] [-C n] [-g path_or_uri ...] [--accept]\n" |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
158 |
" [--licenses] [--no-be-activate] [--no-index] [--no-refresh]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
159 |
" [--no-backup-be | --require-backup-be] [--backup-be-name name]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
160 |
" [--deny-new-be | --require-new-be] [--be-name name]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
161 |
" [--reject pkg_fmri_pattern ... ] pkg_fmri_pattern ...") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
162 |
basic_usage["uninstall"] = _( |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
163 |
"[-nvq] [-C n] [--no-be-activate] [--no-index]\n" |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
164 |
" [--no-backup-be | --require-backup-be] [--backup-be-name]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
165 |
" [--deny-new-be | --require-new-be] [--be-name name]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
166 |
" 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
|
167 |
basic_usage["update"] = _( |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
168 |
"[-fnvq] [-C n] [-g path_or_uri ...] [--accept]\n" |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
169 |
" [--licenses] [--no-be-activate] [--no-index] [--no-refresh]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
170 |
" [--no-backup-be | --require-backup-be] [--backup-be-name]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
171 |
" [--deny-new-be | --require-new-be] [--be-name name]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
172 |
" [--reject pkg_fmri_pattern ...] [pkg_fmri_pattern ...]") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
173 |
basic_usage["list"] = _( |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
174 |
"[-Hafnqsuv] [-g path_or_uri ...] [--no-refresh]\n" |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
175 |
" [pkg_fmri_pattern ...]") |
2719
c79aef418a22
7179317 update-refresh.sh cron job generates pkg refresh messages
Dan Price <daniel.price@oracle.com>
parents:
2716
diff
changeset
|
176 |
basic_usage["refresh"] = _("[-q] [--full] [publisher ...]") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
177 |
basic_usage["version"] = "" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
178 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
179 |
advanced_cmds = [ |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
180 |
"info", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
181 |
"contents", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
182 |
"search", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
183 |
"", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
184 |
"verify", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
185 |
"fix", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
186 |
"revert", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
187 |
"", |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
188 |
"mediator", |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
189 |
"set-mediator", |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
190 |
"unset-mediator", |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
191 |
"", |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
192 |
"variant", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
193 |
"change-variant", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
194 |
"", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
195 |
"facet", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
196 |
"change-facet", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
197 |
"", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
198 |
"avoid", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
199 |
"unavoid", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
200 |
"", |
2452
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
201 |
"freeze", |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
202 |
"unfreeze", |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
203 |
"", |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
204 |
"property", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
205 |
"set-property", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
206 |
"add-property-value", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
207 |
"remove-property-value", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
208 |
"unset-property", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
209 |
"", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
210 |
"publisher", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
211 |
"set-publisher", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
212 |
"unset-publisher", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
213 |
"", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
214 |
"history", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
215 |
"purge-history", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
216 |
"", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
217 |
"rebuild-index", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
218 |
"update-format", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
219 |
"image-create", |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
220 |
] |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
221 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
222 |
adv_usage["info"] = \ |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
223 |
_("[-lqr] [-g path_or_uri ...] [--license] [pkg_fmri_pattern ...]") |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
224 |
adv_usage["contents"] = _( |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
225 |
"[-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
|
226 |
" [-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
|
227 |
" [pkg_fmri_pattern ...]") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
228 |
adv_usage["search"] = _( |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
229 |
"[-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
|
230 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
231 |
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
|
232 |
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
|
233 |
adv_usage["revert"] = _( |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
234 |
"[-nv] [--no-be-activate]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
235 |
" [--no-backup-be | --require-backup-be] [--backup-be-name name]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
236 |
" [--deny-new-be | --require-new-be] [--be-name name]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
237 |
" (--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
|
238 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
239 |
adv_usage["image-create"] = _( |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
240 |
"[-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
|
241 |
" [-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
|
242 |
" [--variant <variant_spec>=<instance> ...]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
243 |
" [-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
|
244 |
" [--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
|
245 |
" [(-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
|
246 |
adv_usage["change-variant"] = _( |
2772
cbeda93b5bbb
7185502 need to document pkg change-{variant|facet} --no-refresh options
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2765
diff
changeset
|
247 |
"[-nvq] [-C n] [-g path_or_uri ...] [--accept]\n" |
cbeda93b5bbb
7185502 need to document pkg change-{variant|facet} --no-refresh options
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2765
diff
changeset
|
248 |
" [--licenses] [--no-be-activate] [--no-index] [--no-refresh]\n" |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
249 |
" [--no-backup-be | --require-backup-be] [--backup-be-name name]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
250 |
" [--deny-new-be | --require-new-be] [--be-name name]\n" |
2772
cbeda93b5bbb
7185502 need to document pkg change-{variant|facet} --no-refresh options
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2765
diff
changeset
|
251 |
" [--reject pkg_fmri_pattern ... ]\n" |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
252 |
" <variant_spec>=<instance> ...") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
253 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
254 |
adv_usage["change-facet"] = _( |
2772
cbeda93b5bbb
7185502 need to document pkg change-{variant|facet} --no-refresh options
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2765
diff
changeset
|
255 |
"[-nvq] [-C n] [-g path_or_uri ...] [--accept]\n" |
cbeda93b5bbb
7185502 need to document pkg change-{variant|facet} --no-refresh options
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2765
diff
changeset
|
256 |
" [--licenses] [--no-be-activate] [--no-index] [--no-refresh]\n" |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
257 |
" [--no-backup-be | --require-backup-be] [--backup-be-name name]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
258 |
" [--deny-new-be | --require-new-be] [--be-name name]\n" |
2772
cbeda93b5bbb
7185502 need to document pkg change-{variant|facet} --no-refresh options
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2765
diff
changeset
|
259 |
" [--reject pkg_fmri_pattern ... ]\n" |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
260 |
" <facet_spec>=[True|False|None] ...") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
261 |
|
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
262 |
adv_usage["mediator"] = _("[-aH] [-F format] [<mediator> ...]") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
263 |
adv_usage["set-mediator"] = _( |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
264 |
"[-nv] [-I <implementation>]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
265 |
" [-V <version>] [--no-be-activate]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
266 |
" [--no-backup-be | --require-backup-be] [--backup-be-name name]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
267 |
" [--deny-new-be | --require-new-be] [--be-name name]\n" |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
268 |
" <mediator> ...") |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
269 |
adv_usage["unset-mediator"] = _("[-nvIV] [--no-be-activate]\n" |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
270 |
" [--no-backup-be | --require-backup-be] [--backup-be-name]\n" |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
271 |
" [--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
|
272 |
" <mediator> ...") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
273 |
|
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
274 |
adv_usage["variant"] = _("[-Haiv] [-F format] [<variant_pattern> ...]") |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
275 |
adv_usage["facet"] = ("[-Haim] [-F format] [<facet_pattern> ...]") |
2228
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
276 |
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
|
277 |
adv_usage["unavoid"] = _("[pkg_fmri_pattern] ...") |
2452
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
278 |
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
|
279 |
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
|
280 |
adv_usage["set-property"] = _("propname propvalue") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
281 |
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
|
282 |
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
|
283 |
adv_usage["unset-property"] = _("propname ...") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
284 |
adv_usage["property"] = _("[-H] [propname ...]") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
285 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
286 |
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
|
287 |
" [-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
|
288 |
" [-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
|
289 |
" [-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
|
290 |
" [-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
|
291 |
" [-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
|
292 |
" [--reset-uuid] [--non-sticky] [--sticky]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
293 |
" [--search-after=publisher]\n" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
294 |
" [--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
|
295 |
" [--search-first]\n" |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
296 |
" [--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
|
297 |
" [--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
|
298 |
" [--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
|
299 |
" [--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
|
300 |
" [--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
|
301 |
" [--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
|
302 |
" [--unset-property name_of_property_to_delete]\n" |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
303 |
" [--proxy proxy to use]\n" |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
304 |
" [publisher]") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
305 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
306 |
adv_usage["unset-publisher"] = _("publisher ...") |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
307 |
adv_usage["publisher"] = _("[-HPn] [-F format] [publisher ...]") |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
308 |
adv_usage["history"] = _("[-HNl] [-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
|
309 |
adv_usage["purge-history"] = "" |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
310 |
adv_usage["rebuild-index"] = "" |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
311 |
adv_usage["update-format"] = "" |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
312 |
|
2743
9f6a3b4462c8
7182704 None is not an operation
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2729
diff
changeset
|
313 |
priv_usage["remote"] = _( |
9f6a3b4462c8
7182704 None is not an operation
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2729
diff
changeset
|
314 |
"--ctlfd=file_descriptor --progfd=file_descriptor") |
2521
c2e46af6fb74
18816 pkg usage should not mention linked image commands
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2517
diff
changeset
|
315 |
priv_usage["list-linked"] = _("-H") |
c2e46af6fb74
18816 pkg usage should not mention linked image commands
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2517
diff
changeset
|
316 |
priv_usage["attach-linked"] = _( |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
317 |
"[-fnvq] [-C n] [--accept] [--licenses] [--no-index]\n" |
2503
6bdf5e17112b
18329 pkg utilities should use same format for usage and not wrap
Shawn Walker <shawn.walker@oracle.com>
parents:
2500
diff
changeset
|
318 |
" [--no-refresh] [--no-pkg-updates] [--linked-md-only]\n" |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
319 |
" [--allow-relink]\n" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
320 |
" [--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
|
321 |
" (-c|-p) <li-name> <dir>") |
2521
c2e46af6fb74
18816 pkg usage should not mention linked image commands
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2517
diff
changeset
|
322 |
priv_usage["detach-linked"] = _( |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
323 |
"[-fnvq] [-a|-l <li-name>] [--no-pkg-updates] [--linked-md-only]") |
2521
c2e46af6fb74
18816 pkg usage should not mention linked image commands
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2517
diff
changeset
|
324 |
priv_usage["property-linked"] = _("[-H] [-l <li-name>] [propname ...]") |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
325 |
priv_usage["audit-linked"] = _( |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
326 |
"[-H] [-a|-l <li-name>] [--no-parent-sync]") |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
327 |
priv_usage["pubcheck-linked"] = "" |
2521
c2e46af6fb74
18816 pkg usage should not mention linked image commands
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2517
diff
changeset
|
328 |
priv_usage["sync-linked"] = _( |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
329 |
"[-nvq] [-C n] [--accept] [--licenses] [--no-index]\n" |
2503
6bdf5e17112b
18329 pkg utilities should use same format for usage and not wrap
Shawn Walker <shawn.walker@oracle.com>
parents:
2500
diff
changeset
|
330 |
" [--no-refresh] [--no-parent-sync] [--no-pkg-updates]\n" |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
331 |
" [--linked-md-only] [-a|-l <name>]") |
2521
c2e46af6fb74
18816 pkg usage should not mention linked image commands
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2517
diff
changeset
|
332 |
priv_usage["set-property-linked"] = _( |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
333 |
"[-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
|
334 |
" [--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
|
335 |
" [--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
|
336 |
|
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
337 |
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
|
338 |
for cmd in cmd_list: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
339 |
if cmd is "": |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
340 |
logger.error("") |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
341 |
else: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
342 |
if cmd not in cmd_dic: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
343 |
# this should never happen - callers |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
344 |
# should check for valid subcommands |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
345 |
# before calling usage(..) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
346 |
raise ValueError( |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
347 |
"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
|
348 |
cmd) |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
349 |
use_txt = cmd_dic[cmd] |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
350 |
if use_txt is not "": |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
351 |
logger.error( |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
352 |
" pkg %(cmd)s %(use_txt)s" % |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
353 |
locals()) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
354 |
else: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
355 |
logger.error(" pkg %s" % cmd) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
356 |
if not full and cmd: |
2521
c2e46af6fb74
18816 pkg usage should not mention linked image commands
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2517
diff
changeset
|
357 |
if cmd not in priv_usage: |
c2e46af6fb74
18816 pkg usage should not mention linked image commands
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2517
diff
changeset
|
358 |
logger.error(_("Usage:")) |
c2e46af6fb74
18816 pkg usage should not mention linked image commands
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2517
diff
changeset
|
359 |
else: |
c2e46af6fb74
18816 pkg usage should not mention linked image commands
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2517
diff
changeset
|
360 |
logger.error(_("Private subcommand usage, options " |
c2e46af6fb74
18816 pkg usage should not mention linked image commands
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2517
diff
changeset
|
361 |
"subject to change at any time:")) |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
362 |
combined = {} |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
363 |
combined.update(basic_usage) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
364 |
combined.update(adv_usage) |
2521
c2e46af6fb74
18816 pkg usage should not mention linked image commands
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2517
diff
changeset
|
365 |
combined.update(priv_usage) |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
366 |
print_cmds([cmd], combined) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
367 |
sys.exit(retcode) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
368 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
369 |
elif not full: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
370 |
# The full usage message isn't desired. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
371 |
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
|
372 |
sys.exit(retcode) |
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
373 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
374 |
logger.error(_("""\ |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
375 |
Usage: |
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
376 |
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
|
377 |
""")) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
378 |
logger.error(_("Basic subcommands:")) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
379 |
print_cmds(basic_cmds, basic_usage) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
380 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
381 |
logger.error(_("\nAdvanced subcommands:")) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
382 |
print_cmds(advanced_cmds, adv_usage) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
383 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
384 |
logger.error(_(""" |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
385 |
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
|
386 |
-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
|
387 |
--help or -? |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
388 |
|
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
389 |
Environment: |
384
9d4746e5dd3e
115 pkg needs to not have a cow on a SIGPIPE
Shawn Walker <swalker@opensolaris.org>
parents:
362
diff
changeset
|
390 |
PKG_IMAGE""")) |
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
391 |
sys.exit(retcode) |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
392 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
393 |
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
|
394 |
""" 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
|
395 |
|
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
396 |
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
|
397 |
errors = [] |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
398 |
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
|
399 |
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
|
400 |
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
|
401 |
continue |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
402 |
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
|
403 |
# 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
|
404 |
# 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
|
405 |
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
|
406 |
err)) |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
407 |
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
|
408 |
# 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
|
409 |
# exceptions. |
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
410 |
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
|
411 |
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
|
412 |
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
|
413 |
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
|
414 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
415 |
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
|
416 |
li_parent_sync, list_all, list_installed_newest, list_newest, |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
417 |
list_upgradable, omit_headers, origins, quiet, refresh_catalogs, summary, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
418 |
verbose): |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
419 |
"""List packages.""" |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
420 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
421 |
api_inst.progresstracker.set_purpose( |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
422 |
api_inst.progresstracker.PURPOSE_LISTING) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
423 |
|
1537 | 424 |
variants = False |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
425 |
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
|
426 |
if list_all: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
427 |
variants = True |
1639
d8c628675154
13800 pkg list option order can cause output differences
Shawn Walker <srw@sun.com>
parents:
1628
diff
changeset
|
428 |
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
|
429 |
elif list_installed_newest: |
1639
d8c628675154
13800 pkg list option order can cause output differences
Shawn Walker <srw@sun.com>
parents:
1628
diff
changeset
|
430 |
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
|
431 |
elif list_newest: |
1639
d8c628675154
13800 pkg list option order can cause output differences
Shawn Walker <srw@sun.com>
parents:
1628
diff
changeset
|
432 |
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
|
433 |
elif list_upgradable: |
1639
d8c628675154
13800 pkg list option order can cause output differences
Shawn Walker <srw@sun.com>
parents:
1628
diff
changeset
|
434 |
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
|
435 |
|
219
f303ff108edd
60 'pkg status does_not_exist' throws a traceback
Richard Lowe <richlowe@richlowe.net>
parents:
217
diff
changeset
|
436 |
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
|
437 |
fmt_str = "%-76s %s" |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
438 |
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
|
439 |
fmt_str = "%-55s %s" |
219
f303ff108edd
60 'pkg status does_not_exist' throws a traceback
Richard Lowe <richlowe@richlowe.net>
parents:
217
diff
changeset
|
440 |
else: |
2544
507e17350a73
18902 pkg list version column should be longer to accommodate new versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2534
diff
changeset
|
441 |
fmt_str = "%-49s %-26s %s" |
219
f303ff108edd
60 'pkg status does_not_exist' throws a traceback
Richard Lowe <richlowe@richlowe.net>
parents:
217
diff
changeset
|
442 |
|
1835
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
443 |
# 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
|
444 |
# 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
|
445 |
# 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
|
446 |
# 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
|
447 |
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
|
448 |
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
|
449 |
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
|
450 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
451 |
api_inst.log_operation_start(op) |
1537 | 452 |
if pkg_list != api_inst.LIST_INSTALLED and refresh_catalogs: |
453 |
# If the user requested packages other than those |
|
454 |
# installed, ensure that a refresh is performed if |
|
455 |
# needed since the catalog may be out of date or |
|
456 |
# invalid as a result of publisher information |
|
457 |
# changing (such as an origin uri, etc.). |
|
458 |
try: |
|
459 |
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
|
460 |
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
|
461 |
# 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
|
462 |
# 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
|
463 |
# 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
|
464 |
# 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
|
465 |
pass |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
466 |
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
|
467 |
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
|
468 |
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
|
469 |
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
|
470 |
# 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
|
471 |
# 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
|
472 |
# refreshed, abort. |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
473 |
return EXIT_OOPS |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
474 |
|
1537 | 475 |
except: |
476 |
# Ignore the above error and just use what |
|
477 |
# already exists. |
|
478 |
pass |
|
479 |
||
480 |
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
|
481 |
[(api.PackageInfo.INSTALLED, "i")], |
1537 | 482 |
[(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
|
483 |
[ |
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 |
(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
|
485 |
(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
|
486 |
], |
1537 | 487 |
] |
488 |
||
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
|
489 |
# 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
|
490 |
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
|
491 |
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
|
492 |
if ppub: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
493 |
ppub = ppub.prefix |
219
f303ff108edd
60 'pkg status does_not_exist' throws a traceback
Richard Lowe <richlowe@richlowe.net>
parents:
217
diff
changeset
|
494 |
try: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
495 |
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
|
496 |
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
|
497 |
for pt, summ, cats, states, attrs in res: |
1537 | 498 |
found = True |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
499 |
|
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
500 |
if quiet: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
501 |
continue |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
502 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
503 |
if not omit_headers: |
1537 | 504 |
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
|
505 |
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
|
506 |
("FMRI", "IFO")) |
1537 | 507 |
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
|
508 |
msg(fmt_str % |
1537 | 509 |
("NAME (PUBLISHER)", |
510 |
"SUMMARY")) |
|
511 |
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
|
512 |
msg(fmt_str % |
1537 | 513 |
("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
|
514 |
"VERSION", "IFO")) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
515 |
omit_headers = True |
1537 | 516 |
|
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
|
517 |
status = "" |
1537 | 518 |
for sentry in state_map: |
519 |
for s, v in sentry: |
|
520 |
if s in states: |
|
521 |
st = v |
|
522 |
break |
|
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
523 |
else: |
1537 | 524 |
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
|
525 |
status += st |
1537 | 526 |
|
527 |
pub, stem, ver = pt |
|
528 |
if pub == ppub: |
|
529 |
spub = "" |
|
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
306
diff
changeset
|
530 |
else: |
1537 | 531 |
spub = " (" + pub + ")" |
532 |
||
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
|
533 |
# 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
|
534 |
if verbose: |
1537 | 535 |
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
|
536 |
msg(fmt_str % (pfmri, status)) |
1537 | 537 |
continue |
538 |
||
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
|
539 |
# Display short FMRI + summary. |
1537 | 540 |
pf = stem + spub |
541 |
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
|
542 |
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
|
543 |
summ = "" |
1537 | 544 |
msg(fmt_str % (pf, summ)) |
545 |
continue |
|
546 |
||
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
|
547 |
# Default case; display short FMRI and version info. |
1537 | 548 |
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
|
549 |
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
|
550 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
551 |
if not found and not pargs: |
1537 | 552 |
if pkg_list == api_inst.LIST_INSTALLED: |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
553 |
if not quiet: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
554 |
error(_("no packages installed")) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
555 |
api_inst.log_operation_end( |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
556 |
result=RESULT_NOTHING_TO_DO) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
557 |
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
|
558 |
elif pkg_list == api_inst.LIST_INSTALLED_NEWEST: |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
559 |
if not quiet: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
560 |
error(_("no packages installed or available " |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
561 |
"for installation")) |
1537 | 562 |
api_inst.log_operation_end( |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
563 |
result=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
|
564 |
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
|
565 |
elif pkg_list == api_inst.LIST_UPGRADABLE: |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
566 |
if not quiet: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
567 |
img = api_inst._img |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
568 |
cat = img.get_catalog( |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
569 |
img.IMG_CATALOG_INSTALLED) |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
570 |
if cat.package_count > 0: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
571 |
error(_("no packages have " |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
572 |
"newer versions available")) |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
573 |
else: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
574 |
error(_("no packages are " |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
575 |
"installed")) |
1537 | 576 |
api_inst.log_operation_end( |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
577 |
result=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
|
578 |
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
|
579 |
else: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
580 |
api_inst.log_operation_end( |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
581 |
result=RESULT_NOTHING_TO_DO) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
582 |
return EXIT_OOPS |
556
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
551
diff
changeset
|
583 |
|
1537 | 584 |
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
|
585 |
return EXIT_OK |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1752
diff
changeset
|
586 |
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
|
587 |
api_errors.ActionExecutionError, |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1752
diff
changeset
|
588 |
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
|
589 |
error(e, cmd=op) |
1672
3a71439a03f3
13021 file manager exceptions should be api exceptions
Shawn Walker <srw@sun.com>
parents:
1658
diff
changeset
|
590 |
return EXIT_OOPS |
2808
05c6015a8c62
7195369 corrupt manifests can end up on disk when -g is used
Dan Price <daniel.price@oracle.com>
parents:
2787
diff
changeset
|
591 |
except api_errors.CatalogRefreshException, e: |
05c6015a8c62
7195369 corrupt manifests can end up on disk when -g is used
Dan Price <daniel.price@oracle.com>
parents:
2787
diff
changeset
|
592 |
display_catalog_failures(e) |
05c6015a8c62
7195369 corrupt manifests can end up on disk when -g is used
Dan Price <daniel.price@oracle.com>
parents:
2787
diff
changeset
|
593 |
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
|
594 |
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
|
595 |
if e.illegal: |
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
523
diff
changeset
|
596 |
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
|
597 |
error(i) |
1537 | 598 |
api_inst.log_operation_end( |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
599 |
result=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
|
600 |
return EXIT_OOPS |
219
f303ff108edd
60 'pkg status does_not_exist' throws a traceback
Richard Lowe <richlowe@richlowe.net>
parents:
217
diff
changeset
|
601 |
|
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
602 |
if found and not quiet: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
603 |
# 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
|
604 |
# 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
|
605 |
logger.error(" ") |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
606 |
|
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
607 |
if quiet: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
608 |
# Print nothing. |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
609 |
pass |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
610 |
elif pkg_list == api.ImageInterface.LIST_ALL or \ |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
611 |
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
|
612 |
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
|
613 |
", ".join(e.notfound), cmd=op) |
1537 | 614 |
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
|
615 |
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
|
616 |
"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
|
617 |
"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
|
618 |
", ".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
|
619 |
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
|
620 |
elif pkg_list == api.ImageInterface.LIST_UPGRADABLE: |
2919
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
621 |
# Creating a list of packages that are uptodate |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
622 |
# and that are not installed on the system. |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
623 |
no_updates = [] |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
624 |
not_installed = [] |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
625 |
try: |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
626 |
for entry in api_inst.get_pkg_list( |
2930
89257716c7c1
16297554 pkg history fails when time travelling
<xiaobo.shen@oracle.com>
parents:
2926
diff
changeset
|
627 |
api.ImageInterface.LIST_INSTALLED, |
2919
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
628 |
patterns=e.notfound, raise_unmatched=True): |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
629 |
pub, stem, ver = entry[0] |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
630 |
no_updates.append(stem) |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
631 |
except api_errors.InventoryException, exc: |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
632 |
not_installed = exc.notfound |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
633 |
|
2930
89257716c7c1
16297554 pkg history fails when time travelling
<xiaobo.shen@oracle.com>
parents:
2926
diff
changeset
|
634 |
err_str = "" |
2919
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
635 |
if len(not_installed) == 1: |
2930
89257716c7c1
16297554 pkg history fails when time travelling
<xiaobo.shen@oracle.com>
parents:
2926
diff
changeset
|
636 |
err_str = _("No package matching '%s'" |
89257716c7c1
16297554 pkg history fails when time travelling
<xiaobo.shen@oracle.com>
parents:
2926
diff
changeset
|
637 |
" is installed. ") % \ |
89257716c7c1
16297554 pkg history fails when time travelling
<xiaobo.shen@oracle.com>
parents:
2926
diff
changeset
|
638 |
not_installed[0] |
2919
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
639 |
elif not_installed: |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
640 |
err_str = _("No packages matching '%s'" |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
641 |
" are installed. ") % \ |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
642 |
", ".join(not_installed) |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
643 |
|
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
644 |
if len(no_updates) == 1: |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
645 |
err_str = err_str + _("No updates are available" |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
646 |
" for package '%s'.") % \ |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
647 |
no_updates[0] |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
648 |
elif no_updates: |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
649 |
err_str = err_str + _("No updates are available" |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
650 |
" for packages '%s'.") % \ |
8d48e4b3aad7
15648766 pkg list -u claims no such package installed when there are simply
thejaswini.k@oracle.com
parents:
2918
diff
changeset
|
651 |
", ".join(no_updates) |
2930
89257716c7c1
16297554 pkg history fails when time travelling
<xiaobo.shen@oracle.com>
parents:
2926
diff
changeset
|
652 |
if err_str: |
89257716c7c1
16297554 pkg history fails when time travelling
<xiaobo.shen@oracle.com>
parents:
2926
diff
changeset
|
653 |
error(err_str, 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
|
654 |
|
2946fbd3ba3d
14292 pkg list doesn't exit with partial failure when some names are unmatched
Shawn Walker <srw@sun.com>
parents:
1758
diff
changeset
|
655 |
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
|
656 |
# 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
|
657 |
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
|
658 |
return EXIT_PARTIAL |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
659 |
api_inst.log_operation_end(result=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
|
660 |
return EXIT_OOPS |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
661 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
662 |
def get_tracker(): |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
663 |
if global_settings.client_output_parsable_version is not None: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
664 |
progresstracker = progress.NullProgressTracker() |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
665 |
elif global_settings.client_output_quiet: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
666 |
progresstracker = progress.QuietProgressTracker() |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
667 |
elif global_settings.client_output_progfd: |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
668 |
# This logic handles linked images: for linked children |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
669 |
# we elide the progress output. |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
670 |
output_file = os.fdopen(global_settings.client_output_progfd, |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
671 |
"w") |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
672 |
child_tracker = progress.LinkedChildProgressTracker( |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
673 |
output_file=output_file) |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
674 |
dot_tracker = progress.DotProgressTracker( |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
675 |
output_file=output_file) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
676 |
progresstracker = progress.MultiProgressTracker( |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
677 |
[child_tracker, dot_tracker]) |
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
678 |
else: |
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
679 |
try: |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
680 |
progresstracker = progress.FancyUNIXProgressTracker() |
236
834909099dab
Fancy command line progress was busted (fix for 373)
Dan Price <dp@eng.sun.com>
parents:
235
diff
changeset
|
681 |
except progress.ProgressTrackerException: |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
682 |
progresstracker = progress.CommandLineProgressTracker() |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
683 |
|
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
684 |
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
|
685 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
686 |
def fix_image(api_inst, args): |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
687 |
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
|
688 |
|
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
689 |
accept = show_licenses = False |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
690 |
for opt, arg in opts: |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
691 |
if opt == "--accept": |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
692 |
accept = True |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
693 |
elif opt == "--licenses": |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
694 |
show_licenses = True |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
695 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
696 |
# 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
|
697 |
found = False |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
698 |
try: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
699 |
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
|
700 |
patterns=pargs, raise_unmatched=True, return_fmris=True) |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
701 |
# We un-generate this because this is a long operation and |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
702 |
# we would like to know how many pkgs we will operate upon. |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
703 |
result = list(res) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
704 |
if result: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
705 |
api_inst.progresstracker.verify_start(len(result)) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
706 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
707 |
repairs = [] |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
708 |
for entry in result: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
709 |
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
|
710 |
found = True |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
711 |
entries = [] |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
712 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
713 |
# 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
|
714 |
# 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
|
715 |
# 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
|
716 |
# 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
|
717 |
# 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
|
718 |
for act, errors, warnings, pinfo in img.verify(pfmri, |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
719 |
api_inst.progresstracker, verbose=True, |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
720 |
forever=True): |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
721 |
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
|
722 |
# 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
|
723 |
# 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
|
724 |
# 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
|
725 |
# 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
|
726 |
continue |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
727 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
728 |
# 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
|
729 |
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
|
730 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
731 |
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
|
732 |
# 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
|
733 |
continue |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1672
diff
changeset
|
734 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
735 |
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
|
736 |
"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
|
737 |
"result": _("ERROR") }) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
738 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
739 |
failed = [] |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
740 |
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
|
741 |
if act: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
742 |
failed.append(act) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
743 |
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
|
744 |
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
|
745 |
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
|
746 |
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
|
747 |
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
|
748 |
repairs.append((pfmri, failed)) |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
749 |
if result: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
750 |
api_inst.progresstracker.verify_done() |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
751 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
752 |
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
|
753 |
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
|
754 |
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
|
755 |
error(i) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
756 |
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
|
757 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
758 |
if found: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
759 |
# 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
|
760 |
# 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
|
761 |
logger.error(" ") |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
762 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
763 |
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
|
764 |
", ".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
|
765 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
766 |
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
|
767 |
# 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
|
768 |
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
|
769 |
return EXIT_OOPS |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
770 |
|
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
771 |
# Repair anything we failed to verify |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
772 |
if not repairs: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
773 |
msg(_("No repairs for this image.")) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
774 |
return EXIT_OK |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
775 |
|
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
776 |
# Since BootEnv records the snapshot name in the image history, we need |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
777 |
# to manage our own history start/end & exception handling rather then |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
778 |
# delegating to <Image>.repair() |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
779 |
api_inst.log_operation_start("fix") |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
780 |
# Create a snapshot in case they want to roll back |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
781 |
success = False |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
782 |
try: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
783 |
be = bootenv.BootEnv(img) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
784 |
if be.exists(): |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
785 |
msg(_("Created ZFS snapshot: %s") % be.snapshot_name) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
786 |
except RuntimeError: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
787 |
# Error is printed by the BootEnv call. |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
788 |
be = bootenv.BootEnvNull(img) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
789 |
img.bootenv = be |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
790 |
try: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
791 |
success = img.repair(repairs, api_inst.progresstracker, |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
792 |
accept=accept, show_licenses=show_licenses, |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
793 |
new_history_op=False) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
794 |
except (api_errors.InvalidPlanError, |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
795 |
api_errors.InvalidPackageErrors, |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
796 |
api_errors.ActionExecutionError, |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
797 |
api_errors.PermissionsException, |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
798 |
api_errors.SigningException, |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
799 |
api_errors.InvalidResourceLocation, |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
800 |
api_errors.ConflictingActionErrors), e: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
801 |
logger.error(str(e)) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
802 |
except api_errors.ImageFormatUpdateNeeded, e: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
803 |
format_update_error(e) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
804 |
api_inst.log_operation_end(result=RESULT_FAILED_CONFIGURATION) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
805 |
return EXIT_OOPS |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
806 |
except api_errors.PlanLicenseErrors, e: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
807 |
error(_("The following packages require their " |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
808 |
"licenses to be accepted before they can be repaired: ")) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
809 |
logger.error(str(e)) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
810 |
logger.error(_("To indicate that you agree to and " |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
811 |
"accept the terms of the licenses of the packages " |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
812 |
"listed above, use the --accept option. To " |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
813 |
"display all of the related licenses, use the " |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
814 |
"--licenses option.")) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
815 |
api_inst.log_operation_end( |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
816 |
result=RESULT_FAILED_CONSTRAINED) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
817 |
return EXIT_LICENSE |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
818 |
except api_errors.RebootNeededOnLiveImageException: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
819 |
error(_("Requested \"fix\" operation would affect " |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
820 |
"files that cannot be modified in live image.\n" |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
821 |
"Please retry this operation on an alternate boot " |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
822 |
"environment.")) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
823 |
api_inst.log_operation_end(result=RESULT_FAILED_CONSTRAINED) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
824 |
return EXIT_NOTLIVE |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
825 |
except Exception, e: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
826 |
api_inst.log_operation_end(error=e) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
827 |
raise |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
828 |
|
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
829 |
if not success: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
830 |
api_inst.log_operation_end(result=RESULT_FAILED_UNKNOWN) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
831 |
return EXIT_OOPS |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
832 |
api_inst.log_operation_end(result=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
|
833 |
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
|
834 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
835 |
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
|
836 |
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
|
837 |
|
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
|
838 |
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
|
839 |
verbose = 0 |
443
5ffa5b7dac9c
2589 pyc files generate lots of verify chaff
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
442
diff
changeset
|
840 |
# 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
|
841 |
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
|
842 |
|
227
faba25c4bce3
368 pkg info -m should display raw manifest
Stephen Hahn <sch@Sun.COM>
parents:
222
diff
changeset
|
843 |
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
|
844 |
if opt == "-H": |
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
845 |
display_headers = False |
227
faba25c4bce3
368 pkg info -m should display raw manifest
Stephen Hahn <sch@Sun.COM>
parents:
222
diff
changeset
|
846 |
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
|
847 |
verbose = verbose + 1 |
227
faba25c4bce3
368 pkg info -m should display raw manifest
Stephen Hahn <sch@Sun.COM>
parents:
222
diff
changeset
|
848 |
elif opt == "-f": |
faba25c4bce3
368 pkg info -m should display raw manifest
Stephen Hahn <sch@Sun.COM>
parents:
222
diff
changeset
|
849 |
forever = True |
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
850 |
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
|
851 |
quiet = True |
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
852 |
display_headers = False |
2890
7a90486da579
16656797 pkg verify -q not consistent with other subcommands
Shawn Walker <shawn.walker@oracle.com>
parents:
2886
diff
changeset
|
853 |
global_settings.client_output_quiet = True |
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
854 |
|
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
227
diff
changeset
|
855 |
if verbose and quiet: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
856 |
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
|
857 |
if verbose > 2: |
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
858 |
DebugValues.set_value("plan", "True") |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
859 |
|
2890
7a90486da579
16656797 pkg verify -q not consistent with other subcommands
Shawn Walker <shawn.walker@oracle.com>
parents:
2886
diff
changeset
|
860 |
# Reset the progress tracker here, because we may have |
7a90486da579
16656797 pkg verify -q not consistent with other subcommands
Shawn Walker <shawn.walker@oracle.com>
parents:
2886
diff
changeset
|
861 |
# to switch to a different tracker due to the options parse. |
7a90486da579
16656797 pkg verify -q not consistent with other subcommands
Shawn Walker <shawn.walker@oracle.com>
parents:
2886
diff
changeset
|
862 |
_api_inst.progresstracker = get_tracker() |
7a90486da579
16656797 pkg verify -q not consistent with other subcommands
Shawn Walker <shawn.walker@oracle.com>
parents:
2886
diff
changeset
|
863 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
864 |
# 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
|
865 |
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
|
866 |
processed = False |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
867 |
notfound = EmptyI |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
868 |
try: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
869 |
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
|
870 |
patterns=pargs, raise_unmatched=True, return_fmris=True) |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
871 |
# We un-generate this because this is a long operation and |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
872 |
# we would like to know how many pkgs we will operate upon. |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
873 |
result = list(res) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
874 |
if result: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
875 |
api_inst.progresstracker.verify_start(len(result)) |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
876 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
877 |
for entry in result: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
878 |
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
|
879 |
entries = [] |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
880 |
result = _("OK") |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
881 |
failed = False |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
882 |
processed = True |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
883 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
884 |
# 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
|
885 |
# 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
|
886 |
# 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
|
887 |
# 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
|
888 |
# 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
|
889 |
for act, errors, warnings, pinfo in img.verify(pfmri, |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
890 |
api_inst.progresstracker, verbose=verbose, |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
891 |
forever=forever): |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
892 |
if errors: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
893 |
failed = True |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
894 |
if quiet: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
895 |
# 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
|
896 |
break |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
897 |
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
|
898 |
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
|
899 |
result = _("WARNING") |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
900 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
901 |
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
|
902 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
903 |
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
|
904 |
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
|
905 |
# 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
|
906 |
continue |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
907 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
908 |
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
|
909 |
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
|
910 |
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
|
911 |
"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
|
912 |
"result": _("STATUS") }) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
913 |
|
2463
a23c2a2b7080
18583 the output of pkg verify and fix has rotted a bit
Shawn Walker <shawn.walker@oracle.com>
parents:
2457
diff
changeset
|
914 |
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
|
915 |
"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
|
916 |
"result": result }) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
917 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
918 |
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
|
919 |
if act: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
920 |
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
|
921 |
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
|
922 |
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
|
923 |
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
|
924 |
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
|
925 |
if verbose: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
926 |
# 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
|
927 |
# 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
|
928 |
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
|
929 |
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
|
930 |
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
|
931 |
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
|
932 |
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
|
933 |
error(i) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
934 |
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
|
935 |
notfound = e.notfound |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
936 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
937 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
938 |
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
|
939 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
940 |
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
|
941 |
if processed: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
942 |
# 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
|
943 |
logger.error(" ") |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
944 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
945 |
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
|
946 |
", ".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
|
947 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
948 |
if processed: |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
949 |
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
|
950 |
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
|
951 |
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
|
952 |
msg2 = _("No packages failed\nverification.") |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
953 |
logger.error(_("\nAll other patterns matched " |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
954 |
"installed packages. %s" % msg2)) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
955 |
any_errors = True |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
956 |
|
227
faba25c4bce3
368 pkg info -m should display raw manifest
Stephen Hahn <sch@Sun.COM>
parents:
222
diff
changeset
|
957 |
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
|
958 |
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
|
959 |
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
|
960 |
|
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
961 |
def accept_plan_licenses(api_inst): |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
962 |
"""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
|
963 |
accepted if they require acceptance.""" |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
964 |
|
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
965 |
plan = api_inst.describe() |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
966 |
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
|
967 |
if not dest.must_accept: |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
968 |
continue |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
969 |
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
|
970 |
accepted=True) |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
971 |
|
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
972 |
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
|
973 |
"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
|
974 |
|
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
975 |
def __display_plan(api_inst, verbose, noexecute): |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
976 |
"""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
|
977 |
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
|
978 |
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
|
979 |
|
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
980 |
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
|
981 |
disp = ["basic"] |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
982 |
|
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
983 |
if verbose == 0 and noexecute: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
984 |
disp.append("release-notes") |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
985 |
if verbose > 0: |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
986 |
disp.extend(["fmris", "mediators", "services", |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
987 |
"variants/facets", "boot-archive", |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
988 |
"release-notes"]) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
989 |
if verbose > 1: |
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
990 |
disp.append("actions") |
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
991 |
if verbose > 2: |
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
992 |
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
|
993 |
else: |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
994 |
disp = verbose |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
995 |
|
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
996 |
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
|
997 |
disp.append("solver-errors") |
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
998 |
|
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
999 |
plan = api_inst.describe() |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
1000 |
|
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1001 |
if plan.must_display_notes(): |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1002 |
disp.append("release-notes") |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1003 |
|
2773
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1004 |
if api_inst.is_liveroot and not api_inst.is_active_liveroot_be: |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1005 |
# Warn the user since this isn't likely what they wanted. |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1006 |
if plan.new_be: |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1007 |
logger.warning(_("""\ |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1008 |
WARNING: The boot environment being modified is not the active one. Changes |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1009 |
made in the active BE will not be reflected on the next boot. |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1010 |
""")) |
2773
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1011 |
else: |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1012 |
logger.warning(_("""\ |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1013 |
WARNING: The boot environment being modified is not the active one. Changes |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1014 |
made will not be reflected on the next boot. |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1015 |
""")) |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1016 |
|
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1017 |
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
|
1018 |
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
|
1019 |
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
|
1020 |
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
|
1021 |
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
|
1022 |
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
|
1023 |
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
|
1024 |
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
|
1025 |
else: |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1026 |
# Changing or repairing package content (e.g. fix, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1027 |
# change-facet, etc.) |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1028 |
a.append((dest, dest)) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1029 |
|
2319
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
1030 |
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
|
1031 |
if val: |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
1032 |
return _("Yes") |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
1033 |
return _("No") |
247375ff5e19
14165 pkg operations should provide option to skip BE activation
Shawn Walker <shawn.walker@oracle.com>
parents:
2318
diff
changeset
|
1034 |
|
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1035 |
status = [] |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1036 |
varcets = plan.get_varcets() |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1037 |
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
|
1038 |
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
|
1039 |
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
|
1040 |
if v: |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1041 |
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
|
1042 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1043 |
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
|
1044 |
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
|
1045 |
cond_show(_("Packages to update:"), "%d", len(c)) |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1046 |
if varcets or mediators: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1047 |
cond_show(_("Packages to change:"), "%d", len(a)) |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1048 |
else: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1049 |
cond_show(_("Packages to fix:"), "%d", len(a)) |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1050 |
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
|
1051 |
cond_show(_("Variants/Facets to change:"), "%d", len(varcets)) |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1052 |
if not plan.new_be: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1053 |
cond_show(_("Services to change:"), "%d", |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1054 |
len(plan.services)) |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1055 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1056 |
if verbose: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1057 |
# 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
|
1058 |
abytes = plan.bytes_added |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1059 |
if abytes: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1060 |
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
|
1061 |
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
|
1062 |
status.append(( |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1063 |
_("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
|
1064 |
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
|
1065 |
|
2773
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1066 |
# only display BE information if we're operating on the |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1067 |
# liveroot environment (since otherwise we'll never be |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1068 |
# manipulating BEs). |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1069 |
if api_inst.is_liveroot: |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1070 |
status.append((_("Create boot environment:"), |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1071 |
bool_str(plan.new_be))) |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1072 |
|
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1073 |
if plan.new_be and (verbose or not plan.activate_be): |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1074 |
# Only show activation status if verbose or |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1075 |
# if new BE will not be activated. |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1076 |
status.append((_("Activate boot environment:"), |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1077 |
bool_str(plan.activate_be))) |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1078 |
|
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1079 |
status.append((_("Create backup boot environment:"), |
9e1e8c67549e
7187946 pkg running in a zone always thinks it's modifying a non-active BE
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2772
diff
changeset
|
1080 |
bool_str(plan.backup_be))) |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1081 |
|
2105
212a253a462a
12530 pkg -R install doesn't update boot archive
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2100
diff
changeset
|
1082 |
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
|
1083 |
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
|
1084 |
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
|
1085 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1086 |
# Right-justify all status strings based on length of longest string. |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
1087 |
if status: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
1088 |
rjust_status = max(len(s[0]) for s in status) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
1089 |
rjust_value = max(len(s[1]) for s in status) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
1090 |
for s in status: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
1091 |
logger.info("%s %s" % (s[0].rjust(rjust_status), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
1092 |
s[1].rjust(rjust_value))) |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1093 |
# 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
|
1094 |
# remainder. |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1095 |
logger.info("") |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1096 |
|
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1097 |
if "mediators" in disp and mediators: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1098 |
logger.info(_("Changed mediators:")) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1099 |
for x in mediators: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1100 |
logger.info(" %s" % x) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1101 |
|
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1102 |
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
|
1103 |
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
|
1104 |
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
|
1105 |
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
|
1106 |
|
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
1107 |
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
|
1108 |
first = True |
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
1109 |
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
|
1110 |
if first: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1111 |
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
|
1112 |
first = False |
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
1113 |
logger.info(l) |
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
1114 |
|
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1115 |
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
|
1116 |
changed = collections.defaultdict(list) |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1117 |
for src, dest in itertools.chain(r, i, c, a): |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1118 |
if src and dest: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1119 |
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
|
1120 |
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
|
1121 |
dest.publisher) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1122 |
else: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1123 |
pparent = dest.publisher |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1124 |
pname = dest.pkg_stem |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1125 |
pver = str(src.fmri.version) |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1126 |
if src != dest: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1127 |
pver += " -> %s" % dest.fmri.version |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1128 |
elif dest: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1129 |
pparent = dest.publisher |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1130 |
pname = dest.pkg_stem |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1131 |
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
|
1132 |
else: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1133 |
pparent = src.publisher |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1134 |
pname = src.pkg_stem |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1135 |
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
|
1136 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1137 |
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
|
1138 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1139 |
if changed: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1140 |
logger.info(_("Changed packages:")) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1141 |
last_parent = None |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1142 |
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
|
1143 |
(pparent, pname, pver) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1144 |
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
|
1145 |
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
|
1146 |
): |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1147 |
if pparent != last_parent: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1148 |
logger.info(pparent) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1149 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1150 |
logger.info(" %s" % pname) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1151 |
logger.info(" %s" % pver) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1152 |
last_parent = pparent |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1153 |
|
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1154 |
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
|
1155 |
last_action = None |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1156 |
for action, smf_fmri in plan.services: |
2446
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1157 |
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
|
1158 |
logger.info("Services:") |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1159 |
if action != last_action: |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1160 |
logger.info(" %s:" % action) |
ba222bc0b1ce
18625 new disk space information needs improved formatting, wording
Shawn Walker <shawn.walker@oracle.com>
parents:
2444
diff
changeset
|
1161 |
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
|
1162 |
last_action = action |
2207
029ca014fced
17797 plan debugging should also display solver trim database
Shawn Walker <shawn.walker@oracle.com>
parents:
2205
diff
changeset
|
1163 |
|
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1164 |
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
|
1165 |
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
|
1166 |
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
|
1167 |
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
|
1168 |
|
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1169 |
|
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1170 |
if plan.has_release_notes(): |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1171 |
if "release-notes" in disp: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1172 |
logger.info("Release Notes:") |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1173 |
for a in plan.get_release_notes(): |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1174 |
logger.info(" %s", a) |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1175 |
else: |
2915
a7756acea9ef
17075980 pkg strips newlines from release notes
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2910
diff
changeset
|
1176 |
if not plan.new_be and api_inst.is_liveroot and not DebugValues["GenerateNotesFile"]: |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1177 |
logger.info(_("Release notes can be viewed with 'pkg history -n 1 -N'")) |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1178 |
else: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1179 |
tmp_path = __write_tmp_release_notes(plan) |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1180 |
if tmp_path: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1181 |
logger.info(_("Release notes can be found in %s before rebooting.") |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1182 |
% tmp_path) |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1183 |
logger.info(_("After rebooting, use 'pkg history -n 1 -N' to view release notes.")) |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1184 |
|
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1185 |
def __write_tmp_release_notes(plan): |
2915
a7756acea9ef
17075980 pkg strips newlines from release notes
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2910
diff
changeset
|
1186 |
"""try to write release notes out to a file in /tmp and return the name""" |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1187 |
if plan.has_release_notes: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1188 |
try: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1189 |
fd, path = tempfile.mkstemp(suffix=".txt", prefix="release-notes") |
2918
ff3c422dd0e3
17178428 pkg history is not capturing release notes
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2915
diff
changeset
|
1190 |
# make file world readable |
ff3c422dd0e3
17178428 pkg history is not capturing release notes
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2915
diff
changeset
|
1191 |
os.chmod(path, 0644) |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1192 |
tmpfile = os.fdopen(fd, "w+b") |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1193 |
for a in plan.get_release_notes(): |
2918
ff3c422dd0e3
17178428 pkg history is not capturing release notes
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2915
diff
changeset
|
1194 |
if isinstance(a, unicode): |
2915
a7756acea9ef
17075980 pkg strips newlines from release notes
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2910
diff
changeset
|
1195 |
a = a.encode("utf-8") |
a7756acea9ef
17075980 pkg strips newlines from release notes
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2910
diff
changeset
|
1196 |
print >> tmpfile, a |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1197 |
tmpfile.close() |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1198 |
return path |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1199 |
except Exception: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1200 |
pass |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1201 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
1202 |
def __display_parsable_plan(api_inst, parsable_version, child_images=None): |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1203 |
"""Display the parsable version of the plan.""" |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1204 |
|
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1205 |
assert parsable_version == 0, "parsable_version was %r" % \ |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1206 |
parsable_version |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1207 |
plan = api_inst.describe() |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1208 |
# Set the default values. |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1209 |
added_fmris = [] |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1210 |
removed_fmris = [] |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1211 |
changed_fmris = [] |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1212 |
affected_fmris = [] |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1213 |
backup_be_created = False |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1214 |
new_be_created = False |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1215 |
backup_be_name = None |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1216 |
be_name = None |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1217 |
boot_archive_rebuilt = False |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1218 |
be_activated = True |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1219 |
space_available = None |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1220 |
space_required = None |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1221 |
facets_changed = [] |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1222 |
variants_changed = [] |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1223 |
services_affected = [] |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1224 |
mediators_changed = [] |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1225 |
licenses = [] |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1226 |
if child_images is None: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1227 |
child_images = [] |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1228 |
release_notes = [] |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1229 |
|
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1230 |
if plan: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1231 |
for rem, add in plan.get_changes(): |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1232 |
assert rem is not None or add is not None |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1233 |
if rem is not None and add is not None: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1234 |
# Lists of lists are used here becuase json will |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1235 |
# convert lists of tuples into lists of lists |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1236 |
# anyway. |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1237 |
if rem.fmri == add.fmri: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1238 |
affected_fmris.append(str(rem)) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1239 |
else: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1240 |
changed_fmris.append( |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1241 |
[str(rem), str(add)]) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1242 |
elif rem is not None: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1243 |
removed_fmris.append(str(rem)) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1244 |
else: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1245 |
added_fmris.append(str(add)) |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1246 |
variants_changed, facets_changed = plan.varcets |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1247 |
backup_be_created = plan.backup_be |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1248 |
new_be_created = plan.new_be |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1249 |
backup_be_name = plan.backup_be_name |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1250 |
be_name = plan.be_name |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1251 |
boot_archive_rebuilt = plan.update_boot_archive |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1252 |
be_activated = plan.activate_be |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1253 |
space_available = plan.bytes_avail |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1254 |
space_required = plan.bytes_added |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1255 |
services_affected = plan.services |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1256 |
mediators_changed = plan.mediators |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1257 |
|
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1258 |
for n in plan.get_release_notes(): |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1259 |
release_notes.append(n) |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1260 |
|
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1261 |
for dfmri, src_li, dest_li, acc, disp in \ |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1262 |
plan.get_licenses(): |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1263 |
src_tup = None |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1264 |
if src_li: |
2729
fbe29295150f
7127117 pkg update --parsable option is not working
saurabh.vyas@oracle.com
parents:
2728
diff
changeset
|
1265 |
li_txt = misc.decode(src_li.get_text()) |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1266 |
src_tup = (str(src_li.fmri), src_li.license, |
2729
fbe29295150f
7127117 pkg update --parsable option is not working
saurabh.vyas@oracle.com
parents:
2728
diff
changeset
|
1267 |
li_txt, src_li.must_accept, |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1268 |
src_li.must_display) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1269 |
dest_tup = None |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1270 |
if dest_li: |
2729
fbe29295150f
7127117 pkg update --parsable option is not working
saurabh.vyas@oracle.com
parents:
2728
diff
changeset
|
1271 |
li_txt = misc.decode(dest_li.get_text()) |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1272 |
dest_tup = (str(dest_li.fmri), |
2729
fbe29295150f
7127117 pkg update --parsable option is not working
saurabh.vyas@oracle.com
parents:
2728
diff
changeset
|
1273 |
dest_li.license, li_txt, |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1274 |
dest_li.must_accept, dest_li.must_display) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1275 |
licenses.append( |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1276 |
(str(dfmri), src_tup, dest_tup)) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1277 |
api_inst.set_plan_license_status(dfmri, dest_li.license, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1278 |
displayed=True) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1279 |
ret = { |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1280 |
"create-backup-be": backup_be_created, |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1281 |
"create-new-be": new_be_created, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1282 |
"backup-be-name": backup_be_name, |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1283 |
"be-name": be_name, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1284 |
"boot-archive-rebuild": boot_archive_rebuilt, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1285 |
"activate-be": be_activated, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1286 |
"space-available": space_available, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1287 |
"space-required": space_required, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1288 |
"remove-packages": sorted(removed_fmris), |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1289 |
"add-packages": sorted(added_fmris), |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1290 |
"change-packages": sorted(changed_fmris), |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1291 |
"affect-packages": sorted(affected_fmris), |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1292 |
"change-facets": sorted(facets_changed), |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1293 |
"change-variants": sorted(variants_changed), |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1294 |
"affect-services": sorted(services_affected), |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1295 |
"change-mediators": sorted(mediators_changed), |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1296 |
"release-notes": release_notes, |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1297 |
"image-name": None, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1298 |
"child-images": child_images, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1299 |
"version": parsable_version, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1300 |
"licenses": sorted(licenses) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1301 |
} |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1302 |
# The image name for the parent image is always None. If this image is |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1303 |
# a child image, then the image name will be set when the parent image |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1304 |
# processes this dictionary. |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1305 |
logger.info(json.dumps(ret)) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1306 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1307 |
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
|
1308 |
"""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
|
1309 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
1310 |
'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
|
1311 |
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
|
1312 |
|
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1313 |
plan = api_inst.describe() |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1314 |
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
|
1315 |
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
|
1316 |
continue |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1317 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1318 |
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
|
1319 |
# 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
|
1320 |
# displayed again. |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1321 |
continue |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1322 |
|
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1323 |
lic = dest.license |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1324 |
if show_req: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1325 |
logger.info("-" * 60) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1326 |
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
|
1327 |
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
|
1328 |
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
|
1329 |
logger.info("\n") |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1330 |
|
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1331 |
# Mark license as having been displayed. |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1332 |
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
|
1333 |
|
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1334 |
def display_plan(api_inst, child_image_plans, noexecute, op, parsable_version, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1335 |
quiet, show_licenses, stage, verbose): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1336 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1337 |
plan = api_inst.describe() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1338 |
if not plan: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1339 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1340 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1341 |
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
|
1342 |
# 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
|
1343 |
# 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
|
1344 |
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
|
1345 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1346 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1347 |
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
|
1348 |
# nothing todo |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1349 |
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
|
1350 |
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
|
1351 |
else: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1352 |
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
|
1353 |
if api_inst.ischild(): |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
1354 |
s += " (%s)" % api_inst.get_linked_name() |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1355 |
msg(s) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1356 |
return |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1357 |
|
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1358 |
if parsable_version is None: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1359 |
display_plan_licenses(api_inst, show_all=show_licenses) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1360 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1361 |
if not quiet: |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1362 |
__display_plan(api_inst, verbose, noexecute) |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1363 |
if parsable_version is not None: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1364 |
__display_parsable_plan(api_inst, parsable_version, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1365 |
child_image_plans) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1366 |
|
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1367 |
def __api_prepare_plan(operation, api_inst): |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1368 |
# 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
|
1369 |
# or without some extra decoration done here. |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1370 |
# 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
|
1371 |
try: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
1372 |
api_inst.prepare() |
1779
b80275b45b18
14176 copytree callers must catch shutil.Error and not traceback
Shawn Walker <srw@sun.com>
parents:
1775
diff
changeset
|
1373 |
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
|
1374 |
# 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
|
1375 |
# 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
|
1376 |
error("\n" + str(e)) |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1377 |
return EXIT_OOPS |
1280
9c577f0a6cd8
10411 Protect progress tracker against adversarial interfaces
johansen <johansen@sun.com>
parents:
1271
diff
changeset
|
1378 |
except api_errors.TransportError, e: |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1379 |
# move past the progress tracker line. |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1380 |
msg("\n") |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1381 |
raise e |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1382 |
except api_errors.PlanLicenseErrors, e: |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1383 |
# 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
|
1384 |
# 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
|
1385 |
logger.error("\n") |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1386 |
error(_("The following packages require their " |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1387 |
"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
|
1388 |
"or updated: ")) |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1389 |
logger.error(str(e)) |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1390 |
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
|
1391 |
"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
|
1392 |
"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
|
1393 |
"licenses, use the --licenses option.")) |
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1394 |
return EXIT_LICENSE |
1710
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
1395 |
except api_errors.InvalidPlanError, e: |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
1396 |
# 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
|
1397 |
# 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
|
1398 |
error("\n" + str(e)) |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
1399 |
return EXIT_OOPS |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1400 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1401 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1402 |
return EXIT_OOPS |
2407
a831f1491c86
1769 pkg(5) doesn't check for disk space
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2382
diff
changeset
|
1403 |
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
|
1404 |
error(str(e)) |
a831f1491c86
1769 pkg(5) doesn't check for disk space
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2382
diff
changeset
|
1405 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1406 |
except KeyboardInterrupt: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1407 |
raise |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1408 |
except: |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1409 |
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
|
1410 |
"%s:") % operation) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1411 |
raise |
1618
04f7471c9e72
5943 add 'must-accept' attribute to license actions
Shawn Walker <srw@sun.com>
parents:
1603
diff
changeset
|
1412 |
return EXIT_OK |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1413 |
|
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1857
diff
changeset
|
1414 |
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
|
1415 |
rval = None |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1416 |
try: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
1417 |
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
|
1418 |
rval = EXIT_OK |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1419 |
except RuntimeError, e: |
2826
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
1420 |
error(_("%(operation)s failed: %(err)s") % |
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
1421 |
{"operation": operation, "err": e}) |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1422 |
rval = EXIT_OOPS |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1752
diff
changeset
|
1423 |
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
|
1424 |
api_errors.ActionExecutionError, |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1752
diff
changeset
|
1425 |
api_errors.InvalidPackageErrors), e: |
1710
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
1426 |
# 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
|
1427 |
# 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
|
1428 |
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
|
1429 |
rval = EXIT_OOPS |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1430 |
except (api_errors.LinkedImageException), e: |
2826
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
1431 |
error(_("%(operation)s failed (linked image exception(s)):\n" |
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
1432 |
"%(err)s") % {"operation": operation, "err": e}) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1433 |
rval = e.lix_exitrv |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1434 |
except api_errors.ImageUpdateOnLiveImageException: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1435 |
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
|
1436 |
rval = EXIT_NOTLIVE |
1328
5c3747a4fe0a
9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1326
diff
changeset
|
1437 |
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
|
1438 |
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
|
1439 |
"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
|
1440 |
"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
|
1441 |
"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
|
1442 |
rval = EXIT_NOTLIVE |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1443 |
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
|
1444 |
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
|
1445 |
"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
|
1446 |
rval = EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1447 |
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
|
1448 |
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
|
1449 |
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
|
1450 |
"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
|
1451 |
rval = EXIT_OOPS |
1779
b80275b45b18
14176 copytree callers must catch shutil.Error and not traceback
Shawn Walker <srw@sun.com>
parents:
1775
diff
changeset
|
1452 |
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
|
1453 |
# 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
|
1454 |
# 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
|
1455 |
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
|
1456 |
rval = EXIT_OOPS |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1457 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1458 |
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
|
1459 |
rval = EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1460 |
except api_errors.BEException, e: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1461 |
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
|
1462 |
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
|
1463 |
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
|
1464 |
raise |
2407
a831f1491c86
1769 pkg(5) doesn't check for disk space
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2382
diff
changeset
|
1465 |
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
|
1466 |
error(str(e)) |
2534
e710e16c422b
18836 Out of space error could be improved
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2524
diff
changeset
|
1467 |
rval = EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1468 |
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
|
1469 |
error(_("An unexpected error happened during " |
2826
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
1470 |
"%(operation)s: %(err)s") % |
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
1471 |
{"operation": operation, "err": e}) |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1472 |
raise |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1473 |
finally: |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1474 |
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
|
1475 |
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
|
1476 |
# 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
|
1477 |
# 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
|
1478 |
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
|
1479 |
|
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1480 |
try: |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1481 |
salvaged = api_inst.describe().salvaged |
2930
89257716c7c1
16297554 pkg history fails when time travelling
<xiaobo.shen@oracle.com>
parents:
2926
diff
changeset
|
1482 |
newbe = api_inst.describe().new_be |
2926
e67313720cf4
15814511 SUNBT7196723 pkg can traceback when displaying list of salvaged files
thejaswini.k@oracle.com
parents:
2925
diff
changeset
|
1483 |
if salvaged and (rval == EXIT_OK or not newbe): |
e67313720cf4
15814511 SUNBT7196723 pkg can traceback when displaying list of salvaged files
thejaswini.k@oracle.com
parents:
2925
diff
changeset
|
1484 |
# Only show salvaged file list if populated |
e67313720cf4
15814511 SUNBT7196723 pkg can traceback when displaying list of salvaged files
thejaswini.k@oracle.com
parents:
2925
diff
changeset
|
1485 |
# and operation was successful, or if operation |
e67313720cf4
15814511 SUNBT7196723 pkg can traceback when displaying list of salvaged files
thejaswini.k@oracle.com
parents:
2925
diff
changeset
|
1486 |
# failed and a new BE was not created for |
e67313720cf4
15814511 SUNBT7196723 pkg can traceback when displaying list of salvaged files
thejaswini.k@oracle.com
parents:
2925
diff
changeset
|
1487 |
# the operation. |
2293
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1488 |
logger.error("") |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1489 |
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
|
1490 |
"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
|
1491 |
"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
|
1492 |
"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
|
1493 |
"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
|
1494 |
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
|
1495 |
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
|
1496 |
spath)) |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1497 |
except Exception: |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1498 |
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
|
1499 |
# 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
|
1500 |
# 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
|
1501 |
raise |
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1502 |
|
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1503 |
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
|
1504 |
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
|
1505 |
|
631000734928
3679 modified preserve=true files should be backed up during uninstall
Shawn Walker <shawn.walker@oracle.com>
parents:
2286
diff
changeset
|
1506 |
return rval |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1507 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
1508 |
def __api_alloc(imgdir, exact_match, pkg_image_used): |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1509 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
1510 |
progresstracker = get_tracker() |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1511 |
try: |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1512 |
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
|
1513 |
progresstracker, None, PKG_CLIENT_NAME, |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1514 |
exact_match=exact_match) |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1515 |
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
|
1516 |
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
|
1517 |
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
|
1518 |
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
|
1519 |
"(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
|
1520 |
else: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1521 |
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
|
1522 |
else: |
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1523 |
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
|
1524 |
return |
1672
3a71439a03f3
13021 file manager exceptions should be api exceptions
Shawn Walker <srw@sun.com>
parents:
1658
diff
changeset
|
1525 |
except api_errors.PermissionsException, e: |
3a71439a03f3
13021 file manager exceptions should be api exceptions
Shawn Walker <srw@sun.com>
parents:
1658
diff
changeset
|
1526 |
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
|
1527 |
return |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1528 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1529 |
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
|
1530 |
return |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1531 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1532 |
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
|
1533 |
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
|
1534 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1535 |
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
|
1536 |
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
|
1537 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1538 |
if e_type == api_errors.InventoryException: |
2826
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
1539 |
error("\n" + _("%(operation)s failed (inventory exception):\n" |
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
1540 |
"%(err)s") % {"operation": op, "err": e}) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1541 |
return EXIT_OOPS |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1542 |
if isinstance(e, api_errors.LinkedImageException): |
2826
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
1543 |
error(_("%(operation)s failed (linked image exception(s)):\n" |
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
1544 |
"%(err)s") % {"operation": op, "err": e}) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1545 |
return e.lix_exitrv |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1546 |
if e_type == api_errors.IpkgOutOfDateException: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1547 |
msg(_("""\ |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1548 |
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
|
1549 |
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
|
1550 |
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
|
1551 |
) % locals()) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1552 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1553 |
if e_type == api_errors.NonLeafPackageException: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1554 |
error(_("""\ |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1555 |
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
|
1556 |
) % 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
|
1557 |
for d in e.dependents: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
1558 |
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
|
1559 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1560 |
if e_type == api_errors.CatalogRefreshException: |
2700
d1876b136396
7178155 proxy example in pkg gate needs update
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2693
diff
changeset
|
1561 |
display_catalog_failures(e) |
2034
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1562 |
return EXIT_OOPS |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1563 |
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
|
1564 |
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
|
1565 |
if verbose: |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
1566 |
__display_plan(api_inst, verbose, noexecute) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1567 |
return EXIT_OOPS |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1752
diff
changeset
|
1568 |
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
|
1569 |
api_errors.ReadOnlyFileSystemException, |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1857
diff
changeset
|
1570 |
api_errors.ActionExecutionError, |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1752
diff
changeset
|
1571 |
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
|
1572 |
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
|
1573 |
return EXIT_OOPS |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1574 |
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
|
1575 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
1576 |
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
|
1577 |
|
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1578 |
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
|
1579 |
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
|
1580 |
"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
|
1581 |
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
|
1582 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1583 |
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
|
1584 |
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
|
1585 |
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
|
1586 |
|
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1587 |
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
|
1588 |
# 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
|
1589 |
# 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
|
1590 |
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
|
1591 |
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
|
1592 |
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
|
1593 |
"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
|
1594 |
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
|
1595 |
if verbose: |
d5ee7746faeb
16108 boot environments should be created by default only when needed
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2028
diff
changeset
|
1596 |
logger.error("\n".join(e.verbose_info)) |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1597 |
if e.invalid_mediations: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1598 |
# Bad user input for mediation. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
1599 |
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
|
1600 |
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
|
1601 |
|
2612
7bf2387ebd19
18958 Error message concerning /var/pkg/lock & lack of privileges could be improved
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2609
diff
changeset
|
1602 |
if isinstance(e, (api_errors.CertificateError, |
1779
b80275b45b18
14176 copytree callers must catch shutil.Error and not traceback
Shawn Walker <srw@sun.com>
parents:
1775
diff
changeset
|
1603 |
api_errors.UnknownErrors, |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1604 |
api_errors.PermissionsException, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1605 |
api_errors.InvalidPropertyValue, |
2612
7bf2387ebd19
18958 Error message concerning /var/pkg/lock & lack of privileges could be improved
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2609
diff
changeset
|
1606 |
api_errors.InvalidResourceLocation)): |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1607 |
# 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
|
1608 |
# 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
|
1609 |
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
|
1610 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1611 |
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
|
1612 |
# 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
|
1613 |
# 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
|
1614 |
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
|
1615 |
return EXIT_OOPS |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
1616 |
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
|
1617 |
# 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
|
1618 |
# 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
|
1619 |
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
|
1620 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1621 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1622 |
# 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
|
1623 |
raise |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1624 |
# NOTREACHED |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1625 |
|
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1626 |
def __api_plan(_op, _api_inst, _accept=False, _li_ignore=None, _noexecute=False, |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1627 |
_origins=None, _parsable_version=None, _quiet=False, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1628 |
_review_release_notes=False, _show_licenses=False, _stage=API_STAGE_DEFAULT, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1629 |
_verbose=0, **kwargs): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1630 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1631 |
# 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
|
1632 |
# common arguments. Set those up now. |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1633 |
if _op != PKG_OP_REVERT: |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1634 |
kwargs["li_ignore"] = _li_ignore |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1635 |
kwargs["noexecute"] = _noexecute |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1636 |
if _origins: |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1637 |
kwargs["repos"] = _origins |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1638 |
if _stage != API_STAGE_DEFAULT: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1639 |
kwargs["pubcheck"] = False |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1640 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1641 |
# display plan debugging information |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1642 |
if _verbose > 2: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1643 |
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
|
1644 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1645 |
# plan the requested operation |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1646 |
stuff_to_do = None |
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 _op == PKG_OP_ATTACH: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1649 |
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
|
1650 |
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
|
1651 |
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
|
1652 |
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
|
1653 |
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
|
1654 |
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
|
1655 |
api_plan_func = _api_inst.gen_plan_install |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1656 |
elif _op == PKG_OP_REVERT: |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1657 |
api_plan_func = _api_inst.gen_plan_revert |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1658 |
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
|
1659 |
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
|
1660 |
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
|
1661 |
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
|
1662 |
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
|
1663 |
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
|
1664 |
else: |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1665 |
raise RuntimeError("__api_plan() invalid op: %s" % _op) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1666 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1667 |
planned_self = False |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1668 |
child_plans = [] |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1669 |
try: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1670 |
for pd in api_plan_func(**kwargs): |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1671 |
if planned_self: |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1672 |
# 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
|
1673 |
# since they currently do their own display |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1674 |
# work (unless parsable output is requested). |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1675 |
child_plans.append(pd) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1676 |
continue |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1677 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1678 |
# the first plan description is always for ourself. |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1679 |
planned_self = True |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1680 |
pkg_timer.record("planning", logger=logger) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1681 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1682 |
# if we're in parsable mode don't display anything |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1683 |
# until after we finish planning for all children |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1684 |
if _parsable_version is None: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1685 |
display_plan(_api_inst, [], _noexecute, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1686 |
_op, _parsable_version, _quiet, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1687 |
_show_licenses, _stage, _verbose) |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1688 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1689 |
# if requested accept licenses for child images. we |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1690 |
# have to do this before recursing into children. |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1691 |
if _accept: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1692 |
accept_plan_licenses(_api_inst) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1693 |
except: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1694 |
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
|
1695 |
if rv != EXIT_OK: |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1696 |
pkg_timer.record("planning", logger=logger) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1697 |
return rv |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1698 |
|
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1699 |
if not planned_self: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1700 |
# if we got an exception we didn't do planning for children |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1701 |
pkg_timer.record("planning", logger=logger) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1702 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1703 |
elif _api_inst.isparent(_li_ignore): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1704 |
# if we didn't get an exception and we're a parent image then |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1705 |
# we should have done planning for child images. |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1706 |
pkg_timer.record("planning children", logger=logger) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1707 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1708 |
# if we didn't display our own plan (due to an exception), or if we're |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1709 |
# in parsable mode, then display our plan now. |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1710 |
if not planned_self or _parsable_version is not None: |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1711 |
try: |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1712 |
display_plan(_api_inst, child_plans, _noexecute, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1713 |
_op, _parsable_version, _quiet, _show_licenses, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1714 |
_stage, _verbose) |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1715 |
except api_errors.ApiException, e: |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
1716 |
error(e, cmd=_op) |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1717 |
return EXIT_OOPS |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1718 |
|
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1719 |
# if we didn't accept licenses (due to an exception) then do that now. |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1720 |
if not planned_self and _accept: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1721 |
accept_plan_licenses(_api_inst) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1722 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1723 |
return EXIT_OK |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1724 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1725 |
def __api_plan_file(api_inst): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1726 |
"""Return the path to the PlanDescription save file.""" |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1727 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1728 |
plandir = api_inst.img_plandir |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1729 |
return os.path.join(plandir, "plandesc") |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1730 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1731 |
def __api_plan_save(api_inst): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1732 |
"""Save an image plan to a file.""" |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1733 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1734 |
# get a pointer to the plan |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1735 |
plan = api_inst.describe() |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1736 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1737 |
# save the PlanDescription to a file |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1738 |
path = __api_plan_file(api_inst) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1739 |
oflags = os.O_CREAT | os.O_TRUNC | os.O_WRONLY |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1740 |
try: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1741 |
fd = os.open(path, oflags, 0644) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1742 |
with os.fdopen(fd, "wb") as fobj: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1743 |
plan._save(fobj) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1744 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1745 |
# cleanup any old style imageplan save files |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1746 |
for f in os.listdir(api_inst.img_plandir): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1747 |
path = os.path.join(api_inst.img_plandir, f) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1748 |
if re.search("^actions\.[0-9]+\.json$", f): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1749 |
os.unlink(path) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1750 |
if re.search("^pkgs\.[0-9]+\.json$", f): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1751 |
os.unlink(path) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1752 |
except OSError, e: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1753 |
raise api_errors._convert_error(e) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1754 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1755 |
pkg_timer.record("saving plan", logger=logger) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1756 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1757 |
def __api_plan_load(api_inst, stage, origins): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1758 |
"""Loan an image plan from a file.""" |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1759 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1760 |
# load an existing plan |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1761 |
path = __api_plan_file(api_inst) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1762 |
plan = api.PlanDescription() |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1763 |
try: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1764 |
with open(path) as fobj: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1765 |
plan._load(fobj) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1766 |
except OSError, e: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1767 |
raise api_errors._convert_error(e) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1768 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1769 |
pkg_timer.record("loading plan", logger=logger) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1770 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1771 |
api_inst.reset() |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1772 |
api_inst.set_alt_repos(origins) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1773 |
api_inst.load_plan(plan, prepared=(stage == API_STAGE_EXECUTE)) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1774 |
pkg_timer.record("re-initializing plan", logger=logger) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1775 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1776 |
if stage == API_STAGE_EXECUTE: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1777 |
__api_plan_delete(api_inst) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1778 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1779 |
def __api_plan_delete(api_inst): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1780 |
"""Delete an image plan file.""" |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1781 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1782 |
path = __api_plan_file(api_inst) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1783 |
try: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1784 |
os.unlink(path) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1785 |
except OSError, e: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1786 |
raise api_errors._convert_error(e) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1787 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1788 |
def __api_op(_op, _api_inst, _accept=False, _li_ignore=None, _noexecute=False, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1789 |
_origins=None, _parsable_version=None, _quiet=False, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1790 |
_review_release_notes=False, _show_licenses=False, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1791 |
_stage=API_STAGE_DEFAULT, _verbose=0, **kwargs): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1792 |
"""Do something that involves the api. |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1793 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1794 |
Arguments prefixed with '_' are primarily used within this |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1795 |
function. All other arguments must be specified via keyword |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1796 |
assignment and will be passed directly on to the api |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1797 |
interfaces being invoked.""" |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1798 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1799 |
if _stage in [API_STAGE_DEFAULT, API_STAGE_PLAN]: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1800 |
# create a new plan |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1801 |
rv = __api_plan(_op=_op, _api_inst=_api_inst, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1802 |
_accept=_accept, _li_ignore=_li_ignore, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1803 |
_noexecute=_noexecute, _origins=_origins, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1804 |
_parsable_version=_parsable_version, _quiet=_quiet, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1805 |
_review_release_notes=_review_release_notes, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1806 |
_show_licenses=_show_licenses, _stage=_stage, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1807 |
_verbose=_verbose, **kwargs) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1808 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1809 |
if rv != EXIT_OK: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1810 |
return rv |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1811 |
if not _noexecute and _stage == API_STAGE_PLAN: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1812 |
# We always save the plan, even if it is a noop. We |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1813 |
# do this because we want to be able to verify that we |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1814 |
# can load and execute a noop plan. (This mimics |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1815 |
# normal api behavior which doesn't prevent an api |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1816 |
# consumer from creating a noop plan and then |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1817 |
# preparing and executing it.) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1818 |
__api_plan_save(_api_inst) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1819 |
if _api_inst.planned_nothingtodo(): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1820 |
return EXIT_NOP |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1821 |
if _noexecute or _stage == API_STAGE_PLAN: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1822 |
return EXIT_OK |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1823 |
else: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1824 |
assert _stage in [API_STAGE_PREPARE, API_STAGE_EXECUTE] |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1825 |
__api_plan_load(_api_inst, _stage, _origins) |
2339
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 |
# 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
|
1828 |
# with or without some extra decoration done here. |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1829 |
if _stage in [API_STAGE_DEFAULT, API_STAGE_PREPARE]: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1830 |
ret_code = __api_prepare_plan(_op, _api_inst) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1831 |
pkg_timer.record("preparing", logger=logger) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1832 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1833 |
if ret_code != EXIT_OK: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1834 |
return ret_code |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1835 |
if _stage == API_STAGE_PREPARE: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1836 |
return EXIT_OK |
2339
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 |
ret_code = __api_execute_plan(_op, _api_inst) |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1839 |
pkg_timer.record("executing", logger=logger) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1840 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1841 |
if _review_release_notes and ret_code == EXIT_OK and \ |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1842 |
_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
|
1843 |
msg("\n" + "-" * 75) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1844 |
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
|
1845 |
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
|
1846 |
msg("-" * 75 + "\n") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1847 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1848 |
return ret_code |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1849 |
|
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1850 |
class RemoteDispatch(object): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1851 |
"""RPC Server Class which invoked by the PipedRPCServer when a RPC |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1852 |
request is recieved.""" |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1853 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1854 |
def __dispatch(self, op, pwargs): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1855 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1856 |
pkg_timer.record("rpc dispatch wait", logger=logger) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1857 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1858 |
# if we were called with no arguments then pwargs will be [] |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1859 |
if pwargs == []: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1860 |
pwargs = {} |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1861 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1862 |
op_supported = [ |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1863 |
PKG_OP_AUDIT_LINKED, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1864 |
PKG_OP_DETACH, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1865 |
PKG_OP_PUBCHECK, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1866 |
PKG_OP_SYNC, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1867 |
PKG_OP_UPDATE, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1868 |
] |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1869 |
if op not in op_supported: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1870 |
raise Exception( |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1871 |
'method "%s" is not supported' % op) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1872 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1873 |
# if a stage was specified, get it. |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1874 |
stage = pwargs.get("stage", API_STAGE_DEFAULT) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1875 |
assert stage in api_stage_values |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1876 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1877 |
# if we're starting a new operation, reset the api. we do |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1878 |
# this just in case our parent updated our linked image |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1879 |
# metadata. |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1880 |
if stage in [API_STAGE_DEFAULT, API_STAGE_PLAN]: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1881 |
_api_inst.reset() |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1882 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1883 |
op_func = cmds[op][0] |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1884 |
rv = op_func(op, _api_inst, pargs, **pwargs) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1885 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1886 |
if DebugValues["timings"]: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1887 |
msg(str(pkg_timer)) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1888 |
pkg_timer.reset() |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1889 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1890 |
return rv |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1891 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1892 |
def _dispatch(self, op, pwargs): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1893 |
"""Primary RPC dispatch function. |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1894 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1895 |
This function must be kept super simple because if we take an |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1896 |
exception here then no output will be generated and this |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1897 |
package remote process will silently exit with a non-zero |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1898 |
return value (and the lack of an exception message makes this |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1899 |
failure very difficult to debug). Hence we wrap the real |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1900 |
remote dispatch routine with a call to handle_errors(), which |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1901 |
will catch and display any exceptions encountered.""" |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1902 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1903 |
# flush output before and after every operation. |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1904 |
misc.flush_output() |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1905 |
misc.truncate_file(sys.stdout) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1906 |
misc.truncate_file(sys.stderr) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1907 |
rv = handle_errors(self.__dispatch, True, op, pwargs) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1908 |
misc.flush_output() |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1909 |
return rv |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1910 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1911 |
def remote(op, api_inst, pargs, ctlfd): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1912 |
"""Execute commands from a remote pipe""" |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1913 |
|
2896
317cfe39ab72
16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2893
diff
changeset
|
1914 |
# |
317cfe39ab72
16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2893
diff
changeset
|
1915 |
# this is kinda a gross hack. SocketServer.py uses select.select() |
317cfe39ab72
16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2893
diff
changeset
|
1916 |
# which doesn't support file descriptors larger than FD_SETSIZE. |
317cfe39ab72
16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2893
diff
changeset
|
1917 |
# Since ctlfd may have been allocated in a parent process with many |
317cfe39ab72
16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2893
diff
changeset
|
1918 |
# file descriptors, it may be larger than FD_SETSIZE. Here in the |
317cfe39ab72
16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2893
diff
changeset
|
1919 |
# child, though, the majority of those have been closed, so os.dup() |
317cfe39ab72
16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2893
diff
changeset
|
1920 |
# should return a lower-numbered descriptor which will work with |
317cfe39ab72
16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2893
diff
changeset
|
1921 |
# select.select(). |
317cfe39ab72
16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2893
diff
changeset
|
1922 |
# |
317cfe39ab72
16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2893
diff
changeset
|
1923 |
ctlfd_new = os.dup(ctlfd) |
317cfe39ab72
16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2893
diff
changeset
|
1924 |
os.close(ctlfd) |
317cfe39ab72
16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2893
diff
changeset
|
1925 |
ctlfd = ctlfd_new |
317cfe39ab72
16172195 Unable to update T5 with S11u1 (FCS) and 288 zones to S11U1 SRU 3
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2893
diff
changeset
|
1926 |
|
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1927 |
rpc_server = pipeutils.PipedRPCServer(ctlfd) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1928 |
rpc_server.register_introspection_functions() |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1929 |
rpc_server.register_instance(RemoteDispatch()) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1930 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1931 |
pkg_timer.record("rpc startup", logger=logger) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1932 |
rpc_server.serve_forever() |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
1933 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1934 |
def change_variant(op, api_inst, pargs, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1935 |
accept, backup_be, backup_be_name, be_activate, be_name, li_ignore, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1936 |
li_parent_sync, new_be, noexecute, origins, parsable_version, quiet, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1937 |
refresh_catalogs, reject_pats, show_licenses, update_index, verbose): |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1938 |
"""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
|
1939 |
the image contents as necessary.""" |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1940 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1941 |
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
|
1942 |
if not xrval: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1943 |
return EXIT_OOPS |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1944 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1945 |
if not pargs: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1946 |
usage(_("%s: no variants specified") % op) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1947 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
1948 |
variants = dict() |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1949 |
for arg in pargs: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1950 |
# '=' 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
|
1951 |
if (len(arg.split('=')) != 2): |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1952 |
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
|
1953 |
"'<name>=<value>'.") % op) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1954 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1955 |
# get the variant name and value |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1956 |
name, value = arg.split('=') |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1957 |
if not name.startswith("variant."): |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1958 |
name = "variant.%s" % name |
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 |
# 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
|
1961 |
if name in variants: |
2826
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
1962 |
usage(_("%(subcmd)s: duplicate variant specified: " |
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
1963 |
"%(variant)s") % {"subcmd": op, "variant": name}) |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1964 |
variants[name] = value |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1266
diff
changeset
|
1965 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1966 |
return __api_op(op, api_inst, _accept=accept, _li_ignore=li_ignore, |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1967 |
_noexecute=noexecute, _origins=origins, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
1968 |
_parsable_version=parsable_version, _quiet=quiet, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1969 |
_show_licenses=show_licenses, _verbose=verbose, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1970 |
backup_be=backup_be, backup_be_name=backup_be_name, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1971 |
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
|
1972 |
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
|
1973 |
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
|
1974 |
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
|
1975 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1976 |
def change_facet(op, api_inst, pargs, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1977 |
accept, backup_be, backup_be_name, be_activate, be_name, li_ignore, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1978 |
li_parent_sync, new_be, noexecute, origins, parsable_version, quiet, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
1979 |
refresh_catalogs, reject_pats, 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
|
1980 |
"""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
|
1981 |
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
|
1982 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1983 |
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
|
1984 |
if not xrval: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
1985 |
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
|
1986 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1987 |
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
|
1988 |
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
|
1989 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
1990 |
# 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
|
1991 |
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
|
1992 |
allowed_values = { |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
1993 |
"TRUE" : True, |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
1994 |
"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
|
1995 |
"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
|
1996 |
} |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1997 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
1998 |
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
|
1999 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2000 |
# '=' 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
|
2001 |
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
|
2002 |
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
|
2003 |
"'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
|
2004 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2005 |
# 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
|
2006 |
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
|
2007 |
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
|
2008 |
name = "facet." + name |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
2009 |
|
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 |
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
|
2011 |
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
|
2012 |
"'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
|
2013 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2014 |
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
|
2015 |
|
2482
b47e1f7cc268
18646 traceback when setting a facet with no installed actions to 'None'
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2470
diff
changeset
|
2016 |
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
|
2017 |
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
|
2018 |
else: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
2019 |
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
|
2020 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2021 |
return __api_op(op, api_inst, _accept=accept, _li_ignore=li_ignore, |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2022 |
_noexecute=noexecute, _origins=origins, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2023 |
_parsable_version=parsable_version, _quiet=quiet, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2024 |
_show_licenses=show_licenses, _verbose=verbose, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2025 |
backup_be=backup_be, backup_be_name=backup_be_name, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2026 |
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
|
2027 |
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
|
2028 |
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
|
2029 |
update_index=update_index) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2030 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2031 |
def install(op, api_inst, pargs, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2032 |
accept, backup_be, backup_be_name, be_activate, be_name, li_ignore, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2033 |
li_parent_sync, new_be, noexecute, origins, parsable_version, quiet, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2034 |
refresh_catalogs, reject_pats, show_licenses, update_index, verbose): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2035 |
|
50 | 2036 |
"""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
|
2037 |
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
|
2038 |
|
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
|
2039 |
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
|
2040 |
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
|
2041 |
|
1835
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
2042 |
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
|
2043 |
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
|
2044 |
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
|
2045 |
|
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
|
2046 |
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
|
2047 |
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
|
2048 |
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
|
2049 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2050 |
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
|
2051 |
_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
|
2052 |
_show_licenses=show_licenses, _verbose=verbose, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2053 |
backup_be=backup_be, backup_be_name=backup_be_name, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2054 |
be_activate=be_activate, be_name=be_name, |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2055 |
li_parent_sync=li_parent_sync, new_be=new_be, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2056 |
_parsable_version=parsable_version, pkgs_inst=pargs, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2057 |
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
|
2058 |
update_index=update_index) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2059 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2060 |
def uninstall(op, api_inst, pargs, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2061 |
be_activate, backup_be, backup_be_name, be_name, new_be, li_ignore, |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
2062 |
li_parent_sync, update_index, noexecute, parsable_version, quiet, |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
2063 |
verbose, stage): |
14
969c85e852af
start pkg graph management, annotate pkgsend with server states
"Stephen Hahn <sch@sun.com>"
parents:
3
diff
changeset
|
2064 |
"""Attempt to take package specified to DELETED state.""" |
66 | 2065 |
|
361
5aca6ca29a5d
1612 pkg contents doesn't give me the manifest I asked for
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
344
diff
changeset
|
2066 |
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
|
2067 |
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
|
2068 |
|
326
0f1ba0508d1b
583 src/pkg-server.xml missing a CDDL block
Dan Price <dp@eng.sun.com>
parents:
323
diff
changeset
|
2069 |
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
|
2070 |
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
|
2071 |
|
1835
13fdfa2f7993
15029 pkg list can traceback if character only allowed with wildcards used
Shawn Walker <shawn.walker@oracle.com>
parents:
1834
diff
changeset
|
2072 |
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
|
2073 |
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
|
2074 |
return EXIT_OOPS |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
2075 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2076 |
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
|
2077 |
_noexecute=noexecute, _quiet=quiet, _stage=stage, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2078 |
_verbose=verbose, backup_be=backup_be, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2079 |
backup_be_name=backup_be_name, be_activate=be_activate, |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
2080 |
be_name=be_name, li_parent_sync=li_parent_sync, new_be=new_be, |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
2081 |
_parsable_version=parsable_version, |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2082 |
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
|
2083 |
|
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
2084 |
def update(op, api_inst, pargs, accept, backup_be, backup_be_name, be_activate, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
2085 |
be_name, force, li_ignore, li_parent_sync, new_be, noexecute, origins, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
2086 |
parsable_version, quiet, refresh_catalogs, reject_pats, show_licenses, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
2087 |
stage, update_index, verbose): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2088 |
"""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
|
2089 |
version.""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2090 |
|
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
2091 |
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
|
2092 |
if not rval: |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
2093 |
return EXIT_OOPS |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
2094 |
|
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
|
2095 |
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
|
2096 |
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
|
2097 |
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
|
2098 |
|
2681
29aba686b970
7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2675
diff
changeset
|
2099 |
if res: |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2100 |
# 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
|
2101 |
# 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
|
2102 |
# 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
|
2103 |
# 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
|
2104 |
pkgs_update = pargs |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2105 |
review_release_notes = False |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2106 |
else: |
2681
29aba686b970
7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2675
diff
changeset
|
2107 |
# If no packages were specified, attempt to update all installed |
29aba686b970
7140060 install and update should allow multiple pattern matches when they intersect
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2675
diff
changeset
|
2108 |
# packages. |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2109 |
pkgs_update = None |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2110 |
review_release_notes = True |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2111 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2112 |
return __api_op(op, api_inst, _accept=accept, _li_ignore=li_ignore, |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2113 |
_noexecute=noexecute, _origins=origins, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2114 |
_parsable_version=parsable_version, _quiet=quiet, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2115 |
_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
|
2116 |
_show_licenses=show_licenses, _stage=stage, _verbose=verbose, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2117 |
backup_be=backup_be, backup_be_name=backup_be_name, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
2118 |
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
|
2119 |
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
|
2120 |
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
|
2121 |
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
|
2122 |
|
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2123 |
def revert(op, api_inst, pargs, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2124 |
backup_be, backup_be_name, be_activate, be_name, new_be, noexecute, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2125 |
parsable_version, quiet, tagged, 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
|
2126 |
"""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
|
2127 |
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
|
2128 |
|
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
|
2129 |
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
|
2130 |
usage(_("at least one file path or tag name required"), cmd=op) |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2131 |
|
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2132 |
return __api_op(op, api_inst, _noexecute=noexecute, _quiet=quiet, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2133 |
_verbose=verbose, be_activate=be_activate, be_name=be_name, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2134 |
new_be=new_be, _parsable_version=parsable_version, args=pargs, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2135 |
tagged=tagged) |
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
2136 |
|
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2137 |
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
|
2138 |
list_available): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2139 |
"""Display configured or available mediator version(s) and |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2140 |
implementation(s).""" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2141 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2142 |
subcommand = "mediator" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2143 |
if output_format is None: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2144 |
output_format = "default" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2145 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2146 |
# 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
|
2147 |
# of version and implementation indexed by mediator name. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2148 |
mediations = collections.defaultdict(list) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2149 |
if list_available: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2150 |
gen_mediators = api_inst.gen_available_mediators() |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2151 |
else: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2152 |
# Configured mediator information |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2153 |
gen_mediators = ( |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2154 |
(mediator, mediation) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2155 |
for mediator, mediation in api_inst.mediators.iteritems() |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2156 |
) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2157 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2158 |
# 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
|
2159 |
# 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
|
2160 |
mediators = set() |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2161 |
max_mname_len = len(_("MEDIATOR")) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2162 |
max_vsrc_len = len(_("VER. SRC.")) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2163 |
max_version_len = len(_("VERSION")) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2164 |
max_isrc_len = len(_("IMPL. SRC.")) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2165 |
for mname, values in gen_mediators: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2166 |
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
|
2167 |
med_version = values.get("version", "") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2168 |
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
|
2169 |
mediators.add(mname) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2170 |
mediations[mname].append(values) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2171 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2172 |
requested_mediators = set(pargs) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2173 |
if requested_mediators: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2174 |
found = mediators & requested_mediators |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2175 |
notfound = requested_mediators - found |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2176 |
else: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2177 |
found = mediators |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2178 |
notfound = set() |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2179 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2180 |
def gen_listing(): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2181 |
for mediator, mediation in ( |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2182 |
(mname, mentry) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2183 |
for mname in sorted(found) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2184 |
for mentry in mediations[mname] |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2185 |
): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2186 |
med_impl = mediation.get("implementation") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2187 |
med_impl_ver = mediation.get("implementation-version") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2188 |
if output_format == "default" and med_impl and \ |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2189 |
med_impl_ver: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2190 |
med_impl += "(@%s)" % med_impl_ver |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2191 |
yield { |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2192 |
"mediator": mediator, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2193 |
"version": mediation.get("version"), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2194 |
"version-source": mediation.get("version-source"), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2195 |
"implementation": med_impl, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2196 |
"implementation-source": mediation.get( |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2197 |
"implementation-source"), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2198 |
"implementation-version": med_impl_ver, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2199 |
} |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2200 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2201 |
# 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
|
2202 |
# <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
|
2203 |
# <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
|
2204 |
# ... |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2205 |
field_data = { |
2510
f48530fd135d
18440 pkgrepo should be able to list packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2503
diff
changeset
|
2206 |
"mediator" : [("default", "json", "tsv"), _("MEDIATOR"), ""], |
f48530fd135d
18440 pkgrepo should be able to list packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2503
diff
changeset
|
2207 |
"version" : [("default", "json", "tsv"), _("VERSION"), ""], |
f48530fd135d
18440 pkgrepo should be able to list packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2503
diff
changeset
|
2208 |
"version-source": [("default", "json", "tsv"), _("VER. SRC."), ""], |
f48530fd135d
18440 pkgrepo should be able to list packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2503
diff
changeset
|
2209 |
"implementation" : [("default", "json", "tsv"), _("IMPLEMENTATION"), |
f48530fd135d
18440 pkgrepo should be able to list packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2503
diff
changeset
|
2210 |
""], |
f48530fd135d
18440 pkgrepo should be able to list packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2503
diff
changeset
|
2211 |
"implementation-source": [("default", "json", "tsv"), |
f48530fd135d
18440 pkgrepo should be able to list packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2503
diff
changeset
|
2212 |
_("IMPL. SRC."), ""], |
f48530fd135d
18440 pkgrepo should be able to list packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2503
diff
changeset
|
2213 |
"implementation-version" : [("json", "tsv"), _("IMPL. VER."), ""], |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2214 |
} |
2510
f48530fd135d
18440 pkgrepo should be able to list packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2503
diff
changeset
|
2215 |
desired_field_order = (_("MEDIATOR"), _("VER. SRC."), _("VERSION"), |
f48530fd135d
18440 pkgrepo should be able to list packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2503
diff
changeset
|
2216 |
_("IMPL. SRC."), _("IMPLEMENTATION"), _("IMPL. VER.")) |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2217 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2218 |
# Default output formatting. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2219 |
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
|
2220 |
"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
|
2221 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2222 |
if found or (not requested_mediators and output_format == "default"): |
2510
f48530fd135d
18440 pkgrepo should be able to list packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2503
diff
changeset
|
2223 |
sys.stdout.write(misc.get_listing(desired_field_order, |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2224 |
field_data, gen_listing(), output_format, def_fmt, |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2225 |
omit_headers, escape_output=False)) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2226 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2227 |
if found and notfound: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2228 |
return EXIT_PARTIAL |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2229 |
if requested_mediators and not found: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2230 |
if output_format == "default": |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2231 |
# Don't pollute other output formats. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2232 |
error(_("no matching mediators found"), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2233 |
cmd=subcommand) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2234 |
return EXIT_OOPS |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2235 |
return EXIT_OK |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2236 |
|
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2237 |
def set_mediator(op, api_inst, pargs, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2238 |
backup_be, backup_be_name, be_activate, be_name, med_implementation, |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2239 |
med_version, new_be, noexecute, parsable_version, quiet, update_index, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2240 |
verbose): |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2241 |
"""Set the version and/or implementation for the specified |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2242 |
mediator(s).""" |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2243 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2244 |
if not pargs: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2245 |
usage(_("at least one mediator must be specified"), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2246 |
cmd=op) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2247 |
if not (med_version or med_implementation): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2248 |
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
|
2249 |
"specified using -V and -I"), cmd=op) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2250 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2251 |
if verbose > 2: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2252 |
DebugValues.set_value("plan", "True") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2253 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2254 |
# 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
|
2255 |
# 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
|
2256 |
# 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
|
2257 |
mediators = collections.defaultdict(dict) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2258 |
for m in pargs: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2259 |
if med_version == "": |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2260 |
# Request reset of version. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2261 |
mediators[m]["version"] = None |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2262 |
elif med_version == "None": |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2263 |
# Explicit selection of no version. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2264 |
mediators[m]["version"] = "" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2265 |
elif med_version: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2266 |
mediators[m]["version"] = med_version |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2267 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2268 |
if med_implementation == "": |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2269 |
# Request reset of implementation. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2270 |
mediators[m]["implementation"] = None |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2271 |
elif med_implementation == "None": |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2272 |
# Explicit selection of no implementation. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2273 |
mediators[m]["implementation"] = "" |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2274 |
elif med_implementation: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2275 |
mediators[m]["implementation"] = med_implementation |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2276 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2277 |
stuff_to_do = None |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2278 |
try: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2279 |
for pd in api_inst.gen_plan_set_mediators(mediators, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2280 |
noexecute=noexecute, backup_be=backup_be, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2281 |
backup_be_name=backup_be_name, be_name=be_name, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2282 |
new_be=new_be, be_activate=be_activate): |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2283 |
continue |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2284 |
stuff_to_do = not api_inst.planned_nothingtodo() |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2285 |
except: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2286 |
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
|
2287 |
verbose) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2288 |
if ret_code != EXIT_OK: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2289 |
return ret_code |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2290 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2291 |
if not stuff_to_do: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2292 |
if verbose: |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
2293 |
__display_plan(api_inst, verbose, noexecute) |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2294 |
if parsable_version is not None: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2295 |
try: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2296 |
__display_parsable_plan(api_inst, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2297 |
parsable_version) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2298 |
except api_errors.ApiException, e: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2299 |
error(e, cmd=op) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2300 |
return EXIT_OOPS |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2301 |
else: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2302 |
msg(_("No changes required.")) |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2303 |
return EXIT_NOP |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2304 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2305 |
if not quiet: |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
2306 |
__display_plan(api_inst, verbose, noexecute) |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2307 |
if parsable_version is not None: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2308 |
try: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2309 |
__display_parsable_plan(api_inst, parsable_version) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2310 |
except api_errors.ApiException, e: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2311 |
error(e, cmd=op) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2312 |
return EXIT_OOPS |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2313 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2314 |
if noexecute: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2315 |
return EXIT_OK |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2316 |
|
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
2317 |
ret_code = __api_prepare_plan(op, api_inst) |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2318 |
if ret_code != EXIT_OK: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2319 |
return ret_code |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2320 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2321 |
ret_code = __api_execute_plan(op, api_inst) |
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 |
return ret_code |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2324 |
|
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2325 |
def unset_mediator(op, api_inst, pargs, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2326 |
backup_be, backup_be_name, be_activate, be_name, med_implementation, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2327 |
med_version, new_be, noexecute, parsable_version, quiet, update_index, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2328 |
verbose): |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2329 |
"""Unset the version and/or implementation for the specified |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2330 |
mediator(s).""" |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2331 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2332 |
if not pargs: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2333 |
usage(_("at least one mediator must be specified"), |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2334 |
cmd=op) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2335 |
if verbose > 2: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2336 |
DebugValues.set_value("plan", "True") |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2337 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2338 |
# 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
|
2339 |
mediators = collections.defaultdict(dict) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2340 |
if not (med_version or med_implementation): |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2341 |
# Unset both if nothing specific requested. |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2342 |
med_version = True |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2343 |
med_implementation = True |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2344 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2345 |
# 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
|
2346 |
for m in pargs: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2347 |
if med_version: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2348 |
mediators[m]["version"] = None |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2349 |
if med_implementation: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2350 |
mediators[m]["implementation"] = None |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2351 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2352 |
stuff_to_do = None |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2353 |
try: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2354 |
for pd in api_inst.gen_plan_set_mediators(mediators, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2355 |
noexecute=noexecute, backup_be=backup_be, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2356 |
backup_be_name=backup_be_name, be_name=be_name, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
2357 |
new_be=new_be, be_activate=be_activate): |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2358 |
continue |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2359 |
stuff_to_do = not api_inst.planned_nothingtodo() |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2360 |
except: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2361 |
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
|
2362 |
verbose) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2363 |
if ret_code != EXIT_OK: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2364 |
return ret_code |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2365 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2366 |
if not stuff_to_do: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2367 |
if verbose: |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
2368 |
__display_plan(api_inst, verbose, noexecute) |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2369 |
if parsable_version is not None: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2370 |
try: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2371 |
__display_parsable_plan(api_inst, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2372 |
parsable_version) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2373 |
except api_errors.ApiException, e: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2374 |
error(e, cmd=op) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2375 |
return EXIT_OOPS |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2376 |
else: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2377 |
msg(_("No changes required.")) |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2378 |
return EXIT_NOP |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2379 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2380 |
if not quiet: |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
2381 |
__display_plan(api_inst, verbose, noexecute) |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2382 |
if parsable_version is not None: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2383 |
try: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2384 |
__display_parsable_plan(api_inst, parsable_version) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2385 |
except api_errors.ApiException, e: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2386 |
error(e, cmd=op) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
2387 |
return EXIT_OOPS |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2388 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2389 |
if noexecute: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2390 |
return EXIT_OK |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2391 |
|
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
2392 |
ret_code = __api_prepare_plan(op, api_inst) |
2453
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2393 |
if ret_code != EXIT_OK: |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2394 |
return ret_code |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2395 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2396 |
ret_code = __api_execute_plan(op, api_inst) |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2397 |
|
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2398 |
return ret_code |
330443795456
18619 link mediation support needed
Shawn Walker <shawn.walker@oracle.com>
parents:
2452
diff
changeset
|
2399 |
|
2228
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2400 |
def avoid(api_inst, args): |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2401 |
"""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
|
2402 |
if not args: |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2403 |
return __display_avoids(api_inst) |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2404 |
|
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2405 |
try: |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2406 |
api_inst.avoid_pkgs(args) |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2407 |
return EXIT_OK |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2408 |
except: |
2413
c22af530e922
18432 consumers of __api_plan_exception not updated
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2410
diff
changeset
|
2409 |
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
|
2410 |
|
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2411 |
def unavoid(api_inst, args): |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2412 |
"""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
|
2413 |
if not args: |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2414 |
return __display_avoids(api_inst) |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2415 |
|
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2416 |
try: |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2417 |
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
|
2418 |
return EXIT_OK |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2419 |
except: |
2413
c22af530e922
18432 consumers of __api_plan_exception not updated
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2410
diff
changeset
|
2420 |
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
|
2421 |
|
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2422 |
def __display_avoids(api_inst): |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2423 |
"""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
|
2424 |
that pkg""" |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2425 |
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
|
2426 |
tracking = " ".join(a[1]) |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2427 |
if tracking: |
2826
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
2428 |
logger.info(_( |
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
2429 |
" %(avoid_pkg)s (group dependency of " |
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
2430 |
"'%(tracking_pkg)s')") |
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
2431 |
% {"avoid_pkg": a[0], "tracking_pkg": tracking}) |
2228
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2432 |
else: |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2433 |
logger.info(" %s" % a[0]) |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2434 |
|
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2435 |
return EXIT_OK |
5319ee47781d
2774 new depend action behavior: follow if possible
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2219
diff
changeset
|
2436 |
|
2452
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2437 |
def freeze(api_inst, args): |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2438 |
"""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
|
2439 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2440 |
opts, pargs = getopt.getopt(args, "Hc:n") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2441 |
comment = None |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2442 |
display_headers = True |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2443 |
dry_run = False |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2444 |
for opt, arg in opts: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2445 |
if opt == "-H": |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2446 |
display_headers = False |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2447 |
elif opt == "-c": |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2448 |
comment = arg |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2449 |
elif opt == "-n": |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2450 |
dry_run = True |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2451 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2452 |
if comment and not pargs: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2453 |
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
|
2454 |
"given when -c is used."), cmd="freeze") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2455 |
if not display_headers and pargs: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2456 |
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
|
2457 |
"currently frozen packages.")) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2458 |
if not pargs: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2459 |
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
|
2460 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2461 |
try: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2462 |
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
|
2463 |
comment=comment) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2464 |
for pfmri in pfmris: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2465 |
vertext = pfmri.version.get_short_version() |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2466 |
ts = pfmri.version.get_timestamp() |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2467 |
if ts: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2468 |
vertext += ":" + pfmri.version.timestr |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2469 |
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
|
2470 |
{"name": pfmri.pkg_name, "ver": vertext}) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2471 |
return EXIT_OK |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2472 |
except api_errors.FreezePkgsException, e: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2473 |
error("\n%s" % e, cmd="freeze") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2474 |
return EXIT_OOPS |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2475 |
except: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2476 |
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
|
2477 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2478 |
def unfreeze(api_inst, args): |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2479 |
"""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
|
2480 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2481 |
opts, pargs = getopt.getopt(args, "Hn") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2482 |
display_headers = True |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2483 |
dry_run = False |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2484 |
for opt, arg in opts: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2485 |
if opt == "-H": |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2486 |
display_headers = False |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2487 |
elif opt == "-n": |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2488 |
dry_run = True |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2489 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2490 |
if not pargs: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2491 |
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
|
2492 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2493 |
try: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2494 |
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
|
2495 |
dry_run=dry_run) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2496 |
if not pkgs: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2497 |
return EXIT_NOP |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2498 |
for s in pkgs: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2499 |
logger.info(_("%s was unfrozen.") % s) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2500 |
return EXIT_OK |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2501 |
except: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2502 |
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
|
2503 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2504 |
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
|
2505 |
"""Display the current frozen list""" |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2506 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2507 |
try: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2508 |
lst = sorted(api_inst.get_frozen_list()) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2509 |
except api_errors.ApiException, e: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2510 |
error(e) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2511 |
return EXIT_OOPS |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2512 |
if len(lst) == 0: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2513 |
return EXIT_OK |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2514 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2515 |
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
|
2516 |
if display_headers: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2517 |
logger.info(fmt % { |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2518 |
"name": _("NAME"), |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2519 |
"ver": _("VERSION"), |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2520 |
"time": _("DATE"), |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2521 |
"comment": _("COMMENT") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2522 |
}) |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
2523 |
|
2452
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2524 |
for pfmri, comment, timestamp in lst: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2525 |
vertext = pfmri.version.get_short_version() |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2526 |
ts = pfmri.version.get_timestamp() |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2527 |
if ts: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2528 |
vertext += ":" + pfmri.version.timestr |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2529 |
if not comment: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2530 |
comment = "None" |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2531 |
logger.info(fmt % { |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2532 |
"name": pfmri.pkg_name, |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2533 |
"comment": comment, |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2534 |
"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
|
2535 |
time.localtime(timestamp)), |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2536 |
"ver": vertext |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2537 |
}) |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2538 |
return EXIT_OK |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2539 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2540 |
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
|
2541 |
"""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
|
2542 |
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
|
2543 |
|
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2544 |
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
|
2545 |
|
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2546 |
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
|
2547 |
below. |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2548 |
|
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2549 |
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
|
2550 |
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
|
2551 |
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
|
2552 |
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
|
2553 |
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
|
2554 |
states which value matched the query.""" |
1234
d9885dff5d16
4705 UnboundLocalError in depend action
Shawn Walker <srw@sun.com>
parents:
1218
diff
changeset
|
2555 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2556 |
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
|
2557 |
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
|
2558 |
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
|
2559 |
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
|
2560 |
|
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2561 |
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
|
2562 |
"""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
|
2563 |
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
|
2564 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2565 |
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
|
2566 |
return match |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2567 |
if match == "basename": |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2568 |
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
|
2569 |
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
|
2570 |
if r: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2571 |
return r |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2572 |
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
|
2573 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2574 |
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
|
2575 |
"""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
|
2576 |
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
|
2577 |
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
|
2578 |
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
|
2579 |
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
|
2580 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2581 |
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
|
2582 |
return match |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2583 |
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
|
2584 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2585 |
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
|
2586 |
"""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
|
2587 |
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
|
2588 |
|
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2589 |
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
|
2590 |
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
|
2591 |
|
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2592 |
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
|
2593 |
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
|
2594 |
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
|
2595 |
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
|
2596 |
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
|
2597 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2598 |
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
|
2599 |
the result was obtained.""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2600 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2601 |
action = None |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2602 |
match = None |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2603 |
match_type = None |
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
1094
diff
changeset
|
2604 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2605 |
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
|
2606 |
try: |
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2607 |
pfmri, match, action = tup |
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2608 |
except ValueError: |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
2609 |
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
|
2610 |
"The problematic structure:%r") % (tup,)) |
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2611 |
return False |
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2612 |
try: |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2613 |
action = actions.fromstr(action.rstrip()) |
1234
d9885dff5d16
4705 UnboundLocalError in depend action
Shawn Walker <srw@sun.com>
parents:
1218
diff
changeset
|
2614 |
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
|
2615 |
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
|
2616 |
"unsupported action.\n%s") % e) |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2617 |
return False |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2618 |
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
|
2619 |
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
|
2620 |
else: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2621 |
pfmri = tup |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2622 |
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
|
2623 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
2624 |
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
|
2625 |
"""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
|
2626 |
|
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2627 |
# 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
|
2628 |
page_timeout = .5 |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2629 |
max_timeout = 5 |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2630 |
min_page_size = 5 |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2631 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2632 |
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
|
2633 |
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
|
2634 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2635 |
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
|
2636 |
search_prefixes.extend(["search."]) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2637 |
|
1843
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2638 |
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
|
2639 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2640 |
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
|
2641 |
"search.match", "pkg.shortfmri"] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2642 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2643 |
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
|
2644 |
|
499
ff214b0daeb1
2672 Search should allow for case insensitive search.
Brock Pytlik <bpytlik@sun.com>
parents:
497
diff
changeset
|
2645 |
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
|
2646 |
servers = [] |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2647 |
attrs = [] |
1843
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2648 |
|
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2649 |
display_headers = True |
1843
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2650 |
prune_versions = True |
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2651 |
return_actions = True |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2652 |
use_default_attrs = True |
1843
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2653 |
|
204
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2654 |
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
|
2655 |
if opt == "-H": |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2656 |
display_headers = False |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2657 |
elif opt == "-a": |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2658 |
return_actions = True |
1843
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2659 |
elif opt == "-f": |
b9333a197e40
6177 filtering search against a particular incorporation is needed
Brock Pytlik <bpytlik@sun.com>
parents:
1835
diff
changeset
|
2660 |
prune_versions = False |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2661 |
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
|
2662 |
local = True |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2663 |
elif opt == "-o": |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2664 |
attrs.extend(arg.split(",")) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2665 |
use_default_attrs = False |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2666 |
elif opt == "-p": |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2667 |
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
|
2668 |
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
|
2669 |
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
|
2670 |
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
|
2671 |
remote = True |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2672 |
servers.append({ |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2673 |
"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
|
2674 |
elif opt == "-I": |
ff214b0daeb1
2672 Search should allow for case insensitive search.
Brock Pytlik <bpytlik@sun.com>
parents:
497
diff
changeset
|
2675 |
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
|
2676 |
|
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2677 |
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
|
2678 |
remote = True |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
2679 |
|
204
8f650d596aec
72 pkg command throws an exception when no search arguments are given
Danek Duvall <danek.duvall@sun.com>
parents:
201
diff
changeset
|
2680 |
if not pargs: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
2681 |
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
|
2682 |
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
|
2683 |
|
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2684 |
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
|
2685 |
prefixes=search_prefixes) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2686 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2687 |
action_attr = False |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2688 |
for a in attrs: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2689 |
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
|
2690 |
action_attr = True |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2691 |
if not return_actions: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2692 |
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
|
2693 |
"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
|
2694 |
cmd="search") |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2695 |
break |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2696 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2697 |
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
|
2698 |
|
2920
69f5dd9b9488
15620551 search for package along with the publisher should work.
thejaswini.k@oracle.com
parents:
2919
diff
changeset
|
2699 |
# Strip pkg:/ or pkg:/// from the fmri. |
69f5dd9b9488
15620551 search for package along with the publisher should work.
thejaswini.k@oracle.com
parents:
2919
diff
changeset
|
2700 |
# If fmri has pkg:// then strip the prefix |
69f5dd9b9488
15620551 search for package along with the publisher should work.
thejaswini.k@oracle.com
parents:
2919
diff
changeset
|
2701 |
# from 'pkg://' upto the first slash. |
69f5dd9b9488
15620551 search for package along with the publisher should work.
thejaswini.k@oracle.com
parents:
2919
diff
changeset
|
2702 |
|
69f5dd9b9488
15620551 search for package along with the publisher should work.
thejaswini.k@oracle.com
parents:
2919
diff
changeset
|
2703 |
qtext = re.sub(r"pkg:///|pkg://[^/]*/|pkg:/", "", " ".join(pargs)) |
69f5dd9b9488
15620551 search for package along with the publisher should work.
thejaswini.k@oracle.com
parents:
2919
diff
changeset
|
2704 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2705 |
try: |
2920
69f5dd9b9488
15620551 search for package along with the publisher should work.
thejaswini.k@oracle.com
parents:
2919
diff
changeset
|
2706 |
query = [api.Query(qtext, case_sensitive, |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2707 |
return_actions)] |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2708 |
except api_errors.BooleanQueryException, e: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2709 |
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
|
2710 |
return EXIT_OOPS |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2711 |
|
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2712 |
good_res = False |
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2713 |
bad_res = False |
1234
d9885dff5d16
4705 UnboundLocalError in depend action
Shawn Walker <srw@sun.com>
parents:
1218
diff
changeset
|
2714 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2715 |
try: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2716 |
if local: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2717 |
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
|
2718 |
if remote: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2719 |
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
|
2720 |
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
|
2721 |
# 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
|
2722 |
retcode = EXIT_OOPS |
302
a5268194080e
981 pkg search could have more useful output
Danek Duvall <danek.duvall@sun.com>
parents:
301
diff
changeset
|
2723 |
|
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2724 |
# 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
|
2725 |
justs = calc_justs(attrs) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2726 |
page_again = True |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2727 |
widths = [] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2728 |
st = None |
1628
82c58b51e409
12739 remote search returns no results if one depot fails
Brock Pytlik <bpytlik@sun.com>
parents:
1618
diff
changeset
|
2729 |
err = None |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2730 |
header_attrs = attrs |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2731 |
last_line = None |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2732 |
shown_headers = False |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2733 |
while page_again: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2734 |
unprocessed_res = [] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2735 |
page_again = False |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2736 |
# 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
|
2737 |
# 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
|
2738 |
# results, then propogate the error. |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2739 |
try: |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2740 |
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
|
2741 |
if not st: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2742 |
st = time.time() |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2743 |
try: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2744 |
query_num, pub, \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2745 |
(v, return_type, tmp) = \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2746 |
raw_value |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2747 |
except ValueError, e: |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
2748 |
error(_("The repository " |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
2749 |
"returned a malformed " |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
2750 |
"result:%r") % |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2751 |
(raw_value,)) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2752 |
bad_res = True |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2753 |
continue |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2754 |
# 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
|
2755 |
# 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
|
2756 |
# using the <> operator. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2757 |
if action_attr and \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2758 |
return_type != \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2759 |
api.Query.RETURN_ACTIONS: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2760 |
usage(_("action level options " |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2761 |
"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
|
2762 |
"the queries that return " |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2763 |
"packages"), cmd="search") |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2764 |
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
|
2765 |
if return_type == \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2766 |
api.Query.RETURN_ACTIONS: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2767 |
attrs = \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2768 |
default_attrs_action |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2769 |
header_attrs = \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2770 |
["index", "action", |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2771 |
"value", "package"] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2772 |
else: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2773 |
attrs = default_attrs_package |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2774 |
header_attrs = \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2775 |
["package", |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2776 |
"publisher"] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2777 |
justs = calc_justs(attrs) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2778 |
ret = v1_extract_info( |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2779 |
tmp, return_type, pub) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2780 |
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
|
2781 |
if ret: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2782 |
good_res = True |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2783 |
unprocessed_res.append(ret) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2784 |
# 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
|
2785 |
# should be increased. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2786 |
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
|
2787 |
if len(unprocessed_res) > \ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2788 |
min_page_size: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2789 |
page_again = True |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2790 |
break |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2791 |
else: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2792 |
page_timeout = min( |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2793 |
page_timeout * 2, |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2794 |
max_timeout) |
1628
82c58b51e409
12739 remote search returns no results if one depot fails
Brock Pytlik <bpytlik@sun.com>
parents:
1618
diff
changeset
|
2795 |
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
|
2796 |
err = e |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2797 |
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
|
2798 |
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
|
2799 |
last_res=last_line) |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2800 |
if not lines: |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2801 |
continue |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2802 |
old_widths = widths[:] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2803 |
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
|
2804 |
# 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
|
2805 |
# 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
|
2806 |
# the new widths. |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2807 |
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
|
2808 |
old_widths[:-1] != widths[:-1]): |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2809 |
shown_headers = True |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2810 |
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
|
2811 |
for line in lines: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2812 |
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
|
2813 |
widths, justs, line) % |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2814 |
tuple(line)).rstrip()) |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
2815 |
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
|
2816 |
st = time.time() |
1628
82c58b51e409
12739 remote search returns no results if one depot fails
Brock Pytlik <bpytlik@sun.com>
parents:
1618
diff
changeset
|
2817 |
if err: |
82c58b51e409
12739 remote search returns no results if one depot fails
Brock Pytlik <bpytlik@sun.com>
parents:
1618
diff
changeset
|
2818 |
raise err |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2819 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2820 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2821 |
except (api_errors.IncorrectIndexFileHash, |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2822 |
api_errors.InconsistentIndexException): |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2823 |
error(_("The search index appears corrupted. Please " |
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2824 |
"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
|
2825 |
return EXIT_OOPS |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2826 |
except api_errors.ProblematicSearchServers, e: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2827 |
error(e) |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2828 |
bad_res = True |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2829 |
except api_errors.SlowSearchUsed, e: |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2830 |
error(e) |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2831 |
except (api_errors.IncorrectIndexFileHash, |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
2832 |
api_errors.InconsistentIndexException): |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2833 |
error(_("The search index appears corrupted. Please " |
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2834 |
"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
|
2835 |
return EXIT_OOPS |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
2836 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
2837 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
2838 |
return EXIT_OOPS |
1053
00fe9773d072
8098 parsing errors should not cause a stacktrace
Brock Pytlik <bpytlik@sun.com>
parents:
1052
diff
changeset
|
2839 |
except api_errors.ApiException, e: |
00fe9773d072
8098 parsing errors should not cause a stacktrace
Brock Pytlik <bpytlik@sun.com>
parents:
1052
diff
changeset
|
2840 |
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
|
2841 |
return EXIT_OOPS |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2842 |
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
|
2843 |
retcode = EXIT_PARTIAL |
1052
b022868f7356
6251 Unpacking value errors leave unhelpful messages
Brock Pytlik <bpytlik@sun.com>
parents:
1050
diff
changeset
|
2844 |
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
|
2845 |
retcode = EXIT_OOPS |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
2846 |
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
|
2847 |
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
|
2848 |
return retcode |
60
6bd5cd83cfb1
Reverse index database and searching support.
Danek Duvall <danek.duvall@sun.com>
parents:
59
diff
changeset
|
2849 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
2850 |
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
|
2851 |
"""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
|
2852 |
""" |
195
b23d0425f0f7
11 use FMRIs with fully specified authorities internally
johansen <johansen@sun.com>
parents:
192
diff
changeset
|
2853 |
|
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2854 |
display_license = False |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2855 |
info_local = False |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2856 |
info_remote = False |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2857 |
origins = set() |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2858 |
quiet = False |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2859 |
|
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2860 |
opts, pargs = getopt.getopt(args, "g:lqr", ["license"]) |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2861 |
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
|
2862 |
if opt == "-g": |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2863 |
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
|
2864 |
info_remote = True |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2865 |
elif opt == "-l": |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2866 |
info_local = True |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2867 |
elif opt == "-q": |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2868 |
quiet = True |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2869 |
global_settings.client_output_quiet = True |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2870 |
elif opt == "-r": |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2871 |
info_remote = True |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2872 |
elif opt == "--license": |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2873 |
display_license = True |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2874 |
|
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2875 |
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
|
2876 |
info_local = True |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2877 |
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
|
2878 |
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
|
2879 |
|
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2880 |
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
|
2881 |
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
|
2882 |
cmd="info") |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
2883 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
2884 |
err = 0 |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
2885 |
|
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2886 |
# Reset the progress tracker here, because we may have to switch to a |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2887 |
# different tracker due to the options parse. |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2888 |
_api_inst.progresstracker = get_tracker() |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2889 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
2890 |
api_inst.progresstracker.set_purpose( |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
2891 |
api_inst.progresstracker.PURPOSE_LISTING) |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2892 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2893 |
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
|
2894 |
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
|
2895 |
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
|
2896 |
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
|
2897 |
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
|
2898 |
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
|
2899 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2900 |
try: |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2901 |
ret = api_inst.info(pargs, info_local, info_needed, |
2547
032eaff05522
17801 contents -r should return only highest-ranked match by default
Shawn Walker <shawn.walker@oracle.com>
parents:
2544
diff
changeset
|
2902 |
ranked=info_remote, repos=origins) |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
2903 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
2904 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
2905 |
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
|
2906 |
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
|
2907 |
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
|
2908 |
return EXIT_OOPS |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2909 |
except api_errors.ApiException, e: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2910 |
error(e) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
2911 |
return EXIT_OOPS |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2912 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2913 |
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
|
2914 |
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
|
2915 |
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
|
2916 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2917 |
if illegals: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2918 |
# 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
|
2919 |
# specified. |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
2920 |
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
|
2921 |
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
|
2922 |
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
|
2923 |
|
789
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
2924 |
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
|
2925 |
for i, pi in enumerate(pis): |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2926 |
if not quiet and i > 0: |
384
9d4746e5dd3e
115 pkg needs to not have a cow on a SIGPIPE
Shawn Walker <swalker@opensolaris.org>
parents:
362
diff
changeset
|
2927 |
msg("") |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
2928 |
|
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2929 |
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
|
2930 |
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
|
2931 |
no_licenses.append(pi.fmri) |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2932 |
elif not quiet: |
789
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
2933 |
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
|
2934 |
msg(lic) |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
2935 |
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
|
2936 |
|
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2937 |
if quiet: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2938 |
continue |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
2939 |
|
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
2940 |
state = "" |
2452
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2941 |
if api.PackageInfo.INSTALLED in pi.states: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2942 |
state = _("Installed") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2943 |
elif api.PackageInfo.UNSUPPORTED in pi.states: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2944 |
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
|
2945 |
else: |
2452
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2946 |
state = _("Not installed") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2947 |
|
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2948 |
lparen = False |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2949 |
if api.PackageInfo.OBSOLETE in pi.states: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2950 |
state += " (%s" % _("Obsolete") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2951 |
lparen = True |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2952 |
elif api.PackageInfo.RENAMED in pi.states: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2953 |
state += " (%s" % _("Renamed") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2954 |
lparen = True |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2955 |
if api.PackageInfo.FROZEN in pi.states: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2956 |
if lparen: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2957 |
state += ", %s)" % _("Frozen") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2958 |
else: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2959 |
state += " (%s)" % _("Frozen") |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2960 |
elif lparen: |
3be84ba08176
18441 pkg needs a freeze mechanism
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2446
diff
changeset
|
2961 |
state += ")" |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
2962 |
|
688
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2963 |
name_str = _(" Name:") |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2964 |
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
|
2965 |
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
|
2966 |
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
|
2967 |
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
|
2968 |
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
|
2969 |
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
|
2970 |
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
|
2971 |
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
|
2972 |
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
|
2973 |
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
|
2974 |
msg(desc_label, res) |
688
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2975 |
if pi.category_info_list: |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2976 |
verbose = len(pi.category_info_list) > 1 |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2977 |
msg(_(" Category:"), |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2978 |
pi.category_info_list[0].__str__(verbose)) |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2979 |
if len(pi.category_info_list) > 1: |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2980 |
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
|
2981 |
msg(" " * len(name_str), |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2982 |
ci.__str__(verbose)) |
32a3ca40676e
4260 pkg info should print the classification
Brock Pytlik <bpytlik@sun.com>
parents:
685
diff
changeset
|
2983 |
|
615
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
611
diff
changeset
|
2984 |
msg(_(" State:"), state) |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
2985 |
|
1801
09b5c1ddef24
14832 pkg info traceback for renamed packages with no variant-applicable dependencies
Shawn Walker <srw@sun.com>
parents:
1795
diff
changeset
|
2986 |
# 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
|
2987 |
# 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
|
2988 |
# returned. |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
2989 |
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
|
2990 |
renamed_to = "" |
09b5c1ddef24
14832 pkg info traceback for renamed packages with no variant-applicable dependencies
Shawn Walker <srw@sun.com>
parents:
1795
diff
changeset
|
2991 |
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
|
2992 |
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
|
2993 |
msg(_(" Renamed to:"), renamed_to) |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
2994 |
for dep in pi.dependencies[1:]: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
2995 |
msg(" " * len(name_str), dep) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1431
diff
changeset
|
2996 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
2997 |
# 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
|
2998 |
msg(_(" Publisher:"), pi.publisher) |
2493
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
2999 |
hum_ver = pi.get_attr_values("pkg.human-version") |
2940
0e5359bd88dd
17355511 pkg info displays human-version even when identical to actual version
Xiaobo Shen <xiaobo.shen@oracle.com>
parents:
2930
diff
changeset
|
3000 |
if hum_ver and hum_ver[0] != str(pi.version): |
2493
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
3001 |
msg(_(" Version:"), "%s (%s)" % |
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
3002 |
(pi.version, hum_ver[0])) |
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
3003 |
else: |
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
3004 |
msg(_(" Version:"), pi.version) |
615
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
611
diff
changeset
|
3005 |
msg(_(" Build Release:"), pi.build_release) |
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
611
diff
changeset
|
3006 |
msg(_(" Branch:"), pi.branch) |
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
611
diff
changeset
|
3007 |
msg(_("Packaging Date:"), pi.packaging_date) |
aeeeb9f31173
4114 Api.Info needs to provide more info
Brock Pytlik <bpytlik@sun.com>
parents:
611
diff
changeset
|
3008 |
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
|
3009 |
msg(_(" FMRI:"), pi.fmri) |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3010 |
# XXX add license/copyright info here? |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3011 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3012 |
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
|
3013 |
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
|
3014 |
err = EXIT_PARTIAL |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3015 |
if not quiet: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3016 |
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
|
3017 |
else: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3018 |
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
|
3019 |
|
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3020 |
if not quiet: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3021 |
if info_local: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3022 |
logger.error(_("""\ |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
3023 |
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
|
3024 |
installed on the system. Try specifying -r to query remotely:""")) |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3025 |
elif info_remote: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3026 |
logger.error(_("""\ |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
3027 |
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
|
3028 |
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
|
3029 |
examining the catalogs:""")) |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3030 |
logger.error("") |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3031 |
for p in notfound: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3032 |
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
|
3033 |
|
789
f82de17d23fd
2274 "pkg info --license" succeeds even if there are no license actions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
786
diff
changeset
|
3034 |
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
|
3035 |
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
|
3036 |
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
|
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_PARTIAL |
2893
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3039 |
|
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3040 |
if not quiet: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3041 |
error(_("no license information could be found for the " |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3042 |
"following packages:")) |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3043 |
for pfmri in no_licenses: |
f5a02a06d6c3
16663535 want -q option for pkg list/info scripting
Shawn Walker <shawn.walker@oracle.com>
parents:
2891
diff
changeset
|
3044 |
logger.error("\t%s" % pfmri) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3045 |
return err |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3046 |
|
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3047 |
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
|
3048 |
"""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
|
3049 |
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
|
3050 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3051 |
if not widths: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3052 |
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
|
3053 |
for l in lines: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3054 |
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
|
3055 |
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
|
3056 |
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
|
3057 |
return widths |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3058 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3059 |
def calc_justs(attrs): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3060 |
"""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
|
3061 |
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
|
3062 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3063 |
def __chose_just(attr): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3064 |
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
|
3065 |
"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
|
3066 |
return JUST_LEFT |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3067 |
return JUST_UNKNOWN |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3068 |
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
|
3069 |
|
2907
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3070 |
def produce_lines(actionlist, attrs, show_all=False, |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3071 |
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
|
3072 |
"""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
|
3073 |
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
|
3074 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3075 |
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
|
3076 |
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
|
3077 |
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
|
3078 |
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
|
3079 |
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
|
3080 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3081 |
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
|
3082 |
should be displayed. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3083 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3084 |
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
|
3085 |
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
|
3086 |
|
1752
b62d86fb62c8
14515 client can traceback during search
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
3087 |
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
|
3088 |
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
|
3089 |
|
2907
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3090 |
The "last_res" parameter is a seed to compare the first result against |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3091 |
for duplicate removal. |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3092 |
""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3093 |
|
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3094 |
# 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
|
3095 |
# lines. |
1752
b62d86fb62c8
14515 client can traceback during search
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
3096 |
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
|
3097 |
lines = [] |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3098 |
if last_res: |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3099 |
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
|
3100 |
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
|
3101 |
line = [] |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3102 |
for attr in attrs: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3103 |
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
|
3104 |
a = action.attrs[attr] |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3105 |
elif attr == "action.name": |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3106 |
a = action.name |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3107 |
elif attr == "action.key": |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3108 |
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
|
3109 |
elif attr == "action.raw": |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3110 |
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
|
3111 |
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
|
3112 |
a = getattr(action, "hash", "") |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3113 |
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
|
3114 |
a = pfmri.get_name() |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3115 |
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
|
3116 |
a = pfmri |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3117 |
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
|
3118 |
a = pfmri.get_short_fmri() |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
3119 |
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
|
3120 |
a = pfmri.get_publisher() |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3121 |
if a is None: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3122 |
a = pub |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3123 |
if a is None: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3124 |
a = "" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3125 |
elif attr == "search.match": |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3126 |
a = match |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3127 |
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
|
3128 |
a = match_type |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3129 |
else: |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3130 |
a = "" |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3131 |
|
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3132 |
line.append(a) |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3133 |
|
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3134 |
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
|
3135 |
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
|
3136 |
lines[-1] != line): |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3137 |
lines.append(line) |
1729
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3138 |
if last_res: |
4cee72755ae9
12271 consecutive duplicate search rows should be eliminated
Brock Pytlik <bpytlik@sun.com>
parents:
1715
diff
changeset
|
3139 |
lines.pop(0) |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3140 |
return lines |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3141 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3142 |
def default_left(v): |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3143 |
"""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
|
3144 |
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
|
3145 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3146 |
if v == JUST_UNKNOWN: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3147 |
return JUST_LEFT |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3148 |
return v |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3149 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3150 |
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
|
3151 |
"""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
|
3152 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3153 |
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
|
3154 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3155 |
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
|
3156 |
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
|
3157 |
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
|
3158 |
function. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3159 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3160 |
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
|
3161 |
header.""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3162 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3163 |
headers = [] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3164 |
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
|
3165 |
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
|
3166 |
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
|
3167 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3168 |
# 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
|
3169 |
# 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
|
3170 |
# pass to the %-expander. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3171 |
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
|
3172 |
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
|
3173 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3174 |
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
|
3175 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3176 |
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
|
3177 |
"""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
|
3178 |
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
|
3179 |
should be left justified.""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3180 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3181 |
if j != JUST_UNKNOWN: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3182 |
return j |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3183 |
try: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3184 |
int(v) |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3185 |
return JUST_RIGHT |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3186 |
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
|
3187 |
# 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
|
3188 |
# a list. |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3189 |
return JUST_LEFT |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3190 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3191 |
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
|
3192 |
"""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
|
3193 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3194 |
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
|
3195 |
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
|
3196 |
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
|
3197 |
formatting of the line. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3198 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3199 |
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
|
3200 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3201 |
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
|
3202 |
column. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3203 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3204 |
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
|
3205 |
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
|
3206 |
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
|
3207 |
""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3208 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3209 |
if display_headers: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3210 |
# 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
|
3211 |
# 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
|
3212 |
# pass to the %-expander. |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3213 |
line_widths = [ |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3214 |
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
|
3215 |
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
|
3216 |
] |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3217 |
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
|
3218 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3219 |
return fmt |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3220 |
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
|
3221 |
fmt.rstrip("\t") |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3222 |
return fmt |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3223 |
|
2907
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3224 |
def display_contents_results(actionlist, attrs, sort_attrs, display_headers): |
1857
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3225 |
"""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
|
3226 |
was produced.""" |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3227 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3228 |
justs = calc_justs(attrs) |
2907
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3229 |
lines = produce_lines(actionlist, attrs) |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3230 |
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
|
3231 |
|
2522
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3232 |
if sort_attrs: |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3233 |
sortidx = 0 |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3234 |
for i, attr in enumerate(attrs): |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3235 |
if attr == sort_attrs[0]: |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3236 |
sortidx = i |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3237 |
break |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3238 |
|
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3239 |
# Sort numeric columns numerically. |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3240 |
if justs[sortidx] == JUST_RIGHT: |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3241 |
def key_extract(x): |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3242 |
try: |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3243 |
return int(x[sortidx]) |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3244 |
except (ValueError, TypeError): |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3245 |
return 0 |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3246 |
else: |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3247 |
key_extract = lambda x: x[sortidx] |
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3248 |
line_gen = sorted(lines, key=key_extract) |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3249 |
else: |
2522
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3250 |
line_gen = lines |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3251 |
|
1857
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3252 |
printed_output = False |
2522
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3253 |
for line in line_gen: |
1857
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3254 |
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
|
3255 |
line) % tuple(line)).rstrip() |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3256 |
if not text: |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3257 |
continue |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3258 |
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
|
3259 |
print_headers(attrs, widths, justs) |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3260 |
printed_output = True |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3261 |
msg(text) |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3262 |
return printed_output |
1351
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3263 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3264 |
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
|
3265 |
"""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
|
3266 |
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
|
3267 |
""" |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3268 |
|
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3269 |
if reference is None: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3270 |
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
|
3271 |
if prefixes is None: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3272 |
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
|
3273 |
for a in attrs: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3274 |
for p in prefixes: |
75f7a28beaf5
10515 search should support -o for output like pkg contents
Brock Pytlik <bpytlik@sun.com>
parents:
1335
diff
changeset
|
3275 |
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
|
3276 |
usage(_("Invalid attribute '%s'") % a, cmd) |
162
275856fd67a7
Implement simple 'info' and 'list' subcommands.
Danek Duvall <danek.duvall@sun.com>
parents:
161
diff
changeset
|
3277 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
3278 |
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
|
3279 |
"""List package contents. |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3280 |
|
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3281 |
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
|
3282 |
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
|
3283 |
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
|
3284 |
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
|
3285 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3286 |
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
|
3287 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3288 |
subcommand = "contents" |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3289 |
display_headers = True |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3290 |
display_raw = False |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3291 |
origins = set() |
1857
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3292 |
output_fields = False |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
3293 |
remote = False |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
3294 |
local = False |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3295 |
attrs = [] |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3296 |
sort_attrs = [] |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3297 |
action_types = [] |
1563
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3298 |
attr_match = {} |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3299 |
for opt, arg in opts: |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3300 |
if opt == "-H": |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3301 |
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
|
3302 |
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
|
3303 |
try: |
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
3304 |
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
|
3305 |
except ValueError: |
1806
e835bd77038f
14625 incorrect error message for 'contents -a foo'
Tim Foster <tim.foster@sun.com>
parents:
1801
diff
changeset
|
3306 |
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
|
3307 |
"<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
|
3308 |
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
|
3309 |
elif opt == "-g": |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3310 |
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
|
3311 |
elif opt == "-o": |
1857
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3312 |
output_fields = True |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3313 |
attrs.extend(arg.split(",")) |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3314 |
elif opt == "-s": |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3315 |
sort_attrs.append(arg) |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3316 |
elif opt == "-t": |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3317 |
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
|
3318 |
elif opt == "-r": |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
3319 |
remote = True |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3320 |
elif opt == "-m": |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3321 |
display_raw = True |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3322 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3323 |
if origins: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3324 |
remote = True |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3325 |
elif not remote: |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
3326 |
local = True |
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
3327 |
|
442
01fb28d438b3
2418 'pkg version', 'pkg image-update' should error on additional arguments
Dan Price <dp@eng.sun.com>
parents:
432
diff
changeset
|
3328 |
if remote and not pargs: |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
3329 |
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
|
3330 |
"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
|
3331 |
|
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3332 |
if display_raw: |
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
306
diff
changeset
|
3333 |
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
|
3334 |
attrs = ["action.raw"] |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3335 |
|
2522
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3336 |
invalid = set(("-H", "-o", "-t", "-s", "-a")). \ |
391
23ec5f7ee0d3
2245 client - pylint cleanup needed
Shawn Walker <swalker@opensolaris.org>
parents:
388
diff
changeset
|
3337 |
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
|
3338 |
|
391
23ec5f7ee0d3
2245 client - pylint cleanup needed
Shawn Walker <swalker@opensolaris.org>
parents:
388
diff
changeset
|
3339 |
if len(invalid) > 0: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
3340 |
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
|
3341 |
"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
|
3342 |
|
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3343 |
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
|
3344 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
3345 |
api_inst.progresstracker.set_purpose( |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
3346 |
api_inst.progresstracker.PURPOSE_LISTING) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
3347 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3348 |
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
|
3349 |
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
|
3350 |
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
|
3351 |
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
|
3352 |
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
|
3353 |
|
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3354 |
# |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3355 |
# 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
|
3356 |
# 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
|
3357 |
# |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3358 |
if not attrs: |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3359 |
# 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
|
3360 |
# 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
|
3361 |
# 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
|
3362 |
# dependencies. |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3363 |
attrs = ["path"] |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3364 |
|
2522
459b1a360b59
4315 'pkg contents -m' for multiple packages sorts, when it shouldn't
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2521
diff
changeset
|
3365 |
if not sort_attrs and not display_raw: |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3366 |
# XXX reverse sorting |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3367 |
# 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
|
3368 |
# make it explicit |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3369 |
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
|
3370 |
sort_attrs = ["path"] |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3371 |
else: |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3372 |
sort_attrs = attrs[:1] |
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3373 |
|
969
da90392d2f80
6672 "pkg contents -m" filters out other variants
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
3374 |
# 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
|
3375 |
# 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
|
3376 |
if display_raw: |
da90392d2f80
6672 "pkg contents -m" filters out other variants
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
3377 |
excludes = EmptyI |
da90392d2f80
6672 "pkg contents -m" filters out other variants
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
3378 |
else: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3379 |
excludes = api_inst.excludes |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3380 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3381 |
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
|
3382 |
"""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
|
3383 |
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
|
3384 |
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
|
3385 |
|
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3386 |
# 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
|
3387 |
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
|
3388 |
return True |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3389 |
|
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3390 |
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
|
3391 |
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
|
3392 |
|
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3393 |
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
|
3394 |
|
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3395 |
# 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
|
3396 |
# 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
|
3397 |
# 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
|
3398 |
# multiple possible matches). |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3399 |
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
|
3400 |
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
|
3401 |
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
|
3402 |
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
|
3403 |
return True |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3404 |
return False |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3405 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3406 |
# 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
|
3407 |
processed = False |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3408 |
notfound = EmptyI |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3409 |
try: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3410 |
res = api_inst.get_pkg_list(pkg_list, patterns=pargs, |
2547
032eaff05522
17801 contents -r should return only highest-ranked match by default
Shawn Walker <shawn.walker@oracle.com>
parents:
2544
diff
changeset
|
3411 |
raise_unmatched=True, ranked=remote, return_fmris=True, |
032eaff05522
17801 contents -r should return only highest-ranked match by default
Shawn Walker <shawn.walker@oracle.com>
parents:
2544
diff
changeset
|
3412 |
variants=True, 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
|
3413 |
manifests = [] |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3414 |
|
2493
5db1603f0c3f
18609 support for a human-readable version string
Danek Duvall <danek.duvall@oracle.com>
parents:
2488
diff
changeset
|
3415 |
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
|
3416 |
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
|
3417 |
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
|
3418 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3419 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3420 |
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
|
3421 |
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
|
3422 |
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
|
3423 |
api_inst.log_operation_end( |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
3424 |
result=RESULT_FAILED_UNKNOWN) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3425 |
return EXIT_OOPS |
2808
05c6015a8c62
7195369 corrupt manifests can end up on disk when -g is used
Dan Price <daniel.price@oracle.com>
parents:
2787
diff
changeset
|
3426 |
except api_errors.CatalogRefreshException, e: |
05c6015a8c62
7195369 corrupt manifests can end up on disk when -g is used
Dan Price <daniel.price@oracle.com>
parents:
2787
diff
changeset
|
3427 |
display_catalog_failures(e) |
05c6015a8c62
7195369 corrupt manifests can end up on disk when -g is used
Dan Price <daniel.price@oracle.com>
parents:
2787
diff
changeset
|
3428 |
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
|
3429 |
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
|
3430 |
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
|
3431 |
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
|
3432 |
error(i) |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3433 |
api_inst.log_operation_end( |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
3434 |
result=RESULT_FAILED_BAD_REQUEST) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3435 |
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
|
3436 |
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
|
3437 |
else: |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3438 |
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
|
3439 |
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
|
3440 |
api_inst.log_operation_end( |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
3441 |
result=RESULT_NOTHING_TO_DO) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3442 |
return EXIT_OOPS |
969
da90392d2f80
6672 "pkg contents -m" filters out other variants
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
3443 |
|
2907
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3444 |
# Build a generator expression based on whether specific action types |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3445 |
# were provided. |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3446 |
if action_types: |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3447 |
# If query is limited to specific action types, use the more |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3448 |
# efficient type-based generation mechanism. |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3449 |
gen_expr = ( |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3450 |
(m.fmri, a, None, None, None) |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3451 |
for m in manifests |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3452 |
for a in m.gen_actions_by_types(action_types, |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3453 |
excludes=excludes) |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3454 |
if mmatches(a) |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3455 |
) |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3456 |
else: |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3457 |
gen_expr = ( |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3458 |
(m.fmri, a, None, None, None) |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3459 |
for m in manifests |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3460 |
for a in m.gen_actions(excludes=excludes) |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3461 |
if mmatches(a) |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3462 |
) |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3463 |
|
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3464 |
# Determine if the query returned any results by "peeking" at the first |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3465 |
# value returned from the generator expression. |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3466 |
try: |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3467 |
found = gen_expr.next() |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3468 |
except StopIteration: |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3469 |
found = None |
2908
499ea50ecf83
16916660 pkg contents -t performance could be improved (fix merge)
Shawn Walker <shawn.walker@oracle.com>
parents:
2907
diff
changeset
|
3470 |
actionlist = [] |
2907
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3471 |
|
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3472 |
if found: |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3473 |
# If any matching entries were found, create a new generator |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3474 |
# expression using itertools.chain that includes the first |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3475 |
# result. |
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3476 |
actionlist = itertools.chain([found], gen_expr) |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3477 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3478 |
rval = EXIT_OK |
2907
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3479 |
if attr_match and manifests and not found: |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3480 |
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
|
3481 |
logger.error(_("""\ |
b24d60ef4c70
2885 pkg contents can't specify hash for output field
Danek Duvall <danek.duvall@sun.com>
parents:
1543
diff
changeset
|
3482 |
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
|
3483 |
|
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3484 |
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
|
3485 |
displayed_results = display_contents_results(actionlist, attrs, |
2907
df429d6d018a
16916660 pkg contents -t performance could be improved
Shawn Walker <shawn.walker@oracle.com>
parents:
2896
diff
changeset
|
3486 |
sort_attrs, display_headers) |
1857
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3487 |
|
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3488 |
if not displayed_results: |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3489 |
if output_fields: |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3490 |
error(gettext.ngettext("""\ |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3491 |
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
|
3492 |
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
|
3493 |
package manifests.""", """\ |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3494 |
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
|
3495 |
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
|
3496 |
package manifests.""", len(pargs))) |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3497 |
else: |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3498 |
error(gettext.ngettext("""\ |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3499 |
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
|
3500 |
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
|
3501 |
the raw package manifests.""", """\ |
d272ec25678e
1797 packages without filesystem content appear empty
Tim Foster <tim.foster@sun.com>
parents:
1853
diff
changeset
|
3502 |
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
|
3503 |
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
|
3504 |
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
|
3505 |
|
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3506 |
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
|
3507 |
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
|
3508 |
if manifests: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3509 |
logger.error("") |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3510 |
if local: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3511 |
logger.error(_("""\ |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
3512 |
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
|
3513 |
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
|
3514 |
elif remote: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3515 |
logger.error(_("""\ |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
3516 |
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
|
3517 |
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
|
3518 |
examining the catalogs:""")) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3519 |
logger.error("") |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
417
diff
changeset
|
3520 |
for p in notfound: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
3521 |
logger.error(" %s" % p) |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
3522 |
api_inst.log_operation_end(result=RESULT_NOTHING_TO_DO) |
556
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
551
diff
changeset
|
3523 |
else: |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
3524 |
api_inst.log_operation_end(result=RESULT_SUCCEEDED) |
1970
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3525 |
return rval |
60471574c487
16238 client api should ignore invalid and not yet supported packages
Shawn Walker <shawn.walker@oracle.com>
parents:
1945
diff
changeset
|
3526 |
|
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
3527 |
|
1538
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3528 |
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
|
3529 |
total = cre.total |
3dc9fc9b5fee
1540 changes to authorities should include refresh
Brock Pytlik <bpytlik@sun.com>
parents:
526
diff
changeset
|
3530 |
succeeded = cre.succeeded |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
3531 |
|
2826
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
3532 |
txt = _("pkg: %(succeeded)s/%(total)s catalogs successfully " |
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
3533 |
"updated:") % {"succeeded": succeeded, "total": total} |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
3534 |
if cre.failed: |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
3535 |
# 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
|
3536 |
logger.error(txt) |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
3537 |
else: |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
987
diff
changeset
|
3538 |
msg(txt) |
259
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3539 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
3540 |
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
|
3541 |
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
|
3542 |
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
|
3543 |
# 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
|
3544 |
# 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
|
3545 |
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
|
3546 |
break |
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3547 |
|
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3548 |
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
|
3549 |
# 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
|
3550 |
# 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
|
3551 |
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
|
3552 |
|
78ac66abc186
12130 install/update operations should always refresh publisher metadata (when allowed)
Shawn Walker <srw@sun.com>
parents:
1537
diff
changeset
|
3553 |
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
|
3554 |
logger.error(" ") |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
3555 |
logger.error(str(err)) |
259
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3556 |
|
1603
84bd53597209
13019 DeprecationWarnings seen after python 2.6 migration
Dan Price <dp@eng.sun.com>
parents:
1570
diff
changeset
|
3557 |
if cre.errmessage: |
84bd53597209
13019 DeprecationWarnings seen after python 2.6 migration
Dan Price <dp@eng.sun.com>
parents:
1570
diff
changeset
|
3558 |
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
|
3559 |
|
259
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3560 |
return succeeded |
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3561 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3562 |
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
|
3563 |
"""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
|
3564 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3565 |
try: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3566 |
# 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
|
3567 |
# refresh to occur immediately. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3568 |
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
|
3569 |
immediate=True, pubs=pubs) |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3570 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3571 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3572 |
return EXIT_OOPS |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3573 |
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
|
3574 |
error(e) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3575 |
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
|
3576 |
return EXIT_OOPS |
1779
b80275b45b18
14176 copytree callers must catch shutil.Error and not traceback
Shawn Walker <srw@sun.com>
parents:
1775
diff
changeset
|
3577 |
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
|
3578 |
# 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
|
3579 |
# 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
|
3580 |
error("\n" + str(e)) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3581 |
return EXIT_OOPS |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3582 |
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
|
3583 |
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
|
3584 |
return EXIT_OOPS |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3585 |
return EXIT_PARTIAL |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3586 |
return EXIT_OK |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3587 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
3588 |
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
|
3589 |
"""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
|
3590 |
|
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3591 |
# 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
|
3592 |
full_refresh = False |
2719
c79aef418a22
7179317 update-refresh.sh cron job generates pkg refresh messages
Dan Price <daniel.price@oracle.com>
parents:
2716
diff
changeset
|
3593 |
opts, pargs = getopt.getopt(args, "q", ["full"]) |
327
6c6bd07efe8d
1031 authority prefix needs validation
johansen <johansen@sun.com>
parents:
326
diff
changeset
|
3594 |
for opt, arg in opts: |
2719
c79aef418a22
7179317 update-refresh.sh cron job generates pkg refresh messages
Dan Price <daniel.price@oracle.com>
parents:
2716
diff
changeset
|
3595 |
if opt == "-q": |
c79aef418a22
7179317 update-refresh.sh cron job generates pkg refresh messages
Dan Price <daniel.price@oracle.com>
parents:
2716
diff
changeset
|
3596 |
global_settings.client_output_quiet = True |
327
6c6bd07efe8d
1031 authority prefix needs validation
johansen <johansen@sun.com>
parents:
326
diff
changeset
|
3597 |
if opt == "--full": |
6c6bd07efe8d
1031 authority prefix needs validation
johansen <johansen@sun.com>
parents:
326
diff
changeset
|
3598 |
full_refresh = True |
2719
c79aef418a22
7179317 update-refresh.sh cron job generates pkg refresh messages
Dan Price <daniel.price@oracle.com>
parents:
2716
diff
changeset
|
3599 |
# Reset the progress tracker here, because we may have |
c79aef418a22
7179317 update-refresh.sh cron job generates pkg refresh messages
Dan Price <daniel.price@oracle.com>
parents:
2716
diff
changeset
|
3600 |
# to switch to a different tracker due to the options parse. |
c79aef418a22
7179317 update-refresh.sh cron job generates pkg refresh messages
Dan Price <daniel.price@oracle.com>
parents:
2716
diff
changeset
|
3601 |
_api_inst.progresstracker = get_tracker() |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
3602 |
# suppress phase information since we're doing just one thing. |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
3603 |
api_inst.progresstracker.set_major_phase( |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
3604 |
api_inst.progresstracker.PHASE_UTILITY) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3605 |
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
|
3606 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3607 |
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
|
3608 |
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
|
3609 |
# 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
|
3610 |
# 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
|
3611 |
if is_zone: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3612 |
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
|
3613 |
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
|
3614 |
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
|
3615 |
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
|
3616 |
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
|
3617 |
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
|
3618 |
elif orig_cwd: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3619 |
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
|
3620 |
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
|
3621 |
orig_cwd, ssl_cert)) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3622 |
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
|
3623 |
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
|
3624 |
orig_cwd, ssl_key)) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3625 |
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
|
3626 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3627 |
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
|
3628 |
"""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
|
3629 |
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
|
3630 |
value for errors.""" |
259
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3631 |
|
5083c093ab6c
563 server problems on image-create give traceback
Stephen Hahn <sch@Sun.COM>
parents:
251
diff
changeset
|
3632 |
try: |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3633 |
return func(*args, **kwargs) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3634 |
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
|
3635 |
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
|
3636 |
if isinstance(e, entry): |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3637 |
raise |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
3638 |
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
|
3639 |
pfx |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
3640 |
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
|
3641 |
txt += " \n%s" % err |
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
3642 |
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
|
3643 |
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
|
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 |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3647 |
if pfx: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3648 |
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
|
3649 |
"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
|
3650 |
"\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
|
3651 |
"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
|
3652 |
"\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
|
3653 |
"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
|
3654 |
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
|
3655 |
"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
|
3656 |
"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
|
3657 |
"\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
|
3658 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3659 |
for entry in raise_errors: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3660 |
if isinstance(e, entry): |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3661 |
raise |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3662 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
3663 |
return EXIT_OOPS, "" |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3664 |
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
|
3665 |
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
|
3666 |
if isinstance(e, entry): |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3667 |
raise |
790
e2cf47b23e7a
5481 pkg refresh traceback without permissions
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
789
diff
changeset
|
3668 |
# 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
|
3669 |
# 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
|
3670 |
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
|
3671 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
3672 |
def publisher_set(api_inst, args): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
3673 |
"""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
|
3674 |
[-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
|
3675 |
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
|
3676 |
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
|
3677 |
[--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
|
3678 |
[--search-after=publisher] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3679 |
[--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
|
3680 |
[--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
|
3681 |
[--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
|
3682 |
[--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
|
3683 |
[--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
|
3684 |
[--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
|
3685 |
[--unset-property name of property to delete] |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3686 |
[--proxy proxy to use] |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3687 |
[publisher] """ |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3688 |
|
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3689 |
cmd_name = "set-publisher" |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
3690 |
|
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
3691 |
ssl_key = None |
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
3692 |
ssl_cert = None |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3693 |
origin_uri = None |
551 | 3694 |
reset_uuid = False |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3695 |
add_mirrors = set() |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3696 |
remove_mirrors = set() |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3697 |
add_origins = set() |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3698 |
remove_origins = set() |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3699 |
refresh_allowed = True |
786
a400f8c4d1c0
2340 support authority enable and disable
Tom Mueller <Tom.Mueller@sun.com>
parents:
770
diff
changeset
|
3700 |
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
|
3701 |
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
|
3702 |
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
|
3703 |
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
|
3704 |
search_first = False |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3705 |
repo_uri = None |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3706 |
proxy_uri = None |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3707 |
|
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3708 |
approved_ca_certs = [] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3709 |
revoked_ca_certs = [] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3710 |
unset_ca_certs = [] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3711 |
set_props = {} |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3712 |
add_prop_values = {} |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3713 |
remove_prop_values = {} |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3714 |
unset_props = set() |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3715 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3716 |
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
|
3717 |
["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
|
3718 |
"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
|
3719 |
"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
|
3720 |
"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
|
3721 |
"set-property=", "add-property-value=", "remove-property-value=", |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3722 |
"unset-property=", "proxy="]) |
461
37cf3ac75e37
1018 actions with payloads should include all sizes and hashes
johansen <johansen@sun.com>
parents:
443
diff
changeset
|
3723 |
|
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
3724 |
for opt, arg in opts: |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3725 |
if opt == "-c": |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3726 |
ssl_cert = arg |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3727 |
elif opt == "-d" or opt == "--disable": |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3728 |
disable = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3729 |
elif opt == "-e" or opt == "--enable": |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3730 |
disable = False |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3731 |
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
|
3732 |
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
|
3733 |
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
|
3734 |
if arg == "*": |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3735 |
# 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
|
3736 |
# 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
|
3737 |
remove_origins.add("*") |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3738 |
else: |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3739 |
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
|
3740 |
cwd=orig_cwd)) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3741 |
elif opt == "-k": |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
3742 |
ssl_key = arg |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3743 |
elif opt == "-O": |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3744 |
origin_uri = arg |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3745 |
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
|
3746 |
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
|
3747 |
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
|
3748 |
if arg == "*": |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3749 |
# 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
|
3750 |
# 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
|
3751 |
remove_mirrors.add("*") |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3752 |
else: |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
3753 |
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
|
3754 |
cwd=orig_cwd)) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3755 |
elif opt == "-p": |
2930
89257716c7c1
16297554 pkg history fails when time travelling
<xiaobo.shen@oracle.com>
parents:
2926
diff
changeset
|
3756 |
if repo_uri: |
2922
37531d03eb31
15678637 SUNBT7133912 image-create and set-publisher only use last -p specified
thejaswini.k@oracle.com
parents:
2920
diff
changeset
|
3757 |
usage(_("The -p option can be specified only " |
2930
89257716c7c1
16297554 pkg history fails when time travelling
<xiaobo.shen@oracle.com>
parents:
2926
diff
changeset
|
3758 |
"once."), cmd=cmd_name) |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3759 |
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
|
3760 |
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
|
3761 |
search_first = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3762 |
elif opt == "--reset-uuid": |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
3763 |
reset_uuid = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3764 |
elif opt == "--no-refresh": |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3765 |
refresh_allowed = False |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3766 |
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
|
3767 |
sticky = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3768 |
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
|
3769 |
sticky = False |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3770 |
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
|
3771 |
search_before = arg |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3772 |
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
|
3773 |
search_after = arg |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3774 |
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
|
3775 |
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
|
3776 |
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
|
3777 |
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
|
3778 |
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
|
3779 |
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
|
3780 |
elif opt == "--set-property": |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3781 |
t = arg.split("=", 1) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3782 |
if len(t) < 2: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3783 |
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
|
3784 |
"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
|
3785 |
"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
|
3786 |
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
|
3787 |
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
|
3788 |
"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
|
3789 |
cmd=cmd_name) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3790 |
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
|
3791 |
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
|
3792 |
t = arg.split("=", 1) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3793 |
if len(t) < 2: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3794 |
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
|
3795 |
"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
|
3796 |
"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
|
3797 |
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
|
3798 |
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
|
3799 |
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
|
3800 |
t = arg.split("=", 1) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3801 |
if len(t) < 2: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3802 |
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
|
3803 |
"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
|
3804 |
"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
|
3805 |
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
|
3806 |
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
|
3807 |
elif opt == "--unset-property": |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3808 |
unset_props.add(arg) |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3809 |
elif opt == "--proxy": |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3810 |
proxy_uri = arg |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3811 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3812 |
name = None |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3813 |
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
|
3814 |
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
|
3815 |
elif len(pargs) > 1: |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3816 |
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
|
3817 |
cmd="set-publisher") |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3818 |
elif pargs: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3819 |
name = pargs[0] |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
3820 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3821 |
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
|
3822 |
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
|
3823 |
"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
|
3824 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3825 |
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
|
3826 |
(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
|
3827 |
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
|
3828 |
"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
|
3829 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3830 |
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
|
3831 |
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
|
3832 |
reset_uuid): |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3833 |
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
|
3834 |
"--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
|
3835 |
"-M, --remove-mirror, --enable, --disable, --no-refresh, " |
2100
6a366b063036
17144 Unix socket support is defunct
johansen <johansen@opensolaris.org>
parents:
2097
diff
changeset
|
3836 |
"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
|
3837 |
|
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3838 |
if proxy_uri and not (add_origins or add_mirrors or repo_uri or |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3839 |
remove_origins or remove_mirrors): |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3840 |
usage(_("the --proxy argument may only be combined with the -g," |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3841 |
" --add-origin, -m, --add-mirror, or -p options"), |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3842 |
cmd="set-publisher") |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3843 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3844 |
# 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
|
3845 |
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
|
3846 |
ssl_cert, ssl_key) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3847 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3848 |
if not repo_uri: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3849 |
# Normal case. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3850 |
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
|
3851 |
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
|
3852 |
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
|
3853 |
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
|
3854 |
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
|
3855 |
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
|
3856 |
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
|
3857 |
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
|
3858 |
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
|
3859 |
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
|
3860 |
unset_props=unset_props, approved_cas=approved_ca_certs, |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3861 |
revoked_cas=revoked_ca_certs, unset_cas=unset_ca_certs, |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3862 |
proxy_uri=proxy_uri) |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3863 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3864 |
rval, rmsg = ret |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3865 |
if rmsg: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3866 |
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
|
3867 |
return rval |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3868 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3869 |
pubs = None |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3870 |
# 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
|
3871 |
def get_pubs(): |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3872 |
if proxy_uri: |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3873 |
proxies = [publisher.ProxyURI(proxy_uri)] |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3874 |
else: |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3875 |
proxies = [] |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3876 |
repo = publisher.RepositoryURI(repo_uri, |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3877 |
ssl_cert=ssl_cert, ssl_key=ssl_key, proxies=proxies) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3878 |
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
|
3879 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3880 |
ret = None |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
3881 |
try: |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3882 |
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
|
3883 |
[api_errors.UnsupportedRepositoryOperation]) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3884 |
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
|
3885 |
# 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
|
3886 |
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
|
3887 |
logger.error(_(""" |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3888 |
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
|
3889 |
privileged user: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3890 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3891 |
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
|
3892 |
""") % repo_uri) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3893 |
return EXIT_OOPS |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3894 |
else: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3895 |
rval, rmsg = ret |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3896 |
if rval != EXIT_OK: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3897 |
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
|
3898 |
return rval |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3899 |
pubs = rmsg |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3900 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3901 |
# 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
|
3902 |
# 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
|
3903 |
# specified publisher prefix. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3904 |
if not pubs: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3905 |
error(_(""" |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3906 |
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
|
3907 |
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
|
3908 |
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
|
3909 |
assistance.""")) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3910 |
return EXIT_OOPS |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3911 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3912 |
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
|
3913 |
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
|
3914 |
unknown = [name] |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3915 |
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
|
3916 |
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
|
3917 |
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
|
3918 |
return EXIT_OOPS |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3919 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3920 |
added = [] |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3921 |
updated = [] |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3922 |
failed = [] |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3923 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3924 |
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
|
3925 |
prefix = src_pub.prefix |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3926 |
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
|
3927 |
# 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
|
3928 |
continue |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3929 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3930 |
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
|
3931 |
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
|
3932 |
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
|
3933 |
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
|
3934 |
# 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
|
3935 |
# 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
|
3936 |
# 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
|
3937 |
# 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
|
3938 |
# 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
|
3939 |
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
|
3940 |
|
2765
4b21dadc47c0
7189832 set-publisher --proxy value not applied to all origins when using -p
Tim Foster <tim.s.foster@oracle.com>
parents:
2763
diff
changeset
|
3941 |
# Any -p origins/mirrors returned from get_pubs() should |
4b21dadc47c0
7189832 set-publisher --proxy value not applied to all origins when using -p
Tim Foster <tim.s.foster@oracle.com>
parents:
2763
diff
changeset
|
3942 |
# use the proxy we declared, if any. |
4b21dadc47c0
7189832 set-publisher --proxy value not applied to all origins when using -p
Tim Foster <tim.s.foster@oracle.com>
parents:
2763
diff
changeset
|
3943 |
if proxy_uri and src_repo: |
4b21dadc47c0
7189832 set-publisher --proxy value not applied to all origins when using -p
Tim Foster <tim.s.foster@oracle.com>
parents:
2763
diff
changeset
|
3944 |
proxies = [publisher.ProxyURI(proxy_uri)] |
4b21dadc47c0
7189832 set-publisher --proxy value not applied to all origins when using -p
Tim Foster <tim.s.foster@oracle.com>
parents:
2763
diff
changeset
|
3945 |
for repo_uri in src_repo.origins: |
4b21dadc47c0
7189832 set-publisher --proxy value not applied to all origins when using -p
Tim Foster <tim.s.foster@oracle.com>
parents:
2763
diff
changeset
|
3946 |
repo_uri.proxies = proxies |
4b21dadc47c0
7189832 set-publisher --proxy value not applied to all origins when using -p
Tim Foster <tim.s.foster@oracle.com>
parents:
2763
diff
changeset
|
3947 |
for repo_uri in src_repo.mirrors: |
4b21dadc47c0
7189832 set-publisher --proxy value not applied to all origins when using -p
Tim Foster <tim.s.foster@oracle.com>
parents:
2763
diff
changeset
|
3948 |
repo_uri.proxies = proxies |
4b21dadc47c0
7189832 set-publisher --proxy value not applied to all origins when using -p
Tim Foster <tim.s.foster@oracle.com>
parents:
2763
diff
changeset
|
3949 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3950 |
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
|
3951 |
[], 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
|
3952 |
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
|
3953 |
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
|
3954 |
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
|
3955 |
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
|
3956 |
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
|
3957 |
set_props=set_props, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
3958 |
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
|
3959 |
remove_prop_values=remove_prop_values, |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
3960 |
unset_props=unset_props, proxy_uri=proxy_uri) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3961 |
if rval == EXIT_OK: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3962 |
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
|
3963 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3964 |
# 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
|
3965 |
# 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
|
3966 |
# ordered correctly. |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
3967 |
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
|
3968 |
search_after = prefix |
2757
90e46e54ecea
7177867 pkg set-publisher fails for multi-publisher repository when using search-before
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2743
diff
changeset
|
3969 |
search_before = None |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3970 |
else: |
2891
c8c988eec7ac
15771543 set-publisher -p should simply update existing publisher sources
thejaswini.k@oracle.com
parents:
2890
diff
changeset
|
3971 |
add_origins = [] |
c8c988eec7ac
15771543 set-publisher -p should simply update existing publisher sources
thejaswini.k@oracle.com
parents:
2890
diff
changeset
|
3972 |
add_mirrors = [] |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
3973 |
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
|
3974 |
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
|
3975 |
dest_repo = dest_pub.repository |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3976 |
if dest_repo.origins and \ |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
3977 |
not dest_repo.has_origin(repo_uri): |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
3978 |
add_origins = [repo_uri] |
2891
c8c988eec7ac
15771543 set-publisher -p should simply update existing publisher sources
thejaswini.k@oracle.com
parents:
2890
diff
changeset
|
3979 |
|
c8c988eec7ac
15771543 set-publisher -p should simply update existing publisher sources
thejaswini.k@oracle.com
parents:
2890
diff
changeset
|
3980 |
if not src_repo and not 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
|
3981 |
# 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
|
3982 |
# 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
|
3983 |
# 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
|
3984 |
# 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
|
3985 |
# 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
|
3986 |
# 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
|
3987 |
if not dest_repo.origins: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
3988 |
add_origins = [repo_uri] |
2891
c8c988eec7ac
15771543 set-publisher -p should simply update existing publisher sources
thejaswini.k@oracle.com
parents:
2890
diff
changeset
|
3989 |
elif src_repo: |
1795
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3990 |
# 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
|
3991 |
# 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
|
3992 |
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
|
3993 |
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
|
3994 |
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
|
3995 |
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
|
3996 |
] |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
3997 |
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
|
3998 |
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
|
3999 |
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
|
4000 |
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
|
4001 |
] |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
4002 |
|
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
4003 |
# 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
|
4004 |
# 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
|
4005 |
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
|
4006 |
"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
|
4007 |
"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
|
4008 |
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
|
4009 |
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
|
4010 |
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
|
4011 |
src_val) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4012 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4013 |
# 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
|
4014 |
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
|
4015 |
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
|
4016 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4017 |
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
|
4018 |
[], 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
|
4019 |
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
|
4020 |
set_props=set_props, |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4021 |
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
|
4022 |
remove_prop_values=remove_prop_values, |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4023 |
unset_props=unset_props, proxy_uri=proxy_uri) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4024 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4025 |
if rval == EXIT_OK: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4026 |
updated.append(prefix) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4027 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4028 |
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
|
4029 |
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
|
4030 |
continue |
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 |
first = True |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4033 |
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
|
4034 |
if first: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4035 |
first = False |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4036 |
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
|
4037 |
"publishers", cmd="set-publisher") |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4038 |
logger.error(" %s:" % pub) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4039 |
logger.error(rmsg) |
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 |
if added or updated: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4042 |
if first: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4043 |
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
|
4044 |
if added: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4045 |
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
|
4046 |
", ".join(added)) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4047 |
if updated: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4048 |
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
|
4049 |
", ".join(updated)) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4050 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4051 |
if failed: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4052 |
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
|
4053 |
# 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
|
4054 |
# updated. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4055 |
return EXIT_PARTIAL |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4056 |
return EXIT_OOPS |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4057 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4058 |
# 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
|
4059 |
# 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
|
4060 |
# 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
|
4061 |
# 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
|
4062 |
# 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
|
4063 |
# 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
|
4064 |
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
|
4065 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4066 |
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
|
4067 |
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
|
4068 |
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
|
4069 |
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
|
4070 |
reset_uuid=None, refresh_allowed=False, |
2100
6a366b063036
17144 Unix socket support is defunct
johansen <johansen@opensolaris.org>
parents:
2097
diff
changeset
|
4071 |
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
|
4072 |
remove_prop_values=EmptyI, unset_props=EmptyI, approved_cas=EmptyI, |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4073 |
revoked_cas=EmptyI, unset_cas=EmptyI, proxy_uri=None): |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4074 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4075 |
repo = None |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4076 |
new_pub = False |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4077 |
if not pub: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4078 |
try: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4079 |
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
|
4080 |
alias=prefix, duplicate=True) |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4081 |
if reset_uuid: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4082 |
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
|
4083 |
repo = pub.repository |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4084 |
except api_errors.UnknownPublisher, e: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4085 |
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
|
4086 |
(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
|
4087 |
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
|
4088 |
return EXIT_OOPS, str(e) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
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 |
# 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
|
4091 |
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
|
4092 |
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
|
4093 |
new_pub = True |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4094 |
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
|
4095 |
new_pub = True |
327
6c6bd07efe8d
1031 authority prefix needs validation
johansen <johansen@sun.com>
parents:
326
diff
changeset
|
4096 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4097 |
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
|
4098 |
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
|
4099 |
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
|
4100 |
# 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
|
4101 |
# 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
|
4102 |
# configuration. |
1b3bed835773
14856 image-create / set-publisher shouldn't require repository configuration to have origins
Shawn Walker <srw@sun.com>
parents:
1779
diff
changeset
|
4103 |
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
|
4104 |
pub.repository = repo |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4105 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4106 |
if disable is not None: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4107 |
# Set disabled property only if provided. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4108 |
pub.disabled = disable |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4109 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4110 |
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
|
4111 |
# 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
|
4112 |
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
|
4113 |
|
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4114 |
if proxy_uri: |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4115 |
# we only support a single proxy for now. |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4116 |
proxies = [publisher.ProxyURI(proxy_uri)] |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4117 |
else: |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4118 |
proxies = [] |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4119 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4120 |
if origin_uri: |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
4121 |
# 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
|
4122 |
# 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
|
4123 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4124 |
# 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
|
4125 |
# https for transport. |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4126 |
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
|
4127 |
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
|
4128 |
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
|
4129 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4130 |
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
|
4131 |
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
|
4132 |
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
|
4133 |
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
|
4134 |
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
|
4135 |
break |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4136 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4137 |
repo.reset_origins() |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4138 |
o = publisher.RepositoryURI(origin_uri, proxies=proxies) |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4139 |
repo.add_origin(o) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4140 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4141 |
# 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
|
4142 |
# 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
|
4143 |
# here. |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4144 |
|
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
4145 |
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
|
4146 |
add_origins, remove_origins)): |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
4147 |
etype, add, remove = entry |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
4148 |
# XXX once image configuration supports storing this |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
4149 |
# 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
|
4150 |
# here. |
2253
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
4151 |
if "*" in remove: |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
4152 |
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
|
4153 |
else: |
fd7f8e8228ae
17599 set-publisher should allow '*' for -G and -M options
Shawn Walker <shawn.walker@oracle.com>
parents:
2228
diff
changeset
|
4154 |
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
|
4155 |
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
|
4156 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4157 |
for u in add: |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4158 |
uri = publisher.RepositoryURI(u, proxies=proxies) |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4159 |
getattr(repo, "add_%s" % etype)(uri) |
786
a400f8c4d1c0
2340 support authority enable and disable
Tom Mueller <Tom.Mueller@sun.com>
parents:
770
diff
changeset
|
4160 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4161 |
# 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
|
4162 |
# ssl_key by using -k "" or -c "". |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4163 |
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
|
4164 |
# 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
|
4165 |
# 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
|
4166 |
# 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
|
4167 |
found_ssl = False |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4168 |
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
|
4169 |
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
|
4170 |
continue |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4171 |
found_ssl = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4172 |
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
|
4173 |
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
|
4174 |
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
|
4175 |
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
|
4176 |
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
|
4177 |
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
|
4178 |
continue |
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4179 |
found_ssl = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4180 |
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
|
4181 |
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
|
4182 |
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
|
4183 |
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
|
4184 |
|
2269
460556da69d6
17278 pkg(1) should allow mixing https origins with other types
Shawn Walker <shawn.walker@oracle.com>
parents:
2260
diff
changeset
|
4185 |
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
|
4186 |
# 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
|
4187 |
# 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
|
4188 |
# 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
|
4189 |
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
|
4190 |
"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
|
4191 |
|
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4192 |
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
|
4193 |
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
|
4194 |
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
|
4195 |
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
|
4196 |
unset_props=unset_props) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4197 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4198 |
if new_pub: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4199 |
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
|
4200 |
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
|
4201 |
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
|
4202 |
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
|
4203 |
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
|
4204 |
else: |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4205 |
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
|
4206 |
try: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4207 |
ca = os.path.normpath( |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4208 |
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
|
4209 |
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
|
4210 |
s = fh.read() |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4211 |
except EnvironmentError, e: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4212 |
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
|
4213 |
raise api_errors.MissingFileArgumentException( |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4214 |
ca) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4215 |
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
|
4216 |
raise api_errors.PermissionsException( |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4217 |
ca) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4218 |
raise |
2286
938fbb350ad2
16867 pkgsign should handle existing signatures better
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2280
diff
changeset
|
4219 |
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
|
4220 |
|
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4221 |
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
|
4222 |
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
|
4223 |
|
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4224 |
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
|
4225 |
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
|
4226 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4227 |
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
|
4228 |
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
|
4229 |
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
|
4230 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4231 |
return EXIT_OK, None |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4232 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4233 |
def publisher_unset(api_inst, args): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4234 |
"""pkg unset-publisher publisher ...""" |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4235 |
|
2886
7585254070fc
16180319 pkg unset-publisher -nv <legit-publisher> seems to fail but succeeds
Nishchaya Bahuguna <nishchaya.bahuguna@oracle.com>
parents:
2875
diff
changeset
|
4236 |
opts, pargs = getopt.getopt(args, "") |
7585254070fc
16180319 pkg unset-publisher -nv <legit-publisher> seems to fail but succeeds
Nishchaya Bahuguna <nishchaya.bahuguna@oracle.com>
parents:
2875
diff
changeset
|
4237 |
if not pargs: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
4238 |
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
|
4239 |
cmd="unset-publisher") |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4240 |
|
936
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4241 |
errors = [] |
2891
c8c988eec7ac
15771543 set-publisher -p should simply update existing publisher sources
thejaswini.k@oracle.com
parents:
2890
diff
changeset
|
4242 |
goal = len(args) |
c8c988eec7ac
15771543 set-publisher -p should simply update existing publisher sources
thejaswini.k@oracle.com
parents:
2890
diff
changeset
|
4243 |
progtrack = api_inst.progresstracker |
c8c988eec7ac
15771543 set-publisher -p should simply update existing publisher sources
thejaswini.k@oracle.com
parents:
2890
diff
changeset
|
4244 |
progtrack.job_start(progtrack.JOB_PKG_CACHE, goal=goal) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4245 |
for name in args: |
2891
c8c988eec7ac
15771543 set-publisher -p should simply update existing publisher sources
thejaswini.k@oracle.com
parents:
2890
diff
changeset
|
4246 |
|
709
cfb249e57576
2393 traceback when attempting to change client settings without permission
Brock Pytlik <bpytlik@sun.com>
parents:
706
diff
changeset
|
4247 |
try: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4248 |
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
|
4249 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4250 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4251 |
return EXIT_OOPS |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4252 |
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
|
4253 |
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
|
4254 |
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
|
4255 |
errors.append((name, e)) |
2891
c8c988eec7ac
15771543 set-publisher -p should simply update existing publisher sources
thejaswini.k@oracle.com
parents:
2890
diff
changeset
|
4256 |
finally: |
c8c988eec7ac
15771543 set-publisher -p should simply update existing publisher sources
thejaswini.k@oracle.com
parents:
2890
diff
changeset
|
4257 |
progtrack.job_add_progress(progtrack.JOB_PKG_CACHE) |
c8c988eec7ac
15771543 set-publisher -p should simply update existing publisher sources
thejaswini.k@oracle.com
parents:
2890
diff
changeset
|
4258 |
|
c8c988eec7ac
15771543 set-publisher -p should simply update existing publisher sources
thejaswini.k@oracle.com
parents:
2890
diff
changeset
|
4259 |
progtrack.job_done(progtrack.JOB_PKG_CACHE) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4260 |
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
|
4261 |
if errors: |
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4262 |
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
|
4263 |
# 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
|
4264 |
# 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
|
4265 |
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
|
4266 |
else: |
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4267 |
# 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
|
4268 |
# 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
|
4269 |
# 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
|
4270 |
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
|
4271 |
|
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
4272 |
txt = "" |
936
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4273 |
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
|
4274 |
txt += "\n" |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
4275 |
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
|
4276 |
"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
|
4277 |
txt += "\n" |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
4278 |
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
|
4279 |
|
649787977ed3
2283 pkg unset-authority fails unless all specified authorities are valid
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
934
diff
changeset
|
4280 |
return retcode |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4281 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4282 |
def publisher_list(api_inst, args): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4283 |
"""pkg publishers""" |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4284 |
omit_headers = False |
410
403886a7592b
1259 Need CLI option to retrieve preferred authority
Shawn Walker <swalker@opensolaris.org>
parents:
409
diff
changeset
|
4285 |
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
|
4286 |
inc_disabled = True |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4287 |
valid_formats = ( "tsv", ) |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
4288 |
output_format = "default" |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4289 |
field_data = { |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4290 |
"publisher" : [("default", "tsv"), _("PUBLISHER"), ""], |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4291 |
"attrs" : [("default"), "", ""], |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4292 |
"type" : [("default", "tsv"), _("TYPE"), ""], |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4293 |
"status" : [("default", "tsv"), _("STATUS"), ""], |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4294 |
"repo_loc" : [("default"), _("LOCATION"), ""], |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4295 |
"uri": [("tsv"), _("URI"), ""], |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4296 |
"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
|
4297 |
"enabled" : [("tsv"), _("ENABLED"), ""], |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4298 |
"syspub" : [("tsv"), _("SYSPUB"), ""], |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4299 |
"proxy" : [("tsv"), _("PROXY"), ""], |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4300 |
"proxied" : [("default"), _("P"), ""] |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4301 |
} |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4302 |
|
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
|
4303 |
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
|
4304 |
_("SYSPUB"), _("ENABLED"), _("TYPE"), |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4305 |
_("STATUS"), _("P"), _("LOCATION")) |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4306 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4307 |
# 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
|
4308 |
def sort_fields(one, two): |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4309 |
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
|
4310 |
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
|
4311 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4312 |
# 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
|
4313 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4314 |
def filter_default(record): |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4315 |
return "default" in record[0] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4316 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4317 |
def filter_tsv(record): |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4318 |
return "tsv" in record[0] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4319 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4320 |
def get_header(record): |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4321 |
return record[1] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4322 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4323 |
def get_value(record): |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4324 |
return record[2] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4325 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4326 |
def set_value(record, value): |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4327 |
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
|
4328 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4329 |
# 'a' is left over |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4330 |
opts, pargs = getopt.getopt(args, "F:HPan") |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4331 |
for opt, arg in opts: |
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4332 |
if opt == "-H": |
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4333 |
omit_headers = True |
410
403886a7592b
1259 Need CLI option to retrieve preferred authority
Shawn Walker <swalker@opensolaris.org>
parents:
409
diff
changeset
|
4334 |
if opt == "-P": |
403886a7592b
1259 Need CLI option to retrieve preferred authority
Shawn Walker <swalker@opensolaris.org>
parents:
409
diff
changeset
|
4335 |
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
|
4336 |
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
|
4337 |
inc_disabled = False |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4338 |
if opt == "-F": |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
4339 |
output_format = arg |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
4340 |
if output_format not in valid_formats: |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4341 |
usage(_("Unrecognized format %(format)s." |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4342 |
" Supported formats: %(valid)s") % \ |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
4343 |
{ "format": output_format, |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4344 |
"valid": valid_formats }, cmd="publisher") |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4345 |
return EXIT_OOPS |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4346 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
4347 |
api_inst.progresstracker.set_purpose( |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
4348 |
api_inst.progresstracker.PURPOSE_LISTING) |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4349 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4350 |
cert_cache = {} |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4351 |
def get_cert_info(ssl_cert): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4352 |
if not ssl_cert: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4353 |
return None |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4354 |
if ssl_cert not in cert_cache: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4355 |
c = cert_cache[ssl_cert] = {} |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4356 |
errors = c["errors"] = [] |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4357 |
times = c["info"] = { |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4358 |
"effective": "", |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4359 |
"expiration": "", |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4360 |
} |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4361 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4362 |
try: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4363 |
cert = misc.validate_ssl_cert(ssl_cert) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4364 |
except (EnvironmentError, |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4365 |
api_errors.CertificateError, |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4366 |
api_errors.PermissionsException), e: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4367 |
# If the cert information can't be retrieved, |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4368 |
# add the errors to a list and continue on. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4369 |
errors.append(e) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4370 |
c["valid"] = False |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4371 |
else: |
479
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4372 |
nb = cert.get_notBefore() |
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4373 |
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
|
4374 |
nb = datetime.datetime.utcfromtimestamp( |
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4375 |
calendar.timegm(t)) |
1150
2b8aaf0b0b4e
4346 use of ctime() creates non-localized time strings
Rich Burridge <rich.burridge@sun.com>
parents:
1141
diff
changeset
|
4376 |
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
|
4377 |
|
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4378 |
na = cert.get_notAfter() |
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4379 |
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
|
4380 |
na = datetime.datetime.utcfromtimestamp( |
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4381 |
calendar.timegm(t)) |
1150
2b8aaf0b0b4e
4346 use of ctime() creates non-localized time strings
Rich Burridge <rich.burridge@sun.com>
parents:
1141
diff
changeset
|
4382 |
times["expiration"] = na.strftime("%c") |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4383 |
c["valid"] = True |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4384 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4385 |
return cert_cache[ssl_cert] |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4386 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4387 |
retcode = EXIT_OK |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4388 |
if len(pargs) == 0: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4389 |
if preferred_only: |
2659
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4390 |
pref_pub = api_inst.get_highest_ranked_publisher() |
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4391 |
if api_inst.has_publisher(pref_pub): |
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4392 |
pubs = [pref_pub] |
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4393 |
else: |
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4394 |
# Only publisher known is from an installed |
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4395 |
# package and is not configured in the image. |
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4396 |
pubs = [] |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4397 |
else: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4398 |
pubs = [ |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4399 |
p for p in api_inst.get_publishers() |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4400 |
if inc_disabled or not p.disabled |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4401 |
] |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4402 |
# 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
|
4403 |
# format |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
4404 |
if output_format == "default": |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4405 |
fmt = "%-14s %-12s %-8s %-2s %s %s" |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4406 |
filter_func = filter_default |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4407 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4408 |
# 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
|
4409 |
# format |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
4410 |
if output_format == "tsv": |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4411 |
fmt = "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s" |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4412 |
filter_func = filter_tsv |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4413 |
desired_field_order = (_("PUBLISHER"), "", _("STICKY"), |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4414 |
_("SYSPUB"), _("ENABLED"), _("TYPE"), |
2716
9cbeedd42e78
7181582 proxy column in tsv "pkg publisher" output got stuck in the middle
Tim Foster <tim.s.foster@oracle.com>
parents:
2708
diff
changeset
|
4415 |
_("STATUS"), _("URI"), _("PROXY")) |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4416 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4417 |
# 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
|
4418 |
# 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
|
4419 |
# 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
|
4420 |
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
|
4421 |
field_data.values()), sort_fields)) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4422 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4423 |
# Output an header if desired |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4424 |
if not omit_headers: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4425 |
msg(fmt % tuple(hdrs)) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4426 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4427 |
for p in pubs: |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4428 |
# 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
|
4429 |
# field_data ready for output |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4430 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4431 |
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
|
4432 |
# 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
|
4433 |
# format is default. |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
4434 |
if output_format == "default": |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4435 |
pstatus = "" |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4436 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4437 |
if not p.sticky: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4438 |
pstatus_list = [_("non-sticky")] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4439 |
else: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4440 |
pstatus_list = [] |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4441 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4442 |
if p.disabled: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4443 |
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
|
4444 |
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
|
4445 |
pstatus_list.append(_("syspub")) |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4446 |
if pstatus_list: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4447 |
pstatus = "(%s)" % \ |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4448 |
", ".join(pstatus_list) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4449 |
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
|
4450 |
|
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4451 |
if p.sticky: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4452 |
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
|
4453 |
else: |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4454 |
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
|
4455 |
if not p.disabled: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4456 |
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
|
4457 |
else: |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4458 |
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
|
4459 |
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
|
4460 |
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
|
4461 |
else: |
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4462 |
set_value(field_data["syspub"], _("false")) |
926
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 |
# Only show the selected repository's information in |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4465 |
# summary view. |
2659
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4466 |
if p.repository: |
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4467 |
origins = p.repository.origins |
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4468 |
mirrors = p.repository.mirrors |
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4469 |
else: |
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4470 |
origins = mirrors = [] |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4471 |
|
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4472 |
set_value(field_data["repo_loc"], "") |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4473 |
set_value(field_data["proxied"], "") |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4474 |
# 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
|
4475 |
# a publisher record in our desired format. |
2659
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4476 |
for uri in sorted(origins): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4477 |
# XXX get the real origin status |
2100
6a366b063036
17144 Unix socket support is defunct
johansen <johansen@opensolaris.org>
parents:
2097
diff
changeset
|
4478 |
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
|
4479 |
set_value(field_data["status"], _("online")) |
2716
9cbeedd42e78
7181582 proxy column in tsv "pkg publisher" output got stuck in the middle
Tim Foster <tim.s.foster@oracle.com>
parents:
2708
diff
changeset
|
4480 |
set_value(field_data["proxy"], "-") |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4481 |
set_value(field_data["proxied"], "F") |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4482 |
|
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4483 |
set_value(field_data["uri"], uri) |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4484 |
|
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4485 |
if uri.proxies: |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4486 |
set_value(field_data["proxied"], _("T")) |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4487 |
set_value(field_data["proxy"], |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4488 |
", ".join( |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4489 |
[proxy.uri |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4490 |
for proxy in uri.proxies])) |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4491 |
if uri.system: |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4492 |
set_value(field_data["repo_loc"], |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4493 |
SYSREPO_HIDDEN_URI) |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4494 |
else: |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4495 |
set_value(field_data["repo_loc"], uri) |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4496 |
|
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4497 |
values = map(get_value, |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4498 |
sorted(filter(filter_func, |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4499 |
field_data.values()), sort_fields) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4500 |
) |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4501 |
msg(fmt % tuple(values)) |
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4502 |
# 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
|
4503 |
# a publisher record in our desired format. |
2659
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4504 |
for uri in mirrors: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4505 |
# 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
|
4506 |
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
|
4507 |
set_value(field_data["status"], _("online")) |
2716
9cbeedd42e78
7181582 proxy column in tsv "pkg publisher" output got stuck in the middle
Tim Foster <tim.s.foster@oracle.com>
parents:
2708
diff
changeset
|
4508 |
set_value(field_data["proxy"], "-") |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4509 |
set_value(field_data["proxied"], _("F")) |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4510 |
|
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4511 |
set_value(field_data["uri"], uri) |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4512 |
|
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4513 |
if uri.proxies: |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4514 |
set_value(field_data["proxied"], _("T")) |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4515 |
set_value(field_data["proxy"], |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4516 |
", ".join( |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4517 |
[p.uri for p in uri.proxies])) |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4518 |
if uri.system: |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4519 |
set_value(field_data["repo_loc"], |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4520 |
SYSREPO_HIDDEN_URI) |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4521 |
else: |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4522 |
set_value(field_data["repo_loc"], uri) |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4523 |
|
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4524 |
values = map(get_value, |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4525 |
sorted(filter(filter_func, |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4526 |
field_data.values()), sort_fields) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4527 |
) |
1709
28592bd37c9d
12738 zone install/attach incorporation logic needs enhancement
Gary Pennington <gary.pennington@sun.com>
parents:
1687
diff
changeset
|
4528 |
msg(fmt % tuple(values)) |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4529 |
|
2659
8c7c10cb3df8
7141684 'pkg publisher -P' traceback when NO publisher is configured
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2612
diff
changeset
|
4530 |
if not origins and not mirrors: |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4531 |
set_value(field_data["type"], "") |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4532 |
set_value(field_data["status"], "") |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4533 |
set_value(field_data["uri"], "") |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4534 |
set_value(field_data["proxy"], "") |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4535 |
values = map(get_value, |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4536 |
sorted(filter(filter_func, |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4537 |
field_data.values()), sort_fields) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4538 |
) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4539 |
msg(fmt % tuple(values)) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
4540 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4541 |
else: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4542 |
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
|
4543 |
retcode = EXIT_OK |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4544 |
c = get_cert_info(uri.ssl_cert) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4545 |
msg(_(" SSL Key:"), uri.ssl_key) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4546 |
msg(_(" SSL Cert:"), uri.ssl_cert) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4547 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4548 |
if not c: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4549 |
return retcode |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4550 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4551 |
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
|
4552 |
retcode = EXIT_OOPS |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4553 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4554 |
for e in c["errors"]: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
4555 |
logger.error("\n" + str(e) + "\n") |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4556 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4557 |
if c["valid"]: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4558 |
msg(_(" Cert. Effective Date:"), |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4559 |
c["info"]["effective"]) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4560 |
msg(_("Cert. Expiration Date:"), |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4561 |
c["info"]["expiration"]) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4562 |
return retcode |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4563 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4564 |
def display_repository(r): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4565 |
retcode = 0 |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4566 |
for uri in r.origins: |
2100
6a366b063036
17144 Unix socket support is defunct
johansen <johansen@opensolaris.org>
parents:
2097
diff
changeset
|
4567 |
msg(_(" Origin URI:"), uri) |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4568 |
if uri.proxies: |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4569 |
msg(_(" Proxy:"), |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4570 |
", ".join( |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4571 |
[p.uri for p in uri.proxies])) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4572 |
rval = display_ssl_info(uri) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4573 |
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
|
4574 |
retcode = EXIT_PARTIAL |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4575 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4576 |
for uri in r.mirrors: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4577 |
msg(_(" Mirror URI:"), uri) |
2701
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4578 |
if uri.proxies: |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4579 |
msg(_(" Proxy:"), |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4580 |
", ".join( |
55bf0cb749ae
7136244 granular configuration of http_proxy option
Tim Foster <tim.s.foster@oracle.com>
parents:
2700
diff
changeset
|
4581 |
[p.uri for p in uri.proxies])) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4582 |
rval = display_ssl_info(uri) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4583 |
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
|
4584 |
retcode = EXIT_PARTIAL |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4585 |
return retcode |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4586 |
|
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4587 |
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
|
4588 |
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
|
4589 |
msg(_(" Approved CAs:"), |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4590 |
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
|
4591 |
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
|
4592 |
msg(_(" :"), h) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4593 |
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
|
4594 |
msg(_(" Revoked CAs:"), |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4595 |
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
|
4596 |
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
|
4597 |
msg(_(" :"), h) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4598 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4599 |
for name in pargs: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4600 |
# detailed print |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4601 |
pub = api_inst.get_publisher(prefix=name, alias=name) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4602 |
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
|
4603 |
if dt: |
1150
2b8aaf0b0b4e
4346 use of ctime() creates non-localized time strings
Rich Burridge <rich.burridge@sun.com>
parents:
1141
diff
changeset
|
4604 |
dt = dt.strftime("%c") |
479
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
461
diff
changeset
|
4605 |
|
384
9d4746e5dd3e
115 pkg needs to not have a cow on a SIGPIPE
Shawn Walker <swalker@opensolaris.org>
parents:
362
diff
changeset
|
4606 |
msg("") |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4607 |
msg(_(" Publisher:"), pub.prefix) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4608 |
msg(_(" Alias:"), pub.alias) |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4609 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2293
diff
changeset
|
4610 |
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
|
4611 |
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
|
4612 |
# 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
|
4613 |
# 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
|
4614 |
# 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
|
4615 |
retcode = rval |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4616 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4617 |
msg(_(" Client UUID:"), pub.client_uuid) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4618 |
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
|
4619 |
display_signing_certs(pub) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4620 |
if pub.disabled: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4621 |
msg(_(" Enabled:"), _("No")) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4622 |
else: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4623 |
msg(_(" Enabled:"), _("Yes")) |
2609
bc81048dca72
19058 need a way to get publisher specific properties
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2569
diff
changeset
|
4624 |
pub_items = sorted(pub.properties.iteritems()) |
bc81048dca72
19058 need a way to get publisher specific properties
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2569
diff
changeset
|
4625 |
property_padding = " " |
bc81048dca72
19058 need a way to get publisher specific properties
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2569
diff
changeset
|
4626 |
properties_displayed = False |
bc81048dca72
19058 need a way to get publisher specific properties
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2569
diff
changeset
|
4627 |
for k, v in pub_items: |
bc81048dca72
19058 need a way to get publisher specific properties
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2569
diff
changeset
|
4628 |
if not v: |
bc81048dca72
19058 need a way to get publisher specific properties
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2569
diff
changeset
|
4629 |
continue |
bc81048dca72
19058 need a way to get publisher specific properties
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2569
diff
changeset
|
4630 |
if not properties_displayed: |
bc81048dca72
19058 need a way to get publisher specific properties
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2569
diff
changeset
|
4631 |
msg(_(" Properties:")) |
bc81048dca72
19058 need a way to get publisher specific properties
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2569
diff
changeset
|
4632 |
properties_displayed = True |
bc81048dca72
19058 need a way to get publisher specific properties
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2569
diff
changeset
|
4633 |
if not isinstance(v, basestring): |
bc81048dca72
19058 need a way to get publisher specific properties
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2569
diff
changeset
|
4634 |
v = ", ".join(sorted(v)) |
bc81048dca72
19058 need a way to get publisher specific properties
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2569
diff
changeset
|
4635 |
msg(property_padding, k + " =", str(v)) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
4636 |
return retcode |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
4637 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4638 |
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
|
4639 |
"""pkg add-property-value propname propvalue""" |
551 | 4640 |
|
4641 |
# 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
|
4642 |
subcommand = "add-property-value" |
551 | 4643 |
opts, pargs = getopt.getopt(args, "") |
4644 |
try: |
|
4645 |
propname, propvalue = pargs |
|
4646 |
except ValueError: |
|
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4647 |
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
|
4648 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4649 |
# 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
|
4650 |
try: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4651 |
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
|
4652 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4653 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4654 |
return EXIT_OOPS |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4655 |
except api_errors.ApiException, e: |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4656 |
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
|
4657 |
return EXIT_OOPS |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4658 |
return EXIT_OK |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4659 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4660 |
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
|
4661 |
"""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
|
4662 |
|
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4663 |
# 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
|
4664 |
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
|
4665 |
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
|
4666 |
try: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4667 |
propname, propvalue = pargs |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4668 |
except ValueError: |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4669 |
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
|
4670 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4671 |
# 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
|
4672 |
try: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4673 |
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
|
4674 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4675 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4676 |
return EXIT_OOPS |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4677 |
except api_errors.ApiException, e: |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4678 |
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
|
4679 |
return EXIT_OOPS |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4680 |
return EXIT_OK |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4681 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4682 |
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
|
4683 |
"""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
|
4684 |
|
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4685 |
# 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
|
4686 |
subcommand = "set-property" |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4687 |
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
|
4688 |
try: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4689 |
propname = pargs[0] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4690 |
propvalues = pargs[1:] |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4691 |
except IndexError: |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4692 |
propvalues = [] |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4693 |
if len(propvalues) == 0: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
4694 |
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
|
4695 |
cmd=subcommand) |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4696 |
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
|
4697 |
"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
|
4698 |
len(propvalues) == 1: |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4699 |
# 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
|
4700 |
# 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
|
4701 |
# 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
|
4702 |
# 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
|
4703 |
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
|
4704 |
|
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4705 |
props = { propname: propvalues } |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4706 |
if propname == "signature-policy": |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4707 |
policy = propvalues[0] |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4708 |
props[propname] = policy |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4709 |
params = propvalues[1:] |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4710 |
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
|
4711 |
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
|
4712 |
"parameters.") % policy, cmd=subcommand) |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4713 |
elif policy == "require-names": |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4714 |
props["signature-required-names"] = params |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4715 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4716 |
# XXX image property management should be in pkg.client.api |
551 | 4717 |
try: |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4718 |
img.set_properties(props) |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4719 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4720 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4721 |
return EXIT_OOPS |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4722 |
except api_errors.ApiException, e: |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4723 |
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
|
4724 |
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
|
4725 |
return EXIT_OK |
551 | 4726 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4727 |
def property_unset(api_inst, args): |
551 | 4728 |
"""pkg unset-property propname ...""" |
4729 |
||
4730 |
# is this an existing property in our image? |
|
4731 |
# if so, delete it |
|
4732 |
# if not, error |
|
4733 |
||
4734 |
# 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
|
4735 |
subcommand = "unset-property" |
551 | 4736 |
opts, pargs = getopt.getopt(args, "") |
4737 |
if not pargs: |
|
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
4738 |
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
|
4739 |
cmd=subcommand) |
551 | 4740 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4741 |
# XXX image property management should be in pkg.client.api |
551 | 4742 |
for p in pargs: |
4743 |
try: |
|
4744 |
img.delete_property(p) |
|
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4745 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4746 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
4747 |
return EXIT_OOPS |
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4748 |
except api_errors.ApiException, e: |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4749 |
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
|
4750 |
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
|
4751 |
|
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4752 |
return EXIT_OK |
551 | 4753 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4754 |
def property_list(api_inst, args): |
551 | 4755 |
"""pkg property [-H] [propname ...]""" |
4756 |
omit_headers = False |
|
4757 |
||
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4758 |
subcommand = "property" |
551 | 4759 |
opts, pargs = getopt.getopt(args, "H") |
4760 |
for opt, arg in opts: |
|
4761 |
if opt == "-H": |
|
4762 |
omit_headers = True |
|
4763 |
||
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
4764 |
# XXX image property management should be in pkg.client.api |
551 | 4765 |
for p in pargs: |
4766 |
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
|
4767 |
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
|
4768 |
return EXIT_OOPS |
551 | 4769 |
|
4770 |
if not pargs: |
|
2097
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4771 |
# 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
|
4772 |
# requested; otherwise, list them sorted. |
068cc63b4d6e
17055 image configuration should use pkg.config classes
Shawn Walker <shawn.walker@oracle.com>
parents:
2092
diff
changeset
|
4773 |
pargs = sorted(list(img.properties())) |
551 | 4774 |
|
4775 |
width = max(max([len(p) for p in pargs]), 8) |
|
4776 |
fmt = "%%-%ss %%s" % width |
|
4777 |
if not omit_headers: |
|
4778 |
msg(fmt % ("PROPERTY", "VALUE")) |
|
4779 |
||
4780 |
for p in pargs: |
|
4781 |
msg(fmt % (p, img.get_property(p))) |
|
4782 |
||
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4783 |
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
|
4784 |
|
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4785 |
def list_variant(op, api_inst, pargs, omit_headers, output_format, |
2915
a7756acea9ef
17075980 pkg strips newlines from release notes
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2910
diff
changeset
|
4786 |
list_all_items, list_installed, verbose): |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4787 |
"""pkg variant [-Haiv] [-F format] [<variant_pattern> ...]""" |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4788 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4789 |
subcommand = "variant" |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4790 |
if output_format is None: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4791 |
output_format = "default" |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4792 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4793 |
# To work around Python 2.x's scoping limits, a list is used. |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4794 |
found = [False] |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4795 |
req_variants = set(pargs) |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4796 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4797 |
def gen_current(): |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4798 |
for (name, val, pvals) in api_inst.gen_variants(variant_list, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4799 |
patterns=req_variants): |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4800 |
found[0] = True |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4801 |
yield { |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4802 |
"variant": name, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4803 |
"value": val |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4804 |
} |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4805 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4806 |
def gen_possible(): |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4807 |
for (name, val, pvals) in api_inst.gen_variants(variant_list, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4808 |
patterns=req_variants): |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4809 |
found[0] = True |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4810 |
for pval in pvals: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4811 |
yield { |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4812 |
"variant": name, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4813 |
"value": pval |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4814 |
} |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4815 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4816 |
if verbose: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4817 |
gen_listing = gen_possible |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4818 |
else: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4819 |
gen_listing = gen_current |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4820 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4821 |
if list_all_items: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4822 |
if verbose: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4823 |
variant_list = api_inst.VARIANT_ALL_POSSIBLE |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4824 |
else: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4825 |
variant_list = api_inst.VARIANT_ALL |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4826 |
elif list_installed: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4827 |
if verbose: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4828 |
variant_list = api_inst.VARIANT_INSTALLED_POSSIBLE |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4829 |
else: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4830 |
variant_list = api_inst.VARIANT_INSTALLED |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4831 |
else: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4832 |
if verbose: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4833 |
variant_list = api_inst.VARIANT_IMAGE_POSSIBLE |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4834 |
else: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4835 |
variant_list = api_inst.VARIANT_IMAGE |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4836 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4837 |
# VARIANT VALUE |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4838 |
# <variant> <value> |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4839 |
# <variant_2> <value_2> |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4840 |
# ... |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4841 |
field_data = { |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4842 |
"variant" : [("default", "json", "tsv"), _("VARIANT"), ""], |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4843 |
"value" : [("default", "json", "tsv"), _("VALUE"), ""], |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4844 |
} |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4845 |
desired_field_order = (_("VARIANT"), _("VALUE")) |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4846 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4847 |
# Default output formatting. |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4848 |
def_fmt = "%-70s %s" |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4849 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4850 |
# print without trailing newline. |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4851 |
sys.stdout.write(misc.get_listing(desired_field_order, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4852 |
field_data, gen_listing(), output_format, def_fmt, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4853 |
omit_headers)) |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4854 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4855 |
if not found[0] and req_variants: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4856 |
if output_format == "default": |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4857 |
# Don't pollute other output formats. |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4858 |
error(_("no matching variants found"), |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4859 |
cmd=subcommand) |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4860 |
return EXIT_OOPS |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4861 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4862 |
# Successful if no variants exist or if at least one matched. |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4863 |
return EXIT_OK |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4864 |
|
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4865 |
def list_facet(op, api_inst, pargs, omit_headers, output_format, list_all_items, |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4866 |
list_masked, list_installed): |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4867 |
"""pkg facet [-Hai] [-F format] [<facet_pattern> ...]""" |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4868 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4869 |
subcommand = "facet" |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4870 |
if output_format is None: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4871 |
output_format = "default" |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4872 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4873 |
# To work around Python 2.x's scoping limits, a list is used. |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4874 |
found = [False] |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4875 |
req_facets = set(pargs) |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4876 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4877 |
facet_list = api_inst.FACET_IMAGE |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4878 |
if list_all_items: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4879 |
facet_list = api_inst.FACET_ALL |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4880 |
elif list_installed: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4881 |
facet_list = api_inst.FACET_INSTALLED |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4882 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4883 |
def gen_listing(): |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4884 |
for (name, val, src, masked) in \ |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4885 |
api_inst.gen_facets(facet_list, patterns=req_facets): |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4886 |
found[0] = True |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4887 |
|
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4888 |
if not list_masked and masked: |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4889 |
continue |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4890 |
|
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4891 |
# "value" and "masked" are intentionally not _(). |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4892 |
yield { |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4893 |
"facet": name, |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4894 |
"value": val and "True" or "False", |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4895 |
"src": src, |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4896 |
"masked": masked and "True" or "False", |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4897 |
} |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4898 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4899 |
# FACET VALUE |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4900 |
# <facet> <value> <src> |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4901 |
# <facet_2> <value_2> <src2> |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4902 |
# ... |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4903 |
field_data = { |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4904 |
"facet" : [("default", "json", "tsv"), _("FACET"), ""], |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4905 |
"value" : [("default", "json", "tsv"), _("VALUE"), ""], |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4906 |
"src" : [("default", "json", "tsv"), _("SRC"), ""], |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4907 |
} |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4908 |
desired_field_order = (_("FACET"), _("VALUE"), _("SRC")) |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4909 |
def_fmt = "%-64s %-5s %s" |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4910 |
|
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4911 |
if list_masked: |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4912 |
# if we're displaying masked facets, we should also mark which |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4913 |
# facets are masked in the output. |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4914 |
field_data["masked"] = \ |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4915 |
[("default", "json", "tsv"), _("MASKED"), ""] |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4916 |
desired_field_order += (_("MASKED"),) |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
4917 |
def_fmt = "%-57s %-5s %-6s %-s" |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4918 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4919 |
# print without trailing newline. |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4920 |
sys.stdout.write(misc.get_listing(desired_field_order, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4921 |
field_data, gen_listing(), output_format, def_fmt, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4922 |
omit_headers)) |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4923 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4924 |
if not found[0] and req_facets: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4925 |
if output_format == "default": |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4926 |
# Don't pollute other output formats. |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4927 |
error(_("no matching facets found"), |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4928 |
cmd=subcommand) |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4929 |
return EXIT_OOPS |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4930 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
4931 |
# Successful if no facets exist or if at least one matched. |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
4932 |
return EXIT_OK |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
4933 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4934 |
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
|
4935 |
li_ignore, omit_headers): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4936 |
"""pkg list-linked [-H] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4937 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4938 |
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
|
4939 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
4940 |
api_inst.progresstracker.set_purpose( |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
4941 |
api_inst.progresstracker.PURPOSE_LISTING) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4942 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4943 |
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
|
4944 |
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
|
4945 |
return EXIT_OK |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4946 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4947 |
fmt = "" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4948 |
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
|
4949 |
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
|
4950 |
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
|
4951 |
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
|
4952 |
if (fmt != ''): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4953 |
fmt += "\t" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4954 |
fmt += "%%-%ss" % width |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4955 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4956 |
if not omit_headers: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4957 |
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
|
4958 |
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
|
4959 |
msg(fmt % tuple(row)) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4960 |
return EXIT_OK |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4961 |
|
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
4962 |
def pubcheck_linked(op, api_inst, pargs): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
4963 |
"""If we're a child image, verify that the parent image |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
4964 |
publisher configuration is a subset of our publisher configuration. |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
4965 |
If we have any children, recurse into them and perform a publisher |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
4966 |
check.""" |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
4967 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
4968 |
try: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
4969 |
api_inst.linked_publisher_check() |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
4970 |
except api_errors.ImageLockedError, e: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
4971 |
error(e) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
4972 |
return EXIT_LOCKED |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
4973 |
|
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
4974 |
return EXIT_OK |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
4975 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4976 |
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
|
4977 |
""""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
|
4978 |
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
|
4979 |
not specified.""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4980 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4981 |
linked_props = dict() |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4982 |
for pv in args: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4983 |
try: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4984 |
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
|
4985 |
except ValueError: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4986 |
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
|
4987 |
"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
|
4988 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4989 |
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
|
4990 |
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
|
4991 |
cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4992 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4993 |
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
|
4994 |
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
|
4995 |
"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
|
4996 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4997 |
linked_props[p] = v |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4998 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
4999 |
return linked_props |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5000 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5001 |
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
|
5002 |
li_name, omit_headers): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5003 |
"""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
|
5004 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5005 |
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
|
5006 |
image.""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5007 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
5008 |
api_inst.progresstracker.set_purpose( |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
5009 |
api_inst.progresstracker.PURPOSE_LISTING) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5010 |
|
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5011 |
lin = None |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5012 |
if li_name: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5013 |
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
|
5014 |
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
|
5015 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5016 |
for p in pargs: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5017 |
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
|
5018 |
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
|
5019 |
{"op": op, "p": p}) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5020 |
return EXIT_OOPS |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5021 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5022 |
if len(props) == 0: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5023 |
return EXIT_OK |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5024 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5025 |
if not pargs: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5026 |
pargs = props.keys() |
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 |
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
|
5029 |
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
|
5030 |
if not omit_headers: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5031 |
msg(fmt % ("PROPERTY", "VALUE")) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5032 |
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
|
5033 |
if not props[p]: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5034 |
continue |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5035 |
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
|
5036 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5037 |
return EXIT_OK |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5038 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5039 |
def set_property_linked(op, api_inst, pargs, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
5040 |
accept, backup_be, backup_be_name, be_activate, be_name, li_ignore, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
5041 |
li_md_only, li_name, li_parent_sync, li_pkg_updates, new_be, noexecute, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
5042 |
origins, parsable_version, quiet, refresh_catalogs, reject_pats, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
5043 |
show_licenses, update_index, verbose): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5044 |
"""pkg set-property-linked |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5045 |
[-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
|
5046 |
[--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
|
5047 |
[--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
|
5048 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5049 |
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
|
5050 |
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
|
5051 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
5052 |
api_inst.progresstracker.set_purpose( |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
5053 |
api_inst.progresstracker.PURPOSE_LISTING) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5054 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5055 |
# 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
|
5056 |
if li_name: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5057 |
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
|
5058 |
else: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5059 |
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
|
5060 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5061 |
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
|
5062 |
if not xrval: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5063 |
return EXIT_OOPS |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5064 |
|
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
5065 |
return EXIT_OK |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5066 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5067 |
def audit_linked(op, api_inst, pargs, |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5068 |
li_parent_sync, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5069 |
li_target_all, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5070 |
li_target_list, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5071 |
omit_headers, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5072 |
quiet): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5073 |
"""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
|
5074 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5075 |
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
|
5076 |
with their parent image.""" |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5077 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
5078 |
api_inst.progresstracker.set_purpose( |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
5079 |
api_inst.progresstracker.PURPOSE_LISTING) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5080 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5081 |
# 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
|
5082 |
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
|
5083 |
# audit the current image |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5084 |
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
|
5085 |
else: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5086 |
# 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
|
5087 |
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
|
5088 |
if not rvdict: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5089 |
# 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
|
5090 |
return EXIT_OK |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5091 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5092 |
# display audit return values |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5093 |
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
|
5094 |
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
|
5095 |
if not omit_headers: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5096 |
msg(fmt % ("NAME", "STATUS")) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5097 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5098 |
if not quiet: |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5099 |
for k, (rv, err, p_dict) in rvdict.items(): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5100 |
if rv == EXIT_OK: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5101 |
msg(fmt % (k, _("synced"))) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5102 |
elif rv == EXIT_DIVERGED: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5103 |
msg(fmt % (k, _("diverged"))) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5104 |
|
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5105 |
rv, err, p_dicts = api_inst.audit_linked_rvdict2rv(rvdict) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5106 |
if err: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5107 |
error(err, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5108 |
return rv |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5109 |
|
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5110 |
def sync_linked(op, api_inst, pargs, accept, backup_be, backup_be_name, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5111 |
be_activate, be_name, li_ignore, li_md_only, li_parent_sync, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5112 |
li_pkg_updates, li_target_all, li_target_list, new_be, noexecute, origins, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5113 |
parsable_version, quiet, refresh_catalogs, reject_pats, show_licenses, |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5114 |
stage, update_index, verbose): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5115 |
"""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
|
5116 |
[-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
|
5117 |
[--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
|
5118 |
[--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
|
5119 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5120 |
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
|
5121 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5122 |
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
|
5123 |
if not xrval: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5124 |
return EXIT_OOPS |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5125 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5126 |
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
|
5127 |
# sync the current image |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5128 |
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
|
5129 |
_li_ignore=li_ignore, _noexecute=noexecute, |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5130 |
_origins=origins, _parsable_version=parsable_version, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5131 |
_quiet=quiet, _show_licenses=show_licenses, _stage=stage, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
5132 |
_verbose=verbose, backup_be=backup_be, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
5133 |
backup_be_name=backup_be_name, be_activate=be_activate, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5134 |
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
|
5135 |
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
|
5136 |
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
|
5137 |
refresh_catalogs=refresh_catalogs, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5138 |
reject_list=reject_pats, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5139 |
update_index=update_index) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5140 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5141 |
# sync the requested child image(s) |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5142 |
api_inst.progresstracker.set_major_phase( |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5143 |
api_inst.progresstracker.PHASE_UTILITY) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5144 |
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
|
5145 |
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
|
5146 |
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
|
5147 |
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
|
5148 |
|
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5149 |
rv, err, p_dicts = api_inst.sync_linked_rvdict2rv(rvdict) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5150 |
if err: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5151 |
error(err, cmd=op) |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5152 |
if parsable_version is not None and rv == EXIT_OK: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5153 |
try: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5154 |
__display_parsable_plan(api_inst, parsable_version, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5155 |
p_dicts) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5156 |
except api_errors.ApiException, e: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5157 |
error(e, cmd=op) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5158 |
return EXIT_OOPS |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5159 |
return rv |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5160 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5161 |
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
|
5162 |
accept, allow_relink, attach_child, attach_parent, be_activate, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
5163 |
backup_be, backup_be_name, be_name, force, li_ignore, li_md_only, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
5164 |
li_parent_sync, li_pkg_updates, li_props, new_be, noexecute, origins, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
5165 |
parsable_version, quiet, refresh_catalogs, reject_pats, show_licenses, |
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
5166 |
update_index, verbose): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5167 |
"""pkg attach-linked |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5168 |
[-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
|
5169 |
[--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
|
5170 |
[--allow-relink] |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5171 |
[--parsable-version=<version>] |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5172 |
[--prop-linked <propname>=<propvalue> ...] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5173 |
(-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
|
5174 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5175 |
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
|
5176 |
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
|
5177 |
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
|
5178 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5179 |
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
|
5180 |
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
|
5181 |
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
|
5182 |
k, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5183 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5184 |
if len(pargs) < 2: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5185 |
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
|
5186 |
cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5187 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5188 |
li_name = pargs[0] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5189 |
li_path = pargs[1] |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5190 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5191 |
# parse the specified name |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5192 |
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
|
5193 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5194 |
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
|
5195 |
if not xrval: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5196 |
return EXIT_OOPS |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5197 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5198 |
if attach_parent: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5199 |
# 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
|
5200 |
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
|
5201 |
_li_ignore=li_ignore, _noexecute=noexecute, |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5202 |
_origins=origins, _parsable_version=parsable_version, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5203 |
_quiet=quiet, _show_licenses=show_licenses, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5204 |
_verbose=verbose, allow_relink=allow_relink, |
2517
8f26a1d7100c
18827 pkg(1) should provide interfaces to control backup BE creation
Shawn Walker <shawn.walker@oracle.com>
parents:
2510
diff
changeset
|
5205 |
backup_be=backup_be, backup_be_name=backup_be_name, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5206 |
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
|
5207 |
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
|
5208 |
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
|
5209 |
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
|
5210 |
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
|
5211 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5212 |
# attach the requested child image |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5213 |
api_inst.progresstracker.set_major_phase( |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5214 |
api_inst.progresstracker.PHASE_UTILITY) |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5215 |
(rv, err, p_dict) = api_inst.attach_linked_child(lin, li_path, li_props, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5216 |
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
|
5217 |
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
|
5218 |
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
|
5219 |
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
|
5220 |
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
|
5221 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5222 |
if err: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5223 |
error(err, cmd=op) |
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5224 |
if parsable_version is not None and rv == EXIT_OK: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5225 |
assert p_dict is not None |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5226 |
try: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5227 |
__display_parsable_plan(api_inst, parsable_version, |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5228 |
[p_dict]) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5229 |
except api_errors.ApiException, e: |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5230 |
error(e, cmd=op) |
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5231 |
return EXIT_OOPS |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5232 |
return rv |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5233 |
|
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
5234 |
def detach_linked(op, api_inst, pargs, force, li_md_only, li_pkg_updates, |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
5235 |
li_target_all, li_target_list, noexecute, quiet, verbose): |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5236 |
"""pkg detach-linked |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5237 |
[-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
|
5238 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5239 |
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
|
5240 |
|
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5241 |
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
|
5242 |
# detach the current image |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5243 |
return __api_op(op, api_inst, _noexecute=noexecute, |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
5244 |
_quiet=quiet, _verbose=verbose, force=force, |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
5245 |
li_md_only=li_md_only, li_pkg_updates=li_pkg_updates) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5246 |
|
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5247 |
api_inst.progresstracker.set_major_phase( |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5248 |
api_inst.progresstracker.PHASE_UTILITY) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5249 |
rvdict = api_inst.detach_linked_children(li_target_list, force=force, |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
5250 |
li_md_only=li_md_only, li_pkg_updates=li_pkg_updates, |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5251 |
noexecute=noexecute) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5252 |
|
2500
a63fead21404
18439 pkg commands that modify the image should have a parsable output option
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2493
diff
changeset
|
5253 |
rv, err, p_dicts = api_inst.detach_linked_rvdict2rv(rvdict) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5254 |
if err: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5255 |
error(err, cmd=op) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5256 |
return rv |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5257 |
|
1370
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1352
diff
changeset
|
5258 |
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
|
5259 |
"""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
|
5260 |
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
|
5261 |
|
9c9942a52984
(image flag day) remove pkg catalog, improve pkg status, localize pkg(1), use
Stephen Hahn <sch@Sun.COM>
parents:
111
diff
changeset
|
5262 |
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
|
5263 |
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
|
5264 |
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
|
5265 |
kernel statistics or device information.""" |
30 | 5266 |
|
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5267 |
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
|
5268 |
|
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5269 |
force = False |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5270 |
imgtype = IMG_TYPE_USER |
104
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
103
diff
changeset
|
5271 |
is_zone = False |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5272 |
add_mirrors = set() |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5273 |
add_origins = set() |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5274 |
pub_name = None |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5275 |
pub_url = None |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5276 |
refresh_allowed = True |
310
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
5277 |
ssl_key = None |
8fa744df663a
975 Catalogs need to know their origins
johansen <johansen@sun.com>
parents:
309
diff
changeset
|
5278 |
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
|
5279 |
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
|
5280 |
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
|
5281 |
set_props = {} |
2144
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5282 |
version = None |
30 | 5283 |
|
2787
1a1b0a56046e
7136331 old authority command recognition should be removed
Shawn Walker <shawn.walker@oracle.com>
parents:
2773
diff
changeset
|
5284 |
opts, pargs = getopt.getopt(args, "fFPUzg:m:p:k:c:", |
1a1b0a56046e
7136331 old authority command recognition should be removed
Shawn Walker <shawn.walker@oracle.com>
parents:
2773
diff
changeset
|
5285 |
["force", "full", "partial", "user", "zone", "facet=", "mirror=", |
1a1b0a56046e
7136331 old authority command recognition should be removed
Shawn Walker <shawn.walker@oracle.com>
parents:
2773
diff
changeset
|
5286 |
"origin=", "publisher=", "no-refresh", "variant=", |
2100
6a366b063036
17144 Unix socket support is defunct
johansen <johansen@opensolaris.org>
parents:
2097
diff
changeset
|
5287 |
"set-property="]) |
30 | 5288 |
|
5289 |
for opt, arg in opts: |
|
2787
1a1b0a56046e
7136331 old authority command recognition should be removed
Shawn Walker <shawn.walker@oracle.com>
parents:
2773
diff
changeset
|
5290 |
if opt in ("-p", "--publisher"): |
2930
89257716c7c1
16297554 pkg history fails when time travelling
<xiaobo.shen@oracle.com>
parents:
2926
diff
changeset
|
5291 |
if pub_url: |
2922
37531d03eb31
15678637 SUNBT7133912 image-create and set-publisher only use last -p specified
thejaswini.k@oracle.com
parents:
2920
diff
changeset
|
5292 |
usage(_("The -p option can be specified only " |
2930
89257716c7c1
16297554 pkg history fails when time travelling
<xiaobo.shen@oracle.com>
parents:
2926
diff
changeset
|
5293 |
"once."), cmd=cmd_name) |
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
|
5294 |
try: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
5295 |
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
|
5296 |
except ValueError: |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5297 |
pub_name = None |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5298 |
pub_url = arg |
2430
a1937ef0a955
18325 image-create should accept simple paths for sources
Shawn Walker <shawn.walker@oracle.com>
parents:
2413
diff
changeset
|
5299 |
if pub_url: |
a1937ef0a955
18325 image-create should accept simple paths for sources
Shawn Walker <shawn.walker@oracle.com>
parents:
2413
diff
changeset
|
5300 |
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
|
5301 |
elif opt == "-c": |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5302 |
ssl_cert = arg |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5303 |
elif opt == "-f" or opt == "--force": |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5304 |
force = True |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5305 |
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
|
5306 |
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
|
5307 |
elif opt == "-k": |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5308 |
ssl_key = arg |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5309 |
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
|
5310 |
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
|
5311 |
elif opt == "-z" or opt == "--zone": |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5312 |
is_zone = True |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5313 |
imgtype = IMG_TYPE_ENTIRE |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5314 |
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
|
5315 |
imgtype = IMG_TYPE_ENTIRE |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5316 |
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
|
5317 |
imgtype = IMG_TYPE_PARTIAL |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
5318 |
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
|
5319 |
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
|
5320 |
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
|
5321 |
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
|
5322 |
try: |
ca4d89069b17
14860 image-create facet option usage message is oddly worded
Shawn Walker <shawn.walker@oracle.com>
parents:
2253
diff
changeset
|
5323 |
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
|
5324 |
except ValueError: |
ca4d89069b17
14860 image-create facet option usage message is oddly worded
Shawn Walker <shawn.walker@oracle.com>
parents:
2253
diff
changeset
|
5325 |
f_name = arg |
ca4d89069b17
14860 image-create facet option usage message is oddly worded
Shawn Walker <shawn.walker@oracle.com>
parents:
2253
diff
changeset
|
5326 |
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
|
5327 |
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
|
5328 |
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
|
5329 |
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
|
5330 |
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
|
5331 |
"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
|
5332 |
cmd=cmd_name) |
1537 | 5333 |
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
|
5334 |
elif opt == "--no-refresh": |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5335 |
refresh_allowed = False |
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5336 |
elif opt == "--set-property": |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5337 |
t = arg.split("=", 1) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5338 |
if len(t) < 2: |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5339 |
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
|
5340 |
"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
|
5341 |
"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
|
5342 |
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
|
5343 |
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
|
5344 |
"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
|
5345 |
cmd=cmd_name) |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1970
diff
changeset
|
5346 |
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
|
5347 |
elif opt == "--variant": |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5348 |
try: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5349 |
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
|
5350 |
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
|
5351 |
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
|
5352 |
except ValueError: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5353 |
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
|
5354 |
"form '<name>=<value>'."), |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5355 |
cmd=cmd_name) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5356 |
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
|
5357 |
|
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5358 |
if not pargs: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5359 |
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
|
5360 |
cmd=cmd_name) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5361 |
elif len(pargs) > 1: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
5362 |
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
|
5363 |
cmd=cmd_name) |
1111
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1102
diff
changeset
|
5364 |
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
|
5365 |
|
2823
8def820a649c
7140147 The error: Invalid linked image name: i2 Isn't descriptive enough
thejaswini.k@oracle.com
parents:
2808
diff
changeset
|
5366 |
if pub_url and 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
|
5367 |
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
|
5368 |
"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
|
5369 |
|
2763
ce7b48c9e2b8
7140654 image-create traceback if -g or -m specified without -p
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2757
diff
changeset
|
5370 |
if not pub_url and (add_origins or add_mirrors): |
ce7b48c9e2b8
7140654 image-create traceback if -g or -m specified without -p
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2757
diff
changeset
|
5371 |
usage(_("A publisher must be specified if -g or -m are used."), |
ce7b48c9e2b8
7140654 image-create traceback if -g or -m specified without -p
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2757
diff
changeset
|
5372 |
cmd=cmd_name) |
ce7b48c9e2b8
7140654 image-create traceback if -g or -m specified without -p
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2757
diff
changeset
|
5373 |
|
2100
6a366b063036
17144 Unix socket support is defunct
johansen <johansen@opensolaris.org>
parents:
2097
diff
changeset
|
5374 |
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
|
5375 |
# 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
|
5376 |
# 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
|
5377 |
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
|
5378 |
repo_uri = None |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5379 |
else: |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5380 |
repo_uri = pub_url |
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5381 |
|
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5382 |
# 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
|
5383 |
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
|
5384 |
ssl_key) |
327
6c6bd07efe8d
1031 authority prefix needs validation
johansen <johansen@sun.com>
parents:
326
diff
changeset
|
5385 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
5386 |
progtrack = get_tracker() |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
5387 |
progtrack.set_major_phase(progtrack.PHASE_UTILITY) |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5388 |
global _api_inst |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5389 |
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
|
5390 |
try: |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5391 |
_api_inst = api.image_create(PKG_CLIENT_NAME, CLIENT_API_VERSION, |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5392 |
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
|
5393 |
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
|
5394 |
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
|
5395 |
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
|
5396 |
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
|
5397 |
props=set_props) |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5398 |
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
|
5399 |
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
|
5400 |
# Ensure messages are displayed after the spinner. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
5401 |
logger.error("\n") |
1063
80e49e35ce17
4461 l10n changes to allow string inputs reordering
Rich Burridge <rich.burridge@sun.com>
parents:
1053
diff
changeset
|
5402 |
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
|
5403 |
"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
|
5404 |
"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
|
5405 |
"\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
|
5406 |
{ "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
|
5407 |
cmd=cmd_name) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5408 |
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
|
5409 |
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
|
5410 |
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
|
5411 |
# 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
|
5412 |
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
|
5413 |
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
|
5414 |
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
|
5415 |
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
|
5416 |
return EXIT_PARTIAL |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5417 |
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
|
5418 |
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
|
5419 |
return EXIT_OOPS |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
5420 |
finally: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
5421 |
# Normally this would get flushed by handle_errors |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
5422 |
# but that won't happen if the above code throws, because |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
5423 |
# _api_inst will be None. |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
5424 |
progtrack.flush() |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
5425 |
|
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
5426 |
return EXIT_OK |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
5427 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5428 |
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
|
5429 |
"""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
|
5430 |
|
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
427
diff
changeset
|
5431 |
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
|
5432 |
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
|
5433 |
|
442
01fb28d438b3
2418 'pkg version', 'pkg image-update' should error on additional arguments
Dan Price <dp@eng.sun.com>
parents:
432
diff
changeset
|
5434 |
if pargs: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
5435 |
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
|
5436 |
" ".join(pargs), cmd="rebuild-index") |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
5437 |
|
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
427
diff
changeset
|
5438 |
try: |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
5439 |
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
|
5440 |
except api_errors.ImageFormatUpdateNeeded, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5441 |
format_update_error(e) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5442 |
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
|
5443 |
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
|
5444 |
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
|
5445 |
"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
|
5446 |
return EXIT_OOPS |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
938
diff
changeset
|
5447 |
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
|
5448 |
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
|
5449 |
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
|
5450 |
"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
|
5451 |
return EXIT_OOPS |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5452 |
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
|
5453 |
return EXIT_OK |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5454 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5455 |
def history_list(api_inst, args): |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5456 |
"""Display history about the current image. |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5457 |
""" |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5458 |
# define column name, header, field width and <History> attribute name |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5459 |
# we compute 'reason', 'time' and 'release_note' columns ourselves |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5460 |
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
|
5461 |
"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
|
5462 |
"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
|
5463 |
"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
|
5464 |
"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
|
5465 |
"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
|
5466 |
"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
|
5467 |
"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
|
5468 |
"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
|
5469 |
"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
|
5470 |
"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
|
5471 |
"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
|
5472 |
"reason": (_("REASON"), "%-10s", None), |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5473 |
"release_notes": (_("RELEASE NOTES"), "%-12s", None), |
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 |
"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
|
5475 |
"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
|
5476 |
"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
|
5477 |
"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
|
5478 |
# 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
|
5479 |
# 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
|
5480 |
} |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5481 |
|
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5482 |
omit_headers = False |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5483 |
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
|
5484 |
column_format = False |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5485 |
show_notes = 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
|
5486 |
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
|
5487 |
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
|
5488 |
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
|
5489 |
|
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5490 |
opts, pargs = getopt.getopt(args, "HNln:o:t:") |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5491 |
for opt, arg in opts: |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5492 |
if opt == "-H": |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5493 |
omit_headers = True |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5494 |
elif opt == "-N": |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5495 |
show_notes = True |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5496 |
elif opt == "-l": |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5497 |
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
|
5498 |
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
|
5499 |
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
|
5500 |
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
|
5501 |
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
|
5502 |
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
|
5503 |
_("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
|
5504 |
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
|
5505 |
|
e670eae1a5f4
15365 pkg history could use a way to show the most recent N entries
Richard Lowe <richlowe@richlowe.net>
parents:
1859
diff
changeset
|
5506 |
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
|
5507 |
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
|
5508 |
_("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
|
5509 |
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
|
5510 |
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
|
5511 |
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
|
5512 |
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
|
5513 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5514 |
# '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
|
5515 |
# 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
|
5516 |
# 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
|
5517 |
# 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
|
5518 |
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
|
5519 |
# 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
|
5520 |
# 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
|
5521 |
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
|
5522 |
"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
|
5523 |
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
|
5524 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5525 |
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
|
5526 |
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
|
5527 |
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
|
5528 |
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
|
5529 |
_("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
|
5530 |
"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
|
5531 |
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
|
5532 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5533 |
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
|
5534 |
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
|
5535 |
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
|
5536 |
_("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
|
5537 |
col) |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5538 |
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
|
5539 |
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
|
5540 |
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
|
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 |
elif opt == "-t": |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5543 |
time_vals.extend(arg.split(",")) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5544 |
|
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5545 |
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
|
5546 |
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
|
5547 |
|
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5548 |
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
|
5549 |
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
|
5550 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5551 |
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
|
5552 |
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
|
5553 |
|
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5554 |
if column_format and show_notes: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5555 |
usage(_("-o and -N may not be combined"), cmd="history") |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5556 |
|
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5557 |
if long_format and show_notes: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5558 |
usage(_("-l and -N may not be combined"), cmd="history") |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5559 |
|
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5560 |
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
|
5561 |
|
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5562 |
if not long_format and not show_notes: |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5563 |
headers = [] |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5564 |
# 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
|
5565 |
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
|
5566 |
# 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
|
5567 |
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
|
5568 |
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
|
5569 |
else: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5570 |
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
|
5571 |
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
|
5572 |
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
|
5573 |
else: |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5574 |
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
|
5575 |
headers.append(history_cols[col][0]) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5576 |
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
|
5577 |
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
|
5578 |
|
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5579 |
def gen_entries(): |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5580 |
"""Error handler for history generation; avoids need to indent |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5581 |
and clobber formatting of logic below.""" |
732
9ea802fef2fb
3540 client should be resilient against corrupt history
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
727
diff
changeset
|
5582 |
try: |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5583 |
for he in api_inst.gen_history(limit=display_limit, |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5584 |
times=time_vals): |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5585 |
yield he |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5586 |
except api_errors.HistoryException, e: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5587 |
error(str(e), cmd="history") |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5588 |
sys.exit(EXIT_OOPS) |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5589 |
|
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5590 |
if show_notes: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5591 |
for he in gen_entries(): |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5592 |
start_time = misc.timestamp_to_time( |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5593 |
he.operation_start_time) |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5594 |
start_time = datetime.datetime.fromtimestamp( |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5595 |
start_time).isoformat() |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5596 |
if he.operation_release_notes: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5597 |
msg(_("%s: Release notes:") % start_time) |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5598 |
for a in he.notes: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5599 |
msg(" %s" % a) |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5600 |
else: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5601 |
msg(_("%s: Release notes: None") % start_time) |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5602 |
|
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5603 |
return EXIT_OK |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5604 |
|
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5605 |
for he in gen_entries(): |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5606 |
# 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
|
5607 |
output = {} |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5608 |
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
|
5609 |
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
|
5610 |
continue |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5611 |
output[col] = getattr(he, history_cols[col][2], None) |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5612 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5613 |
# 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
|
5614 |
output["start"] = misc.timestamp_to_time( |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5615 |
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
|
5616 |
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
|
5617 |
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
|
5618 |
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
|
5619 |
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
|
5620 |
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
|
5621 |
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
|
5622 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5623 |
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
|
5624 |
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
|
5625 |
if dt_start > dt_end: |
2930
89257716c7c1
16297554 pkg history fails when time travelling
<xiaobo.shen@oracle.com>
parents:
2926
diff
changeset
|
5626 |
output["finish"] = _("%s (clock drift detected)") % \ |
89257716c7c1
16297554 pkg history fails when time travelling
<xiaobo.shen@oracle.com>
parents:
2926
diff
changeset
|
5627 |
output["finish"] |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5628 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5629 |
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
|
5630 |
# 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
|
5631 |
# 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
|
5632 |
# 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
|
5633 |
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
|
5634 |
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
|
5635 |
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
|
5636 |
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
|
5637 |
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
|
5638 |
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
|
5639 |
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
|
5640 |
(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
|
5641 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5642 |
output["command"] = " ".join(he.client_args) |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5643 |
|
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5644 |
# Where we weren't able to lookup the current name, add a '*' to |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5645 |
# the entry, indicating the boot environment is no longer |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5646 |
# present. |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5647 |
if he.operation_be and he.operation_current_be: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5648 |
output["be"] = he.operation_current_be |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5649 |
elif he.operation_be_uuid: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5650 |
output["be"] = "%s*" % he.operation_be |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5651 |
else: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5652 |
output["be"] = he.operation_be |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5653 |
|
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5654 |
if he.operation_new_be and he.operation_current_new_be: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5655 |
output["new_be"] = he.operation_current_new_be |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5656 |
elif he.operation_new_be_uuid: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5657 |
output["new_be"] = "%s*" % he.operation_new_be |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5658 |
else: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5659 |
output["new_be"] = "%s" % he.operation_new_be |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5660 |
|
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5661 |
if he.operation_release_notes: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5662 |
output["release_notes"] = _("Yes") |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5663 |
else: |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5664 |
output["release_notes"] = _("No") |
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5665 |
|
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5666 |
outcome, reason = he.operation_result_text |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5667 |
output["outcome"] = outcome |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5668 |
output["reason"] = reason |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5669 |
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
|
5670 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5671 |
# 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
|
5672 |
# 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
|
5673 |
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
|
5674 |
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
|
5675 |
|
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5676 |
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
|
5677 |
output["be_uuid"] = _("(Unknown)") |
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5678 |
|
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5679 |
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
|
5680 |
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
|
5681 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5682 |
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
|
5683 |
output["new_be"] = _("(None)") |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5684 |
|
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5685 |
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
|
5686 |
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
|
5687 |
|
2675
49931dc5f9b6
7140680 "pkg history" does not work in some localized locales
abhinandan.ekande@oracle.com
parents:
2659
diff
changeset
|
5688 |
enc = locale.getlocale(locale.LC_CTYPE)[1] |
49931dc5f9b6
7140680 "pkg history" does not work in some localized locales
abhinandan.ekande@oracle.com
parents:
2659
diff
changeset
|
5689 |
if not enc: |
49931dc5f9b6
7140680 "pkg history" does not work in some localized locales
abhinandan.ekande@oracle.com
parents:
2659
diff
changeset
|
5690 |
enc = locale.getpreferredencoding() |
49931dc5f9b6
7140680 "pkg history" does not work in some localized locales
abhinandan.ekande@oracle.com
parents:
2659
diff
changeset
|
5691 |
|
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5692 |
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
|
5693 |
data = __get_long_history_data(he, output) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5694 |
for field, value in data: |
2675
49931dc5f9b6
7140680 "pkg history" does not work in some localized locales
abhinandan.ekande@oracle.com
parents:
2659
diff
changeset
|
5695 |
if isinstance(field, unicode): |
49931dc5f9b6
7140680 "pkg history" does not work in some localized locales
abhinandan.ekande@oracle.com
parents:
2659
diff
changeset
|
5696 |
field = field.encode(enc) |
49931dc5f9b6
7140680 "pkg history" does not work in some localized locales
abhinandan.ekande@oracle.com
parents:
2659
diff
changeset
|
5697 |
if isinstance(value, unicode): |
49931dc5f9b6
7140680 "pkg history" does not work in some localized locales
abhinandan.ekande@oracle.com
parents:
2659
diff
changeset
|
5698 |
value = value.encode(enc) |
2141
3757a0f8a7d1
17385 history should store uuids for boot environments
Tim Foster <tim.s.foster@oracle.com>
parents:
2135
diff
changeset
|
5699 |
msg("%18s: %s" % (field, value)) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5700 |
|
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5701 |
# Separate log entries with a blank line. |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5702 |
msg("") |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5703 |
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
|
5704 |
items = [] |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5705 |
for col in columns: |
2675
49931dc5f9b6
7140680 "pkg history" does not work in some localized locales
abhinandan.ekande@oracle.com
parents:
2659
diff
changeset
|
5706 |
item = output[col] |
49931dc5f9b6
7140680 "pkg history" does not work in some localized locales
abhinandan.ekande@oracle.com
parents:
2659
diff
changeset
|
5707 |
if isinstance(item, unicode): |
49931dc5f9b6
7140680 "pkg history" does not work in some localized locales
abhinandan.ekande@oracle.com
parents:
2659
diff
changeset
|
5708 |
item = item.encode(enc) |
49931dc5f9b6
7140680 "pkg history" does not work in some localized locales
abhinandan.ekande@oracle.com
parents:
2659
diff
changeset
|
5709 |
items.append(item) |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5710 |
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
|
5711 |
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
|
5712 |
|
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5713 |
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
|
5714 |
"""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
|
5715 |
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
|
5716 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5717 |
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
|
5718 |
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
|
5719 |
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
|
5720 |
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
|
5721 |
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
|
5722 |
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
|
5723 |
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
|
5724 |
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
|
5725 |
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
|
5726 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5727 |
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
|
5728 |
"""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
|
5729 |
data = [] |
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5730 |
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
|
5731 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5732 |
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
|
5733 |
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
|
5734 |
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
|
5735 |
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
|
5736 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5737 |
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
|
5738 |
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
|
5739 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5740 |
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
|
5741 |
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
|
5742 |
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
|
5743 |
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
|
5744 |
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
|
5745 |
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
|
5746 |
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
|
5747 |
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
|
5748 |
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
|
5749 |
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
|
5750 |
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
|
5751 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5752 |
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
|
5753 |
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
|
5754 |
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
|
5755 |
data.append((_("Command"), hist_info["command"])) |
2708
4dac3e277ccf
7137406 pkg image-update could display release notes (or pointer to)
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2707
diff
changeset
|
5756 |
data.append((_("Release Notes"), hist_info["release_notes"])) |
2135
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5757 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5758 |
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
|
5759 |
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
|
5760 |
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
|
5761 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5762 |
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
|
5763 |
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
|
5764 |
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
|
5765 |
|
6eeb55920e13
3419 history command -- ability to specify dates or date ranges desired
Tim Foster <tim.s.foster@oracle.com>
parents:
2133
diff
changeset
|
5766 |
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
|
5767 |
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
|
5768 |
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
|
5769 |
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
|
5770 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5771 |
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
|
5772 |
"""Purge image history""" |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5773 |
api_inst.purge_history() |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5774 |
msg(_("History purged.")) |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
5775 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5776 |
def print_proxy_config(): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5777 |
"""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
|
5778 |
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
|
5779 |
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
|
5780 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5781 |
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
|
5782 |
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
|
5783 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5784 |
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
|
5785 |
return |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5786 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
5787 |
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
|
5788 |
" environment:\n")) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5789 |
if http_proxy: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
5790 |
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
|
5791 |
if https_proxy: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
5792 |
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
|
5793 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5794 |
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
|
5795 |
"""Update image to newest format.""" |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5796 |
|
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5797 |
try: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5798 |
res = api_inst.update_format() |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5799 |
except api_errors.ApiException, e: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5800 |
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
|
5801 |
return EXIT_OOPS |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5802 |
|
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5803 |
if res: |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5804 |
logger.info(_("Image format updated.")) |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5805 |
return EXIT_OK |
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5806 |
|
2ac203b826ab
7276 /var/pkg metadata needs reorg (looks busy)
Shawn Walker <shawn.walker@oracle.com>
parents:
2141
diff
changeset
|
5807 |
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
|
5808 |
return EXIT_NOP |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
5809 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5810 |
def print_version(pargs): |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5811 |
if pargs: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5812 |
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
|
5813 |
" ".join(pargs), cmd="version") |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5814 |
msg(pkg.VERSION) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5815 |
return EXIT_OK |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
5816 |
|
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
5817 |
# To allow exception handler access to the image. |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
5818 |
_api_inst = None |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5819 |
pargs = None |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
5820 |
img = None |
1752
b62d86fb62c8
14515 client can traceback during search
Shawn Walker <srw@sun.com>
parents:
1736
diff
changeset
|
5821 |
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
|
5822 |
|
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5823 |
# |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5824 |
# Mapping of the internal option name to short and long CLI options. |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5825 |
# |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5826 |
# {option_name: (short, long)} |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5827 |
# |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5828 |
# |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5829 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5830 |
opts_mapping = { |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5831 |
"backup_be_name" : ("", "backup-be-name"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5832 |
"be_name" : ("", "be-name"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5833 |
"deny_new_be" : ("", "deny-new-be"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5834 |
"no_backup_be" : ("", "no-backup-be"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5835 |
"be_activate" : ("", "no-be-activate"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5836 |
"require_backup_be" : ("", "require-backup-be"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5837 |
"require_new_be" : ("", "require-new-be"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5838 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5839 |
"concurrency" : ("C", "concurrency"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5840 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5841 |
"force" : ("f", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5842 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5843 |
"li_ignore_all" : ("I", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5844 |
"li_ignore_list" : ("i", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5845 |
"li_md_only" : ("", "linked-md-only"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5846 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5847 |
"li_pkg_updates" : ("", "no-pkg-updates"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5848 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5849 |
"li_parent_sync" : ("", "no-parent-sync"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5850 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5851 |
"li_props" : ("", "prop-linked"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5852 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5853 |
"li_target_all" : ("a", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5854 |
"li_target_list" : ("l", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5855 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5856 |
"li_name" : ("l", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5857 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5858 |
"accept" : ("", "accept"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5859 |
"show_licenses" : ("", "licenses"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5860 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5861 |
"omit_headers" : ("H", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5862 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5863 |
"update_index" : ("", "no-index"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5864 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5865 |
"refresh_catalogs" : ("", "no-refresh"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5866 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5867 |
"reject_pats" : ("", "reject"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5868 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5869 |
"verbose" : ("v", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5870 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5871 |
"quiet" : ("q", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5872 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5873 |
"parsable_version" : ("", "parsable"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5874 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5875 |
"noexecute" : ("n", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5876 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5877 |
"origins" : ("g", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5878 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5879 |
"stage" : ("", "stage"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5880 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5881 |
"allow_relink" : ("", "allow-relink"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5882 |
"attach_child" : ("c", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5883 |
"attach_parent" : ("p", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5884 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5885 |
"list_available" : ("a", ""), |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
5886 |
"list_masked" : ("m", ""), |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
5887 |
"list_all_items" : ("a", ""), |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5888 |
"output_format" : ("F", "output-format"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5889 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5890 |
"tagged" : ("", "tagged"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5891 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5892 |
# These options are used in set-mediator and unset-mediator but |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5893 |
# the long options are only valid in set_mediator (as per the previous |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5894 |
# implementation). However, the long options are not documented in the |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5895 |
# manpage for set-mediator either, so I think we're good. |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5896 |
"med_implementation" : ("I", "implementation"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5897 |
"med_version" : ("V", "version"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5898 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5899 |
"list_installed_newest" : ("a", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5900 |
"list_all" : ("f", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5901 |
"list_newest" : ("n", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5902 |
"summary" : ("s", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5903 |
"list_upgradable" : ("u", ""), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5904 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5905 |
"ctlfd" : ("", "ctlfd"), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5906 |
"progfd" : ("", "progfd"), |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
5907 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
5908 |
"list_installed" : ("i", ""), |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5909 |
} |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5910 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5911 |
# |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5912 |
# cmds dictionary is used to dispatch subcommands. The format of this |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5913 |
# dictionary is: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5914 |
# |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5915 |
# "subcommand-name" : subcommand-cb |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5916 |
# |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5917 |
# subcommand-cb: the callback function invoked for this subcommand |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5918 |
# |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5919 |
# placeholders in this lookup table for image-create, help and version |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5920 |
# which don't have dedicated methods |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5921 |
# |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5922 |
cmds = { |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5923 |
"add-property-value" : [property_add_value], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5924 |
"attach-linked" : [attach_linked, 2], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5925 |
"avoid" : [avoid], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5926 |
"audit-linked" : [audit_linked, 0], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5927 |
"authority" : [publisher_list], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5928 |
"change-facet" : [change_facet], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5929 |
"change-variant" : [change_variant], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5930 |
"contents" : [list_contents], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5931 |
"detach-linked" : [detach_linked, 0], |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
5932 |
"facet" : [list_facet], |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5933 |
"fix" : [fix_image], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5934 |
"freeze" : [freeze], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5935 |
"help" : [None], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5936 |
"history" : [history_list], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5937 |
"image-create" : [None], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5938 |
"info" : [info], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5939 |
"install" : [install], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5940 |
"list" : [list_inventory], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5941 |
"list-linked" : [list_linked, 0], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5942 |
"mediator" : [list_mediators], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5943 |
"property" : [property_list], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5944 |
"property-linked" : [list_property_linked], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5945 |
"pubcheck-linked" : [pubcheck_linked, 0], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5946 |
"publisher" : [publisher_list], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5947 |
"purge-history" : [history_purge], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5948 |
"rebuild-index" : [rebuild_index], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5949 |
"refresh" : [publisher_refresh], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5950 |
"remote" : [remote, 0], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5951 |
"remove-property-value" : [property_remove_value], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5952 |
"revert" : [revert], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5953 |
"search" : [search], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5954 |
"set-authority" : [publisher_set], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5955 |
"set-mediator" : [set_mediator], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5956 |
"set-property" : [property_set], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5957 |
"set-property-linked" : [set_property_linked], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5958 |
"set-publisher" : [publisher_set], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5959 |
"sync-linked" : [sync_linked, 0], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5960 |
"unavoid" : [unavoid], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5961 |
"unfreeze" : [unfreeze], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5962 |
"uninstall" : [uninstall], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5963 |
"unset-authority" : [publisher_unset], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5964 |
"unset-property" : [property_unset], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5965 |
"unset-mediator" : [unset_mediator], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5966 |
"unset-publisher" : [publisher_unset], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5967 |
"update" : [update], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5968 |
"update-format" : [update_format], |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
5969 |
"variant" : [list_variant], |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5970 |
"verify" : [verify_image], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5971 |
"version" : [None], |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5972 |
} |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
5973 |
|
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5974 |
# These tables are an addendum to the the pkg_op_opts/opts_* lists in |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5975 |
# modules/client/options.py. They contain all the options for functions which |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5976 |
# are not represented in options.py but go through common option processing. |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5977 |
# This list should get shortened and eventually removed by moving more/all |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5978 |
# functions out of client.py. |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5979 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5980 |
def opts_cb_remote(api_inst, opts, opts_new): |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5981 |
options.opts_cb_fd("ctlfd", api_inst, opts, opts_new) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5982 |
options.opts_cb_fd("progfd", api_inst, opts, opts_new) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5983 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5984 |
# move progfd from opts_new into a global |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5985 |
global_settings.client_output_progfd = opts_new["progfd"] |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5986 |
del opts_new["progfd"] |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5987 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5988 |
opts_remote = [ |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5989 |
opts_cb_remote, |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5990 |
("ctlfd", None), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5991 |
("progfd", None), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5992 |
] |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
5993 |
|
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
5994 |
def opts_cb_varcet(api_inst, opts, opts_new): |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
5995 |
if opts_new["list_all_items"] and opts_new["list_installed"]: |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
5996 |
raise api_errors.InvalidOptionError( |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
5997 |
api_errors.InvalidOptionError.INCOMPAT, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
5998 |
["list_all_items", "list_installed"]) |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
5999 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6000 |
opts_list_varcet = \ |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6001 |
options.opts_table_no_headers + \ |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6002 |
[ |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6003 |
opts_cb_varcet, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6004 |
("list_all_items", False), |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6005 |
("list_installed", False), |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6006 |
("output_format", None) |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6007 |
] |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6008 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6009 |
opts_list_facet = \ |
2925
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
6010 |
opts_list_varcet + \ |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
6011 |
[ |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
6012 |
("list_masked", False), |
3e1fbeb31067
15743323 linked images should propagate incorporation facet version locks
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2922
diff
changeset
|
6013 |
] |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6014 |
|
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6015 |
opts_list_variant = \ |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6016 |
opts_list_varcet + \ |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6017 |
[ |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6018 |
("verbose", False) |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6019 |
] |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6020 |
|
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6021 |
opts_list_mediator = \ |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6022 |
options.opts_table_no_headers + \ |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6023 |
[ |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6024 |
("list_available", False), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6025 |
("output_format", None) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6026 |
] |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6027 |
opts_unset_mediator = \ |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6028 |
options.opts_table_beopts + \ |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6029 |
options.opts_table_no_index + \ |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6030 |
options.opts_table_nqv + \ |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6031 |
options.opts_table_parsable + \ |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6032 |
[ |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6033 |
("med_implementation", False), |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6034 |
("med_version", False) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6035 |
] |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6036 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6037 |
cmd_opts = { |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6038 |
"facet" : opts_list_facet, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6039 |
"mediator" : opts_list_mediator, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6040 |
"unset-mediator" : opts_unset_mediator, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6041 |
"remote" : opts_remote, |
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6042 |
"variant" : opts_list_variant, |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6043 |
} |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6044 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6045 |
|
242
7bd1830635c8
402 Start on some pylint cleanup, and fix missing imports
Dan Price <dp@eng.sun.com>
parents:
239
diff
changeset
|
6046 |
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
|
6047 |
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
|
6048 |
|
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6049 |
global _api_inst |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
6050 |
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
|
6051 |
global orig_cwd |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
6052 |
global pargs |
1687
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
6053 |
|
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
6054 |
try: |
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
6055 |
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
|
6056 |
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
|
6057 |
try: |
dd4aca6ac390
11554 pkg set-publisher should accept relative paths to keys and certs
Tim Foster <tim.foster@sun.com>
parents:
1685
diff
changeset
|
6058 |
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
|
6059 |
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
|
6060 |
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
|
6061 |
except KeyError: |
1736
727dda1e7968
11522 pkg should require publisher prefix to match repository information
Shawn Walker <srw@sun.com>
parents:
1729
diff
changeset
|
6062 |
orig_cwd = None |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
6063 |
|
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
6064 |
try: |
934
f36f3c3d9666
7277 client should use --help and -? options to show usage information
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
930
diff
changeset
|
6065 |
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
|
6066 |
["debug=", "help", "runid="]) |
52
d7c452ef7ae1
Sanitize getopt exception handling
Danek Duvall <danek.duvall@sun.com>
parents:
50
diff
changeset
|
6067 |
except getopt.GetoptError, e: |
301
35f03c7a3adc
Rework status,list,info subcommands -> list,contents,info
Dan Price <dp@eng.sun.com>
parents:
296
diff
changeset
|
6068 |
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
|
6069 |
|
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
6070 |
runid = None |
934
f36f3c3d9666
7277 client should use --help and -? options to show usage information
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
930
diff
changeset
|
6071 |
show_usage = False |
584
22bc748edce6
577 need service action for smf(5) manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
583
diff
changeset
|
6072 |
for opt, arg in opts: |
22bc748edce6
577 need service action for smf(5) manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
583
diff
changeset
|
6073 |
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
|
6074 |
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
|
6075 |
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
|
6076 |
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
|
6077 |
else: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
6078 |
try: |
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
6079 |
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
|
6080 |
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
|
6081 |
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
|
6082 |
"name=value, not %(arg)s") % { |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2215
diff
changeset
|
6083 |
"opt": opt, "arg": arg }) |
584
22bc748edce6
577 need service action for smf(5) manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
583
diff
changeset
|
6084 |
DebugValues.set_value(key, value) |
22bc748edce6
577 need service action for smf(5) manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
583
diff
changeset
|
6085 |
elif opt == "-R": |
22bc748edce6
577 need service action for smf(5) manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
583
diff
changeset
|
6086 |
mydir = arg |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6087 |
elif opt == "--runid": |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6088 |
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
|
6089 |
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
|
6090 |
show_usage = True |
584
22bc748edce6
577 need service action for smf(5) manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
583
diff
changeset
|
6091 |
|
934
f36f3c3d9666
7277 client should use --help and -? options to show usage information
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
930
diff
changeset
|
6092 |
subcommand = None |
f36f3c3d9666
7277 client should use --help and -? options to show usage information
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
930
diff
changeset
|
6093 |
if pargs: |
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1066
diff
changeset
|
6094 |
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
|
6095 |
# '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
|
6096 |
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
|
6097 |
if subcommand == "help": |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6098 |
if pargs: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6099 |
sub = pargs.pop(0) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6100 |
if sub in cmds and \ |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6101 |
sub not in ["help", "-?", "--help"]: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6102 |
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
|
6103 |
elif sub not in ["help", "-?", "--help"]: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6104 |
usage(_("unknown subcommand '%s'") % |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6105 |
sub, full=True) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6106 |
else: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6107 |
usage(retcode=0, full=True) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6108 |
else: |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6109 |
usage(retcode=0, full=True) |
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6110 |
|
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6111 |
# 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
|
6112 |
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
|
6113 |
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
|
6114 |
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
|
6115 |
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
|
6116 |
if show_usage: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
6117 |
usage(retcode=0, full=True) |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6118 |
if not subcommand: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
6119 |
usage(_("no subcommand specified")) |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
6120 |
if runid is not None: |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6121 |
try: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6122 |
runid = int(runid) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6123 |
except: |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6124 |
usage(_("runid must be an integer")) |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
6125 |
global_settings.client_runid = runid |
0
f08899079fb4
implemented open, add (file case), close for transactions
"Stephen Hahn <sch@sun.com>"
parents:
diff
changeset
|
6126 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
6127 |
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
|
6128 |
if opt in pargs: |
2047
5e1340de1aba
12723 pkg per-subcommand usage/help
Tim Foster <tim.s.foster@oracle.com>
parents:
2034
diff
changeset
|
6129 |
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
|
6130 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
6131 |
# 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
|
6132 |
# 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
|
6133 |
# 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
|
6134 |
# 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
|
6135 |
# code the value here, at least for now. |
49cd5492effc
9996 Exception thrown after cancel of install
johansen <johansen@sun.com>
parents:
1191
diff
changeset
|
6136 |
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
|
6137 |
|
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6138 |
cmds_no_image = { |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6139 |
"version" : print_version, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6140 |
"image-create" : image_create, |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6141 |
} |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6142 |
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
|
6143 |
if func: |
584
22bc748edce6
577 need service action for smf(5) manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
583
diff
changeset
|
6144 |
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
|
6145 |
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
|
6146 |
subcommand, cmd=subcommand) |
221
e1dbb27a23b5
52 catalog can leave inventory behind, making pkg(1) blind
Stephen Hahn <sch@Sun.COM>
parents:
219
diff
changeset
|
6147 |
try: |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
6148 |
pkg_timer.record("client startup", logger=logger) |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6149 |
ret = func(pargs) |
221
e1dbb27a23b5
52 catalog can leave inventory behind, making pkg(1) blind
Stephen Hahn <sch@Sun.COM>
parents:
219
diff
changeset
|
6150 |
except getopt.GetoptError, e: |
1266
21bd4bf5295d
9690 cli usage errors cause unexpectedly verbose usage message
Shawn Walker <srw@sun.com>
parents:
1254
diff
changeset
|
6151 |
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
|
6152 |
return ret |
50 | 6153 |
|
561
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
556
diff
changeset
|
6154 |
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
|
6155 |
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
|
6156 |
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
|
6157 |
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
|
6158 |
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
|
6159 |
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
|
6160 |
# 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
|
6161 |
# 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
|
6162 |
# environment. |
561
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
556
diff
changeset
|
6163 |
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
|
6164 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
6165 |
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
|
6166 |
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
|
6167 |
"$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
|
6168 |
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
|
6169 |
|
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
6170 |
# Get ImageInterface and image object. |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2690
diff
changeset
|
6171 |
api_inst = __api_alloc(mydir, provided_image_dir, pkg_image_used) |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
6172 |
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
|
6173 |
return EXIT_OOPS |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6174 |
_api_inst = api_inst |
2158
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
6175 |
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
|
6176 |
|
5a688b5b92a3
15864 inferring image location from current working directory can be harmful
Shawn Walker <shawn.walker@oracle.com>
parents:
2154
diff
changeset
|
6177 |
# 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
|
6178 |
func = cmds[subcommand][0] |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6179 |
pargs_limit = None |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6180 |
if len(cmds[subcommand]) > 1: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6181 |
pargs_limit = cmds[subcommand][1] |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6182 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6183 |
pkg_timer.record("client startup", logger=logger) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6184 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6185 |
# Get the available options for the requested operation to create the |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6186 |
# getopt parsing strings. |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6187 |
valid_opts = options.get_pkg_opts(subcommand, add_table=cmd_opts) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6188 |
if not valid_opts: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6189 |
# if there are no options for an op, it has its own processing |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6190 |
try: |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6191 |
return func(api_inst, pargs) |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6192 |
except getopt.GetoptError, e: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6193 |
usage(_("illegal option -- %s") % e.opt, |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6194 |
cmd=subcommand) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6195 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6196 |
try: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6197 |
# Parse CLI arguments into dictionary containing corresponding |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6198 |
# options and values. |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6199 |
opt_dict, pargs = misc.opts_parse(subcommand, pargs, valid_opts, |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6200 |
opts_mapping, usage) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6201 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6202 |
if pargs_limit is not None and len(pargs) > pargs_limit: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6203 |
usage(_("illegal argument -- %s") % pargs[pargs_limit], |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6204 |
cmd=subcommand) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6205 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6206 |
opts = options.opts_assemble(subcommand, api_inst, opt_dict, |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6207 |
add_table=cmd_opts, cwd=orig_cwd) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6208 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6209 |
except api_errors.InvalidOptionError, e: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6210 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6211 |
# We can't use the string representation of the exception since |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6212 |
# it references internal option names. We substitute the CLI |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6213 |
# options and create a new exception to make sure the messages |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6214 |
# are correct. |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6215 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6216 |
# Convert the internal options to CLI options. We make sure that |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6217 |
# when there is a short and a long version for the same option |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6218 |
# we print both to avoid confusion. |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6219 |
def get_cli_opt(option): |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6220 |
try: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6221 |
s, l = opts_mapping[option] |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6222 |
if l and not s: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6223 |
return "--%s" % l |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6224 |
elif s and not l: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6225 |
return "-%s" % s |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6226 |
else: |
2910
2bb9f6ffdff9
15654935 pkg facet/variant should also display those implicitly set
Shawn Walker <shawn.walker@oracle.com>
parents:
2908
diff
changeset
|
6227 |
return "-%s/--%s" % (s, l) |
2875
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6228 |
except KeyError: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6229 |
# ignore if we can't find a match |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6230 |
# (happens for repeated arguments) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6231 |
return option |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6232 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6233 |
cli_opts = [] |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6234 |
opt_def = [] |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6235 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6236 |
for o in e.options: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6237 |
cli_opts.append(get_cli_opt(o)) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6238 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6239 |
# collect the default value (see comment below) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6240 |
opt_def.append(options.get_pkg_opts_defaults(subcommand, |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6241 |
o, add_table=cmd_opts)) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6242 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6243 |
# Prepare for headache: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6244 |
# If we have an option 'b' which is set to True by default it |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6245 |
# will be toggled to False if the users specifies the according |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6246 |
# option on the CLI. |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6247 |
# If we now have an option 'a' which requires option 'b' to be |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6248 |
# set, we can't say "'a' requires 'b'" because the user can only |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6249 |
# specify 'not b'. So the correct message would be: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6250 |
# "'a' is incompatible with 'not b'". |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6251 |
# We can get there by just changing the type of the exception |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6252 |
# for all cases where the default value of one of the options is |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6253 |
# True. |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6254 |
if e.err_type == api_errors.InvalidOptionError.REQUIRED: |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6255 |
if len(opt_def) == 2 and (opt_def[0] or opt_def[1]): |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6256 |
e.err_type = \ |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6257 |
api_errors.InvalidOptionError.INCOMPAT |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6258 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6259 |
# This new exception will have the CLI options, so can be passed |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6260 |
# directly to usage(). |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6261 |
new_e = api_errors.InvalidOptionError(err_type=e.err_type, |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6262 |
options=cli_opts, msg=e.msg) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6263 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6264 |
usage(str(new_e), cmd=subcommand) |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6265 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6266 |
# Reset the progress tracker here, because we may have |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6267 |
# to switch to a different tracker due to the options parse. |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6268 |
_api_inst.progresstracker = get_tracker() |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6269 |
|
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6270 |
return func(op=subcommand, api_inst=api_inst, |
09e276ba70c6
15804991 option mangling and verification should be part of the API, not the CLI client
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
6271 |
pargs=pargs, **opts) |
192
0c6f1066777b
58 getopt handling needs cleanup
Dan Price <dp@eng.sun.com>
parents:
177
diff
changeset
|
6272 |
|
0c6f1066777b
58 getopt handling needs cleanup
Dan Price <dp@eng.sun.com>
parents:
177
diff
changeset
|
6273 |
# |
0c6f1066777b
58 getopt handling needs cleanup
Dan Price <dp@eng.sun.com>
parents:
177
diff
changeset
|
6274 |
# 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
|
6275 |
# 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
|
6276 |
# |
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
|
6277 |
def handle_errors(func, non_wrap_print=True, *args, **kwargs): |
2569
1f9f50d0cde3
18977 pkg stack traces should tell customers to report issues to service
Shawn Walker <shawn.walker@oracle.com>
parents:
2550
diff
changeset
|
6278 |
traceback_str = misc.get_traceback_message() |
221
e1dbb27a23b5
52 catalog can leave inventory behind, making pkg(1) blind
Stephen Hahn <sch@Sun.COM>
parents:
219
diff
changeset
|
6279 |
try: |
1035
0e243b7eb121
2297 top level error handler for out of memory conditions needed
Danek Duvall <danek.duvall@sun.com>
parents:
1023
diff
changeset
|
6280 |
# 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
|
6281 |
# 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
|
6282 |
# 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
|
6283 |
# 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
|
6284 |
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
|
6285 |
__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
|
6286 |
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
|
6287 |
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
|
6288 |
__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
|
6289 |
raise |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6290 |
if _api_inst: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6291 |
_api_inst.abort( |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6292 |
result=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
|
6293 |
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
|
6294 |
__ret = EXIT_OOPS |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
6295 |
except SystemExit, __e: |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6296 |
if _api_inst: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6297 |
_api_inst.abort(result=RESULT_FAILED_UNKNOWN) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
6298 |
raise __e |
384
9d4746e5dd3e
115 pkg needs to not have a cow on a SIGPIPE
Shawn Walker <swalker@opensolaris.org>
parents:
362
diff
changeset
|
6299 |
except (PipeError, KeyboardInterrupt): |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6300 |
if _api_inst: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6301 |
_api_inst.abort(result=RESULT_CANCELED) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
6302 |
# 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
|
6303 |
# 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
|
6304 |
__ret = EXIT_OOPS |
2339
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6305 |
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
|
6306 |
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
|
6307 |
str(__e)) |
aa5954c06b9d
16148 need linked image support for zones, phase 1
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2336
diff
changeset
|
6308 |
__ret = __e.lix_exitrv |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
6309 |
except api_errors.CertificateError, __e: |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6310 |
if _api_inst: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6311 |
_api_inst.abort(result=RESULT_FAILED_CONFIGURATION) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
6312 |
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
|
6313 |
__ret = EXIT_OOPS |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
6314 |
except api_errors.PublisherError, __e: |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6315 |
if _api_inst: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6316 |
_api_inst.abort(result=RESULT_FAILED_BAD_REQUEST) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
917
diff
changeset
|
6317 |
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
|
6318 |
__ret = EXIT_OOPS |
1710
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
6319 |
except api_errors.ImageLockedError, __e: |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6320 |
if _api_inst: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6321 |
_api_inst.abort(result=RESULT_FAILED_LOCKED) |
1710
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
6322 |
error(__e) |
139720e2e756
1668 image locking needed to prevent race conditions
Shawn Walker <srw@sun.com>
parents:
1709
diff
changeset
|
6323 |
__ret = EXIT_LOCKED |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1174
diff
changeset
|
6324 |
except api_errors.TransportError, __e: |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6325 |
if _api_inst: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6326 |
_api_inst.abort(result=RESULT_FAILED_TRANSPORT) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
6327 |
logger.error(_("\nErrors were encountered while attempting " |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
6328 |
"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
|
6329 |
"operation.")) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
6330 |
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
|
6331 |
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
|
6332 |
__ret = EXIT_OOPS |
1658
49b8cc06eecb
13360 client can traceback if corrupt catalogs exist
Shawn Walker <srw@sun.com>
parents:
1639
diff
changeset
|
6333 |
except api_errors.InvalidCatalogFile, __e: |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6334 |
if _api_inst: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6335 |
_api_inst.abort(result=RESULT_FAILED_STORAGE) |
1658
49b8cc06eecb
13360 client can traceback if corrupt catalogs exist
Shawn Walker <srw@sun.com>
parents:
1639
diff
changeset
|
6336 |
logger.error(_(""" |
49b8cc06eecb
13360 client can traceback if corrupt catalogs exist
Shawn Walker <srw@sun.com>
parents:
1639
diff
changeset
|
6337 |
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
|
6338 |
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
|
6339 |
__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
|
6340 |
except api_errors.InvalidDepotResponseException, __e: |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6341 |
if _api_inst: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6342 |
_api_inst.abort(result=RESULT_FAILED_TRANSPORT) |
1895
0a260cc2a689
15762 client support for filesystem-based repository access
Shawn Walker <shawn.walker@oracle.com>
parents:
1889
diff
changeset
|
6343 |
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
|
6344 |
"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
|
6345 |
"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
|
6346 |
"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
|
6347 |
"network configuration and repository's location.")) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1389
diff
changeset
|
6348 |
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
|
6349 |
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
|
6350 |
__ret = EXIT_OOPS |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6351 |
except api_errors.HistoryLoadException, __e: |
569
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
6352 |
# 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
|
6353 |
# information about the current operation(s) in progress. |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6354 |
if _api_inst: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6355 |
_api_inst.clear_history() |
569
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
6356 |
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
|
6357 |
"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
|
6358 |
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
|
6359 |
__ret = EXIT_OOPS |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6360 |
except api_errors.HistoryStoreException, __e: |
569
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
6361 |
# 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
|
6362 |
# information about the current operation(s) in progress. |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6363 |
if _api_inst: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6364 |
_api_inst.clear_history() |
569
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
6365 |
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
|
6366 |
"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
|
6367 |
"history.")) |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
6368 |
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
|
6369 |
__ret = EXIT_OOPS |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6370 |
except api_errors.HistoryPurgeException, __e: |
569
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
6371 |
# 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
|
6372 |
# information about the current operation(s) in progress. |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6373 |
if _api_inst: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6374 |
_api_inst.clear_history() |
569
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
6375 |
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
|
6376 |
"client history.")) |
48f7e9d2b1ac
3715 permission or read-only filesystem errors cause history traceback
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
565
diff
changeset
|
6377 |
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
|
6378 |
__ret = EXIT_OOPS |
652
daa3a6212b76
4011 client.py would traceback on a api VersionException
Brock Pytlik <bpytlik@sun.com>
parents:
648
diff
changeset
|
6379 |
except api_errors.VersionException, __e: |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6380 |
if _api_inst: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6381 |
_api_inst.abort(result=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
|
6382 |
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
|
6383 |
" 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
|
6384 |
"%(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
|
6385 |
{'client': __e.received_version, |
daa3a6212b76
4011 client.py would traceback on a api VersionException
Brock Pytlik <bpytlik@sun.com>
parents:
648
diff
changeset
|
6386 |
'api': __e.expected_version |
daa3a6212b76
4011 client.py would traceback on a api VersionException
Brock Pytlik <bpytlik@sun.com>
parents:
648
diff
changeset
|
6387 |
}) |
1505
cc598d70bbbe
4425 pkg install should deal w/ complex dependency changes in one install
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1504
diff
changeset
|
6388 |
__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
|
6389 |
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
|
6390 |
__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
|
6391 |
except api_errors.WrapIndexingException, __e: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
6392 |
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
|
6393 |
raise __e.wrapped |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
6394 |
__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
|
6395 |
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
|
6396 |
if __ret == 99: |
2826
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
6397 |
s += _("\n%(err)s%(stacktrace)s") % \ |
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2823
diff
changeset
|
6398 |
{"err": __e, "stacktrace": traceback_str} |
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
|
6399 |
|
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
6400 |
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
|
6401 |
"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
|
6402 |
error(s) |
1335
3dde2385d05c
516 Clean up traceback for installs to read-only filesystems
John Sonnenschein <John.Sonnenschein@Sun.COM>
parents:
1328
diff
changeset
|
6403 |
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
|
6404 |
__ret = EXIT_OOPS |
221
e1dbb27a23b5
52 catalog can leave inventory behind, making pkg(1) blind
Stephen Hahn <sch@Sun.COM>
parents:
219
diff
changeset
|
6405 |
except: |
2524
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6406 |
if _api_inst: |
0c32a79b1684
17252 pkg.client.api should provide history management interface
Shawn Walker <shawn.walker@oracle.com>
parents:
2522
diff
changeset
|
6407 |
_api_inst.abort(result=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
|
6408 |
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
|
6409 |
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
|
6410 |
error(traceback_str) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
6411 |
__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
|
6412 |
return __ret |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
6413 |
|
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
|
6414 |
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
|
6415 |
misc.setlocale(locale.LC_ALL, "", error) |
2728
69903f3b722b
7166082 pkg command does not handle Japanese character encoding on Solaris 11
Abhinandan Ekande <abhinandan.ekande@oracle.com>
parents:
2719
diff
changeset
|
6416 |
gettext.install("pkg", "/usr/share/locale", |
69903f3b722b
7166082 pkg command does not handle Japanese character encoding on Solaris 11
Abhinandan Ekande <abhinandan.ekande@oracle.com>
parents:
2719
diff
changeset
|
6417 |
codeset=locale.getpreferredencoding()) |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
6418 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
6419 |
# 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
|
6420 |
import warnings |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
6421 |
warnings.simplefilter('error') |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1710
diff
changeset
|
6422 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
6423 |
__retval = handle_errors(main_func) |
2690
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
6424 |
if DebugValues["timings"]: |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
6425 |
def __display_timings(): |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
6426 |
msg(str(pkg_timer)) |
11a8cae074e0
7140224 package downloaded messages displayed twice for each zone
Edward Pilatowicz <edward.pilatowicz@oracle.com>
parents:
2681
diff
changeset
|
6427 |
handle_errors(__display_timings) |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
6428 |
try: |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
6429 |
logging.shutdown() |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
6430 |
except IOError: |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
6431 |
# Ignore python's spurious pipe problems. |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
6432 |
pass |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1351
diff
changeset
|
6433 |
sys.exit(__retval) |