Example #1
0
    def make_story_xml(self,
                       name=None,
                       description=None,
                       story_type=None,
                       owned_by=None,
                       requested_by=None,
                       estimate=None,
                       current_state=None,
                       labels=None):
        story = XMLBuilder('story')
        if name is not None:
            story.name(name)
        if description is not None:
            story.description(description)
        if requested_by is not None:
            story.requested_by(requested_by)
        if owned_by is not None:
            story.owned_by(owned_by)
        if story_type is not None:
            story.story_type(story_type)
        if estimate is not None:
            story.estimate(str(estimate), type='integer')
        if current_state is not None:
            story.current_state(current_state)
        if labels is not None:
            label_string = ','
            if labels:
                label_string = ','.join(labels)
            story.labels(label_string)

        return str(story)
Example #2
0
 def build_snapshot_xml(self, name=None, description=None):
     """
     :rtype : String
     :type name: String
     :type description: String
     """
     xml_builder = XMLBuilder('domainsnapshot')
     if not (name is None):
         xml_builder.name(name)
     if not (description is None):
         xml_builder.description(description)
     return str(xml_builder)
Example #3
0
 def build_snapshot_xml(self, name=None, description=None):
     """
     :rtype : String
     :type name: String
     :type description: String
     """
     xml_builder = XMLBuilder('domainsnapshot')
     if not (name is None):
         xml_builder.name(name)
     if not (description is None):
         xml_builder.description(description)
     return str(xml_builder)
Example #4
0
    def create_snapshot(self, domain, snapshot_name, \
                        snapshot_description):
        """Create VM snapshot
           connection: object with a connection to the Hypervisor
           domain: VM name
           snapshot_name
           snapshot_description
        """
        try:
            libvirt_domain = self.libvirt_connection.lookupByName(domain)
            xml_base = XMLBuilder('domainsnapshot')
            xml_base.name(snapshot_name)
            xml_base.description(snapshot_description)
            xml = str(xml_base)
            libvirt_domain.snapshotCreateXML(xml)
        except:
            print 'Unable to create snapshot'
            sys.exit(1)

        print 'Snapshot has been created successfully.'
    def build_snapshot_xml(self, name=None, description=None, node=None,
                           disk_only=False, external=False, external_dir=None):
        """Generate snapshot XML

        :rtype : String
        :type name: String
        :type description: String
        """
        xml_builder = XMLBuilder('domainsnapshot')
        if name is not None:
            xml_builder.name(name)
        if description is not None:
            xml_builder.description(description)
        if external:
            domain = self.driver.conn.lookupByUUIDString(node.uuid)
            # Add memory file for active machines
            if domain.isActive() and not disk_only:
                memory_file = '{0}/snapshot-memory-{1}_{2}.{3}'.format(
                    external_dir,
                    node.environment.name,
                    node.name,
                    name)
                file_count = 0
                tmp_memory_file = memory_file
                while os.path.exists(tmp_memory_file):
                    tmp_memory_file = memory_file + '-' + str(file_count)
                    file_count += 1
                xml_builder.memory(
                    file=tmp_memory_file,
                    snapshot='external')
            else:
                xml_builder.memory(snapshot='no')
            for disk in node.disk_devices:
                if disk.device == 'disk':
                    with xml_builder.disks:
                        xml_builder.disk(name=disk.target_dev,
                                         file=disk.volume.get_path(),
                                         snapshot='external')
        return str(xml_builder)
Example #6
0
    def make_story_xml(self, name=None, description=None, story_type=None,
                       owned_by=None, requested_by=None, estimate=None, current_state=None, labels=None):
        story = XMLBuilder('story')
        if name is not None:
            story.name(name)
        if description is not None:
            story.description(description)
        if requested_by is not None:
            story.requested_by(requested_by)
        if owned_by is not None:
            story.owned_by(owned_by)
        if story_type is not None:
            story.story_type(story_type)
        if estimate is not None:
            story.estimate(str(estimate), type='integer')
        if current_state is not None:
            story.current_state(current_state)
        if labels is not None:
            label_string = ','
            if labels:
                label_string = ','.join(labels)
            story.labels(label_string)

        return str(story)