Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 37 lines (30 sloc) 1.462 kb
e80d7bc @Kami Merge storage_api branch.
Kami authored
1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements. See the NOTICE file distributed with
3 # this work for additional information regarding copyright ownership.
4 # The ASF licenses this file to You under the Apache License, Version 2.0
5 # (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 from libcloud.compute.types import Provider
16 from libcloud.compute.providers import get_driver
17
18 EC2 = get_driver(Provider.EC2_US_EAST)
19 Slicehost = get_driver(Provider.SLICEHOST)
20 Rackspace = get_driver(Provider.RACKSPACE)
21
22 drivers = [ EC2('access key id', 'secret key'),
23 Slicehost('api key'),
24 Rackspace('username', 'api key') ]
25
26 nodes = [ driver.list_nodes() for driver in drivers ]
27
28 print nodes
29 # [ <Node: provider=Amazon, status=RUNNING, name=bob, ip=1.2.3.4.5>,
30 # <Node: provider=Slicehost, status=REBOOT, name=korine, ip=6.7.8.9.10>, ... ]
31
32 # grab the node named "test"
33 node = filter(lambda x: x.name == 'test', nodes)[0]
34
35 # reboot "test"
36 node.reboot()
Something went wrong with that request. Please try again.