Exemplo n.º 1
0
 def attach_volume(self, instance=None, volume=None, device=None, **kwargs):
     rsp = self.request.invoke(Action='AttachVolume',
                               callback=XmlParser.parser,
                               InstanceId=instance,
                               VolumeId=volume,
                               **kwargs)
     validate_rsp(rsp, 'AttachVolume')
Exemplo n.º 2
0
 def create_snapshot(self, disk=None, name=None, **kwargs):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='CreateSnapshot',
                               VolumeId=disk,
                               **kwargs)
     validate_rsp(rsp)
     return find_all(rsp, "snapshotId")
Exemplo n.º 3
0
 def create_security_group(self, name=None, description=None, **kwargs):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='CreateSecurityGroup',
                               GroupName=name,
                               GroupDescription=description)
     validate_rsp(rsp, 'CreateSecurityGroup')
     return find_all(rsp, 'groupId')
Exemplo n.º 4
0
 def list_images(self, image_type=1):
     data = {}
     if image_type == 1:
         data['Filter.1.Name'] = 'is-public'
         data['Filter.1.Value.1'] = 'false'
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeImages', **data)
     validate_rsp(rsp, 'DescribeImages')
     return find_all(rsp, 'imageId')
Exemplo n.º 5
0
 def list_images(self, image_type=1):
     data = {}
     if image_type == 1:
         data['Filter.1.Name'] = 'is-public'
         data['Filter.1.Value.1'] = 'false'
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='DescribeImages',
                               **data)
     validate_rsp(rsp, 'DescribeImages')
     return find_all(rsp, 'imageId')
Exemplo n.º 6
0
 def create_image(self,
                  from_snapshot=None,
                  from_instance=None,
                  name=None,
                  **kwargs):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='CreateImage',
                               InstanceId=from_instance,
                               Name=name)
     validate_rsp(rsp, 'CreateImage')
     return find_all(rsp, 'imageId')[0]
Exemplo n.º 7
0
 def create_volume(self, name=None, snapshot=None, size=0, **kwargs):
     rsp = None
     if snapshot is not None or len(snapshot) > 0:
         rsp = self.request.invoke(callback=XmlParser.parser, Action='CreateVolume',
                                   SnapshotId=snapshot,
                                   **kwargs)
     elif size > 0:
         rsp = self.request.invoke(callback=XmlParser.parser, Action='CreateVolume', Size=size,
                                   **kwargs)
     else:
         raise RequestError(400, 'Invalid Request')
     validate_rsp(rsp, 'CreateVolume')
     return find_all(rsp, 'volumeId')[0]
Exemplo n.º 8
0
 def launch(self, image=None, flavor=None, hostname=None, bandwidth=None, **kwargs):
     """
     :param image: image id
     :param flavor: InstanceType
     :param hostname: host name,not valid
     :param bandwidth: not valid
     :param kwargs: MaxCount,MinCount,KeyName
     :return:
     """
     rsp = self.request.invoke(callback=XmlParser.parser, Action='RunInstances', ImageId=image,
                               MaxCount=1,
                               MinCount=1, InstanceType=flavor, **kwargs)
     validate_rsp(rsp, 'RunInstances')
     return find_all(rsp, 'instanceId')
Exemplo n.º 9
0
 def create_volume(self, name=None, snapshot=None, size=0, **kwargs):
     rsp = None
     if snapshot is not None or len(snapshot) > 0:
         rsp = self.request.invoke(callback=XmlParser.parser,
                                   Action='CreateVolume',
                                   SnapshotId=snapshot,
                                   **kwargs)
     elif size > 0:
         rsp = self.request.invoke(callback=XmlParser.parser,
                                   Action='CreateVolume',
                                   Size=size,
                                   **kwargs)
     else:
         raise RequestError(400, 'Invalid Request')
     validate_rsp(rsp, 'CreateVolume')
     return find_all(rsp, 'volumeId')[0]
Exemplo n.º 10
0
 def launch(self, image=None, flavor=None, hostname=None, bandwidth=None, **kwargs):
     """
     :param image: image id
     :param flavor: InstanceType
     :param hostname: host name,not valid
     :param bandwidth: not valid
     :param kwargs: MaxCount,MinCount,KeyName
     :return:
     """
     rsp = self.request.invoke(
         callback=XmlParser.parser,
         Action="RunInstances",
         ImageId=image,
         MaxCount=1,
         MinCount=1,
         InstanceType=flavor,
         **kwargs
     )
     validate_rsp(rsp, "RunInstances")
     return find_all(rsp, "instanceId")
Exemplo n.º 11
0
 def remove_image(self, image):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DeregisterImage', ImageId=image)
     validate_rsp(rsp)
Exemplo n.º 12
0
 def create_image(self, from_snapshot=None, from_instance=None, name=None, **kwargs):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='CreateImage',
                               InstanceId=from_instance, Name=name)
     validate_rsp(rsp, 'CreateImage')
     return find_all(rsp, 'imageId')[0]
Exemplo n.º 13
0
 def query_image(self, name=None, **kwargs):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeImages')
     validate_rsp(rsp, 'DescribeImages')
     return find_all(rsp, 'imageName')
Exemplo n.º 14
0
 def remove_snapshot(self, snapshot):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='DeleteSnapshot',
                               SnapshotId=snapshot)
     validate_rsp(rsp)
Exemplo n.º 15
0
 def remove_volume(self, volume):
     rsp = self.request.invoke(Action='DeleteVolume', callback=XmlParser.parser,
                               VolumeId=volume)
     validate_rsp(rsp, 'DeleteVolume')
Exemplo n.º 16
0
 def list_instances(self):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeInstances')
     validate_rsp(rsp, 'DescribeInstances')
     return find_all(rsp, 'instanceId')
Exemplo n.º 17
0
 def list_snapshot(self, instance=None, disk=None, **kwargs):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='DescribeSnapshots')
     validate_rsp(rsp)
     return find_all(rsp, "snapshotId")
Exemplo n.º 18
0
 def detach_volume(self, instance=None, volume=None):
     rsp = self.request.invoke(Action='DetachVolume',
                               callback=XmlParser.parser,
                               InstanceId=instance,
                               VolumeId=volume)
     validate_rsp(rsp, 'DetachVolume')
Exemplo n.º 19
0
 def remove_volume(self, volume):
     rsp = self.request.invoke(Action='DeleteVolume',
                               callback=XmlParser.parser,
                               VolumeId=volume)
     validate_rsp(rsp, 'DeleteVolume')
Exemplo n.º 20
0
 def list_volume(self):
     rsp = self.request.invoke(Action='DescribeVolumes',
                               callback=XmlParser.parser)
     validate_rsp(rsp, 'DescribeVolumes')
     return find_all(rsp, 'volumeId')
Exemplo n.º 21
0
 def create_security_group(self, name=None, description=None, **kwargs):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='CreateSecurityGroup',
                               GroupName=name,
                               GroupDescription=description)
     validate_rsp(rsp, 'CreateSecurityGroup')
     return find_all(rsp, 'groupId')
Exemplo n.º 22
0
 def attach_volume(self, instance=None, volume=None, device=None, **kwargs):
     rsp = self.request.invoke(Action='AttachVolume', callback=XmlParser.parser, InstanceId=instance,
                               VolumeId=volume, **kwargs)
     validate_rsp(rsp, 'AttachVolume')
Exemplo n.º 23
0
 def list_zones(self):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeAvailabilityZones')
     validate_rsp(rsp, 'DescribeAvailabilityZones')
     return find_all(rsp, 'zoneName')
Exemplo n.º 24
0
 def list_regions(self):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeRegions')
     validate_rsp(rsp, 'DescribeRegions')
     return find_all(rsp, 'regionName')
Exemplo n.º 25
0
 def list_volume(self):
     rsp = self.request.invoke(Action='DescribeVolumes', callback=XmlParser.parser)
     validate_rsp(rsp, 'DescribeVolumes')
     return find_all(rsp, 'volumeId')
Exemplo n.º 26
0
 def create_snapshot(self, disk=None, name=None, **kwargs):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='CreateSnapshot', VolumeId=disk, **kwargs)
     validate_rsp(rsp)
     return find_all(rsp, "snapshotId")
Exemplo n.º 27
0
 def stop(self, instance, force=False):
     data = {'InstanceId.1': instance}
     rsp = self.request.invoke(callback=XmlParser.parser, Action='TerminateInstances', **data)
     validate_rsp(rsp, 'TerminateInstances')
Exemplo n.º 28
0
 def list_regions(self):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='DescribeRegions')
     validate_rsp(rsp, 'DescribeRegions')
     return find_all(rsp, 'regionName')
Exemplo n.º 29
0
 def remove_instance(self, instance):
     data = {'InstanceId.1': instance}
     rsp = self.request.invoke(callback=XmlParser.parser, Action='StopInstances', **data)
     validate_rsp(rsp, 'StopInstances')
Exemplo n.º 30
0
 def remove_security_group(self, group):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DeleteSecurityGroup', GroupId=group)
     validate_rsp(rsp, 'DeleteSecurityGroup')
Exemplo n.º 31
0
 def query_image(self, name=None, **kwargs):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='DescribeImages')
     validate_rsp(rsp, 'DescribeImages')
     return find_all(rsp, 'imageName')
Exemplo n.º 32
0
 def remove_image(self, image):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='DeregisterImage',
                               ImageId=image)
     validate_rsp(rsp)
Exemplo n.º 33
0
 def list_snapshot(self, instance=None, disk=None, **kwargs):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeSnapshots')
     validate_rsp(rsp)
     return find_all(rsp, "snapshotId")
Exemplo n.º 34
0
 def detach_volume(self, instance=None, volume=None):
     rsp = self.request.invoke(Action='DetachVolume', callback=XmlParser.parser,
                               InstanceId=instance,
                               VolumeId=volume)
     validate_rsp(rsp, 'DetachVolume')
Exemplo n.º 35
0
 def remove_snapshot(self, snapshot):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DeleteSnapshot', SnapshotId=snapshot)
     validate_rsp(rsp)
Exemplo n.º 36
0
 def list_instances(self):
     rsp = self.request.invoke(callback=XmlParser.parser, Action="DescribeInstances")
     validate_rsp(rsp, "DescribeInstances")
     return find_all(rsp, "instanceId")
Exemplo n.º 37
0
 def list_zones(self):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='DescribeAvailabilityZones')
     validate_rsp(rsp, 'DescribeAvailabilityZones')
     return find_all(rsp, 'zoneName')
Exemplo n.º 38
0
 def list_security_group(self):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeSecurityGroups')
     validate_rsp(rsp, 'DescribeSecurityGroups')
     return find_all(rsp, 'groupId')
Exemplo n.º 39
0
 def stop(self, instance, force=False):
     data = {"InstanceId.1": instance}
     rsp = self.request.invoke(callback=XmlParser.parser, Action="TerminateInstances", **data)
     validate_rsp(rsp, "TerminateInstances")
Exemplo n.º 40
0
 def list_security_group(self):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='DescribeSecurityGroups')
     validate_rsp(rsp, 'DescribeSecurityGroups')
     return find_all(rsp, 'groupId')
Exemplo n.º 41
0
 def remove_instance(self, instance):
     data = {"InstanceId.1": instance}
     rsp = self.request.invoke(callback=XmlParser.parser, Action="StopInstances", **data)
     validate_rsp(rsp, "StopInstances")
Exemplo n.º 42
0
 def remove_security_group(self, group):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='DeleteSecurityGroup',
                               GroupId=group)
     validate_rsp(rsp, 'DeleteSecurityGroup')