Пример #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')
Пример #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")
Пример #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')
Пример #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')
Пример #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')
Пример #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]
Пример #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]
Пример #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')
Пример #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]
Пример #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")
Пример #11
0
 def remove_image(self, image):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DeregisterImage', ImageId=image)
     validate_rsp(rsp)
Пример #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]
Пример #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')
Пример #14
0
 def remove_snapshot(self, snapshot):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='DeleteSnapshot',
                               SnapshotId=snapshot)
     validate_rsp(rsp)
Пример #15
0
 def remove_volume(self, volume):
     rsp = self.request.invoke(Action='DeleteVolume', callback=XmlParser.parser,
                               VolumeId=volume)
     validate_rsp(rsp, 'DeleteVolume')
Пример #16
0
 def list_instances(self):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeInstances')
     validate_rsp(rsp, 'DescribeInstances')
     return find_all(rsp, 'instanceId')
Пример #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")
Пример #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')
Пример #19
0
 def remove_volume(self, volume):
     rsp = self.request.invoke(Action='DeleteVolume',
                               callback=XmlParser.parser,
                               VolumeId=volume)
     validate_rsp(rsp, 'DeleteVolume')
Пример #20
0
 def list_volume(self):
     rsp = self.request.invoke(Action='DescribeVolumes',
                               callback=XmlParser.parser)
     validate_rsp(rsp, 'DescribeVolumes')
     return find_all(rsp, 'volumeId')
Пример #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')
Пример #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')
Пример #23
0
 def list_zones(self):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeAvailabilityZones')
     validate_rsp(rsp, 'DescribeAvailabilityZones')
     return find_all(rsp, 'zoneName')
Пример #24
0
 def list_regions(self):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DescribeRegions')
     validate_rsp(rsp, 'DescribeRegions')
     return find_all(rsp, 'regionName')
Пример #25
0
 def list_volume(self):
     rsp = self.request.invoke(Action='DescribeVolumes', callback=XmlParser.parser)
     validate_rsp(rsp, 'DescribeVolumes')
     return find_all(rsp, 'volumeId')
Пример #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")
Пример #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')
Пример #28
0
 def list_regions(self):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='DescribeRegions')
     validate_rsp(rsp, 'DescribeRegions')
     return find_all(rsp, 'regionName')
Пример #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')
Пример #30
0
 def remove_security_group(self, group):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DeleteSecurityGroup', GroupId=group)
     validate_rsp(rsp, 'DeleteSecurityGroup')
Пример #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')
Пример #32
0
 def remove_image(self, image):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='DeregisterImage',
                               ImageId=image)
     validate_rsp(rsp)
Пример #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")
Пример #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')
Пример #35
0
 def remove_snapshot(self, snapshot):
     rsp = self.request.invoke(callback=XmlParser.parser, Action='DeleteSnapshot', SnapshotId=snapshot)
     validate_rsp(rsp)
Пример #36
0
 def list_instances(self):
     rsp = self.request.invoke(callback=XmlParser.parser, Action="DescribeInstances")
     validate_rsp(rsp, "DescribeInstances")
     return find_all(rsp, "instanceId")
Пример #37
0
 def list_zones(self):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='DescribeAvailabilityZones')
     validate_rsp(rsp, 'DescribeAvailabilityZones')
     return find_all(rsp, 'zoneName')
Пример #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')
Пример #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")
Пример #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')
Пример #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")
Пример #42
0
 def remove_security_group(self, group):
     rsp = self.request.invoke(callback=XmlParser.parser,
                               Action='DeleteSecurityGroup',
                               GroupId=group)
     validate_rsp(rsp, 'DeleteSecurityGroup')