tiktalik-cli 1.7__tar.gz → 1.8.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of tiktalik-cli might be problematic. Click here for more details.

@@ -41,7 +41,7 @@ To get a help on a specific command, run:
41
41
 
42
42
  `$ tiktalik COMMAND --help`
43
43
 
44
- We also have [a tutorial](https://www.tiktalik.com/docs/cli-howto/) to quickly get
44
+ We also have [a tutorial](http://articles.tiktalik.com/content/help/using-tiktalik-command-line-utility/) to quickly get
45
45
  you started.
46
46
 
47
47
  ## License
@@ -2,7 +2,7 @@ from setuptools import setup
2
2
 
3
3
  setup(
4
4
  name="tiktalik-cli",
5
- version="1.7",
5
+ version="1.8.1",
6
6
  description="Tiktalik Computing command line interface",
7
7
  author="Techstorage sp. z o.o.",
8
8
  author_email="kontakt@tiktalik.com",
@@ -21,5 +21,5 @@ setup(
21
21
  ]
22
22
  },
23
23
 
24
- install_requires=["tiktalik>=1.4.2"]
24
+ install_requires=["tiktalik>=1.5"]
25
25
  )
@@ -41,15 +41,12 @@ class ListInstances(ComputingCommand):
41
41
  def execute(self):
42
42
  instances = Instance.list_all(self.conn, actions=self.args.actions,
43
43
  cost=self.args.cost, vpsimage=self.args.vpsimage)
44
- # instances = self.conn.list_instances(actions=self.args.actions, cost=self.args.cost, vpsimage=self.args.vpsimage)
45
- if not self.args.verbose:
46
- self._print_short(instances)
47
- else:
48
- map(util.print_instance, instances)
49
-
50
- def _print_short(self, instances):
51
44
  for instance in sorted(instances, key = lambda x: x.hostname):
52
- print "%s (%s) %s" % (instance.hostname, instance.uuid, "Running" if instance.running else "Not running")
45
+ if not self.args.verbose:
46
+ print "%s (%s) - %s" % (instance.hostname, instance.uuid, "Running" if instance.running else "Not running")
47
+ else:
48
+ util.print_instance(instance, verbose=bool(self.args.verbose))
49
+
53
50
 
54
51
 
55
52
  class CreateInstance(ComputingCommand):
@@ -62,8 +59,8 @@ class CreateInstance(ComputingCommand):
62
59
  p.add_argument("-n", dest="networks", metavar="NETWORK_NAME", action="append",
63
60
  help="Attach these networks to the new instance. Use the list-networks command to list available networks.")
64
61
  p.add_argument("-b", dest="batch_mode", action="store_true", help="Batch mode. Don't confirm the operation.")
65
- p.add_argument("-d", dest="disk_size_mb", action="store", type=int,
66
- help="For standard instances must set disk size in MB.")
62
+ p.add_argument("-d", dest="disk_size_gb", action="store", type=int,
63
+ help="For standard instances must set disk size in GB.")
67
64
 
68
65
  return "create-instance"
69
66
 
@@ -94,11 +91,11 @@ class CreateInstance(ComputingCommand):
94
91
  size = self._parse_instance_size(self.args.size)
95
92
 
96
93
  # For standard instances - must be set disk_size param
97
- disk_size_mb = None
94
+ disk_size_gb = None
98
95
  if size.endswith("s"):
99
- if not self.args.disk_size_mb:
96
+ if not self.args.disk_size_gb:
100
97
  raise CommandError("Disk size not set, see -d param.")
101
- disk_size_mb = self.args.disk_size_mb
98
+ disk_size_gb = self.args.disk_size_gb
102
99
 
103
100
  if not self.args.batch_mode:
104
101
  self.yesno(
@@ -107,7 +104,8 @@ class CreateInstance(ComputingCommand):
107
104
  "Is this OK?" % (self.args.image_uuid, size, self.args.hostname,
108
105
  ", ".join(self.args.networks)))
109
106
 
110
- response = self.conn.create_instance(self.args.hostname, size, self.args.image_uuid, networks, disk_size_mb=disk_size_mb)
107
+ response = self.conn.create_instance(self.args.hostname, size, \
108
+ self.args.image_uuid, networks, disk_size_gb=disk_size_gb)
111
109
 
112
110
  print "Instance", self.args.hostname, "is now being installed."
113
111
 
@@ -134,7 +132,7 @@ class CreateInstance(ComputingCommand):
134
132
  sz = None
135
133
 
136
134
  if sz is None:
137
- raise CommandError('Size must be 0.25, 0.5, integral value 1-15 or "cpuhog".')
135
+ raise CommandError('Instance size must be one of 0.25, 0.5, integral value 1-15, "1s", "2s", "4s" or "cpuhog".')
138
136
 
139
137
  return str(sz)
140
138
 
@@ -245,14 +243,17 @@ class BackupInstance(InstanceCommand):
245
243
  p = subparser.add_parser("backup", description="Backup an instance. Either name or UUID must be specified.",
246
244
  parents=[parent])
247
245
  InstanceCommand.add_common_arguments(p)
246
+ p.add_argument("--set_name", type=str, help="Set name of your backup", )
248
247
  return "backup"
249
248
 
250
249
  def execute(self):
251
250
  instance = self._instance_from_args()
252
251
  if instance.running:
253
252
  raise CommandError("Instance is running. Please stop it before starting backup.")
254
-
255
- instance.backup()
253
+ if self.args.set_name:
254
+ instance.backup(self.args.set_name)
255
+ else:
256
+ instance.backup()
256
257
  print "Instance %s (%s) is now being backed up" % (instance.hostname, instance.uuid)
257
258
 
258
259
 
@@ -304,3 +305,30 @@ class AddInterface(InstanceCommand):
304
305
  instance = self._instance_from_args()
305
306
  instance.add_interface(self.args.network_uuid, self.args.seq)
306
307
 
308
+
309
+ class RemoveInterface(InstanceCommand):
310
+ @classmethod
311
+ def add_parser(cls, parent, subparser):
312
+ p = subparser.add_parser("remove-interface",
313
+ description="Removes network interface from an instance.",
314
+ parents=[parent])
315
+ p.add_argument("seq_or_ip", help="Interface name (eg \"eth1\") or IP address assign to interface to be removed.")
316
+ InstanceCommand.add_common_arguments(p)
317
+
318
+ return "remove-interface"
319
+
320
+ def execute(self):
321
+ instance = self._instance_from_args()
322
+
323
+ seq_str = self.args.seq_or_ip.replace('eth', '')
324
+ iface_uuid = None
325
+ for iface in instance.interfaces:
326
+ if iface.ip == self.args.seq_or_ip or str(iface.seq) == seq_str:
327
+ iface_uuid = iface.uuid
328
+ break
329
+ if not iface_uuid:
330
+ raise CommandError("Cannot find interface by seq nor by IP address.")
331
+
332
+ instance.remove_interface(iface_uuid)
333
+
334
+
@@ -29,3 +29,15 @@ class ListNetworks(ComputingNetworkCommand):
29
29
  networks = self.conn.list_networks()
30
30
  for net in networks:
31
31
  print "%s %s %s %s, owned by %s" % (net.name, net.uuid, net.net, "public" if net.public else "private", net.owner)
32
+
33
+ class CreateNetwork(ComputingNetworkCommand):
34
+ @classmethod
35
+ def add_parser(cls, parent, subparser):
36
+ p = subparser.add_parser("create-network", description="Create a new network.", parents=[parent])
37
+ p.add_argument("name", help="Network name - as part of local domain.")
38
+
39
+ return "create-network"
40
+
41
+ def execute(self):
42
+ network = self.conn.create_network(self.args.name)
43
+ print "%s %s %s %s, owned by %s" % (network.name, network.uuid, network.net, "public" if network.public else "private", network.owner)
@@ -37,8 +37,7 @@ def print_instance(i, verbose=False):
37
37
 
38
38
  if verbose and i.block_devices:
39
39
  for b in i.block_devices:
40
- print " block device %d: %d MB (%.1f GB)" % \
41
- (b.seq, b.size, b.size / 1000.0) # div by 1000, not 1024
40
+ print " block device %d: %.1f GB" % (b.seq, b.size_gb)
42
41
 
43
42
  if not i.interfaces:
44
43
  print " no network interfaces"