Hello Hrvoje,

* 'Hrvoje Ribicic' via ganeti-devel <[email protected]> [2014-06-25 
13:08:12 +0200]:

> No, it does not seem we can bypass this easily - tried several things like
> replacing the empty string with spaces, and they failed quite badly.
> 
> But we already use strings like NonEmptyString which are expected not to be
> interpreted as literals - why not use EmptyString?
> 

Exactly! Why not? :)

> A hackish mini-patch achieving this:
> 
> diff --git a/lib/build/sphinx_ext.py b/lib/build/sphinx_ext.py
> index 5f29473..9cceee9 100644
> --- a/lib/build/sphinx_ext.py
> +++ b/lib/build/sphinx_ext.py
> @@ -173,6 +173,8 @@ def _BuildOpcodeParams(op_id, include, exclude, alias):
>      if has_default or has_test:
>        buf.write(" (")
>        if has_default:
> +        if default == "":
> +          default = "EmptyString"
>          buf.write("defaults to ``%s``" % (default,))
>          if has_test:
>            buf.write(", ")
> 
> Do you think this would be fine?
> 

From my point of view I really prefer this hackish mini-patch over the
ugly if-then-else in cmdlib. Plus it will be useful in case another param
should default to "".

> On Mon, Jun 23, 2014 at 5:31 PM, Dimitris Aragiorgis <[email protected]>
> wrote:
> 
> >
> > Hi,
> >
> > As an alternative I tried this:
> >
> >  pNetworkVlan :: Field
> >  pNetworkVlan =
> > -  withDoc "Network vlan when connecting to a group" $
> > +  withDoc "Network vlan when connecting to a group" .
> > +  defaultField [| "" |] .
> >    optionalField $ simpleField "network_vlan" [t| String |]
> >
> 
> While we're touching this: there is an optionalStringField function defined
> near the top of the file which is more compact.
> 

So I will resend the patch with your hack included along with the
Haskell change.

Thanks a lot for digging into it,
dimara

> 
> >
> > but make doc/html exited with a (sphinx) warning:
> >
> > Warning, treated as error:
> > OP_NETWORK_CONNECT:25: WARNING: Inline literal start-string without
> > end-string.
> >
> > This seems to be related with the generated doc/html/rapi.html and
> > especially
> > the docutils literal class:
> >
> > <p><tt class="docutils literal"><span class="pre">network_vlan</span></tt>
> > (defaults to <tt class="docutils literal"><span class="pre"> </span></tt>,
> > must be <tt class="docutils literal"><span class="pre">None</span> <span
> > class="pre">or</span> <span class="pre">String</span></tt>)</p>
> >
> > Apparently this cannot be fixed/bypassed, right?
> >
> > Thanks,
> > dimara
> >
> >
> > * Dimitris Aragiorgis <[email protected]> [2014-06-23 18:28:48 +0300]:
> >
> > > To keep backwards compatibility with old RAPI, make network_vlan
> > > param of OpNetworkConnect optional. If not passed, cmdlib will use
> > > the empty string as default value.
> > >
> > > Signed-off-by: Dimitris Aragiorgis <[email protected]>
> > > ---
> > >  lib/cmdlib/network.py  |    5 ++++-
> > >  src/Ganeti/OpParams.hs |    2 +-
> > >  2 files changed, 5 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/lib/cmdlib/network.py b/lib/cmdlib/network.py
> > > index d93f2dd..c2f3bcb 100644
> > > --- a/lib/cmdlib/network.py
> > > +++ b/lib/cmdlib/network.py
> > > @@ -572,7 +572,10 @@ class LUNetworkConnect(LogicalUnit):
> > >      self.group_name = self.op.group_name
> > >      self.network_mode = self.op.network_mode
> > >      self.network_link = self.op.network_link
> > > -    self.network_vlan = self.op.network_vlan
> > > +    if self.op.network_vlan:
> > > +      self.network_vlan = self.op.network_vlan
> > > +    else:
> > > +      self.network_vlan = ""
> > >
> > >      self.network_uuid = self.cfg.LookupNetwork(self.network_name)
> > >      self.group_uuid = self.cfg.LookupNodeGroup(self.group_name)
> > > diff --git a/src/Ganeti/OpParams.hs b/src/Ganeti/OpParams.hs
> > > index ae00822..d24b440 100644
> > > --- a/src/Ganeti/OpParams.hs
> > > +++ b/src/Ganeti/OpParams.hs
> > > @@ -1635,4 +1635,4 @@ pNetworkLink =
> > >  pNetworkVlan :: Field
> > >  pNetworkVlan =
> > >    withDoc "Network vlan when connecting to a group" $
> > > -  simpleField "network_vlan" [t| String |]
> > > +  optionalField $ simpleField "network_vlan" [t| String |]
> > > --
> > > 1.7.10.4
> >

Attachment: signature.asc
Description: Digital signature

Reply via email to