コード例 #1
0
ファイル: cdn.py プロジェクト: torchbox/raxtool
    def __init__(self, ctx, args):
        super(CDNMode, self).__init__('cdn')

        self.cdnname = args[0]

        try:
            self.cdn = CDN.by_name(ctx, self.cdnname)
        except CDN.NotFound:
            self.cdn = CDN(ctx, {
                'name': self.cdnname,
                'flavor_id': 'cdn',
                'origins': [],
                'domains': []
            })
            self.cdn._modified = True
            sys.stdout.write("% Creating new CDN.\n")

        self.add_commands([
            [ "name", None, "Set CDN name" ],
            [ "name <name>", self.c_name ],
            [ "flavour", None, "Set CDN flavour" ],
            [ "flavour <name>", self.c_flavour ],
            [ "log-delivery", self.c_enable_log_delivery, "Enable log delivery" ],
            [ "no log-delivery", self.c_disable_log_delivery, "Disable log delivery" ],
            [ "commit", self.c_commit, "Commit changes" ],
        ])
コード例 #2
0
ファイル: cdn.py プロジェクト: torchbox/raxtool
class CDNMode(cli.Mode):
    def __init__(self, ctx, args):
        super(CDNMode, self).__init__('cdn')

        self.cdnname = args[0]

        try:
            self.cdn = CDN.by_name(ctx, self.cdnname)
        except CDN.NotFound:
            self.cdn = CDN(ctx, {
                'name': self.cdnname,
                'flavor_id': 'cdn',
                'origins': [],
                'domains': []
            })
            self.cdn._modified = True
            sys.stdout.write("% Creating new CDN.\n")

        self.add_commands([
            [ "name", None, "Set CDN name" ],
            [ "name <name>", self.c_name ],
            [ "flavour", None, "Set CDN flavour" ],
            [ "flavour <name>", self.c_flavour ],
            [ "log-delivery", self.c_enable_log_delivery, "Enable log delivery" ],
            [ "no log-delivery", self.c_disable_log_delivery, "Disable log delivery" ],
            [ "commit", self.c_commit, "Commit changes" ],
        ])

    def c_enable_log_delivery(self, parser, ctx, args):
        self.cdn.log_delivery = True

    def c_disable_log_delivery(self, parser, ctx, args):
        self.cdn.log_delivery = False

    def c_flavour(self, parser, ctx, args):
        self.cdn.flavour = args[0]

    def c_name(self, parser, ctx, args):
        self.cdn.name = args[0]

    def c_commit(self, parser, ctx, args):
        try:
            self.cdn.save()
        except api.Error, e:
            raise cli.CLIError(str(e))
コード例 #3
0
ファイル: cdn.py プロジェクト: torchbox/raxtool
def c_show_cdn_flavours(p, ctx, args):
    flavours = CDN.flavours(ctx)

    for flavour in flavours:
        print("\"{}\", providers:".format(flavour.name))
        for provider in flavour.providers:
            if provider.url != None:
                url = ", " + provider.url
            else:
                url = ""
            print("  {}{}".format(provider.name, url))
コード例 #4
0
ファイル: cdn.py プロジェクト: torchbox/raxtool
def c_show(p, ctx, args):
    cdns = CDN.all(ctx)

    for c in cdns:
        print(c.name)
コード例 #5
0
ファイル: cdn.py プロジェクト: torchbox/raxtool
def c_purge(p, ctx, args, hard=False):
    try:
        c = CDN.by_name(ctx, args[0])
    except CDN.NotFound, e:
        raise cli.CLIError(str(e))
コード例 #6
0
ファイル: cdn.py プロジェクト: torchbox/raxtool
def c_show_cdn(p, ctx, args):
    try:
        c = CDN.by_name(ctx, args[0])
    except CDN.NotFound, e:
        raise cli.CLIError(str(e))