~ubuntu-branches/ubuntu/trusty/python-seamicroclient/trusty

« back to all changes in this revision

Viewing changes to seamicroclient/v2/system.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2014-04-09 13:37:27 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140409133727-z546hv7p8fv794ln
Tags: 0.2.0-0ubuntu1
* New upstream release (LP: #1305220)
  - Remove use of auth_token for REST API. Fixes concurrent access by
    using user/password each time instead of auth_token (LP: #1302828)
* debian/watch: Updated to include correct URL link.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
2
#    not use this file except in compliance with the License. You may obtain
 
3
#    a copy of the License at
 
4
#
 
5
#         http://www.apache.org/licenses/LICENSE-2.0
 
6
#
 
7
#    Unless required by applicable law or agreed to in writing, software
 
8
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
9
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
10
#    License for the specific language governing permissions and limitations
 
11
#    under the License.
 
12
 
 
13
"""
 
14
System interface.
 
15
"""
 
16
 
 
17
from seamicroclient import base
 
18
 
 
19
 
 
20
class System(base.Resource):
 
21
    HUMAN_ID = True
 
22
 
 
23
    def switchover(self, mxcard=None, **kwargs):
 
24
        return self.manager.switchover(self, mxcard, **kwargs)
 
25
 
 
26
    def writemem(self, **kwargs):
 
27
        return self.manager.writemem(self, **kwargs)
 
28
 
 
29
 
 
30
class SystemManager(base.ManagerWithFind):
 
31
    resource_class = System
 
32
 
 
33
    def list(self, filters=None):
 
34
        """
 
35
        Get a list of system properties.
 
36
 
 
37
        :rtype: list of :class:`System`
 
38
        """
 
39
        return self._list("/chassis/systems", filters=filters)
 
40
 
 
41
    def switchover(self, system, mxcard=None, **kwargs):
 
42
        """
 
43
        Switchover system to different mxcard
 
44
        """
 
45
        url = "/chassis/system/switchover"
 
46
        body = {}
 
47
        if mxcard is not None:
 
48
            body = {'newActive': mxcard}
 
49
        return self.api.client.put(url, body=body)
 
50
 
 
51
    def writemem(self, system, **kwargs):
 
52
        """
 
53
        Write current system config to flash memory
 
54
        This will persist even after reboot of chassis
 
55
        """
 
56
        url = "/chassis/system/writeMem"
 
57
        return self.api.client.put(url, body={})
 
58
 
 
59
    def reload(self, system, **kwargs):
 
60
        """
 
61
        Reload the chassis and start the boot image
 
62
        """
 
63
        url = "/chassis/system/reload"
 
64
        return self.api.client.put(url, body={})