Exemplo n.º 1
0
    def create_template_from_snapshot(self,
                                      apiclient,
                                      services,
                                      snapshotid=None,
                                      volumeid=None):
        """Create template from Volume"""
        # Create template from Virtual machine and Volume ID
        cmd = createTemplate.createTemplateCmd()
        cmd.displaytext = "StorPool_Template"
        cmd.name = "-".join(["StorPool-", random_gen()])
        if "ostypeid" in services:
            cmd.ostypeid = services["ostypeid"]
        elif "ostype" in services:
            # Find OSTypeId from Os type
            sub_cmd = listOsTypes.listOsTypesCmd()
            sub_cmd.description = services["ostype"]
            ostypes = apiclient.listOsTypes(sub_cmd)

            if not isinstance(ostypes, list):
                raise Exception("Unable to find Ostype id with desc: %s" %
                                services["ostype"])
            cmd.ostypeid = ostypes[0].id
        else:
            raise Exception(
                "Unable to find Ostype is required for creating template")

        cmd.isfeatured = True
        cmd.ispublic = True
        cmd.isextractable = False

        if snapshotid:
            cmd.snapshotid = snapshotid
        if volumeid:
            cmd.volumeid = volumeid
        return Template(apiclient.createTemplate(cmd).__dict__)
Exemplo n.º 2
0
def create(apiclient,
           services,
           volumeid=None,
           account=None,
           domainid=None,
           projectid=None):
    cmd = createTemplate.createTemplateCmd()
    cmd.displaytext = services["displaytext"]
    cmd.name = services["name"]
    if "ostypeid" in services:
        cmd.ostypeid = services["ostypeid"]
    elif "ostype" in services:
        sub_cmd = listOsTypes.listOsTypesCmd()
        sub_cmd.description = services["ostype"]
        ostypes = apiclient.listOsTypes(sub_cmd)

        if not isinstance(ostypes, list):
            raise Exception("Unable to find Ostype id with desc: %s" %
                            services["ostype"])
        cmd.ostypeid = ostypes[0].id
    else:
        raise Exception(
            "Unable to find Ostype is required for creating template")

    cmd.isfeatured = services[
        "isfeatured"] if "isfeatured" in services else False

    cmd.ispublic = services["ispublic"] if "ispublic" in services else False
    cmd.isextractable = services[
        "isextractable"] if "isextractable" in services else False
    cmd.passwordenabled = services[
        "passwordenabled"] if "passwordenabled" in services else False

    if volumeid:
        cmd.volumeid = volumeid
    if account:
        cmd.account = account
    if domainid:
        cmd.domainid = domainid
    if projectid:
        cmd.projectid = projectid
    return apiclient.createTemplate(cmd)
Exemplo n.º 3
0
def create(apiclient, services, volumeid=None, account=None, domainid=None, projectid=None):
    cmd = createTemplate.createTemplateCmd()
    cmd.displaytext = services["displaytext"]
    cmd.name = services["name"]
    if "ostypeid" in services:
        cmd.ostypeid = services["ostypeid"]
    elif "ostype" in services:
        sub_cmd = listOsTypes.listOsTypesCmd()
        sub_cmd.description = services["ostype"]
        ostypes = apiclient.listOsTypes(sub_cmd)

        if not isinstance(ostypes, list):
            raise Exception(
                "Unable to find Ostype id with desc: %s" % services["ostype"]
            )
        cmd.ostypeid = ostypes[0].id
    else:
        raise Exception(
            "Unable to find Ostype is required for creating template")

    cmd.isfeatured = services[
        "isfeatured"] if "isfeatured" in services else False

    cmd.ispublic = services[
        "ispublic"] if "ispublic" in services else False
    cmd.isextractable = services[
        "isextractable"] if "isextractable" in services else False
    cmd.passwordenabled = services[
        "passwordenabled"] if "passwordenabled" in services else False

    if volumeid:
        cmd.volumeid = volumeid
    if account:
        cmd.account = account
    if domainid:
        cmd.domainid = domainid
    if projectid:
        cmd.projectid = projectid
    return apiclient.createTemplate(cmd)
    def create_Template_from_Snapshot(self, snapshot):
        try:
            self.debug("Creating template from snapshot: %s" % snapshot.name)

            cmd = createTemplate.createTemplateCmd()
            cmd.displaytext = self.services["template"]["displaytext"]
            cmd.name = "-".join([self.services["template"]["name"],
                                 random_gen()])

            ncmd = listOsTypes.listOsTypesCmd()
            ncmd.description = self.services["template"]["ostype"]
            ostypes = self.apiclient.listOsTypes(ncmd)

            if not isinstance(ostypes, list):
                raise Exception(
                    "Unable to find Ostype id with desc: %s" %
                                        self.services["template"]["ostype"])
            cmd.ostypeid = ostypes[0].id
            cmd.snapshotid = snapshot.id

            return cmd
        except Exception as e:
            self.fail("Failed to create template from snapshot: %s - %s" %
                                                        (snapshot.name, e))
    def create_Template_from_Snapshot(self, snapshot):
        try:
            self.debug("Creating template from snapshot: %s" % snapshot.name)

            cmd = createTemplate.createTemplateCmd()
            cmd.displaytext = self.services["template"]["displaytext"]
            cmd.name = "-".join(
                [self.services["template"]["name"],
                 random_gen()])

            ncmd = listOsTypes.listOsTypesCmd()
            ncmd.description = self.services["template"]["ostype"]
            ostypes = self.apiclient.listOsTypes(ncmd)

            if not isinstance(ostypes, list):
                raise Exception("Unable to find Ostype id with desc: %s" %
                                self.services["template"]["ostype"])
            cmd.ostypeid = ostypes[0].id
            cmd.snapshotid = snapshot.id

            return cmd
        except Exception as e:
            self.fail("Failed to create template from snapshot: %s - %s" %
                      (snapshot.name, e))