~ubuntu-branches/ubuntu/raring/eucalyptus/raring

« back to all changes in this revision

Viewing changes to clc/eucadmin/eucadmin/modifystoragecontroller.py

  • Committer: Package Import Robot
  • Author(s): Brian Thomason
  • Date: 2011-11-29 13:17:52 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 185.
  • Revision ID: package-import@ubuntu.com-20111129131752-rq31al3ntutv2vvl
Tags: upstream-3.0.999beta1
ImportĀ upstreamĀ versionĀ 3.0.999beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2011, Eucalyptus Systems, Inc.
 
2
# All rights reserved.
 
3
#
 
4
# Redistribution and use of this software in source and binary forms, with or
 
5
# without modification, are permitted provided that the following conditions
 
6
# are met:
 
7
#
 
8
#   Redistributions of source code must retain the above
 
9
#   copyright notice, this list of conditions and the
 
10
#   following disclaimer.
 
11
#
 
12
#   Redistributions in binary form must reproduce the above
 
13
#   copyright notice, this list of conditions and the
 
14
#   following disclaimer in the documentation and/or other
 
15
#   materials provided with the distribution.
 
16
#
 
17
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
18
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
19
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
20
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 
21
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
22
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
23
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
24
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
25
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
26
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
27
# POSSIBILITY OF SUCH DAMAGE.
 
28
#
 
29
# Author: Mitch Garnaat mgarnaat@eucalyptus.com
 
30
 
 
31
from boto.roboto.awsqueryrequest import AWSQueryRequest
 
32
from boto.roboto.param import Param
 
33
import eucadmin
 
34
 
 
35
def encode_prop(param, dict, value):
 
36
    t = value.split('=')
 
37
    if len(t) != 2:
 
38
        print "Options must be of the form KEY=VALUE: %s" % value
 
39
        sys.exit(1)
 
40
    dict['Attribute'] = t[0]
 
41
    dict['Value'] = t[1]
 
42
 
 
43
class ModifyStorageControllerAttribute(AWSQueryRequest):
 
44
 
 
45
    ServicePath = '/services/Properties'
 
46
    ServiceClass = eucadmin.EucAdmin
 
47
    Description = 'Modify storage controller attribute'
 
48
 
 
49
    Params = [Param(name='property',
 
50
                    short_name='p',
 
51
                    long_name='property',
 
52
                    ptype='string',
 
53
                    optional=False,
 
54
                    encoder=encode_prop,
 
55
                    doc='Modify attribute (KEY=VALUE)'),
 
56
              Param(name='Partition',
 
57
                    short_name='P',
 
58
                    long_name='partition',
 
59
                    ptype='string',
 
60
                    optional=True,
 
61
                    doc='Partition for the cluster.')]
 
62
    Args = [Param(name='Name',
 
63
                  long_name='name',
 
64
                  ptype='string',
 
65
                  optional=False,
 
66
                  doc='The storage controller name')]
 
67
 
 
68
    def get_connection(self, **args):
 
69
        if self.connection is None:
 
70
            args['path'] = self.ServicePath
 
71
            self.connection = self.ServiceClass(**args)
 
72
        return self.connection
 
73
 
 
74
    def cli_formatter(self, data):
 
75
        print data
 
76
 
 
77
    def main(self, **args):
 
78
        return self.send(**args)
 
79
 
 
80
    def main_cli(self):
 
81
        eucadmin.print_version_if_necessary()
 
82
        self.do_cli()